aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/namespace.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2011-01-14 13:45:42 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2011-01-15 20:07:34 -0500
commit36d43a43761b004ad1879ac21471d8fc5f3157ec (patch)
tree6cb6c6d978f4e58de7f9bf901707d6929f098345 /fs/nfs/namespace.c
parentd18610b0ce9eb48c60649d8fcbf68374c84349d3 (diff)
NFS: Use d_automount() rather than abusing follow_link()
Make NFS use the new d_automount() dentry operation rather than abusing follow_link() on directories. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com> Acked-by: Ian Kent <raven@themaw.net> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfs/namespace.c')
-rw-r--r--fs/nfs/namespace.c84
1 files changed, 40 insertions, 44 deletions
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index bfcb933e5755..f3fbb1bf3f18 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -97,9 +97,8 @@ Elong:
97} 97}
98 98
99/* 99/*
100 * nfs_follow_mountpoint - handle crossing a mountpoint on the server 100 * nfs_d_automount - Handle crossing a mountpoint on the server
101 * @dentry - dentry of mountpoint 101 * @path - The mountpoint
102 * @nd - nameidata info
103 * 102 *
104 * When we encounter a mountpoint on the server, we want to set up 103 * When we encounter a mountpoint on the server, we want to set up
105 * a mountpoint on the client too, to prevent inode numbers from 104 * a mountpoint on the client too, to prevent inode numbers from
@@ -109,84 +108,81 @@ Elong:
109 * situation, and that different filesystems may want to use 108 * situation, and that different filesystems may want to use
110 * different security flavours. 109 * different security flavours.
111 */ 110 */
112static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) 111struct vfsmount *nfs_d_automount(struct path *path)
113{ 112{
114 struct vfsmount *mnt; 113 struct vfsmount *mnt;
115 struct nfs_server *server = NFS_SERVER(dentry->d_inode); 114 struct nfs_server *server = NFS_SERVER(path->dentry->d_inode);
116 struct dentry *parent; 115 struct dentry *parent;
117 struct nfs_fh *fh = NULL; 116 struct nfs_fh *fh = NULL;
118 struct nfs_fattr *fattr = NULL; 117 struct nfs_fattr *fattr = NULL;
119 int err; 118 int err;
120 119
121 dprintk("--> nfs_follow_mountpoint()\n"); 120 dprintk("--> nfs_d_automount()\n");
122 121
123 err = -ESTALE; 122 mnt = ERR_PTR(-ESTALE);
124 if (IS_ROOT(dentry)) 123 if (IS_ROOT(path->dentry))
125 goto out_err; 124 goto out_nofree;
126 125
127 err = -ENOMEM; 126 mnt = ERR_PTR(-ENOMEM);
128 fh = nfs_alloc_fhandle(); 127 fh = nfs_alloc_fhandle();
129 fattr = nfs_alloc_fattr(); 128 fattr = nfs_alloc_fattr();
130 if (fh == NULL || fattr == NULL) 129 if (fh == NULL || fattr == NULL)
131 goto out_err; 130 goto out;
132 131
133 dprintk("%s: enter\n", __func__); 132 dprintk("%s: enter\n", __func__);
134 dput(nd->path.dentry);
135 nd->path.dentry = dget(dentry);
136 133
137 /* Look it up again */ 134 /* Look it up again to get its attributes */
138 parent = dget_parent(nd->path.dentry); 135 parent = dget_parent(path->dentry);
139 err = server->nfs_client->rpc_ops->lookup(parent->d_inode, 136 err = server->nfs_client->rpc_ops->lookup(parent->d_inode,
140 &nd->path.dentry->d_name, 137 &path->dentry->d_name,
141 fh, fattr); 138 fh, fattr);
142 dput(parent); 139 dput(parent);
143 if (err != 0) 140 if (err != 0) {
144 goto out_err; 141 mnt = ERR_PTR(err);
142 goto out;
143 }
145 144
146 if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) 145 if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)
147 mnt = nfs_do_refmount(nd->path.mnt, nd->path.dentry); 146 mnt = nfs_do_refmount(path->mnt, path->dentry);
148 else 147 else
149 mnt = nfs_do_submount(nd->path.mnt, nd->path.dentry, fh, 148 mnt = nfs_do_submount(path->mnt, path->dentry, fh, fattr);
150 fattr);
151 err = PTR_ERR(mnt);
152 if (IS_ERR(mnt)) 149 if (IS_ERR(mnt))
153 goto out_err; 150 goto out;
154 151
155 mntget(mnt); 152 mntget(mnt);
156 err = do_add_mount(mnt, &nd->path, nd->path.mnt->mnt_flags|MNT_SHRINKABLE, 153 err = do_add_mount(mnt, path, path->mnt->mnt_flags | MNT_SHRINKABLE,
157 &nfs_automount_list); 154 &nfs_automount_list);
158 if (err < 0) { 155 switch (err) {
156 case 0:
157 dprintk("%s: done, success\n", __func__);
158 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
159 break;
160 case -EBUSY:
161 /* someone else made a mount here whilst we were busy */
159 mntput(mnt); 162 mntput(mnt);
160 if (err == -EBUSY) 163 dprintk("%s: done, collision\n", __func__);
161 goto out_follow; 164 mnt = NULL;
162 goto out_err; 165 break;
166 default:
167 mntput(mnt);
168 dprintk("%s: done, error %d\n", __func__, err);
169 mnt = ERR_PTR(err);
170 break;
163 } 171 }
164 path_put(&nd->path); 172
165 nd->path.mnt = mnt;
166 nd->path.dentry = dget(mnt->mnt_root);
167 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
168out: 173out:
169 nfs_free_fattr(fattr); 174 nfs_free_fattr(fattr);
170 nfs_free_fhandle(fh); 175 nfs_free_fhandle(fh);
171 dprintk("%s: done, returned %d\n", __func__, err); 176out_nofree:
172 177 dprintk("<-- nfs_follow_mountpoint() = %p\n", mnt);
173 dprintk("<-- nfs_follow_mountpoint() = %d\n", err); 178 return mnt;
174 return ERR_PTR(err);
175out_err:
176 path_put(&nd->path);
177 goto out;
178out_follow:
179 err = follow_down(&nd->path, false);
180 goto out;
181} 179}
182 180
183const struct inode_operations nfs_mountpoint_inode_operations = { 181const struct inode_operations nfs_mountpoint_inode_operations = {
184 .follow_link = nfs_follow_mountpoint,
185 .getattr = nfs_getattr, 182 .getattr = nfs_getattr,
186}; 183};
187 184
188const struct inode_operations nfs_referral_inode_operations = { 185const struct inode_operations nfs_referral_inode_operations = {
189 .follow_link = nfs_follow_mountpoint,
190}; 186};
191 187
192static void nfs_expire_automounts(struct work_struct *work) 188static void nfs_expire_automounts(struct work_struct *work)