From: NeilBrown Date: Tue, 14 Sep 2010 05:44:41 +0000 (+1000) Subject: Change readpage to use ->chain instead of ->lru X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=66dc1469619bba505bd285631a2e3538f7a4dd45;p=LaFS.git Change readpage to use ->chain instead of ->lru ->lru is rather overused, and ->chain is certainly never used on non-B_Valid blocks, so convert readpage to use chain instead. Signed-off-by: NeilBrown --- diff --git a/io.c b/io.c index 138cd98..ca0e350 100644 --- a/io.c +++ b/io.c @@ -440,11 +440,10 @@ blocks_loaded(struct bio *bio, int error) { struct block *bhead = bio->bi_private; - while (!list_empty(&bhead->lru)) { - struct block *b = list_first_entry(&bhead->lru, - struct block, - lru); - list_del_init(&b->lru); + while (bhead->chain) { + struct block *b = bhead->chain; + bhead->chain = b->chain; + b->chain = NULL; bio->bi_private = b; block_loaded(bio, error); } @@ -535,13 +534,13 @@ lafs_load_block(struct block *b, struct bio *bio) return 0; } + LAFS_BUG(b->chain != NULL, b); if (bio->bi_size == 0) { bio->bi_sector = sect; bio->bi_bdev = bdev; bio_add_page(bio, page, fs->blocksize, offset); bio->bi_private = b; bio->bi_end_io = blocks_loaded; - BUG_ON(!list_empty(&b->lru)); return 0; } if (bio->bi_sector + (bio->bi_size / 512) != sect @@ -550,7 +549,8 @@ lafs_load_block(struct block *b, struct bio *bio) return -EINVAL; /* added the block successfully */ headb = bio->bi_private; - list_add_tail(&b->lru, &headb->lru); + b->chain = headb->chain; + headb->chain = b; return 0; } diff --git a/state.h b/state.h index 57bdddf..0bc3cba 100644 --- a/state.h +++ b/state.h @@ -378,7 +378,8 @@ struct block { * in storage (i.e. in another snapshot) */ - struct block *chain; /* on list of unincorporated changes */ + struct block *chain; /* on list of unincorporated changes, or list of blocks + * being read in */ #if DEBUG_REF struct ref {int cnt; char *name; } holders[16];