aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-04-27 13:27:40 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 14:10:02 -0400
commit72de53ec4bca39c26709122a8f78bfefe7b6bca4 (patch)
treedac32c44281b153df7104037c1e97c11deffae69 /fs/nfs/nfs4proc.c
parentdb0a9593d52f935c80085d8993bdcead1ad30b0c (diff)
NFS: Do secinfo as part of lookup
Whenever lookup sees wrongsec do a secinfo and retry the lookup to find attributes of the file or directory, such as "is this a referral mountpoint?". This also allows me to remove handling -NFS4ERR_WRONSEC as part of getattr xdr decoding. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c64
1 files changed, 47 insertions, 17 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ff7571f12bb8..3d92fe6be780 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2528,39 +2528,69 @@ static int _nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir,
2528 return status; 2528 return status;
2529} 2529}
2530 2530
2531void nfs_fixup_secinfo_attributes(struct nfs_fattr *fattr, struct nfs_fh *fh) 2531static void nfs_fixup_secinfo_attributes(struct nfs_fattr *fattr)
2532{ 2532{
2533 memset(fh, 0, sizeof(struct nfs_fh));
2534 fattr->fsid.major = 1;
2535 fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE | 2533 fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE |
2536 NFS_ATTR_FATTR_NLINK | NFS_ATTR_FATTR_FSID | NFS_ATTR_FATTR_MOUNTPOINT; 2534 NFS_ATTR_FATTR_NLINK | NFS_ATTR_FATTR_MOUNTPOINT;
2537 fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO; 2535 fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO;
2538 fattr->nlink = 2; 2536 fattr->nlink = 2;
2539} 2537}
2540 2538
2541static int nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qstr *name, 2539static int nfs4_proc_lookup_common(struct rpc_clnt **clnt, struct inode *dir,
2542 struct nfs_fh *fhandle, struct nfs_fattr *fattr) 2540 struct qstr *name, struct nfs_fh *fhandle,
2541 struct nfs_fattr *fattr)
2543{ 2542{
2544 struct nfs4_exception exception = { }; 2543 struct nfs4_exception exception = { };
2544 struct rpc_clnt *client = *clnt;
2545 int err; 2545 int err;
2546 do { 2546 do {
2547 int status; 2547 err = _nfs4_proc_lookup(client, dir, name, fhandle, fattr);
2548 2548 switch (err) {
2549 status = _nfs4_proc_lookup(clnt, dir, name, fhandle, fattr);
2550 switch (status) {
2551 case -NFS4ERR_BADNAME: 2549 case -NFS4ERR_BADNAME:
2552 return -ENOENT; 2550 err = -ENOENT;
2551 goto out;
2553 case -NFS4ERR_MOVED: 2552 case -NFS4ERR_MOVED:
2554 return nfs4_get_referral(dir, name, fattr, fhandle); 2553 err = nfs4_get_referral(dir, name, fattr, fhandle);
2554 goto out;
2555 case -NFS4ERR_WRONGSEC: 2555 case -NFS4ERR_WRONGSEC:
2556 nfs_fixup_secinfo_attributes(fattr, fhandle); 2556 err = -EPERM;
2557 if (client != *clnt)
2558 goto out;
2559
2560 client = nfs4_create_sec_client(client, dir, name);
2561 if (IS_ERR(client))
2562 return PTR_ERR(client);
2563
2564 exception.retry = 1;
2565 break;
2566 default:
2567 err = nfs4_handle_exception(NFS_SERVER(dir), err, &exception);
2557 } 2568 }
2558 err = nfs4_handle_exception(NFS_SERVER(dir),
2559 status, &exception);
2560 } while (exception.retry); 2569 } while (exception.retry);
2570
2571out:
2572 if (err == 0)
2573 *clnt = client;
2574 else if (client != *clnt)
2575 rpc_shutdown_client(client);
2576
2561 return err; 2577 return err;
2562} 2578}
2563 2579
2580static int nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qstr *name,
2581 struct nfs_fh *fhandle, struct nfs_fattr *fattr)
2582{
2583 int status;
2584 struct rpc_clnt *client = NFS_CLIENT(dir);
2585
2586 status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr);
2587 if (client != NFS_CLIENT(dir)) {
2588 rpc_shutdown_client(client);
2589 nfs_fixup_secinfo_attributes(fattr);
2590 }
2591 return status;
2592}
2593
2564static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) 2594static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry)
2565{ 2595{
2566 struct nfs_server *server = NFS_SERVER(inode); 2596 struct nfs_server *server = NFS_SERVER(inode);
@@ -4996,8 +5026,8 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct
4996 return status; 5026 return status;
4997} 5027}
4998 5028
4999static int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, 5029int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name,
5000 struct nfs4_secinfo_flavors *flavors) 5030 struct nfs4_secinfo_flavors *flavors)
5001{ 5031{
5002 struct nfs4_exception exception = { }; 5032 struct nfs4_exception exception = { };
5003 int err; 5033 int err;