NFSD: introduce struct nfsd_attrs
[ Upstream commit 7fe2a71dda349a1afa75781f0cc7975be9784d15 ] The attributes that nfsd might want to set on a file include 'struct iattr' as well as an ACL and security label. The latter two are passed around quite separately from the first, in part because they are only needed for NFSv4. This leads to some clumsiness in the code, such as the attributes NOT being set in nfsd_create_setattr(). We need to keep the directory locked until all attributes are set to ensure the file is never visibile without all its attributes. This need combined with the inconsistent handling of attributes leads to more clumsiness. As a first step towards tidying this up, introduce 'struct nfsd_attrs'. This is passed (by reference) to vfs.c functions that work with attributes, and is assembled by the various nfs*proc functions which call them. As yet only iattr is included, but future patches will expand this. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3aac39eaa6
commit
45cf4b1bb1
@@ -67,12 +67,15 @@ nfsd3_proc_setattr(struct svc_rqst *rqstp)
|
||||
{
|
||||
struct nfsd3_sattrargs *argp = rqstp->rq_argp;
|
||||
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
||||
struct nfsd_attrs attrs = {
|
||||
.na_iattr = &argp->attrs,
|
||||
};
|
||||
|
||||
dprintk("nfsd: SETATTR(3) %s\n",
|
||||
SVCFH_fmt(&argp->fh));
|
||||
|
||||
fh_copy(&resp->fh, &argp->fh);
|
||||
resp->status = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
|
||||
resp->status = nfsd_setattr(rqstp, &resp->fh, &attrs,
|
||||
argp->check_guard, argp->guardtime);
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -233,6 +236,9 @@ nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||
{
|
||||
struct iattr *iap = &argp->attrs;
|
||||
struct dentry *parent, *child;
|
||||
struct nfsd_attrs attrs = {
|
||||
.na_iattr = iap,
|
||||
};
|
||||
__u32 v_mtime, v_atime;
|
||||
struct inode *inode;
|
||||
__be32 status;
|
||||
@@ -331,7 +337,7 @@ nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||
}
|
||||
|
||||
set_attr:
|
||||
status = nfsd_create_setattr(rqstp, fhp, resfhp, iap);
|
||||
status = nfsd_create_setattr(rqstp, fhp, resfhp, &attrs);
|
||||
|
||||
out:
|
||||
fh_unlock(fhp);
|
||||
@@ -368,6 +374,9 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp)
|
||||
{
|
||||
struct nfsd3_createargs *argp = rqstp->rq_argp;
|
||||
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
||||
struct nfsd_attrs attrs = {
|
||||
.na_iattr = &argp->attrs,
|
||||
};
|
||||
|
||||
dprintk("nfsd: MKDIR(3) %s %.*s\n",
|
||||
SVCFH_fmt(&argp->fh),
|
||||
@@ -378,7 +387,7 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp)
|
||||
fh_copy(&resp->dirfh, &argp->fh);
|
||||
fh_init(&resp->fh, NFS3_FHSIZE);
|
||||
resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
|
||||
&argp->attrs, S_IFDIR, 0, &resp->fh);
|
||||
&attrs, S_IFDIR, 0, &resp->fh);
|
||||
fh_unlock(&resp->dirfh);
|
||||
return rpc_success;
|
||||
}
|
||||
@@ -428,6 +437,9 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp)
|
||||
{
|
||||
struct nfsd3_mknodargs *argp = rqstp->rq_argp;
|
||||
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
||||
struct nfsd_attrs attrs = {
|
||||
.na_iattr = &argp->attrs,
|
||||
};
|
||||
int type;
|
||||
dev_t rdev = 0;
|
||||
|
||||
@@ -453,7 +465,7 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp)
|
||||
|
||||
type = nfs3_ftypes[argp->ftype];
|
||||
resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
|
||||
&argp->attrs, type, rdev, &resp->fh);
|
||||
&attrs, type, rdev, &resp->fh);
|
||||
fh_unlock(&resp->dirfh);
|
||||
out:
|
||||
return rpc_success;
|
||||
|
||||
Reference in New Issue
Block a user