[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <30a6227bc449b6ad48dbec72bc0f57ef73f3a5a2.1396469191.git.jslaby@suse.cz>
Date: Wed, 2 Apr 2014 22:13:04 +0200
From: Jiri Slaby <jslaby@...e.cz>
To: stable@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Trond Myklebust <trond.myklebust@...marydata.com>,
Jeff Layton <jlayton@...hat.com>, Jiri Slaby <jslaby@...e.cz>
Subject: [PATCH 3.12 18/40] NFS: Fix races in nfs_revalidate_mapping
From: Trond Myklebust <trond.myklebust@...marydata.com>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit 17dfeb9113397a6119091a491ef7182649f0c5a9 upstream.
Commit d529ef83c355f97027ff85298a9709fe06216a66 (NFS: fix the handling
of NFS_INO_INVALID_DATA flag in nfs_revalidate_mapping) introduces
a potential race, since it doesn't test the value of nfsi->cache_validity
and set the bitlock in nfsi->flags atomically.
Signed-off-by: Trond Myklebust <trond.myklebust@...marydata.com>
Cc: Jeff Layton <jlayton@...hat.com>
Signed-off-by: Jiri Slaby <jslaby@...e.cz>
---
fs/nfs/inode.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 9b6c90a8a311..12c0fa8ae004 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1048,24 +1048,24 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
nfs_wait_bit_killable, TASK_KILLABLE);
if (ret)
goto out;
- if (!(nfsi->cache_validity & NFS_INO_INVALID_DATA))
- goto out;
- if (!test_and_set_bit_lock(NFS_INO_INVALIDATING, bitlock))
+ spin_lock(&inode->i_lock);
+ if (test_bit(NFS_INO_INVALIDATING, bitlock)) {
+ spin_unlock(&inode->i_lock);
+ continue;
+ }
+ if (nfsi->cache_validity & NFS_INO_INVALID_DATA)
break;
- }
-
- spin_lock(&inode->i_lock);
- if (nfsi->cache_validity & NFS_INO_INVALID_DATA) {
- nfsi->cache_validity &= ~NFS_INO_INVALID_DATA;
- spin_unlock(&inode->i_lock);
- trace_nfs_invalidate_mapping_enter(inode);
- ret = nfs_invalidate_mapping(inode, mapping);
- trace_nfs_invalidate_mapping_exit(inode, ret);
- } else {
- /* something raced in and cleared the flag */
spin_unlock(&inode->i_lock);
+ goto out;
}
+ set_bit(NFS_INO_INVALIDATING, bitlock);
+ nfsi->cache_validity &= ~NFS_INO_INVALID_DATA;
+ spin_unlock(&inode->i_lock);
+ trace_nfs_invalidate_mapping_enter(inode);
+ ret = nfs_invalidate_mapping(inode, mapping);
+ trace_nfs_invalidate_mapping_exit(inode, ret);
+
clear_bit_unlock(NFS_INO_INVALIDATING, bitlock);
smp_mb__after_clear_bit();
wake_up_bit(bitlock, NFS_INO_INVALIDATING);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists