Skip to content

Commit 1c6c4b7

Browse files
author
Trond Myklebust
committed
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>
1 parent 28d5223 commit 1c6c4b7

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

fs/nfs/pagelist.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ EXPORT_SYMBOL_GPL(nfs_pgheader_init);
6363

6464
void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos)
6565
{
66-
spin_lock(&hdr->lock);
67-
if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags)
68-
|| pos < hdr->io_start + hdr->good_bytes) {
66+
unsigned int new = pos - hdr->io_start;
67+
68+
if (hdr->good_bytes > new) {
69+
hdr->good_bytes = new;
6970
clear_bit(NFS_IOHDR_EOF, &hdr->flags);
70-
hdr->good_bytes = pos - hdr->io_start;
71-
hdr->error = error;
71+
if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags))
72+
hdr->error = error;
7273
}
73-
spin_unlock(&hdr->lock);
7474
}
7575

7676
static inline struct nfs_page *
@@ -494,7 +494,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops)
494494

495495
if (hdr) {
496496
INIT_LIST_HEAD(&hdr->pages);
497-
spin_lock_init(&hdr->lock);
498497
hdr->rw_ops = ops;
499498
}
500499
return hdr;

fs/nfs/read.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,14 @@ static void nfs_readpage_result(struct rpc_task *task,
276276
struct nfs_pgio_header *hdr)
277277
{
278278
if (hdr->res.eof) {
279-
loff_t bound;
279+
loff_t pos = hdr->args.offset + hdr->res.count;
280+
unsigned int new = pos - hdr->io_start;
280281

281-
bound = hdr->args.offset + hdr->res.count;
282-
spin_lock(&hdr->lock);
283-
if (bound < hdr->io_start + hdr->good_bytes) {
282+
if (hdr->good_bytes > new) {
283+
hdr->good_bytes = new;
284284
set_bit(NFS_IOHDR_EOF, &hdr->flags);
285285
clear_bit(NFS_IOHDR_ERROR, &hdr->flags);
286-
hdr->good_bytes = bound - hdr->io_start;
287286
}
288-
spin_unlock(&hdr->lock);
289287
} else if (hdr->res.count < hdr->args.count)
290288
nfs_readpage_retry(task, hdr);
291289
}

include/linux/nfs_xdr.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,11 +1482,10 @@ struct nfs_pgio_header {
14821482
const struct nfs_rw_ops *rw_ops;
14831483
struct nfs_io_completion *io_completion;
14841484
struct nfs_direct_req *dreq;
1485-
spinlock_t lock;
1486-
/* fields protected by lock */
1485+
14871486
int pnfs_error;
14881487
int error; /* merge with pnfs_error */
1489-
unsigned long good_bytes; /* boundary of good data */
1488+
unsigned int good_bytes; /* boundary of good data */
14901489
unsigned long flags;
14911490

14921491
/*

0 commit comments

Comments
 (0)