aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/namespace.c')
-rw-r--r--fs/nfs/namespace.c77
1 files changed, 27 insertions, 50 deletions
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 74aaf3963c10..f32b8603dca8 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,87 +108,65 @@ 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 dprintk("%s: done, success\n", __func__);
156 err = do_add_mount(mnt, &nd->path, nd->path.mnt->mnt_flags|MNT_SHRINKABLE, 153 mntget(mnt); /* prevent immediate expiration */
157 &nfs_automount_list); 154 mnt_set_expiry(mnt, &nfs_automount_list);
158 if (err < 0) {
159 mntput(mnt);
160 if (err == -EBUSY)
161 goto out_follow;
162 goto out_err;
163 }
164 path_put(&nd->path);
165 nd->path.mnt = mnt;
166 nd->path.dentry = dget(mnt->mnt_root);
167 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); 155 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
156
168out: 157out:
169 nfs_free_fattr(fattr); 158 nfs_free_fattr(fattr);
170 nfs_free_fhandle(fh); 159 nfs_free_fhandle(fh);
171 dprintk("%s: done, returned %d\n", __func__, err); 160out_nofree:
172 161 dprintk("<-- nfs_follow_mountpoint() = %p\n", mnt);
173 dprintk("<-- nfs_follow_mountpoint() = %d\n", err); 162 return mnt;
174 return ERR_PTR(err);
175out_err:
176 path_put(&nd->path);
177 goto out;
178out_follow:
179 while (d_mountpoint(nd->path.dentry) &&
180 follow_down(&nd->path))
181 ;
182 err = 0;
183 goto out;
184} 163}
185 164
186const struct inode_operations nfs_mountpoint_inode_operations = { 165const struct inode_operations nfs_mountpoint_inode_operations = {
187 .follow_link = nfs_follow_mountpoint,
188 .getattr = nfs_getattr, 166 .getattr = nfs_getattr,
189}; 167};
190 168
191const struct inode_operations nfs_referral_inode_operations = { 169const struct inode_operations nfs_referral_inode_operations = {
192 .follow_link = nfs_follow_mountpoint,
193}; 170};
194 171
195static void nfs_expire_automounts(struct work_struct *work) 172static void nfs_expire_automounts(struct work_struct *work)