提交 609339c1 编写于 作者: T Trond Myklebust 提交者: Anna Schumaker

NFSv4.1: Fix exclusive create

When we use EXCLUSIVE4_1 mode, the server returns an attribute mask where
all the bits indicate which attributes were set, and where the verifier
was stored. In order to figure out which attribute we have to resend,
we need to clear out the attributes that are set in exclcreat_bitmask.
Signed-off-by: NTrond Myklebust <trond.myklebust@primarydata.com>
[Anna: Fixed typo NFS4_CREATE_EXCLUSIVE4 -> NFS4_CREATE_EXCLUSIVE]
Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
上级 f6cdfa6d
...@@ -2750,27 +2750,40 @@ static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st ...@@ -2750,27 +2750,40 @@ static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
* fields corresponding to attributes that were used to store the verifier. * fields corresponding to attributes that were used to store the verifier.
* Make sure we clobber those fields in the later setattr call * Make sure we clobber those fields in the later setattr call
*/ */
static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, static unsigned nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
struct iattr *sattr, struct nfs4_label **label) struct iattr *sattr, struct nfs4_label **label)
{ {
const u32 *attrset = opendata->o_res.attrset; const __u32 *bitmask = opendata->o_arg.server->exclcreat_bitmask;
__u32 attrset[3];
unsigned ret;
unsigned i;
if ((attrset[1] & FATTR4_WORD1_TIME_ACCESS) && for (i = 0; i < ARRAY_SIZE(attrset); i++) {
!(sattr->ia_valid & ATTR_ATIME_SET)) attrset[i] = opendata->o_res.attrset[i];
sattr->ia_valid |= ATTR_ATIME; if (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE4_1)
attrset[i] &= ~bitmask[i];
}
ret = (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE) ?
sattr->ia_valid : 0;
if ((attrset[1] & FATTR4_WORD1_TIME_MODIFY) && if ((attrset[1] & (FATTR4_WORD1_TIME_ACCESS|FATTR4_WORD1_TIME_ACCESS_SET))) {
!(sattr->ia_valid & ATTR_MTIME_SET)) if (sattr->ia_valid & ATTR_ATIME_SET)
sattr->ia_valid |= ATTR_MTIME; ret |= ATTR_ATIME_SET;
else
ret |= ATTR_ATIME;
}
/* Except MODE, it seems harmless of setting twice. */ if ((attrset[1] & (FATTR4_WORD1_TIME_MODIFY|FATTR4_WORD1_TIME_MODIFY_SET))) {
if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE && if (sattr->ia_valid & ATTR_MTIME_SET)
(attrset[1] & FATTR4_WORD1_MODE || ret |= ATTR_MTIME_SET;
attrset[2] & FATTR4_WORD2_MODE_UMASK)) else
sattr->ia_valid &= ~ATTR_MODE; ret |= ATTR_MTIME;
}
if (attrset[2] & FATTR4_WORD2_SECURITY_LABEL) if (!(attrset[2] & FATTR4_WORD2_SECURITY_LABEL))
*label = NULL; *label = NULL;
return ret;
} }
static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
...@@ -2899,12 +2912,15 @@ static int _nfs4_do_open(struct inode *dir, ...@@ -2899,12 +2912,15 @@ static int _nfs4_do_open(struct inode *dir,
if ((opendata->o_arg.open_flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) && if ((opendata->o_arg.open_flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) &&
(opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) { (opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) {
nfs4_exclusive_attrset(opendata, sattr, &label); unsigned attrs = nfs4_exclusive_attrset(opendata, sattr, &label);
/* /*
* send create attributes which was not set by open * send create attributes which was not set by open
* with an extra setattr. * with an extra setattr.
*/ */
if (sattr->ia_valid & NFS4_VALID_ATTRS) { if (attrs || label) {
unsigned ia_old = sattr->ia_valid;
sattr->ia_valid = attrs;
nfs_fattr_init(opendata->o_res.f_attr); nfs_fattr_init(opendata->o_res.f_attr);
status = nfs4_do_setattr(state->inode, cred, status = nfs4_do_setattr(state->inode, cred,
opendata->o_res.f_attr, sattr, opendata->o_res.f_attr, sattr,
...@@ -2914,6 +2930,7 @@ static int _nfs4_do_open(struct inode *dir, ...@@ -2914,6 +2930,7 @@ static int _nfs4_do_open(struct inode *dir,
opendata->o_res.f_attr); opendata->o_res.f_attr);
nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel); nfs_setsecurity(state->inode, opendata->o_res.f_attr, olabel);
} }
sattr->ia_valid = ia_old;
} }
} }
if (opened && opendata->file_created) if (opened && opendata->file_created)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册