diff options
author | Nick Piggin <npiggin@suse.de> | 2010-01-29 15:38:30 -0800 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-04-27 17:32:46 +0200 |
commit | 280c10e37fa879b97c0942e024e0b02059173ea0 (patch) | |
tree | 8bc96a4f6e066700a38267828388e9567e42c2ee | |
parent | e8eb037afa1853a288a587b826c3f483ea046edd (diff) | |
download | lwn-280c10e37fa879b97c0942e024e0b02059173ea0.tar.gz lwn-280c10e37fa879b97c0942e024e0b02059173ea0.zip |
fs-inode_lock-scale-7
Remove the global inode_lock
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | fs/buffer.c | 2 | ||||
-rw-r--r-- | fs/drop_caches.c | 4 | ||||
-rw-r--r-- | fs/fs-writeback.c | 35 | ||||
-rw-r--r-- | fs/hugetlbfs/inode.c | 2 | ||||
-rw-r--r-- | fs/inode.c | 65 | ||||
-rw-r--r-- | fs/notify/inode_mark.c | 14 | ||||
-rw-r--r-- | fs/notify/inotify/inotify.c | 16 | ||||
-rw-r--r-- | fs/quota/dquot.c | 6 | ||||
-rw-r--r-- | include/linux/writeback.h | 1 | ||||
-rw-r--r-- | mm/backing-dev.c | 4 |
10 files changed, 30 insertions, 119 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index b34323cfe2da..416a2686ec66 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1145,7 +1145,7 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size) * inode list. * * mark_buffer_dirty() is atomic. It takes bh->b_page->mapping->private_lock, - * mapping->tree_lock and the global inode_lock. + * and mapping->tree_lock. */ void mark_buffer_dirty(struct buffer_head *bh) { diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 16efb486c693..6947cb2ef50c 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -16,7 +16,6 @@ static void drop_pagecache_sb(struct super_block *sb) { struct inode *inode, *toput_inode = NULL; - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); @@ -28,15 +27,12 @@ static void drop_pagecache_sb(struct super_block *sb) __iget(inode); spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); invalidate_mapping_pages(inode->i_mapping, 0, -1); iput(toput_inode); toput_inode = inode; - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); } spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); iput(toput_inode); } diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 2c9481e7b01d..07d70704078e 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -311,7 +311,7 @@ static void requeue_io(struct inode *inode) static void inode_sync_complete(struct inode *inode) { /* - * Prevent speculative execution through spin_unlock(&inode_lock); + * Prevent speculative execution through spin_unlock(&inode->i_lock); */ smp_mb(); wake_up_bit(&inode->i_state, __I_SYNC); @@ -403,9 +403,7 @@ static void inode_wait_for_writeback(struct inode *inode) do { spin_unlock(&wb_inode_list_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); __wait_on_bit(wqh, &wq, inode_wait, TASK_UNINTERRUPTIBLE); - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&wb_inode_list_lock); } while (inode->i_state & I_SYNC); @@ -466,7 +464,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) spin_unlock(&wb_inode_list_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); ret = do_writepages(mapping, wbc); @@ -483,7 +480,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) ret = err; } - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&wb_inode_list_lock); inode->i_state &= ~I_SYNC; @@ -628,7 +624,6 @@ static void writeback_inodes_wb(struct bdi_writeback *wb, struct super_block *sb = wbc->sb, *pin_sb = NULL; const unsigned long start = jiffies; /* livelock avoidance */ - spin_lock(&inode_lock); again: spin_lock(&wb_inode_list_lock); @@ -688,10 +683,8 @@ again: } spin_unlock(&wb_inode_list_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); iput(inode); cond_resched(); - spin_lock(&inode_lock); spin_lock(&wb_inode_list_lock); if (wbc->nr_to_write <= 0) { wbc->more_io = 1; @@ -703,8 +696,6 @@ again: spin_unlock(&wb_inode_list_lock); unpin_sb_for_writeback(&pin_sb); - - spin_unlock(&inode_lock); /* Leave any unwritten inodes on b_io */ } @@ -817,20 +808,17 @@ static long wb_writeback(struct bdi_writeback *wb, * we'll just busyloop. */ retry: - spin_lock(&inode_lock); spin_lock(&wb_inode_list_lock); if (!list_empty(&wb->b_more_io)) { inode = list_entry(wb->b_more_io.prev, struct inode, i_list); if (!spin_trylock(&inode->i_lock)) { spin_unlock(&wb_inode_list_lock); - spin_unlock(&inode_lock); goto retry; } inode_wait_for_writeback(inode); } spin_unlock(&wb_inode_list_lock); - spin_unlock(&inode_lock); } return wrote; @@ -1085,7 +1073,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) if (unlikely(block_dump)) block_dump___mark_inode_dirty(inode); - spin_lock(&inode_lock); spin_lock(&inode->i_lock); if ((inode->i_state & flags) != flags) { const int was_dirty = inode->i_state & I_DIRTY; @@ -1134,7 +1121,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) } out: spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); } EXPORT_SYMBOL(__mark_inode_dirty); @@ -1165,7 +1151,6 @@ static void wait_sb_inodes(struct super_block *sb) */ WARN_ON(!rwsem_is_locked(&sb->s_umount)); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); /* @@ -1190,14 +1175,12 @@ static void wait_sb_inodes(struct super_block *sb) __iget(inode); spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); /* - * We hold a reference to 'inode' so it couldn't have - * been removed from s_inodes list while we dropped the - * inode_lock. We cannot iput the inode now as we can - * be holding the last reference and we cannot iput it - * under inode_lock. So we keep the reference and iput - * it later. + * We hold a reference to 'inode' so it couldn't have been + * removed from s_inodes list while we dropped the + * sb_inode_list_lock. We cannot iput the inode now as we can + * be holding the last reference and we cannot iput it under + * spinlock. So we keep the reference and iput it later. */ iput(old_inode); old_inode = inode; @@ -1206,11 +1189,9 @@ static void wait_sb_inodes(struct super_block *sb) cond_resched(); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); } spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); iput(old_inode); } @@ -1292,13 +1273,11 @@ int write_inode_now(struct inode *inode, int sync) wbc.nr_to_write = 0; might_sleep(); - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&wb_inode_list_lock); ret = writeback_single_inode(inode, &wbc); spin_unlock(&wb_inode_list_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); if (sync) inode_sync_wait(inode); return ret; @@ -1320,13 +1299,11 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc) { int ret; - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&wb_inode_list_lock); ret = writeback_single_inode(inode, wbc); spin_unlock(&wb_inode_list_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); return ret; } EXPORT_SYMBOL(sync_inode); diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index ab1e261738bf..5b50a7a2225e 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -377,7 +377,7 @@ static void hugetlbfs_delete_inode(struct inode *inode) clear_inode(inode); } -static void hugetlbfs_forget_inode(struct inode *inode) __releases(inode_lock) +static void hugetlbfs_forget_inode(struct inode *inode) { if (generic_detach_inode(inode)) { truncate_hugepages(inode, 0); diff --git a/fs/inode.c b/fs/inode.c index ab43db313517..77dacd47b492 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -84,7 +84,6 @@ static struct hlist_head *inode_hashtable __read_mostly; * NOTE! You also have to own the lock if you change * the i_state of an inode while it is in use.. */ -DEFINE_SPINLOCK(inode_lock); DEFINE_SPINLOCK(sb_inode_list_lock); DEFINE_SPINLOCK(wb_inode_list_lock); DEFINE_SPINLOCK(inode_hash_lock); @@ -355,16 +354,14 @@ static void dispose_list(struct list_head *head) truncate_inode_pages(&inode->i_data, 0); clear_inode(inode); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); spin_lock(&inode->i_lock); spin_lock(&inode_hash_lock); hlist_del_init(&inode->i_hash); spin_unlock(&inode_hash_lock); list_del_init(&inode->i_sb_list); - spin_unlock(&sb_inode_list_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); + spin_unlock(&sb_inode_list_lock); wake_up_inode(inode); destroy_inode(inode); @@ -392,7 +389,6 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose) * change during umount anymore, and because iprune_sem keeps * shrink_icache_memory() away. */ - cond_resched_lock(&inode_lock); cond_resched_lock(&sb_inode_list_lock); next = next->next; @@ -437,13 +433,11 @@ int invalidate_inodes(struct super_block *sb) LIST_HEAD(throw_away); down_write(&iprune_sem); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); inotify_unmount_inodes(&sb->s_inodes); fsnotify_unmount_inodes(&sb->s_inodes); busy = invalidate_list(&sb->s_inodes, &throw_away); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); dispose_list(&throw_away); up_write(&iprune_sem); @@ -486,7 +480,6 @@ static void prune_icache(int nr_to_scan) unsigned long reap = 0; down_read(&iprune_sem); - spin_lock(&inode_lock); again: spin_lock(&wb_inode_list_lock); for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) { @@ -510,12 +503,10 @@ again: spin_unlock(&wb_inode_list_lock); __iget(inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); if (remove_inode_buffers(inode)) reap += invalidate_mapping_pages(&inode->i_data, 0, -1); iput(inode); - spin_lock(&inode_lock); again2: spin_lock(&wb_inode_list_lock); @@ -542,7 +533,6 @@ again2: __count_vm_events(KSWAPD_INODESTEAL, reap); else __count_vm_events(PGINODESTEAL, reap); - spin_unlock(&inode_lock); spin_unlock(&wb_inode_list_lock); dispose_list(&freeable); @@ -693,12 +683,10 @@ void inode_add_to_lists(struct super_block *sb, struct inode *inode) { struct hlist_head *head = inode_hashtable + hash(sb, inode->i_ino); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); spin_lock(&inode->i_lock); __inode_add_to_lists(sb, head, inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); } EXPORT_SYMBOL_GPL(inode_add_to_lists); @@ -724,18 +712,14 @@ struct inode *new_inode(struct super_block *sb) static atomic_t last_ino = ATOMIC_INIT(0); struct inode *inode; - spin_lock_prefetch(&inode_lock); - inode = alloc_inode(sb); if (inode) { - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); spin_lock(&inode->i_lock); inode->i_ino = atomic_inc_return(&last_ino); inode->i_state = 0; __inode_add_to_lists(sb, NULL, inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); } return inode; } @@ -794,7 +778,6 @@ static struct inode *get_new_inode(struct super_block *sb, if (inode) { struct inode *old; - spin_lock(&inode_lock); /* We released the lock, so.. */ old = find_inode(sb, head, test, data); if (!old) { @@ -806,7 +789,6 @@ static struct inode *get_new_inode(struct super_block *sb, inode->i_state = I_NEW; __inode_add_to_lists(sb, head, inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); /* Return the locked inode with I_NEW set, the * caller is responsible for filling in the contents @@ -821,7 +803,6 @@ static struct inode *get_new_inode(struct super_block *sb, */ __iget(old); spin_unlock(&old->i_lock); - spin_unlock(&inode_lock); destroy_inode(inode); inode = old; wait_on_inode(inode); @@ -831,7 +812,6 @@ static struct inode *get_new_inode(struct super_block *sb, set_failed: spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); destroy_inode(inode); return NULL; } @@ -849,7 +829,6 @@ static struct inode *get_new_inode_fast(struct super_block *sb, if (inode) { struct inode *old; - spin_lock(&inode_lock); /* We released the lock, so.. */ old = find_inode_fast(sb, head, ino); if (!old) { @@ -859,7 +838,6 @@ static struct inode *get_new_inode_fast(struct super_block *sb, inode->i_state = I_NEW; __inode_add_to_lists(sb, head, inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); /* Return the locked inode with I_NEW set, the * caller is responsible for filling in the contents @@ -874,7 +852,6 @@ static struct inode *get_new_inode_fast(struct super_block *sb, */ __iget(old); spin_unlock(&old->i_lock); - spin_unlock(&inode_lock); destroy_inode(inode); inode = old; wait_on_inode(inode); @@ -924,7 +901,6 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved) struct hlist_head *head; ino_t res; - spin_lock(&inode_lock); spin_lock(&unique_lock); do { if (counter <= max_reserved) @@ -933,7 +909,6 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved) head = inode_hashtable + hash(sb, res); } while (!test_inode_iunique(sb, head, res)); spin_unlock(&unique_lock); - spin_unlock(&inode_lock); return res; } @@ -943,7 +918,6 @@ struct inode *igrab(struct inode *inode) { struct inode *ret = inode; - spin_lock(&inode_lock); spin_lock(&inode->i_lock); if (!(inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE))) __iget(inode); @@ -955,7 +929,6 @@ struct inode *igrab(struct inode *inode) */ ret = NULL; spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); return ret; } @@ -986,17 +959,14 @@ static struct inode *ifind(struct super_block *sb, { struct inode *inode; - spin_lock(&inode_lock); inode = find_inode(sb, head, test, data); if (inode) { __iget(inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); if (likely(wait)) wait_on_inode(inode); return inode; } - spin_unlock(&inode_lock); return NULL; } @@ -1020,16 +990,13 @@ static struct inode *ifind_fast(struct super_block *sb, { struct inode *inode; - spin_lock(&inode_lock); inode = find_inode_fast(sb, head, ino); if (inode) { __iget(inode); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); wait_on_inode(inode); return inode; } - spin_unlock(&inode_lock); return NULL; } @@ -1193,7 +1160,6 @@ int insert_inode_locked(struct inode *inode) struct hlist_node *node; struct inode *old = NULL; - spin_lock(&inode_lock); repeat: spin_lock(&inode_hash_lock); hlist_for_each_entry(old, node, head, i_hash) { @@ -1213,13 +1179,11 @@ repeat: /* XXX: initialize inode->i_lock to locked? */ hlist_add_head(&inode->i_hash, head); spin_unlock(&inode_hash_lock); - spin_unlock(&inode_lock); return 0; } spin_unlock(&inode_hash_lock); __iget(old); spin_unlock(&old->i_lock); - spin_unlock(&inode_lock); wait_on_inode(old); if (unlikely(!hlist_unhashed(&old->i_hash))) { iput(old); @@ -1242,7 +1206,6 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, struct hlist_node *node; struct inode *old = NULL; - spin_lock(&inode_lock); repeat: spin_lock(&inode_hash_lock); hlist_for_each_entry(old, node, head, i_hash) { @@ -1262,13 +1225,11 @@ repeat: /* XXX: initialize inode->i_lock to locked? */ hlist_add_head(&inode->i_hash, head); spin_unlock(&inode_hash_lock); - spin_unlock(&inode_lock); return 0; } spin_unlock(&inode_hash_lock); __iget(old); spin_unlock(&old->i_lock); - spin_unlock(&inode_lock); wait_on_inode(old); if (unlikely(!hlist_unhashed(&old->i_hash))) { iput(old); @@ -1291,13 +1252,11 @@ void __insert_inode_hash(struct inode *inode, unsigned long hashval) { struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&inode_hash_lock); hlist_add_head(&inode->i_hash, head); spin_unlock(&inode_hash_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); } EXPORT_SYMBOL(__insert_inode_hash); @@ -1309,13 +1268,11 @@ EXPORT_SYMBOL(__insert_inode_hash); */ void remove_inode_hash(struct inode *inode) { - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&inode_hash_lock); hlist_del_init(&inode->i_hash); spin_unlock(&inode_hash_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); } EXPORT_SYMBOL(remove_inode_hash); @@ -1343,7 +1300,6 @@ void generic_delete_inode(struct inode *inode) WARN_ON(inode->i_state & I_NEW); inode->i_state |= I_FREEING; spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); atomic_dec(&inodes_stat.nr_inodes); security_inode_delete(inode); @@ -1361,13 +1317,11 @@ void generic_delete_inode(struct inode *inode) truncate_inode_pages(&inode->i_data, 0); clear_inode(inode); } - spin_lock(&inode_lock); spin_lock(&inode->i_lock); spin_lock(&inode_hash_lock); hlist_del_init(&inode->i_hash); spin_unlock(&inode_hash_lock); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); wake_up_inode(inode); BUG_ON(inode->i_state != I_CLEAR); destroy_inode(inode); @@ -1397,16 +1351,13 @@ int generic_detach_inode(struct inode *inode) if (sb->s_flags & MS_ACTIVE) { spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); return 0; } WARN_ON(inode->i_state & I_NEW); inode->i_state |= I_WILL_FREE; spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); write_inode_now(inode, 1); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); spin_lock(&inode->i_lock); WARN_ON(inode->i_state & I_NEW); @@ -1424,7 +1375,6 @@ int generic_detach_inode(struct inode *inode) WARN_ON(inode->i_state & I_NEW); inode->i_state |= I_FREEING; spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); atomic_dec(&inodes_stat.nr_inodes); return 1; } @@ -1490,17 +1440,12 @@ void iput(struct inode *inode) if (inode) { BUG_ON(inode->i_state == I_CLEAR); -retry1: +retry: spin_lock(&inode->i_lock); if (inode->i_count == 1) { - if (!spin_trylock(&inode_lock)) { -retry2: - spin_unlock(&inode->i_lock); - goto retry1; - } if (!spin_trylock(&sb_inode_list_lock)) { - spin_unlock(&inode_lock); - goto retry2; + spin_unlock(&inode->i_lock); + goto retry; } inode->i_count--; iput_final(inode); @@ -1698,10 +1643,8 @@ static void __wait_on_freeing_inode(struct inode *inode) wq = bit_waitqueue(&inode->i_state, __I_NEW); prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE); spin_unlock(&inode->i_lock); - spin_unlock(&inode_lock); schedule(); finish_wait(wq, &wait.wait); - spin_lock(&inode_lock); } static __initdata unsigned long ihash_entries; diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c index 869f94bb040f..81b5bbb3a7ee 100644 --- a/fs/notify/inode_mark.c +++ b/fs/notify/inode_mark.c @@ -369,13 +369,16 @@ void fsnotify_unmount_inodes(struct list_head *list) list_for_each_entry_safe(inode, next_i, list, i_sb_list) { struct inode *need_iput_tmp; + spin_lock(&inode->i_lock); /* * We cannot __iget() an inode in state I_CLEAR, I_FREEING, * I_WILL_FREE, or I_NEW which is fine because by that point * the inode cannot have any associated watches. */ - if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) + if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) { + spin_unlock(&inode->i_lock); continue; + } /* * If i_count is zero, the inode cannot have any watches and @@ -383,19 +386,20 @@ void fsnotify_unmount_inodes(struct list_head *list) * evict all inodes with zero i_count from icache which is * unnecessarily violent and may in fact be illegal to do. */ - if (!inode->i_count) + if (!inode->i_count) { + spin_unlock(&inode->i_lock); continue; + } need_iput_tmp = need_iput; need_iput = NULL; /* In case fsnotify_inode_delete() drops a reference. */ if (inode != need_iput_tmp) { - spin_lock(&inode->i_lock); __iget(inode); - spin_unlock(&inode->i_lock); } else need_iput_tmp = NULL; + spin_unlock(&inode->i_lock); /* In case the dropping of a reference would nuke next_i. */ if (&next_i->i_sb_list != list) { @@ -416,7 +420,6 @@ void fsnotify_unmount_inodes(struct list_head *list) * iprune_mutex keeps shrink_icache_memory() away. */ spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); if (need_iput_tmp) iput(need_iput_tmp); @@ -428,7 +431,6 @@ void fsnotify_unmount_inodes(struct list_head *list) iput(inode); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); } } diff --git a/fs/notify/inotify/inotify.c b/fs/notify/inotify/inotify.c index 44e90ef0b0a3..7846758db7da 100644 --- a/fs/notify/inotify/inotify.c +++ b/fs/notify/inotify/inotify.c @@ -394,13 +394,16 @@ void inotify_unmount_inodes(struct list_head *list) struct inode *need_iput_tmp; struct list_head *watches; + spin_lock(&inode->i_lock); /* * We cannot __iget() an inode in state I_CLEAR, I_FREEING, * I_WILL_FREE, or I_NEW which is fine because by that point * the inode cannot have any associated watches. */ - if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) + if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) { + spin_unlock(&inode->i_lock); continue; + } /* * If i_count is zero, the inode cannot have any watches and @@ -408,18 +411,21 @@ void inotify_unmount_inodes(struct list_head *list) * evict all inodes with zero i_count from icache which is * unnecessarily violent and may in fact be illegal to do. */ - if (!inode->i_count) + if (!inode->i_count) { + spin_unlock(&inode->i_lock); continue; + } need_iput_tmp = need_iput; need_iput = NULL; /* In case inotify_remove_watch_locked() drops a reference. */ if (inode != need_iput_tmp) { - spin_lock(&inode->i_lock); __iget(inode); - spin_unlock(&inode->i_lock); } else need_iput_tmp = NULL; + + spin_unlock(&inode->i_lock); + /* In case the dropping of a reference would nuke next_i. */ if (&next_i->i_sb_list != list) { spin_lock(&next_i->i_lock); @@ -439,7 +445,6 @@ void inotify_unmount_inodes(struct list_head *list) * iprune_mutex keeps shrink_icache_memory() away. */ spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); if (need_iput_tmp) iput(need_iput_tmp); @@ -459,7 +464,6 @@ void inotify_unmount_inodes(struct list_head *list) mutex_unlock(&inode->inotify_mutex); iput(inode); - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); } } diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 3cbb87192d7a..5305c71ccea5 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -844,7 +844,6 @@ static void add_dquot_ref(struct super_block *sb, int type) struct inode *inode, *old_inode = NULL; int reserved = 0; - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); @@ -869,7 +868,6 @@ static void add_dquot_ref(struct super_block *sb, int type) __iget(inode); spin_unlock(&inode->i_lock); spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); iput(old_inode); sb->dq_op->initialize(inode, type); @@ -879,11 +877,9 @@ static void add_dquot_ref(struct super_block *sb, int type) * reference and we cannot iput it under inode_lock. So we * keep the reference and iput it later. */ old_inode = inode; - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); } spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); iput(old_inode); if (reserved) { @@ -959,7 +955,6 @@ static void remove_dquot_ref(struct super_block *sb, int type, { struct inode *inode; - spin_lock(&inode_lock); spin_lock(&sb_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { /* @@ -972,7 +967,6 @@ static void remove_dquot_ref(struct super_block *sb, int type, remove_inode_dquot_ref(inode, type, tofree_head); } spin_unlock(&sb_inode_list_lock); - spin_unlock(&inode_lock); } /* Gather all references from inodes and drop them */ diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 90ad0abb935f..3e504f49753c 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -9,7 +9,6 @@ struct backing_dev_info; -extern spinlock_t inode_lock; extern spinlock_t sb_inode_list_lock; extern spinlock_t wb_inode_list_lock; extern spinlock_t inode_hash_lock; diff --git a/mm/backing-dev.c b/mm/backing-dev.c index ea2a4e42cab1..8a0d9aa7b207 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -71,7 +71,6 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v) * RCU on the reader side */ nr_wb = nr_dirty = nr_io = nr_more_io = 0; - spin_lock(&inode_lock); spin_lock(&wb_inode_list_lock); list_for_each_entry(wb, &bdi->wb_list, list) { nr_wb++; @@ -83,7 +82,6 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v) nr_more_io++; } spin_unlock(&wb_inode_list_lock); - spin_unlock(&inode_lock); get_dirty_limits(&background_thresh, &dirty_thresh, &bdi_thresh, bdi); @@ -698,13 +696,11 @@ void bdi_destroy(struct backing_dev_info *bdi) if (bdi_has_dirty_io(bdi)) { struct bdi_writeback *dst = &default_backing_dev_info.wb; - spin_lock(&inode_lock); spin_lock(&wb_inode_list_lock); list_splice(&bdi->wb.b_dirty, &dst->b_dirty); list_splice(&bdi->wb.b_io, &dst->b_io); list_splice(&bdi->wb.b_more_io, &dst->b_more_io); spin_unlock(&wb_inode_list_lock); - spin_unlock(&inode_lock); } bdi_unregister(bdi); |