aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-04-10 16:21:14 -0400
committerTheodore Ts'o <tytso@mit.edu>2019-04-17 12:43:14 -0400
commit4c4f7c19b3c721aed418bc97907b411608c5c6a0 (patch)
treef277f0ab8ee56d45ad6ae93950645c405ac7f49c
parentb01531db6cec2aa330dbc91bfbfaaef4a0d387a4 (diff)
vfs: use READ_ONCE() to access ->i_link
Use 'READ_ONCE(inode->i_link)' to explicitly support filesystems caching the symlink target in ->i_link later if it was unavailable at iget() time, or wasn't easily available. I'll be doing this in fscrypt, to improve the performance of encrypted symlinks on ext4, f2fs, and ubifs. ->i_link will start NULL and may later be set to a non-NULL value by a smp_store_release() or cmpxchg_release(). READ_ONCE() is needed on the read side. smp_load_acquire() is unnecessary because only a data dependency barrier is required. (Thanks to Al for pointing this out.) Acked-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/namei.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c
index dede0147b3f6..2855de004c1a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1066,7 +1066,7 @@ const char *get_link(struct nameidata *nd)
1066 return ERR_PTR(error); 1066 return ERR_PTR(error);
1067 1067
1068 nd->last_type = LAST_BIND; 1068 nd->last_type = LAST_BIND;
1069 res = inode->i_link; 1069 res = READ_ONCE(inode->i_link);
1070 if (!res) { 1070 if (!res) {
1071 const char * (*get)(struct dentry *, struct inode *, 1071 const char * (*get)(struct dentry *, struct inode *,
1072 struct delayed_call *); 1072 struct delayed_call *);
@@ -4729,7 +4729,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4729 spin_unlock(&inode->i_lock); 4729 spin_unlock(&inode->i_lock);
4730 } 4730 }
4731 4731
4732 link = inode->i_link; 4732 link = READ_ONCE(inode->i_link);
4733 if (!link) { 4733 if (!link) {
4734 link = inode->i_op->get_link(dentry, inode, &done); 4734 link = inode->i_op->get_link(dentry, inode, &done);
4735 if (IS_ERR(link)) 4735 if (IS_ERR(link))