1
0
Fork 0

NFS: Remove private spinlock in struct nfs_pgio_header

Now that each struct nfs_pgio_header corresponds to one RPC call, we
only have one writer to the struct nfs_pgio_header.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
hifive-unleashed-5.1
Trond Myklebust 2018-09-25 12:34:43 -04:00
parent 28d52235ee
commit 1c6c4b740d
3 changed files with 12 additions and 16 deletions

View File

@ -63,14 +63,14 @@ EXPORT_SYMBOL_GPL(nfs_pgheader_init);
void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos) void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos)
{ {
spin_lock(&hdr->lock); unsigned int new = pos - hdr->io_start;
if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags)
|| pos < hdr->io_start + hdr->good_bytes) { if (hdr->good_bytes > new) {
hdr->good_bytes = new;
clear_bit(NFS_IOHDR_EOF, &hdr->flags); clear_bit(NFS_IOHDR_EOF, &hdr->flags);
hdr->good_bytes = pos - hdr->io_start; if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags))
hdr->error = error; hdr->error = error;
} }
spin_unlock(&hdr->lock);
} }
static inline struct nfs_page * static inline struct nfs_page *
@ -494,7 +494,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops)
if (hdr) { if (hdr) {
INIT_LIST_HEAD(&hdr->pages); INIT_LIST_HEAD(&hdr->pages);
spin_lock_init(&hdr->lock);
hdr->rw_ops = ops; hdr->rw_ops = ops;
} }
return hdr; return hdr;

View File

@ -276,16 +276,14 @@ static void nfs_readpage_result(struct rpc_task *task,
struct nfs_pgio_header *hdr) struct nfs_pgio_header *hdr)
{ {
if (hdr->res.eof) { if (hdr->res.eof) {
loff_t bound; loff_t pos = hdr->args.offset + hdr->res.count;
unsigned int new = pos - hdr->io_start;
bound = hdr->args.offset + hdr->res.count; if (hdr->good_bytes > new) {
spin_lock(&hdr->lock); hdr->good_bytes = new;
if (bound < hdr->io_start + hdr->good_bytes) {
set_bit(NFS_IOHDR_EOF, &hdr->flags); set_bit(NFS_IOHDR_EOF, &hdr->flags);
clear_bit(NFS_IOHDR_ERROR, &hdr->flags); clear_bit(NFS_IOHDR_ERROR, &hdr->flags);
hdr->good_bytes = bound - hdr->io_start;
} }
spin_unlock(&hdr->lock);
} else if (hdr->res.count < hdr->args.count) } else if (hdr->res.count < hdr->args.count)
nfs_readpage_retry(task, hdr); nfs_readpage_retry(task, hdr);
} }

View File

@ -1482,11 +1482,10 @@ struct nfs_pgio_header {
const struct nfs_rw_ops *rw_ops; const struct nfs_rw_ops *rw_ops;
struct nfs_io_completion *io_completion; struct nfs_io_completion *io_completion;
struct nfs_direct_req *dreq; struct nfs_direct_req *dreq;
spinlock_t lock;
/* fields protected by lock */
int pnfs_error; int pnfs_error;
int error; /* merge with pnfs_error */ int error; /* merge with pnfs_error */
unsigned long good_bytes; /* boundary of good data */ unsigned int good_bytes; /* boundary of good data */
unsigned long flags; unsigned long flags;
/* /*