5 #include <linux/module.h>
6 #include <linux/nfs_idmap.h>
8 #include <linux/nfs_fs.h>
15 #define NFSDBG_FACILITY NFSDBG_VFS
18 static void nfs4_evict_inode(
struct inode *
inode);
20 int flags,
const char *dev_name,
void *raw_data);
22 int flags,
const char *dev_name,
void *raw_data);
24 int flags,
const char *dev_name,
void *raw_data);
29 .mount = nfs4_remote_mount,
37 .mount = nfs4_remote_referral_mount,
45 .mount = nfs4_referral_mount,
53 .write_inode = nfs4_write_inode,
56 .evict_inode = nfs4_evict_inode,
67 .nfs_fs = &nfs4_fs_type,
97 static void nfs4_evict_inode(
struct inode *inode)
101 pnfs_return_layout(inode);
114 const char *dev_name,
void *
info)
124 if (IS_ERR(server)) {
125 mntroot = ERR_CAST(server);
136 int flags,
void *
data,
const char *hostname)
142 len =
strlen(hostname) + 5;
144 if (root_devname ==
NULL)
147 if (
strchr(hostname,
':'))
148 snprintf(root_devname, len,
"[%s]:/", hostname);
150 snprintf(root_devname, len,
"%s:/", hostname);
162 static LIST_HEAD(nfs_referral_count_list);
176 #define NFS_MAX_NESTED_REFERRALS 2
178 static int nfs_referral_loop_protect(
void)
187 new->referral_count = 1;
190 spin_lock(&nfs_referral_count_list_lock);
191 p = nfs_find_referral_count();
198 list_add(&new->list, &nfs_referral_count_list);
201 spin_unlock(&nfs_referral_count_list_lock);
207 static void nfs_referral_loop_unprotect(
void)
211 spin_lock(&nfs_referral_count_list_lock);
212 p = nfs_find_referral_count();
218 spin_unlock(&nfs_referral_count_list_lock);
222 static struct dentry *nfs_follow_remote_path(
struct vfsmount *root_mnt,
223 const char *export_path)
228 if (IS_ERR(root_mnt))
229 return ERR_CAST(root_mnt);
231 err = nfs_referral_loop_protect();
238 nfs_referral_loop_unprotect();
252 dfprintk(MOUNT,
"--> nfs4_try_mount()\n");
256 root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info,
260 res = nfs_follow_remote_path(root_mnt, export_path);
262 dfprintk(MOUNT,
"<-- nfs4_try_mount() = %ld%s\n",
263 IS_ERR(res) ? PTR_ERR(res) : 0,
264 IS_ERR(res) ?
" [error]" :
"");
268 static struct dentry *
270 const char *dev_name,
void *raw_data)
278 struct dentry *mntroot = ERR_PTR(-
ENOMEM);
280 dprintk(
"--> nfs4_referral_get_sb()\n");
288 if (IS_ERR(server)) {
289 mntroot = ERR_CAST(server);
295 nfs_free_fhandle(mount_info.
mntfh);
303 int flags,
const char *dev_name,
void *raw_data)
310 dprintk(
"--> nfs4_referral_mount()\n");
315 root_mnt = nfs_do_root_mount(&nfs4_remote_referral_fs_type,
319 res = nfs_follow_remote_path(root_mnt, export_path);
320 dprintk(
"<-- nfs4_referral_mount() = %ld%s\n",
321 IS_ERR(res) ? PTR_ERR(res) : 0,
322 IS_ERR(res) ?
" [error]" :
"");
327 static int __init init_nfs_v4(
void)
347 static void __exit exit_nfs_v4(
void)