NFS Client Bugfixes for Linux 6.3-rc

Bugfixes:
   * 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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEnZ5MQTpR7cLU7KEp18tUv7ClQOsFAmQYnFoACgkQ18tUv7Cl
 QOv86RAAuDaOVfnPHuM1EMgTiBG+EZnCjMz+ktEuYhKuHdtS2cplq0S5Uygx1Zpl
 Kt9/Ww77k2jOPvsk3R1ejmFv1aiyNz+S9eEHrPp6nfwRhhQBw04fvo+y3mjrkNLq
 p4Y0Wes+9/0SnYftcsrcO/ghsc0t5DLm9eiGZMICes21cnrAO8iY1PY5DX2p7ipb
 O4qEnfCA67Nt+rY2T6lbMoI8kMyN+J4FaFCwPaMv8UDP/RqdG1KR429V46JwrKxR
 1FbG1nKH03U3apmaaGcRVr8meswPetQNWfJnmjsAHur6z8pCZ233oIggj4gnBIdy
 jGDWwQ3lT55+6XvkW4yrgGPUT2oDYiYwW4uk401I+xWJIbNvRMXKPIQWehHMTR4v
 0Xo8rhefPkgHrJkhaoBjvnMeKl79QwGUCSw5ECluxKm9nkDGeVa5kRBFCfkeWgfR
 dGJNUOqd6P3vVdGVvTEYP/q5mrDpr+4ZTyggm2IbP0nKNnYgwPoHVn+Prwsht+wh
 XGmXpu5C07U5fex7uzfmK/S8JWZDkEoNOZJQ8AE+NFm8MZFl8wUIfuyaZS4ItSEk
 odIGQ+PSMbEyfo24WhSk3BLt0cqzWxeweENUxP00PVOyqcYmj5duRP7OIVVHmm/w
 dDwh5tQfykrF7opNMoJBXXAGlwI9O0t0UwBvNasBUiINctrapOw=
 =n/JC
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-03-20 10:52:10 -07:00
commit 3d3699bde4
5 changed files with 18 additions and 10 deletions

View file

@ -261,7 +261,6 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
u32 exclusive;
int error;
__be32 *p;
s32 end;
memset(lock, 0, sizeof(*lock));
locks_init_lock(fl);
@ -285,13 +284,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result)
fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
p = xdr_decode_hyper(p, &l_offset);
xdr_decode_hyper(p, &l_len);
end = l_offset + l_len - 1;
fl->fl_start = (loff_t)l_offset;
if (l_len == 0 || end < 0)
fl->fl_end = OFFSET_MAX;
else
fl->fl_end = (loff_t)end;
nlm4svc_set_file_lock_range(fl, l_offset, l_len);
error = 0;
out:
return error;

View file

@ -33,6 +33,17 @@ loff_t_to_s64(loff_t offset)
return res;
}
void nlm4svc_set_file_lock_range(struct file_lock *fl, u64 off, u64 len)
{
s64 end = off + len - 1;
fl->fl_start = off;
if (len == 0 || end < 0)
fl->fl_end = OFFSET_MAX;
else
fl->fl_end = end;
}
/*
* NLM file handles are defined by specification to be a variable-length
* 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)
locks_init_lock(fl);
fl->fl_flags = FL_POSIX;
fl->fl_type = F_RDLCK;
nlm4svc_set_file_lock_range(fl, lock->lock_start, lock->lock_len);
return true;
}

View file

@ -3089,7 +3089,6 @@ static void nfs_access_add_rbtree(struct inode *inode,
else
goto found;
}
set->timestamp = ktime_get_ns();
rb_link_node(&set->rb_node, parent, p);
rb_insert_color(&set->rb_node, root_node);
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,
cache->fsgid = cred->fsgid;
cache->group_info = get_group_info(cred->group_info);
cache->mask = set->mask;
cache->timestamp = ktime_get_ns();
/* The above field assignments must be visible
* before this item appears on the lru. We cannot easily

View file

@ -15,6 +15,7 @@
#include <linux/stat.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/task_io_accounting_ops.h>
#include <linux/pagemap.h>
#include <linux/sunrpc/clnt.h>
#include <linux/nfs_fs.h>
@ -337,6 +338,7 @@ int nfs_read_folio(struct file *file, struct folio *folio)
trace_nfs_aop_readpage(inode, folio);
nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
task_io_account_read(folio_size(folio));
/*
* Try to flush any pending writes to the file..
@ -393,6 +395,7 @@ void nfs_readahead(struct readahead_control *ractl)
trace_nfs_aop_readahead(inode, readahead_pos(ractl), nr_pages);
nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
task_io_account_read(readahead_length(ractl));
ret = -ESTALE;
if (NFS_STALE(inode))

View file

@ -22,6 +22,7 @@
#define nlm4_fbig cpu_to_be32(NLM_FBIG)
#define nlm4_failed cpu_to_be32(NLM_FAILED)
void nlm4svc_set_file_lock_range(struct file_lock *fl, u64 off, u64 len);
bool nlm4svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
bool nlm4svc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
bool nlm4svc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);