Skip to content

Commit 6b25539

Browse files
author
Al Viro
committed
replace ->follow_link() with new method that could stay in RCU mode
new method: ->get_link(); replacement of ->follow_link(). The differences are: * inode and dentry are passed separately * might be called both in RCU and non-RCU mode; the former is indicated by passing it a NULL dentry. * when called that way it isn't allowed to block and should return ERR_PTR(-ECHILD) if it needs to be called in non-RCU mode. It's a flagday change - the old method is gone, all in-tree instances converted. Conversion isn't hard; said that, so far very few instances do not immediately bail out when called in RCU mode. That'll change in the next commits. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 21fc61c commit 6b25539

45 files changed

Lines changed: 234 additions & 132 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/filesystems/Locking‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ prototypes:
5050
int (*rename2) (struct inode *, struct dentry *,
5151
struct inode *, struct dentry *, unsigned int);
5252
int (*readlink) (struct dentry *, char __user *,int);
53-
const char *(*follow_link) (struct dentry *, void **);
53+
const char *(*get_link) (struct dentry *, struct inode *, void **);
5454
void (*put_link) (struct inode *, void *);
5555
void (*truncate) (struct inode *);
5656
int (*permission) (struct inode *, int, unsigned int);
@@ -83,7 +83,7 @@ rmdir: yes (both) (see below)
8383
rename: yes (all) (see below)
8484
rename2: yes (all) (see below)
8585
readlink: no
86-
follow_link: no
86+
get_link: no
8787
put_link: no
8888
setattr: yes
8989
permission: no (may not block if called in rcu-walk mode)

‎Documentation/filesystems/porting‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,3 +509,9 @@ in your dentry operations instead.
509509
any symlink that might use page_follow_link_light/page_put_link() must
510510
have inode_nohighmem(inode) called before anything might start playing with
511511
its pagecache.
512+
--
513+
[mandatory]
514+
->follow_link() is replaced with ->get_link(); same API, except that
515+
* ->get_link() gets inode as a separate argument
516+
* ->get_link() may be called in RCU mode - in that case NULL
517+
dentry is passed

‎drivers/staging/lustre/lustre/llite/symlink.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ static int ll_readlink_internal(struct inode *inode,
118118
return rc;
119119
}
120120

121-
static const char *ll_follow_link(struct dentry *dentry, void **cookie)
121+
static const char *ll_get_link(struct dentry *dentry,
122+
struct inode *inode, void **cookie)
122123
{
123-
struct inode *inode = d_inode(dentry);
124124
struct ptlrpc_request *request = NULL;
125125
int rc;
126126
char *symname = NULL;
127+
if (!dentry)
128+
return ERR_PTR(-ECHILD);
127129

128130
CDEBUG(D_VFSTRACE, "VFS Op\n");
129131
ll_inode_size_lock(inode);
@@ -149,7 +151,7 @@ static void ll_put_link(struct inode *unused, void *cookie)
149151
struct inode_operations ll_fast_symlink_inode_operations = {
150152
.readlink = generic_readlink,
151153
.setattr = ll_setattr,
152-
.follow_link = ll_follow_link,
154+
.get_link = ll_get_link,
153155
.put_link = ll_put_link,
154156
.getattr = ll_getattr,
155157
.permission = ll_inode_permission,

‎fs/9p/vfs_inode.c‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,18 +1223,25 @@ ino_t v9fs_qid2ino(struct p9_qid *qid)
12231223
}
12241224

12251225
/**
1226-
* v9fs_vfs_follow_link - follow a symlink path
1226+
* v9fs_vfs_get_link - follow a symlink path
12271227
* @dentry: dentry for symlink
1228+
* @inode: inode for symlink
12281229
* @cookie: place to pass the data to put_link()
12291230
*/
12301231

1231-
static const char *v9fs_vfs_follow_link(struct dentry *dentry, void **cookie)
1232+
static const char *v9fs_vfs_get_link(struct dentry *dentry,
1233+
struct inode *inode, void **cookie)
12321234
{
1233-
struct v9fs_session_info *v9ses = v9fs_dentry2v9ses(dentry);
1234-
struct p9_fid *fid = v9fs_fid_lookup(dentry);
1235+
struct v9fs_session_info *v9ses;
1236+
struct p9_fid *fid;
12351237
struct p9_wstat *st;
12361238
char *res;
12371239

1240+
if (!dentry)
1241+
return ERR_PTR(-ECHILD);
1242+
1243+
v9ses = v9fs_dentry2v9ses(dentry);
1244+
fid = v9fs_fid_lookup(dentry);
12381245
p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);
12391246

12401247
if (IS_ERR(fid))
@@ -1452,7 +1459,7 @@ static const struct inode_operations v9fs_file_inode_operations = {
14521459

14531460
static const struct inode_operations v9fs_symlink_inode_operations = {
14541461
.readlink = generic_readlink,
1455-
.follow_link = v9fs_vfs_follow_link,
1462+
.get_link = v9fs_vfs_get_link,
14561463
.put_link = kfree_put_link,
14571464
.getattr = v9fs_vfs_getattr,
14581465
.setattr = v9fs_vfs_setattr,

‎fs/9p/vfs_inode_dotl.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,20 +899,26 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
899899
}
900900

901901
/**
902-
* v9fs_vfs_follow_link_dotl - follow a symlink path
902+
* v9fs_vfs_get_link_dotl - follow a symlink path
903903
* @dentry: dentry for symlink
904+
* @inode: inode for symlink
904905
* @cookie: place to pass the data to put_link()
905906
*/
906907

907908
static const char *
908-
v9fs_vfs_follow_link_dotl(struct dentry *dentry, void **cookie)
909+
v9fs_vfs_get_link_dotl(struct dentry *dentry,
910+
struct inode *inode, void **cookie)
909911
{
910-
struct p9_fid *fid = v9fs_fid_lookup(dentry);
912+
struct p9_fid *fid;
911913
char *target;
912914
int retval;
913915

916+
if (!dentry)
917+
return ERR_PTR(-ECHILD);
918+
914919
p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);
915920

921+
fid = v9fs_fid_lookup(dentry);
916922
if (IS_ERR(fid))
917923
return ERR_CAST(fid);
918924
retval = p9_client_readlink(fid, &target);
@@ -984,7 +990,7 @@ const struct inode_operations v9fs_file_inode_operations_dotl = {
984990

985991
const struct inode_operations v9fs_symlink_inode_operations_dotl = {
986992
.readlink = generic_readlink,
987-
.follow_link = v9fs_vfs_follow_link_dotl,
993+
.get_link = v9fs_vfs_get_link_dotl,
988994
.put_link = kfree_put_link,
989995
.getattr = v9fs_vfs_getattr_dotl,
990996
.setattr = v9fs_vfs_setattr_dotl,

‎fs/affs/symlink.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static int affs_symlink_readpage(struct file *file, struct page *page)
2020
char c;
2121
char lc;
2222

23-
pr_debug("follow_link(ino=%lu)\n", inode->i_ino);
23+
pr_debug("get_link(ino=%lu)\n", inode->i_ino);
2424

2525
bh = affs_bread(inode->i_sb, inode->i_ino);
2626
if (!bh)
@@ -71,7 +71,7 @@ const struct address_space_operations affs_symlink_aops = {
7171

7272
const struct inode_operations affs_symlink_inode_operations = {
7373
.readlink = generic_readlink,
74-
.follow_link = page_follow_link_light,
74+
.get_link = page_get_link,
7575
.put_link = page_put_link,
7676
.setattr = affs_notify_change,
7777
};

‎fs/autofs4/symlink.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212

1313
#include "autofs_i.h"
1414

15-
static const char *autofs4_follow_link(struct dentry *dentry, void **cookie)
15+
static const char *autofs4_get_link(struct dentry *dentry,
16+
struct inode *inode, void **cookie)
1617
{
17-
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
18-
struct autofs_info *ino = autofs4_dentry_ino(dentry);
18+
struct autofs_sb_info *sbi;
19+
struct autofs_info *ino;
20+
if (!dentry)
21+
return ERR_PTR(-ECHILD);
22+
sbi = autofs4_sbi(dentry->d_sb);
23+
ino = autofs4_dentry_ino(dentry);
1924
if (ino && !autofs4_oz_mode(sbi))
2025
ino->last_used = jiffies;
2126
return d_inode(dentry)->i_private;
2227
}
2328

2429
const struct inode_operations autofs4_symlink_inode_operations = {
2530
.readlink = generic_readlink,
26-
.follow_link = autofs4_follow_link
31+
.get_link = autofs4_get_link
2732
};

‎fs/btrfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10096,7 +10096,7 @@ static const struct inode_operations btrfs_special_inode_operations = {
1009610096
};
1009710097
static const struct inode_operations btrfs_symlink_inode_operations = {
1009810098
.readlink = generic_readlink,
10099-
.follow_link = page_follow_link_light,
10099+
.get_link = page_get_link,
1010010100
.put_link = page_put_link,
1010110101
.getattr = btrfs_getattr,
1010210102
.setattr = btrfs_setattr,

‎fs/ceph/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
17561756
*/
17571757
static const struct inode_operations ceph_symlink_iops = {
17581758
.readlink = generic_readlink,
1759-
.follow_link = simple_follow_link,
1759+
.get_link = simple_get_link,
17601760
.setattr = ceph_setattr,
17611761
.getattr = ceph_getattr,
17621762
.setxattr = ceph_setxattr,

‎fs/cifs/cifsfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ const struct inode_operations cifs_file_inode_ops = {
900900

901901
const struct inode_operations cifs_symlink_inode_ops = {
902902
.readlink = generic_readlink,
903-
.follow_link = cifs_follow_link,
903+
.get_link = cifs_get_link,
904904
.put_link = kfree_put_link,
905905
.permission = cifs_permission,
906906
/* BB add the following two eventually */

0 commit comments

Comments
 (0)