nfs: make nfs_path() work without vfsmount
part 3: now we have everything to get nfs_path() just by dentry - just follow to (disconnected) root and pick the rest of the thing there. Start killing propagation of struct vfsmount * on the paths that used to bring it to nfs_path(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -54,33 +54,29 @@ Elong:
|
||||
/*
|
||||
* Determine the mount path as a string
|
||||
*/
|
||||
static char *nfs4_path(const struct vfsmount *mnt_parent,
|
||||
const struct dentry *dentry,
|
||||
char *buffer, ssize_t buflen)
|
||||
static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
|
||||
{
|
||||
const char *srvpath;
|
||||
|
||||
srvpath = strchr(mnt_parent->mnt_devname, ':');
|
||||
if (srvpath)
|
||||
srvpath++;
|
||||
else
|
||||
srvpath = mnt_parent->mnt_devname;
|
||||
|
||||
return nfs_path(srvpath, mnt_parent->mnt_root, dentry, buffer, buflen);
|
||||
char *limit;
|
||||
char *path = nfs_path(&limit, dentry, buffer, buflen);
|
||||
if (!IS_ERR(path)) {
|
||||
char *colon = strchr(path, ':');
|
||||
if (colon && colon < limit)
|
||||
path = colon + 1;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that fs_locations::fs_root [RFC3530 6.3] is a prefix for what we
|
||||
* believe to be the server path to this dentry
|
||||
*/
|
||||
static int nfs4_validate_fspath(const struct vfsmount *mnt_parent,
|
||||
const struct dentry *dentry,
|
||||
static int nfs4_validate_fspath(struct dentry *dentry,
|
||||
const struct nfs4_fs_locations *locations,
|
||||
char *page, char *page2)
|
||||
{
|
||||
const char *path, *fs_path;
|
||||
|
||||
path = nfs4_path(mnt_parent, dentry, page, PAGE_SIZE);
|
||||
path = nfs4_path(dentry, page, PAGE_SIZE);
|
||||
if (IS_ERR(path))
|
||||
return PTR_ERR(path);
|
||||
|
||||
@@ -165,20 +161,20 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
|
||||
|
||||
/**
|
||||
* nfs_follow_referral - set up mountpoint when hitting a referral on moved error
|
||||
* @mnt_parent - mountpoint of parent directory
|
||||
* @sb - superblock of parent directory
|
||||
* @dentry - parent directory
|
||||
* @locations - array of NFSv4 server location information
|
||||
*
|
||||
*/
|
||||
static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
|
||||
const struct dentry *dentry,
|
||||
static struct vfsmount *nfs_follow_referral(struct super_block *sb,
|
||||
struct dentry *dentry,
|
||||
const struct nfs4_fs_locations *locations)
|
||||
{
|
||||
struct vfsmount *mnt = ERR_PTR(-ENOENT);
|
||||
struct nfs_clone_mount mountdata = {
|
||||
.sb = mnt_parent->mnt_sb,
|
||||
.sb = sb,
|
||||
.dentry = dentry,
|
||||
.authflavor = NFS_SB(mnt_parent->mnt_sb)->client->cl_auth->au_flavor,
|
||||
.authflavor = NFS_SB(sb)->client->cl_auth->au_flavor,
|
||||
};
|
||||
char *page = NULL, *page2 = NULL;
|
||||
int loc, error;
|
||||
@@ -198,7 +194,7 @@ static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
|
||||
goto out;
|
||||
|
||||
/* Ensure fs path is a prefix of current dentry path */
|
||||
error = nfs4_validate_fspath(mnt_parent, dentry, locations, page, page2);
|
||||
error = nfs4_validate_fspath(dentry, locations, page, page2);
|
||||
if (error < 0) {
|
||||
mnt = ERR_PTR(error);
|
||||
goto out;
|
||||
@@ -225,11 +221,10 @@ out:
|
||||
|
||||
/*
|
||||
* nfs_do_refmount - handle crossing a referral on server
|
||||
* @mnt_parent - mountpoint of referral
|
||||
* @dentry - dentry of referral
|
||||
*
|
||||
*/
|
||||
struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentry *dentry)
|
||||
struct vfsmount *nfs_do_refmount(struct super_block *sb, struct dentry *dentry)
|
||||
{
|
||||
struct vfsmount *mnt = ERR_PTR(-ENOMEM);
|
||||
struct dentry *parent;
|
||||
@@ -262,7 +257,7 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentr
|
||||
fs_locations->fs_path.ncomponents <= 0)
|
||||
goto out_free;
|
||||
|
||||
mnt = nfs_follow_referral(mnt_parent, dentry, fs_locations);
|
||||
mnt = nfs_follow_referral(sb, dentry, fs_locations);
|
||||
out_free:
|
||||
__free_page(page);
|
||||
kfree(fs_locations);
|
||||
|
Reference in New Issue
Block a user