From: Vladimir Saveliev This patch makes generic_sync_sb_inodes to spin lock itself. It helps reiser4 to get rid of some oddities. sync_sb_inodes is always called like: spin_lock(&inode_lock); sync_sb_inodes(sb, wbc); spin_unlock(&inode_lock); This patch moves spin_lock/spin_unlock down to sync_sb_inodes. Signed-off-by: Andrew Morton --- fs/fs-writeback.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff -puN fs/fs-writeback.c~reiser4-sb_sync_inodes-cleanup fs/fs-writeback.c --- 25/fs/fs-writeback.c~reiser4-sb_sync_inodes-cleanup Mon Jun 13 15:00:14 2005 +++ 25-akpm/fs/fs-writeback.c Mon Jun 13 15:00:14 2005 @@ -283,8 +283,6 @@ __writeback_single_inode(struct inode *i * WB_SYNC_HOLD is a hack for sys_sync(): reattach the inode to sb->s_dirty so * that it can be located for waiting on in __writeback_single_inode(). * - * Called under inode_lock. - * * If `bdi' is non-zero then we're being asked to writeback a specific queue. * This function assumes that the blockdev superblock's inodes are backed by * a variety of queues, so all inodes are searched. For other superblocks, @@ -305,6 +303,8 @@ generic_sync_sb_inodes(struct super_bloc { const unsigned long start = jiffies; /* livelock avoidance */ + spin_lock(&inode_lock); + if (!wbc->for_kupdate || list_empty(&sb->s_io)) list_splice_init(&sb->s_dirty, &sb->s_io); @@ -384,6 +384,7 @@ generic_sync_sb_inodes(struct super_bloc if (wbc->nr_to_write <= 0) break; } + spin_unlock(&inode_lock); return; /* Leave any unwritten inodes on s_io */ } EXPORT_SYMBOL(generic_sync_sb_inodes); @@ -436,11 +437,8 @@ restart: * be unmounted by the time it is released. */ if (down_read_trylock(&sb->s_umount)) { - if (sb->s_root) { - spin_lock(&inode_lock); + if (sb->s_root) sync_sb_inodes(sb, wbc); - spin_unlock(&inode_lock); - } up_read(&sb->s_umount); } spin_lock(&sb_lock); @@ -476,9 +474,7 @@ void sync_inodes_sb(struct super_block * (inodes_stat.nr_inodes - inodes_stat.nr_unused) + nr_dirty + nr_unstable; wbc.nr_to_write += wbc.nr_to_write / 2; /* Bit more for luck */ - spin_lock(&inode_lock); sync_sb_inodes(sb, &wbc); - spin_unlock(&inode_lock); } /* _