fs: peel back the inode_lock some more
Subsystems (6)
cover fs: peel back the inode_lock some more
Hi Al,
These as the first versions of the patches that remove the inode lock from the writeback lists, superblock inode lists and the inode hash table. I haven't polished them at all, but they appear to work ok so I thought I'd send them out for comments before I went to bed...
With these patches the inode_lock pretty much disappears from my lock_stat profiles, with the writeback list lock being the most contended of the replacements on an 8-way machine.
Cheers,
Dave.
PATCH 1/3 fs: move i_sb_list out from under inode_lock
From: Dave Chinner <[email protected]>
Protect the per-sb inode list with a new global lock inode_sb_list_lock and use it to protect the list manipulations and traversals. This lock replaces the inode_lock as the inodes on the list can be validity checked while holding the inode->i_lock and hence the inode_lock is no longer needed to protect the list.
--- fs/drop_caches.c | 9 +++++---- fs/fs-writeback.c | 21 +++++++++++---------- fs/inode.c | 43 +++++++++++++++++++++++-------------------- fs/internal.h | 2 ++ fs/notify/inode_mark.c | 15 ++++++++------- fs/quota/dquot.c | 28 ++++++++++++++++------------ 6 files changed, 65 insertions(+), 53 deletions(-)
fs/drop_caches.c +5 -4
@@ -8,6 +8,7 @@#include <linux/writeback.h> #include <linux/sysctl.h> #include <linux/gfp.h> +#include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */ int sysctl_drop_caches;
@@ -16,7 +17,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) {struct inode *inode, *toput_inode =NULL ; -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock);list_for_each_entry (inode, &sb->s_inodes, i_sb_list) {spin_lock (&inode->i_lock); if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
@@ -26,13 +27,13 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) }__iget (inode);spin_unlock (&inode->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);invalidate_mapping_pages (inode->i_mapping,0 ,-1 );iput (toput_inode); toput_inode = inode; -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock); } -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);iput (toput_inode); }
fs/fs-writeback.c +11 -10
@@ -1053,7 +1053,7 @@ static void wait_sb_inodes(struct super_block *sb)*/ WARN_ON (!rwsem_is_locked (&sb->s_umount)); -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock);/* * Data integrity sync. Must wait for all pages under writeback,
@@ -1073,14 +1073,15 @@ static void wait_sb_inodes(struct super_block *sb) }__iget (inode);spin_unlock (&inode->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_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 +* inode_sb_list_lock. We cannot iput the inode now as we can +* be holding the last reference and we cannot iput it under +* inode_sb_list_lock. So we keep the reference and iput it +* later. */ iput (old_inode); old_inode = inode;
@@ -1089,9 +1090,9 @@ static void wait_sb_inodes(struct super_block *sb)cond_resched (); -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock); } -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);iput (old_inode); }
fs/inode.c +23 -20
132 lines not on this page · raw message
fs/internal.h +2 -0
@@ -108,3 +108,5 @@ extern void release_open_intent(struct nameidata *);extern int get_nr_dirty_inodes (void );extern int evict_inodes (struct super_block *);extern int invalidate_inodes (struct super_block *); + +extern spinlock_t inode_sb_list_lock;
fs/notify/inode_mark.c +8 -7
@@ -29,6 +29,8 @@#include <linux/fsnotify_backend.h> #include "fsnotify.h" +#include "../internal.h" +/* * Recalculate the mask of events relevant to a given inode locked. */
@@ -232,15 +234,14 @@ out:* fsnotify_unmount_inodes - an sb is unmounting. handle any watched inodes. * @list: list of inodes being unmounted (sb->s_inodes) * -* Called with inode_lock held, protecting the unmounting super block's list -* of inodes, and with iprune_mutex held, keeping shrink_icache_memory() at bay. -* We temporarily drop inode_lock, however, and CAN block. +* Called during unmount with no locks held, so needs to be safe against +* concurrent modifiers. We temporarily drop inode_sb_list_lock and CAN block. */ void fsnotify_unmount_inodes (struct list_head *list) {struct inode *inode, *next_i, *need_iput =NULL ; -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock);list_for_each_entry_safe (inode, next_i, list, i_sb_list) {struct inode *need_iput_tmp;
@@ -293,7 +294,7 @@ void fsnotify_unmount_inodes(struct list_head *list)* will be added since the umount has begun. Finally, * iprune_mutex keeps shrink_icache_memory() away. */ -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);if (need_iput_tmp)iput (need_iput_tmp);
@@ -305,7 +306,7 @@ void fsnotify_unmount_inodes(struct list_head *list)iput (inode); -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock); } -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock); }
fs/quota/dquot.c +16 -12
@@ -76,7 +76,7 @@#include <linux/buffer_head.h> #include <linux/capability.h> #include <linux/quotaops.h> -#include <linux/writeback.h> /* for inode_lock, oddly enough.. */ +#include "../internal.h" /* ugh */ #include <asm/uaccess.h>
@@ -896,7 +896,7 @@ static void add_dquot_ref(struct super_block *sb, int type)int reserved =0 ;#endif -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock);list_for_each_entry (inode, &sb->s_inodes, i_sb_list) {spin_lock (&inode->i_lock); if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
@@ -911,19 +911,23 @@ static void add_dquot_ref(struct super_block *sb, int type)#endif __iget (inode);spin_unlock (&inode->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);iput (old_inode);__dquot_initialize (inode, type); -/* 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 +* inode_sb_list_lock We cannot iput the inode now as we can be +* holding the last reference and we cannot iput it under +* inode_sb_list_lock. So we keep the reference and iput it +* later. +*/ old_inode = inode; -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock); } -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);iput (old_inode);#ifdef CONFIG_QUOTA_DEBUG
@@ -1004,7 +1008,7 @@ static void remove_dquot_ref(struct super_block *sb, int type,struct inode *inode;int reserved =0 ; -spin_lock (&inode_lock); +spin_lock (&inode_sb_list_lock);list_for_each_entry (inode, &sb->s_inodes, i_sb_list) {/* * We have to scan also I_NEW inodes because they can already
@@ -1018,7 +1022,7 @@ static void remove_dquot_ref(struct super_block *sb, int type,remove_inode_dquot_ref (inode, type, tofree_head); } } -spin_unlock (&inode_lock); +spin_unlock (&inode_sb_list_lock);#ifdef CONFIG_QUOTA_DEBUG if (reserved) { printk(KERN_WARNING "VFS (%s): Writes happened after quota"
Signature · 1 line
1.7.1
Re: [PATCH 1/3] fs: move i_sb_list out from under inode_lock
PATCH 2/3 fs: move i_wb_list out from under inode_lock
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Protect the inode writeback list with a new global lock inode_wb_list_lock and use it to protect the list manipulations and traversals. This lock replaces the inode_lock as the inodes on the list can be validity checked while holding the inode->i_lock and hence the inode_lock is no longer needed to protect the list.
--- fs/block_dev.c | 4 +- fs/fs-writeback.c | 152 ++++++++++++++++++++++++--------------------- fs/inode.c | 12 +++- fs/internal.h | 7 ++- include/linux/writeback.h | 1 + mm/backing-dev.c | 8 +- 6 files changed, 103 insertions(+), 81 deletions(-)
fs/block_dev.c +2 -2
@@ -56,11 +56,11 @@ EXPORT_SYMBOL(I_BDEV);static void bdev_inode_switch_bdi (struct inode *inode,struct backing_dev_info *dst) { -spin_lock (&inode_lock); +spin_lock (&inode_wb_list_lock); inode->i_data.backing_dev_info = dst;if (inode->i_state &I_DIRTY )list_move (&inode->i_wb_list, &dst->wb.b_dirty); -spin_unlock (&inode_lock); +spin_unlock (&inode_wb_list_lock); }static sector_t max_block (struct block_device *bdev)
fs/fs-writeback.c +82 -70
301 lines not on this page · raw message
fs/inode.c +8 -4
@@ -24,6 +24,7 @@#include <linux/mount.h> #include <linux/async.h> #include <linux/posix_acl.h> +#include "internal.h" /* * inode locking rules.
@@ -34,6 +35,8 @@* inode_lru, inode->i_lru * inode_sb_list_lock protects: * sb->s_inodes, inode->i_sb_list +* inode_sb_list_lock protects: +* bdi->wb.b_{dirty,io,more_io}, inode->i_wb_list * * Lock ordering: * inode_lock
@@ -42,6 +45,9 @@* inode_sb_list_lock * inode->i_lock * inode_lru_lock +* +* inode_wb_list_lock +* inode->i_lock */ /*
@@ -103,6 +109,7 @@ static struct hlist_head *inode_hashtable __read_mostly;DEFINE_SPINLOCK (inode_lock);__cacheline_aligned_in_smp DEFINE_SPINLOCK (inode_sb_list_lock ); +__cacheline_aligned_in_smp DEFINE_SPINLOCK (inode_wb_list_lock );/* * iprune_sem provides exclusion between the kswapd or try_to_free_pages
@@ -462,10 +469,7 @@ static void evict(struct inode *inode)BUG_ON (!(inode->i_state &I_FREEING )); -spin_lock (&inode_lock); -list_del_init (&inode->i_wb_list); -spin_unlock (&inode_lock); - +inode_wb_list_del (inode);inode_sb_list_del (inode);if (op->evict_inode) {
fs/internal.h +6 -1
@@ -106,7 +106,12 @@ extern void release_open_intent(struct nameidata *);* inode.c */ extern int get_nr_dirty_inodes (void ); -extern int evict_inodes (struct super_block *); +extern void evict_inodes (struct super_block *);extern int invalidate_inodes (struct super_block *);extern spinlock_t inode_sb_list_lock; + +/* +* fs-writeback.c +*/ +extern void inode_wb_list_del (struct inode *inode);
include/linux/writeback.h +1 -0
@@ -10,6 +10,7 @@struct backing_dev_info ;extern spinlock_t inode_lock; +extern spinlock_t inode_wb_list_lock;/* * fs/fs-writeback.c
mm/backing-dev.c +4 -4
@@ -73,14 +73,14 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)struct inode *inode; nr_wb = nr_dirty = nr_io = nr_more_io =0 ; -spin_lock (&inode_lock); +spin_lock (&inode_wb_list_lock);list_for_each_entry (inode, &wb->b_dirty, i_wb_list) nr_dirty++;list_for_each_entry (inode, &wb->b_io, i_wb_list) nr_io++;list_for_each_entry (inode, &wb->b_more_io, i_wb_list) nr_more_io++; -spin_unlock (&inode_lock); +spin_unlock (&inode_wb_list_lock);global_dirty_limits (&background_thresh, &dirty_thresh); bdi_thresh =bdi_dirty_limit (bdi, dirty_thresh);
@@ -682,11 +682,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 (&inode_wb_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 (&inode_lock); +spin_unlock (&inode_wb_list_lock); }bdi_unregister (bdi);
Signature · 1 line
1.7.1
Re: [PATCH 2/3] fs: move i_wb_list out from under inode_lock
Quoted 3 lines
+ * Write out an inode's dirty pages. Called under
inode_wb_list_lock. Either
+ * the caller has ref on the inode (either via__igetor via syscall against an
+ * fd) or the inode hasI_WILL_FREEset.
Just drop mentioning of how we got the reference ,it's rather pointless.
fs/fs-writeback.c writeback_single_inode(struct inode *inode, struct writeback_control *wbc) · line 371
Quoted 7 lines
writeback_single_inode(struct inode *inode, struct writeback_control *wbc)fs/fs-writeback.c +1
-1@@ -354,7 +368,7 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) inode->i_state |=I_SYNC ; inode->i_state &= ~I_DIRTY_PAGES ;spin_unlock (&inode->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_wb_list_lock);
We don't actually need inode_wb_list_lock here. But I guess we can fix this later and be conservative for now.
Review void __mark_inode_dirty(struct inode *inode, int flags)
Quoted 1 line
(quoted diff) +0
-0@@ -963,63 +976,62 @@ void __mark_inode_dirty(struct inode *inode, int flags)
I think the __mark_inode_dirty cleanup should be a separate patch, it's rather confusing in the current form.
fs/fs-writeback.c void __mark_inode_dirty(struct inode *inode, int flags) · line 1013
Quoted 5 lines
fs/fs-writeback.c +4
-0+if (was_dirty) { +out_unlock_inode:spin_unlock (&inode->i_lock); +return ; + }
Please just move the label to the end of the function and add another goto here.
Re: [PATCH 2/3] fs: move i_wb_list out from under inode_lock
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines
+ * Write out an inode's dirty pages. Called under
inode_wb_list_lock. Either
+ * the caller has ref on the inode (either via__igetor via syscall against an
+ * fd) or the inode hasI_WILL_FREEset.Just drop mentioning of how we got the reference ,it's rather pointless.
OK.
Quoted 10 lines
fs/fs-writeback.c writeback_single_inode(struct inode *inode, struct writeback_control *wbc) · line 371
Quoted 7 lines
writeback_single_inode(struct inode *inode, struct writeback_control *wbc)fs/fs-writeback.c +1
-1@@ -354,7 +368,7 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) inode->i_state |=I_SYNC ; inode->i_state &= ~I_DIRTY_PAGES ;spin_unlock (&inode->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_wb_list_lock);We don't actually need
inode_wb_list_lockhere. But I guess we can fix this later and be conservative for now.
Hmmm - I think you are right. However, there are lots of opportunities for cleaning up the locking in this areaş so leaving it for later is probably best.
Quoted 4 lines
Review void __mark_inode_dirty(struct inode *inode, int flags)
Quoted 1 line
(quoted diff) +0
-0@@ -963,63 +976,62 @@ void __mark_inode_dirty(struct inode *inode, int flags)I think the
__mark_inode_dirtycleanup should be a separate patch, it's rather confusing in the current form.
Ok. I'll leave it out for now - there's various other cleanups needed here now as well (e.g. the unlocked flags check is not needed to avoid a global lock anymore) so I'll leave that for later, too.
Quoted 8 lines
fs/fs-writeback.c void __mark_inode_dirty(struct inode *inode, int flags) · line 1013
Quoted 5 lines
fs/fs-writeback.c +4
-0+if (was_dirty) { +out_unlock_inode:spin_unlock (&inode->i_lock); +return ; + }Please just move the label to the end of the function and add another goto here.
Will do.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH 3/3 fs: move i_hash out from under inode_lock
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Protect the inode hash lists with a new global lock inode_hash_lock and use it to protect the list manipulations and traversals. This lock replaces the inode_lock as the inodes on the list can be validity checked while holding the inode->i_lock and hence the inode_lock is no longer needed to protect the lists.
--- fs/inode.c | 69 ++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 40 insertions(+), 29 deletions(-)
fs/inode.c +40 -29
@@ -37,6 +37,8 @@* sb->s_inodes, inode->i_sb_list * inode_sb_list_lock protects: * bdi->wb.b_{dirty,io,more_io}, inode->i_wb_list +* inode_hash_lock protects: +* inode_hashtable, inode->i_hash * * Lock ordering: * inode_lock
@@ -48,6 +50,12 @@* * inode_wb_list_lock * inode->i_lock +* +* inode_hash_lock +* inode->i_lock +* +* iunique_lock +* inode_hash_lock */ /*
@@ -83,6 +91,8 @@static unsigned int i_hash_mask__read_mostly ;static unsigned int i_hash_shift__read_mostly ; +static struct hlist_head *inode_hashtable__read_mostly ; +static __cacheline_aligned_in_smp DEFINE_SPINLOCK (inode_hash_lock );/* * Each inode can be on two separate lists. One is
@@ -98,7 +108,6 @@ static unsigned int i_hash_shift __read_mostly;static LIST_HEAD (inode_lru);static DEFINE_SPINLOCK (inode_lru_lock); -static struct hlist_head *inode_hashtable__read_mostly ;/* * A simple spinlock to protect the list manipulations.
@@ -420,9 +429,9 @@ void __insert_inode_hash(struct inode *inode, unsigned long hashval) {struct hlist_head *b = inode_hashtable +hash (inode->i_sb, hashval); -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock);hlist_add_head (&inode->i_hash, b); -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock); }EXPORT_SYMBOL (__insert_inode_hash);
@@ -434,9 +443,9 @@ EXPORT_SYMBOL(__insert_inode_hash);*/ void remove_inode_hash (struct inode *inode) { -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock);hlist_del_init (&inode->i_hash); -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock); }EXPORT_SYMBOL (remove_inode_hash);
@@ -914,7 +923,7 @@ static struct inode *get_new_inode(struct super_block *sb,if (inode) {struct inode *old; -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock);/* We released the lock, so.. */ old =find_inode (sb, head, test, data);if (!old) {
@@ -925,8 +934,8 @@ static struct inode *get_new_inode(struct super_block *sb, inode->i_state =I_NEW ;spin_unlock (&inode->i_lock);hlist_add_head (&inode->i_hash, head); +spin_unlock (&inode_hash_lock);inode_sb_list_add (inode); -spin_unlock (&inode_lock);/* Return the locked inode with I_NEW set, the * caller is responsible for filling in the contents
@@ -939,7 +948,7 @@ static struct inode *get_new_inode(struct super_block *sb,* us. Use the old inode instead of the one we just * allocated. */ -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);destroy_inode (inode); inode = old;wait_on_inode (inode);
@@ -947,7 +956,7 @@ static struct inode *get_new_inode(struct super_block *sb,return inode; set_failed: -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);destroy_inode (inode);return NULL ; }
@@ -965,7 +974,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb,if (inode) {struct inode *old; -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock);/* We released the lock, so.. */ old =find_inode_fast (sb, head, ino);if (!old) {
@@ -974,8 +983,8 @@ static struct inode *get_new_inode_fast(struct super_block *sb, inode->i_state =I_NEW ;spin_unlock (&inode->i_lock);hlist_add_head (&inode->i_hash, head); +spin_unlock (&inode_hash_lock);inode_sb_list_add (inode); -spin_unlock (&inode_lock);/* Return the locked inode with I_NEW set, the * caller is responsible for filling in the contents
@@ -988,7 +997,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb,* us. Use the old inode instead of the one we just * allocated. */ -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);destroy_inode (inode); inode = old;wait_on_inode (inode);
@@ -1009,10 +1018,14 @@ static int test_inode_iunique(struct super_block *sb, unsigned long ino)struct hlist_node *node;struct inode *inode; +spin_lock (&inode_hash_lock);hlist_for_each_entry (inode, node, b, i_hash) { -if (inode->i_ino == ino && inode->i_sb == sb) +if (inode->i_ino == ino && inode->i_sb == sb) { +spin_unlock (&inode_hash_lock);return 0 ; + } } +spin_unlock (&inode_hash_lock);return 1 ; }
@@ -1042,7 +1055,6 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved)static unsigned int counter;ino_t res; -spin_lock (&inode_lock);spin_lock (&iunique_lock); do { if (counter <= max_reserved)
@@ -1050,7 +1062,6 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved) res = counter++; }while (!test_inode_iunique (sb, res));spin_unlock (&iunique_lock); -spin_unlock (&inode_lock);return res; }
@@ -1102,15 +1113,15 @@ static struct inode *ifind(struct super_block *sb, {struct inode *inode; -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock); inode =find_inode (sb, head, test, data);if (inode) { -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);if (likely (wait))wait_on_inode (inode);return inode; } -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);return NULL ; }
@@ -1134,14 +1145,14 @@ static struct inode *ifind_fast(struct super_block *sb, {struct inode *inode; -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock); inode =find_inode_fast (sb, head, ino);if (inode) { -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);wait_on_inode (inode);return inode; } -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);return NULL ; }
@@ -1306,7 +1317,7 @@ int insert_inode_locked(struct inode *inode)while (1 ) {struct hlist_node *node;struct inode *old =NULL ; -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock);hlist_for_each_entry (old, node, head, i_hash) {if (old->i_ino != ino)continue ;
@@ -1321,12 +1332,12 @@ int insert_inode_locked(struct inode *inode) }if (likely (!node)) {hlist_add_head (&inode->i_hash, head); -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);return 0 ; }__iget (old);spin_unlock (&old->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);wait_on_inode (old);if (unlikely (!inode_unhashed (old))) {iput (old);
@@ -1351,7 +1362,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,struct hlist_node *node;struct inode *old =NULL ; -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock);hlist_for_each_entry (old, node, head, i_hash) {if (old->i_sb != sb)continue ;
@@ -1366,12 +1377,12 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, }if (likely (!node)) {hlist_add_head (&inode->i_hash, head); -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);return 0 ; }__iget (old);spin_unlock (&old->i_lock); -spin_unlock (&inode_lock); +spin_unlock (&inode_hash_lock);wait_on_inode (old);if (unlikely (!inode_unhashed (old))) {iput (old);
@@ -1651,10 +1662,10 @@ 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); +spin_unlock (&inode_hash_lock);schedule ();finish_wait (wq, &wait.wait); -spin_lock (&inode_lock); +spin_lock (&inode_hash_lock); }static __initdata unsigned long ihash_entries;
Signature · 1 line
1.7.1
Re: [PATCH 3/3] fs: move i_hash out from under inode_lock
fs/inode.c static struct inode *get_new_inode(struct super_block *sb, · line 929
Quoted 7 lines
fs/inode.c +1
-1@@ -925,8 +934,8 @@ static struct inode *get_new_inode(struct super_block *sb, inode->i_state =I_NEW ;spin_unlock (&inode->i_lock);hlist_add_head (&inode->i_hash, head); +spin_unlock (&inode_hash_lock);inode_sb_list_add (inode); -spin_unlock (&inode_lock);
Al said he wanted to have the sb lock nest inside the hash lock for now I think. Doubt it matters much, but it keeps the behaviour that we can't look up an inode which is not added to the per-sb list yet.
After that a better patch description might be:
"rename inode_lock to inode_hash_lock"
as the inode_lock coverage after the previous patches should be 100% identical to the new hash lock.
Shouldn't inode_lock be completely gone after these?
also I hope moving to global locks really is just a step inbetween. Especially for writeback I doubt moving from inode_lock to another global lock makes a whole lot of difference - nevermind that it's not too smart to lock per-object lists with a global lock.