From d053e82dd75650ac2d3b776325fd4a521c4f8aff Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 28 Mar 2011 07:10:00 +1100 Subject: [PATCH] Use separate list for inodes with dirty blocks. I was using the dirty/leafs list for tracking inodes with dirty blocks, but that conflicts with the leafs/leafs lists some times, so create a new dirty_inodes list. Signed-off-by: NeilBrown --- include/lafs/struct.h | 2 ++ lib/lafs_alloc.c | 1 + lib/lafs_dirty_blk.c | 11 ++++------- lib/lafs_flush_inode.c | 19 +++++++++---------- lib/lafs_import_inode_buf.c | 1 + 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/lafs/struct.h b/include/lafs/struct.h index 97e8fdd..1e372d1 100644 --- a/include/lafs/struct.h +++ b/include/lafs/struct.h @@ -58,6 +58,7 @@ struct lafs { } wc[WC_NUM]; struct list_head leafs, account_leafs; + struct list_head dirty_inodes; int youth_next; @@ -89,6 +90,7 @@ struct lafs_ino { struct lafs_iblk *iblock; int inum; struct lafs_ino *filesys; + struct list_head dirty_inodes; struct list_head dirty; /* blocks that might be dirty, or might belong * to inodes with dirty blocks. */ diff --git a/lib/lafs_alloc.c b/lib/lafs_alloc.c index 148a58d..3d364e2 100644 --- a/lib/lafs_alloc.c +++ b/lib/lafs_alloc.c @@ -28,6 +28,7 @@ struct lafs *lafs_alloc(void) INIT_LIST_HEAD(&fs->wc[1].blocks); INIT_LIST_HEAD(&fs->leafs); INIT_LIST_HEAD(&fs->account_leafs); + INIT_LIST_HEAD(&fs->dirty_inodes); for (i=0; i < (1<htable[i]); diff --git a/lib/lafs_dirty_blk.c b/lib/lafs_dirty_blk.c index f4bb874..db091e7 100644 --- a/lib/lafs_dirty_blk.c +++ b/lib/lafs_dirty_blk.c @@ -10,8 +10,6 @@ int lafs_dirty_blk(struct lafs_dblk *db) { - int was_empty; - if (db->b.flags & B_Dirty) return 0; @@ -23,10 +21,9 @@ int lafs_dirty_blk(struct lafs_dblk *db) return 0; trace(1, "dirty %p\n", db); - do { - was_empty = list_empty(&db->b.ino->dirty); - list_move_tail(&db->b.leafs, &db->b.ino->dirty); - db = db->b.ino->dblock; - } while (db && was_empty && db != db->b.ino->dblock); + if (list_empty(&db->b.ino->dirty)) + list_move_tail(&db->b.ino->dirty_inodes, + &db->b.ino->fs->dirty_inodes); + list_move_tail(&db->b.leafs, &db->b.ino->dirty); return 0; } diff --git a/lib/lafs_flush_inode.c b/lib/lafs_flush_inode.c index b84a42b..527a4d5 100644 --- a/lib/lafs_flush_inode.c +++ b/lib/lafs_flush_inode.c @@ -8,14 +8,9 @@ void lafs_flush_inode(struct lafs_ino *inode) { struct lafs_blk *blk; struct list_head *tmp; - struct lafs_ino *ino; + list_for_each_entry_safe(blk, tmp, &inode->dirty, leafs) { - if (!(blk->flags & B_Index) && - blk->ino->type == TypeInodeFile && - (ino = dblk(blk)->my_inode) != NULL && - !list_empty(&ino->dirty)) - lafs_flush_inode(ino); - else if (!(blk->flags & B_Dirty)) + if (!(blk->flags & B_Dirty)) list_del_init(&blk->leafs); if ((blk->flags & B_Dirty) && @@ -26,9 +21,13 @@ void lafs_flush_inode(struct lafs_ino *inode) void lafs_flush(struct lafs *lafs) { - struct lafs_ino *fsys = lafs->ss.root; + struct lafs_ino *ino; + struct list_head *tmp; - if (fsys) - lafs_flush_inode(fsys); + list_for_each_entry_safe(ino, tmp, &lafs->dirty_inodes, dirty_inodes) { + lafs_flush_inode(ino); + if (list_empty(&ino->dirty)) + list_del_init(&ino->dirty_inodes); + } } diff --git a/lib/lafs_import_inode_buf.c b/lib/lafs_import_inode_buf.c index 87f0583..28674ca 100644 --- a/lib/lafs_import_inode_buf.c +++ b/lib/lafs_import_inode_buf.c @@ -27,6 +27,7 @@ struct lafs_ino *lafs_import_inode_buf(struct lafs *fs, ino->inum = inum; ino->filesys = parent; INIT_LIST_HEAD(&ino->dirty); + INIT_LIST_HEAD(&ino->dirty_inodes); if (inode_load(ino, (struct la_inode *)buf)) /* FIXME callers of this should reparent it to themselves. */ -- 2.39.5