Skip to content

Commit 3d3699b

Browse files
committed
Merge tag 'nfs-for-6.3-2' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client fixes from Anna Schumaker: - Fix /proc/PID/io read_bytes accounting - Fix setting NLM file_lock start and end during decoding testargs - Fix timing for setting access cache timestamps * tag 'nfs-for-6.3-2' of git://git.linux-nfs.org/projects/anna/linux-nfs: NFS: Correct timing for assigning access cache timestamp lockd: set file_lock start and end when decoding nlm4 testargs NFS: Fix /proc/PID/io read_bytes for buffered reads
2 parents e8d018d + 21fd9e8 commit 3d3699b

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

fs/lockd/clnt4xdr.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
261261
u32 exclusive;
262262
int error;
263263
__be32 *p;
264-
s32 end;
265264

266265
memset(lock, 0, sizeof(*lock));
267266
locks_init_lock(fl);
@@ -285,13 +284,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
285284
fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
286285
p = xdr_decode_hyper(p, &l_offset);
287286
xdr_decode_hyper(p, &l_len);
288-
end = l_offset + l_len - 1;
289-
290-
fl->fl_start = (loff_t)l_offset;
291-
if (l_len == 0 || end < 0)
292-
fl->fl_end = OFFSET_MAX;
293-
else
294-
fl->fl_end = (loff_t)end;
287+
nlm4svc_set_file_lock_range(fl, l_offset, l_len);
295288
error = 0;
296289
out:
297290
return error;

fs/lockd/xdr4.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ loff_t_to_s64(loff_t offset)
3333
return res;
3434
}
3535

36+
void nlm4svc_set_file_lock_range(struct file_lock *fl, u64 off, u64 len)
37+
{
38+
s64 end = off + len - 1;
39+
40+
fl->fl_start = off;
41+
if (len == 0 || end < 0)
42+
fl->fl_end = OFFSET_MAX;
43+
else
44+
fl->fl_end = end;
45+
}
46+
3647
/*
3748
* NLM file handles are defined by specification to be a variable-length
3849
* XDR opaque no longer than 1024 bytes. However, this implementation
@@ -80,7 +91,7 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)
8091
locks_init_lock(fl);
8192
fl->fl_flags = FL_POSIX;
8293
fl->fl_type = F_RDLCK;
83-
94+
nlm4svc_set_file_lock_range(fl, lock->lock_start, lock->lock_len);
8495
return true;
8596
}
8697

fs/nfs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3089,7 +3089,6 @@ static void nfs_access_add_rbtree(struct inode *inode,
30893089
else
30903090
goto found;
30913091
}
3092-
set->timestamp = ktime_get_ns();
30933092
rb_link_node(&set->rb_node, parent, p);
30943093
rb_insert_color(&set->rb_node, root_node);
30953094
list_add_tail(&set->lru, &nfsi->access_cache_entry_lru);
@@ -3114,6 +3113,7 @@ void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set,
31143113
cache->fsgid = cred->fsgid;
31153114
cache->group_info = get_group_info(cred->group_info);
31163115
cache->mask = set->mask;
3116+
cache->timestamp = ktime_get_ns();
31173117

31183118
/* The above field assignments must be visible
31193119
* before this item appears on the lru. We cannot easily

fs/nfs/read.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/stat.h>
1616
#include <linux/mm.h>
1717
#include <linux/slab.h>
18+
#include <linux/task_io_accounting_ops.h>
1819
#include <linux/pagemap.h>
1920
#include <linux/sunrpc/clnt.h>
2021
#include <linux/nfs_fs.h>
@@ -337,6 +338,7 @@ int nfs_read_folio(struct file *file, struct folio *folio)
337338

338339
trace_nfs_aop_readpage(inode, folio);
339340
nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
341+
task_io_account_read(folio_size(folio));
340342

341343
/*
342344
* Try to flush any pending writes to the file..
@@ -393,6 +395,7 @@ void nfs_readahead(struct readahead_control *ractl)
393395

394396
trace_nfs_aop_readahead(inode, readahead_pos(ractl), nr_pages);
395397
nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
398+
task_io_account_read(readahead_length(ractl));
396399

397400
ret = -ESTALE;
398401
if (NFS_STALE(inode))

include/linux/lockd/xdr4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define nlm4_fbig cpu_to_be32(NLM_FBIG)
2323
#define nlm4_failed cpu_to_be32(NLM_FAILED)
2424

25+
void nlm4svc_set_file_lock_range(struct file_lock *fl, u64 off, u64 len);
2526
bool nlm4svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
2627
bool nlm4svc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
2728
bool nlm4svc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);

0 commit comments

Comments
 (0)