When doing round-robin reads from a multi-plex volume, only switch to the

next plex if the sector to be read isn't nearby the last read sector.

Submitted by:  Vsevolod Lobko <seva@ip.net.ua> via ru@
Approved by:   grog (mentor)
This commit is contained in:
Lukas Ertl 2004-03-19 10:28:34 +00:00
parent f639538c20
commit 2c1305420f
3 changed files with 20 additions and 4 deletions

View File

@ -275,6 +275,7 @@ struct _plex
#ifdef _KERNEL
struct rangelock *lock; /* ranges of locked addresses */
struct mtx *lockmtx; /* lock mutex, one of plexmutex [] */
daddr_t last_addr; /* last address read from this plex */
dev_t dev; /* associated device */
#endif
};

View File

@ -234,10 +234,18 @@ vinumstart(struct buf *bp, int reviveok)
if (vol != NULL) {
plexno = vol->preferred_plex; /* get the plex to use */
if (plexno < 0) { /* round robin */
plexno = vol->last_plex_read;
for (plexno = 0; plexno < vol->plexes; plexno++)
if (abs(bp->b_blkno - PLEX[vol->plex[plexno]].last_addr) <= ROUNDROBIN_SWITCH)
break;
if (plexno >= vol->plexes) {
vol->last_plex_read++;
if (vol->last_plex_read >= vol->plexes) /* got the the end? */
vol->last_plex_read = 0; /* wrap around */
if (vol->last_plex_read >= vol->plexes)
vol->last_plex_read = 0;
plexno = vol->last_plex_read;
} else {
vol->last_plex_read = plexno;
};
PLEX[vol->plex[plexno]].last_addr = bp->b_blkno;
}
status = build_read_request(rq, plexno); /* build a request */
} else {

View File

@ -361,6 +361,13 @@ enum parityop {
rebuildandcheckparity, /* rebuildparity with the -v option */
};
/*
* When doing round-robin reads from a multi-plex volume, switch to the
* next plex if the difference of the last read sector and the next sector
* to be read is this many sectors.
*/
#define ROUNDROBIN_SWITCH 128 /* 64k */
#ifdef VINUMDEBUG
/* Debugging stuff */
enum debugflags {