mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 21:35:07 +00:00
NFSD: Pass the target nfsd_file to nfsd_commit()
In a moment I'm going to introduce separate nfsd_file types, one of which is garbage-collected; the other, not. The garbage-collected variety is to be used by NFSv2 and v3, and the non-garbage-collected variety is to be used by NFSv4. nfsd_commit() is invoked by both NFSv3 and NFSv4 consumers. We want nfsd_commit() to find and use the correct variety of cached nfsd_file object for the NFS version that is in use. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
e0aa651068
commit
c252849082
@ -13,6 +13,7 @@
|
||||
#include "cache.h"
|
||||
#include "xdr3.h"
|
||||
#include "vfs.h"
|
||||
#include "filecache.h"
|
||||
|
||||
#define NFSDDBG_FACILITY NFSDDBG_PROC
|
||||
|
||||
@ -763,6 +764,7 @@ nfsd3_proc_commit(struct svc_rqst *rqstp)
|
||||
{
|
||||
struct nfsd3_commitargs *argp = rqstp->rq_argp;
|
||||
struct nfsd3_commitres *resp = rqstp->rq_resp;
|
||||
struct nfsd_file *nf;
|
||||
|
||||
dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
|
||||
SVCFH_fmt(&argp->fh),
|
||||
@ -770,8 +772,14 @@ nfsd3_proc_commit(struct svc_rqst *rqstp)
|
||||
(unsigned long long) argp->offset);
|
||||
|
||||
fh_copy(&resp->fh, &argp->fh);
|
||||
resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset,
|
||||
resp->status = nfsd_file_acquire(rqstp, &resp->fh, NFSD_MAY_WRITE |
|
||||
NFSD_MAY_NOT_BREAK_LEASE, &nf);
|
||||
if (resp->status)
|
||||
goto out;
|
||||
resp->status = nfsd_commit(rqstp, &resp->fh, nf, argp->offset,
|
||||
argp->count, resp->verf);
|
||||
nfsd_file_put(nf);
|
||||
out:
|
||||
return rpc_success;
|
||||
}
|
||||
|
||||
|
@ -731,10 +731,19 @@ nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
||||
union nfsd4_op_u *u)
|
||||
{
|
||||
struct nfsd4_commit *commit = &u->commit;
|
||||
struct nfsd_file *nf;
|
||||
__be32 status;
|
||||
|
||||
return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset,
|
||||
status = nfsd_file_acquire(rqstp, &cstate->current_fh, NFSD_MAY_WRITE |
|
||||
NFSD_MAY_NOT_BREAK_LEASE, &nf);
|
||||
if (status != nfs_ok)
|
||||
return status;
|
||||
|
||||
status = nfsd_commit(rqstp, &cstate->current_fh, nf, commit->co_offset,
|
||||
commit->co_count,
|
||||
(__be32 *)commit->co_verf.data);
|
||||
nfsd_file_put(nf);
|
||||
return status;
|
||||
}
|
||||
|
||||
static __be32
|
||||
|
@ -1196,6 +1196,7 @@ out:
|
||||
* nfsd_commit - Commit pending writes to stable storage
|
||||
* @rqstp: RPC request being processed
|
||||
* @fhp: NFS filehandle
|
||||
* @nf: target file
|
||||
* @offset: raw offset from beginning of file
|
||||
* @count: raw count of bytes to sync
|
||||
* @verf: filled in with the server's current write verifier
|
||||
@ -1212,19 +1213,13 @@ out:
|
||||
* An nfsstat value in network byte order.
|
||||
*/
|
||||
__be32
|
||||
nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, u64 offset,
|
||||
u32 count, __be32 *verf)
|
||||
nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
|
||||
u64 offset, u32 count, __be32 *verf)
|
||||
{
|
||||
__be32 err = nfs_ok;
|
||||
u64 maxbytes;
|
||||
loff_t start, end;
|
||||
struct nfsd_net *nn;
|
||||
struct nfsd_file *nf;
|
||||
__be32 err;
|
||||
|
||||
err = nfsd_file_acquire(rqstp, fhp,
|
||||
NFSD_MAY_WRITE|NFSD_MAY_NOT_BREAK_LEASE, &nf);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Convert the client-provided (offset, count) range to a
|
||||
@ -1265,8 +1260,6 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, u64 offset,
|
||||
} else
|
||||
nfsd_copy_write_verifier(verf, nn);
|
||||
|
||||
nfsd_file_put(nf);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,8 @@ __be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
|
||||
__be32 nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||
struct svc_fh *resfhp, struct nfsd_attrs *iap);
|
||||
__be32 nfsd_commit(struct svc_rqst *rqst, struct svc_fh *fhp,
|
||||
u64 offset, u32 count, __be32 *verf);
|
||||
struct nfsd_file *nf, u64 offset, u32 count,
|
||||
__be32 *verf);
|
||||
#ifdef CONFIG_NFSD_V4
|
||||
__be32 nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||
char *name, void **bufp, int *lenp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user