diff options
author | Dave Chinner <dchinner@redhat.com> | 2011-03-22 07:23:36 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-24 21:16:31 -0400 |
commit | 250df6ed274d767da844a5d9f05720b804240197 (patch) | |
tree | b74f49a86c4451d9e3e82f90e3f791163025be21 /fs/drop_caches.c | |
parent | 3dc8fe4dca9cd3e4aa828ed36451e2bcfd2350da (diff) |
fs: protect inode->i_state with inode->i_lock
Protect inode state transitions and validity checks with the
inode->i_lock. This enables us to make inode state transitions
independently of the inode_lock and is the first step to peeling
away the inode_lock from the code.
This requires that __iget() is done atomically with i_state checks
during list traversals so that we don't race with another thread
marking the inode I_FREEING between the state check and grabbing the
reference.
Also remove the unlock_new_inode() memory barrier optimisation
required to avoid taking the inode_lock when clearing I_NEW.
Simplify the code by simply taking the inode->i_lock around the
state change and wakeup. Because the wakeup is no longer tricky,
remove the wake_up_inode() function and open code the wakeup where
necessary.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/drop_caches.c')
-rw-r--r-- | fs/drop_caches.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 816f88e6b9ce..6c6f73ba0868 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -18,11 +18,14 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) | |||
18 | 18 | ||
19 | spin_lock(&inode_lock); | 19 | spin_lock(&inode_lock); |
20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
21 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) | 21 | spin_lock(&inode->i_lock); |
22 | continue; | 22 | if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || |
23 | if (inode->i_mapping->nrpages == 0) | 23 | (inode->i_mapping->nrpages == 0)) { |
24 | spin_unlock(&inode->i_lock); | ||
24 | continue; | 25 | continue; |
26 | } | ||
25 | __iget(inode); | 27 | __iget(inode); |
28 | spin_unlock(&inode->i_lock); | ||
26 | spin_unlock(&inode_lock); | 29 | spin_unlock(&inode_lock); |
27 | invalidate_mapping_pages(inode->i_mapping, 0, -1); | 30 | invalidate_mapping_pages(inode->i_mapping, 0, -1); |
28 | iput(toput_inode); | 31 | iput(toput_inode); |