Commit a1e7f30a authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Retrieve ACCESS on open if we're not using NFS4_CREATE_EXCLUSIVE

NFS4_CREATE_EXCLUSIVE does not allow the caller to set an access mode,
so for most Linux filesystems, the access call ends up returning no
permissions. However both NFS4_CREATE_EXCLUSIVE4_1 and
NFS4_CREATE_GUARDED allow the client to set the access mode.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 43d20e80
...@@ -1388,9 +1388,6 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, ...@@ -1388,9 +1388,6 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
sizeof(p->o_arg.u.verifier.data)); sizeof(p->o_arg.u.verifier.data));
} }
} }
/* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
* will return permission denied for all bits until close */
if (!(flags & O_EXCL)) {
/* ask server to check for all possible rights as results /* ask server to check for all possible rights as results
* are cached */ * are cached */
switch (p->o_arg.claim) { switch (p->o_arg.claim) {
...@@ -1398,18 +1395,16 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, ...@@ -1398,18 +1395,16 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
break; break;
case NFS4_OPEN_CLAIM_NULL: case NFS4_OPEN_CLAIM_NULL:
case NFS4_OPEN_CLAIM_FH: case NFS4_OPEN_CLAIM_FH:
p->o_arg.access = NFS4_ACCESS_READ | p->o_arg.access = NFS4_ACCESS_READ | NFS4_ACCESS_MODIFY |
NFS4_ACCESS_MODIFY | NFS4_ACCESS_EXTEND | NFS4_ACCESS_DELETE |
NFS4_ACCESS_EXTEND |
NFS4_ACCESS_EXECUTE; NFS4_ACCESS_EXECUTE;
#ifdef CONFIG_NFS_V4_2 #ifdef CONFIG_NFS_V4_2
if (server->caps & NFS_CAP_XATTR) if (!(server->caps & NFS_CAP_XATTR))
p->o_arg.access |= NFS4_ACCESS_XAREAD | break;
NFS4_ACCESS_XAWRITE | p->o_arg.access |= NFS4_ACCESS_XAREAD | NFS4_ACCESS_XAWRITE |
NFS4_ACCESS_XALIST; NFS4_ACCESS_XALIST;
#endif #endif
} }
}
p->o_arg.clientid = server->nfs_client->cl_clientid; p->o_arg.clientid = server->nfs_client->cl_clientid;
p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time); p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
p->o_arg.id.uniquifier = sp->so_seqid.owner_id; p->o_arg.id.uniquifier = sp->so_seqid.owner_id;
...@@ -2472,11 +2467,15 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) ...@@ -2472,11 +2467,15 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
/* Set the create mode (note dependency on the session type) */ /* Set the create mode (note dependency on the session type) */
data->o_arg.createmode = NFS4_CREATE_UNCHECKED; data->o_arg.createmode = NFS4_CREATE_UNCHECKED;
if (data->o_arg.open_flags & O_EXCL) { if (data->o_arg.open_flags & O_EXCL) {
data->o_arg.createmode = NFS4_CREATE_EXCLUSIVE4_1;
if (clp->cl_mvops->minor_version == 0) {
data->o_arg.createmode = NFS4_CREATE_EXCLUSIVE; data->o_arg.createmode = NFS4_CREATE_EXCLUSIVE;
if (nfs4_has_persistent_session(clp)) /* don't put an ACCESS op in OPEN compound if O_EXCL,
* because ACCESS will return permission denied for
* all bits until close */
data->o_res.access_request = data->o_arg.access = 0;
} else if (nfs4_has_persistent_session(clp))
data->o_arg.createmode = NFS4_CREATE_GUARDED; data->o_arg.createmode = NFS4_CREATE_GUARDED;
else if (clp->cl_mvops->minor_version > 0)
data->o_arg.createmode = NFS4_CREATE_EXCLUSIVE4_1;
} }
return; return;
unlock_no_action: unlock_no_action:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment