* Re: [PATCH] nfsstat01: Read client stats from netns rhost [not found] <20240828132325.23111-1-mdoucha@suse.cz> @ 2024-08-28 14:01 ` Petr Vorel [not found] ` <172487956651.4433.5156438688517075305@noble.neil.brown.name> 1 sibling, 0 replies; 2+ messages in thread From: Petr Vorel @ 2024-08-28 14:01 UTC (permalink / raw) To: Martin Doucha; +Cc: NeilBrown, ltp, Chuck Lever, linux-nfs Hi Martin, Thanks for fixing the test. > On newer kernels, network namespaces have separate NFS stats. Detect > support for per-NS files and read stats from the correct NS. I'll mention before merging that it was kernel 6.9 and it got backported to up to 5.15 so far. Reviewed-by: Petr Vorel <pvorel@suse.cz> Tested-by: Petr Vorel <pvorel@suse.cz> > Signed-off-by: Martin Doucha <mdoucha@suse.cz> > --- > The /proc/net/rpc/nfs file did not exist in nested network namespaces > on older kernels. The per-NS stats patchset adds it so we need to check > for its presence to read the correct stats on kernels where it was > backported. > Kernel devs have also asked for a test that'll ensure the patchset doesn't > get accidentaly reverted. Since this test uses namespaces only when > the server and client run on the same machine, it'll be better to create > a separate test for that. I'll send it later. Thanks! Kind regards, Petr > testcases/network/nfs/nfsstat01/nfsstat01.sh | 24 +++++++++++++++++--- > 1 file changed, 21 insertions(+), 3 deletions(-) > diff --git a/testcases/network/nfs/nfsstat01/nfsstat01.sh b/testcases/network/nfs/nfsstat01/nfsstat01.sh > index c2856eff1..8d7202cf3 100755 > --- a/testcases/network/nfs/nfsstat01/nfsstat01.sh > +++ b/testcases/network/nfs/nfsstat01/nfsstat01.sh > @@ -3,8 +3,19 @@ > # Copyright (c) 2016-2018 Oracle and/or its affiliates. All Rights Reserved. > # Copyright (c) International Business Machines Corp., 2001 > +TST_SETUP="nfsstat_setup" > TST_TESTFUNC="do_test" > TST_NEEDS_CMDS="nfsstat" > +NS_STAT_RHOST=0 > + > +nfsstat_setup() > +{ > + nfs_setup > + > + if tst_net_use_netns && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then > + tst_rhost_run -c "test -r /proc/net/rpc/nfs" && NS_STAT_RHOST=1 > + fi > +} > get_calls() > { > @@ -15,15 +26,22 @@ get_calls() > local calls opt > [ "$name" = "rpc" ] && opt="r" || opt="n" > - ! tst_net_use_netns && [ "$nfs_f" != "nfs" ] && type="rhost" > + [ "$nfs_f" = "nfsd" ] && opt="-s$opt" || opt="-c$opt" > + > + if tst_net_use_netns; then > + # In netns setup, rhost is the client > + [ "$nfs_f" = "nfs" ] && [ $NS_STAT_RHOST -ne 0 ] && type="rhost" > + else > + [ "$nfs_f" != "nfs" ] && type="rhost" > + fi > if [ "$type" = "lhost" ]; then > calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)" > - ROD nfsstat -c$opt | grep -q "$calls" > + ROD nfsstat $opt | grep -q "$calls" > else > calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \ > cut -d' ' -f$field) > - tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls" > + tst_rhost_run -s -c "nfsstat $opt" | grep -q "$calls" > fi > if ! tst_is_int "$calls"; then ^ permalink raw reply [flat|nested] 2+ messages in thread
[parent not found: <172487956651.4433.5156438688517075305@noble.neil.brown.name>]
* Re: [PATCH] nfsstat01: Read client stats from netns rhost [not found] ` <172487956651.4433.5156438688517075305@noble.neil.brown.name> @ 2024-08-28 21:43 ` Petr Vorel 0 siblings, 0 replies; 2+ messages in thread From: Petr Vorel @ 2024-08-28 21:43 UTC (permalink / raw) To: ltp; +Cc: linux-nfs, Chuck Lever Hi all, > On Wed, 28 Aug 2024, Martin Doucha wrote: > > On newer kernels, network namespaces have separate NFS stats. Detect > > support for per-NS files and read stats from the correct NS. > > Signed-off-by: Martin Doucha <mdoucha@suse.cz> > Thanks for doing this Martin. I very much prefer this approach. > NeilBrown FYI patch merged. Thanks all for your time. Kind regards, Petr > > --- > > The /proc/net/rpc/nfs file did not exist in nested network namespaces > > on older kernels. The per-NS stats patchset adds it so we need to check > > for its presence to read the correct stats on kernels where it was > > backported. > > Kernel devs have also asked for a test that'll ensure the patchset doesn't > > get accidentaly reverted. Since this test uses namespaces only when > > the server and client run on the same machine, it'll be better to create > > a separate test for that. I'll send it later. > > testcases/network/nfs/nfsstat01/nfsstat01.sh | 24 +++++++++++++++++--- > > 1 file changed, 21 insertions(+), 3 deletions(-) > > diff --git a/testcases/network/nfs/nfsstat01/nfsstat01.sh b/testcases/network/nfs/nfsstat01/nfsstat01.sh > > index c2856eff1..8d7202cf3 100755 > > --- a/testcases/network/nfs/nfsstat01/nfsstat01.sh > > +++ b/testcases/network/nfs/nfsstat01/nfsstat01.sh > > @@ -3,8 +3,19 @@ > > # Copyright (c) 2016-2018 Oracle and/or its affiliates. All Rights Reserved. > > # Copyright (c) International Business Machines Corp., 2001 > > +TST_SETUP="nfsstat_setup" > > TST_TESTFUNC="do_test" > > TST_NEEDS_CMDS="nfsstat" > > +NS_STAT_RHOST=0 > > + > > +nfsstat_setup() > > +{ > > + nfs_setup > > + > > + if tst_net_use_netns && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then > > + tst_rhost_run -c "test -r /proc/net/rpc/nfs" && NS_STAT_RHOST=1 > > + fi > > +} > > get_calls() > > { > > @@ -15,15 +26,22 @@ get_calls() > > local calls opt > > [ "$name" = "rpc" ] && opt="r" || opt="n" > > - ! tst_net_use_netns && [ "$nfs_f" != "nfs" ] && type="rhost" > > + [ "$nfs_f" = "nfsd" ] && opt="-s$opt" || opt="-c$opt" > > + > > + if tst_net_use_netns; then > > + # In netns setup, rhost is the client > > + [ "$nfs_f" = "nfs" ] && [ $NS_STAT_RHOST -ne 0 ] && type="rhost" > > + else > > + [ "$nfs_f" != "nfs" ] && type="rhost" > > + fi > > if [ "$type" = "lhost" ]; then > > calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)" > > - ROD nfsstat -c$opt | grep -q "$calls" > > + ROD nfsstat $opt | grep -q "$calls" > > else > > calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \ > > cut -d' ' -f$field) > > - tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls" > > + tst_rhost_run -s -c "nfsstat $opt" | grep -q "$calls" > > fi > > if ! tst_is_int "$calls"; then > > -- > > 2.46.0 ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-28 21:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240828132325.23111-1-mdoucha@suse.cz>
2024-08-28 14:01 ` [PATCH] nfsstat01: Read client stats from netns rhost Petr Vorel
[not found] ` <172487956651.4433.5156438688517075305@noble.neil.brown.name>
2024-08-28 21:43 ` Petr Vorel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox