Skip to content

Commit 4c4f7c1

Browse files
ebiggerstytso
authored andcommitted
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 <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent b01531d commit 4c4f7c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ const char *get_link(struct nameidata *nd)
10661066
return ERR_PTR(error);
10671067

10681068
nd->last_type = LAST_BIND;
1069-
res = inode->i_link;
1069+
res = READ_ONCE(inode->i_link);
10701070
if (!res) {
10711071
const char * (*get)(struct dentry *, struct inode *,
10721072
struct delayed_call *);
@@ -4729,7 +4729,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
47294729
spin_unlock(&inode->i_lock);
47304730
}
47314731

4732-
link = inode->i_link;
4732+
link = READ_ONCE(inode->i_link);
47334733
if (!link) {
47344734
link = inode->i_op->get_link(dentry, inode, &done);
47354735
if (IS_ERR(link))

0 commit comments

Comments
 (0)