Commit 474bc334 authored by Trond Myklebust's avatar Trond Myklebust Committed by J. Bruce Fields

nfsd: Reduce contention for the nfsd_file nf_rwsem

When flushing out the unstable file writes as part of a COMMIT call, try
to perform most of of the data writes and waits outside the semaphore.

This means that if the client is sending the COMMIT as part of a memory
reclaim operation, then it can continue performing I/O, with contention
for the lock occurring only once the data sync is finished.

Fixes: 5011af4c ("nfsd: Fix stable writes")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Tested-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 0ff5b50a
...@@ -1123,6 +1123,19 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, ...@@ -1123,6 +1123,19 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
} }
#ifdef CONFIG_NFSD_V3 #ifdef CONFIG_NFSD_V3
static int
nfsd_filemap_write_and_wait_range(struct nfsd_file *nf, loff_t offset,
loff_t end)
{
struct address_space *mapping = nf->nf_file->f_mapping;
int ret = filemap_fdatawrite_range(mapping, offset, end);
if (ret)
return ret;
filemap_fdatawait_range_keep_errors(mapping, offset, end);
return 0;
}
/* /*
* Commit all pending writes to stable storage. * Commit all pending writes to stable storage.
* *
...@@ -1153,9 +1166,10 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1153,9 +1166,10 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
if (err) if (err)
goto out; goto out;
if (EX_ISSYNC(fhp->fh_export)) { if (EX_ISSYNC(fhp->fh_export)) {
int err2; int err2 = nfsd_filemap_write_and_wait_range(nf, offset, end);
down_write(&nf->nf_rwsem); down_write(&nf->nf_rwsem);
if (!err2)
err2 = vfs_fsync_range(nf->nf_file, offset, end, 0); err2 = vfs_fsync_range(nf->nf_file, offset, end, 0);
switch (err2) { switch (err2) {
case 0: case 0:
......
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