2019-04-08 02:48:07

by Su, Yanjun

[permalink] [raw]
Subject: [PATCH] CACHE: Fix test script as delegation being introduced

When we run nfstest_cache with nfsversion=4, it fails.
As i know nfsv4 introduces delegation, so nfstest_cache runs fail since
nfsv4.

The test commandline is as below:
./nfstest_cache --nfsversion=4 -e /nfsroot --server 192.168.102.143
--client 192.168.102.142 --runtest acregmax_data --verbose all

This patch adds compatible code for nfsv3 and nfsv4.
When we test nfsv4, just use 'chmod' to recall delegation, then
run the test. As 'chmod' will modify atime, so use 'noatime' mount option.

Signed-off-by: Su Yanjun <[email protected]>
---
test/nfstest_cache | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/test/nfstest_cache b/test/nfstest_cache
index 0838418..a31d48f 100755
--- a/test/nfstest_cache
+++ b/test/nfstest_cache
@@ -165,8 +165,13 @@ class CacheTest(TestUtil):
fd = None
attr = 'data' if data_cache else 'attribute'
header = "Verify consistency of %s caching with %s on a file" % (attr,
self.nfsstr())
+
# Mount options
- mtopts = "hard,intr,rsize=4096,wsize=4096"
+ if self.nfsversion >= 4:
+ mtopts = "noatime,hard,intr,rsize=4096,wsize=4096"
+ else: + mtopts = "hard,intr,rsize=4096,wsize=4096"
+
if actimeo:
header += " actimeo = %d" % actimeo
mtopts += ",actimeo=%d" % actimeo
@@ -216,6 +221,11 @@ class CacheTest(TestUtil):
if fstat.st_size != dlen:
raise Exception("Size of newly created file is %d, should have been %d"
%(fstat.st_size, dlen))
+ if self.nfsversion >= 4:
+ # revoke delegation
+ self.dprint('DBG3', "revoke delegation")
+ self.clientobj.run_cmd('chmod +x %s' % self.absfile)
+
if acregmax:
# Stat the unchanging file until acregmax is hit
# each stat doubles the valid cache time

--
2.7.4





2019-04-08 16:07:35

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH] CACHE: Fix test script as delegation being introduced

On Mon, Apr 08, 2019 at 10:47:56AM +0800, Su Yanjun <[email protected]> wrote:
> When we run nfstest_cache with nfsversion=4, it fails.
> As i know nfsv4 introduces delegation, so nfstest_cache runs fail
> since nfsv4.
>
> The test commandline is as below:
> ./nfstest_cache --nfsversion=4 -e /nfsroot --server 192.168.102.143
> --client 192.168.102.142 --runtest acregmax_data --verbose all
>
> This patch adds compatible code for nfsv3 and nfsv4.
> When we test nfsv4, just use 'chmod' to recall delegation, then
> run the test. As 'chmod' will modify atime, so use 'noatime' mount option.

I don't think a chmod is a reliable way to recall delegations.

Maybe mount with "clientaddr=0.0.0.0"? From the nfs man page:

Can specify a value of IPv4_ANY (0.0.0.0) or equivalent IPv6
any address which will signal to the NFS server that this NFS
client does not want delegations.

(I wonder if that documentation's still accurate for versions >= 4.1?)

--b.

>
> Signed-off-by: Su Yanjun <[email protected]>
> ---
> test/nfstest_cache | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/test/nfstest_cache b/test/nfstest_cache
> index 0838418..a31d48f 100755
> --- a/test/nfstest_cache
> +++ b/test/nfstest_cache
> @@ -165,8 +165,13 @@ class CacheTest(TestUtil):
> fd = None
> attr = 'data' if data_cache else 'attribute'
> header = "Verify consistency of %s caching with %s on a file" %
> (attr, self.nfsstr())
> +
> # Mount options
> - mtopts = "hard,intr,rsize=4096,wsize=4096"
> + if self.nfsversion >= 4:
> + mtopts = "noatime,hard,intr,rsize=4096,wsize=4096"
> + else: + mtopts = "hard,intr,rsize=4096,wsize=4096"
> +
> if actimeo:
> header += " actimeo = %d" % actimeo
> mtopts += ",actimeo=%d" % actimeo
> @@ -216,6 +221,11 @@ class CacheTest(TestUtil):
> if fstat.st_size != dlen:
> raise Exception("Size of newly created file is %d, should have been
> %d" %(fstat.st_size, dlen))
> + if self.nfsversion >= 4:
> + # revoke delegation
> + self.dprint('DBG3', "revoke delegation")
> + self.clientobj.run_cmd('chmod +x %s' % self.absfile)
> +
> if acregmax:
> # Stat the unchanging file until acregmax is hit
> # each stat doubles the valid cache time
>
> --
> 2.7.4
>
>

2020-01-09 19:18:42

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH] CACHE: Fix test script as delegation being introduced

On Thu, Jan 09, 2020 at 01:54:51AM +0000, Su, Yanjun wrote:
> Any ping about the 1 year old problem?
> Cc mora:
> Did you test nfs cache with nfs version 4?
> Or maybe the test case is not suitable for v4?

I don't run it personally. Jorge, is it expected to fail in the
presence of delegations?

> Sorry for my late reply. Our mail system has some problem that ignores your reply.
>
> I Get the reply by google seach.
>
> We tested the option "clientaddr=0.0.0.0" and the test case also fails.
>
> Thanks
>
> On Mon, Apr 08, 2019 at 10:47:56AM +0800, Su Yanjun<[email protected]> wrote:
>
> When we run nfstest_cache with nfsversion=4, it fails.
> As i know nfsv4 introduces delegation, so nfstest_cache runs fail
> since nfsv4.
>
> The test commandline is as below:
> ./nfstest_cache --nfsversion=4 -e /nfsroot --server 192.168.102.143
> --client 192.168.102.142 --runtest acregmax_data --verbose all
>
> This patch adds compatible code for nfsv3 and nfsv4.
> When we test nfsv4, just use 'chmod' to recall delegation, then
> run the test. As 'chmod' will modify atime, so use 'noatime' mount option.
>
> I don't think a chmod is a reliable way to recall delegations.

If you run the chmod from the same client, it won't necessarily revoke
the delegation.

If you run it from another client or run it directly on the server, it
should.

> Maybe mount with "clientaddr=0.0.0.0"? From the nfs man page:
>
> Can specify a value of IPv4_ANY (0.0.0.0) or equivalent IPv6
> any address which will signal to the NFS server that this NFS
> client does not want delegations.
>
> (I wonder if that documentation's still accurate for versions >= 4.1?)

Probably not. I don't think there's a way to turn off delegations from
the linux client.

The server may have a way to turn off delegations. E.g. on a linux
server "echo 0>/proc/sys/fs/leases-enable" before starting knfsd should
do it.

--b.