]> git.neil.brown.name Git - LaFS.git/commitdiff
Change readpage to use ->chain instead of ->lru
authorNeilBrown <neilb@suse.de>
Tue, 14 Sep 2010 05:44:41 +0000 (15:44 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 14 Sep 2010 05:44:41 +0000 (15:44 +1000)
->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 <neilb@suse.de>
io.c
state.h

diff --git a/io.c b/io.c
index 138cd98f42c856b29967f99dedb6e8a20c56a5d6..ca0e3509266757e73088e0deac7a5761dd86f33e 100644 (file)
--- 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 57bdddf9e0dcb7973dc952393328ed028ec4b09c..0bc3cbacb02456b4c5c08460e93131745c9c3dcd 100644 (file)
--- 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];