[RFC,1/2] fscrypt: remove d_lock on reading DCACHE_ENCRYPTED_WITH_KEY
diff mbox series

Message ID 1536584468-15695-1-git-send-email-gaoxiang25@huawei.com
State New
Headers show
Series
  • [RFC,1/2] fscrypt: remove d_lock on reading DCACHE_ENCRYPTED_WITH_KEY
Related show

Commit Message

Gao Xiang Sept. 10, 2018, 1:01 p.m. UTC
It seems there is no need to take d_lock when
accessing dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY
in fscrypt_d_revalidate. It only needs to be
serialized for updating.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
Hi,

At glance, I have no idea why fscrypt_d_revalidate disables
RCU-lookup. Therefore I made patches to raise a question and
do some basic test, and it seems to work.

Thanks,

 fs/crypto/crypto.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 0f46cf5..b38c574 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -329,9 +329,8 @@  static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
 		return 0;
 	}
 
-	spin_lock(&dentry->d_lock);
-	cached_with_key = dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY;
-	spin_unlock(&dentry->d_lock);
+	cached_with_key = READ_ONCE(dentry->d_flags) &
+		DCACHE_ENCRYPTED_WITH_KEY;
 	dir_has_key = (d_inode(dir)->i_crypt_info != NULL);
 	dput(dir);