发件人: Calum Mackay 已发送: 2021 6 月 10 日 星期四 19:44 收件人: Su, Yue/苏 越; linux-nfs@xxxxxxxxxxxxxxx 抄送: Calum Mackay; bfields@xxxxxxxxxx 主题: Re: [PATCH] pynfs: courtesy: send RECLAIM_COMPLETE before session2 opening the file Hi Calum, Thanks for your quick reply. Please forgive this bad email format (due to MS office365). Just pasted the nsfd debug dmesg on https://pastebin.com/ssYKUBtz . Although I'm not familiar with nfs enough, I think sever did think the two client differs. Please correct me if found something wrong: In nfsd4_exchange_id(), kernel creates new client struct then calls find_confirmed_client_by_name() to find existed older one. In pynfs, we call ' c2 = env.c1.new_client(b"%s_2" % env.testname(t))' to geneate new name so they can't be the same client in server view. I also added printks in nfsd module to verify this. -- Su ----------------------------------------------------------- On 10/06/2021 2:01 am, suy.fnst@xxxxxxxxxxx wrote: > The test fails on v5.13-rc5 and old kernels. Because the second session > doesn't send RECLAIM_COMPLETE before attempting to do a non-reclaim > open. So the server returns NFS4ERR_GRACE instead of NFS4_OK. Thanks. I suppose the problem here is that we're trying to pretend this is two separate clients, but the server sees it as a single client getting a new client id? thanks, calum. > > # ./testserver.py ${server_IP}:/nfsroot --rundeps COUR2 > INFO :rpc.poll:got connection from ('127.0.0.1', 39206), assigned to > fd=5 > INFO :rpc.thread:Called connect(('193.168.140.239', 2049)) > INFO :rpc.poll:Adding 6 generated by another thread > INFO :test.env:Created client to 193.168.140.239, 2049 > INFO :test.env:Called do_readdir() > INFO :test.env:do_readdir() = [entry4(cookie=512, > name=b'COUR2_1623055313', attrs={})] > fileb'COUR2_1623119443'created by sess1 > INFO :test.env:Sleeping for 22 seconds: twice the lease period > INFO :test.env:Woke up > session created > ************************************************** > COUR2 st_courtesy.testLockSleepLock : > FAILURE > OP_OPEN should return NFS4_OK, instead got > NFS4ERR_GRACE > ************************************************** > Command line asked for 1 of 255 tests > Of those: 0 Skipped, 1 Failed, 0 Warned, 0 Passed > > RFC5661, page 567: > "Whenever a client establishes a new client ID and before it does the > first non-reclaim operation that obtains a lock, it MUST send a > RECLAIM_COMPLETE with rca_one_fs set to FALSE, even if there are no > locks to reclaim. If non-reclaim locking operations are done before > the RECLAIM_COMPLETE, an NFS4ERR_GRACE error will be returned." > > Send RECLAIM_COMPLETE before the file open to let the test pass. > Signed-off-by: Su Yue <suy.fnst@xxxxxxxxxxxxxx> > --- > nfs4.1/server41tests/st_courtesy.py | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/nfs4.1/server41tests/st_courtesy.py b/nfs4.1/server41tests/st_courtesy.py > index dd911a37772d..3478a9d93dbf 100644 > --- a/nfs4.1/server41tests/st_courtesy.py > +++ b/nfs4.1/server41tests/st_courtesy.py > @@ -74,6 +74,9 @@ def testLockSleepLock(t, env): > c2 = env.c1.new_client(b"%s_2" % env.testname(t)) > sess2 = c2.create_session() > > + res = sess2.compound([op.reclaim_complete(FALSE)]) > + check(res) > + > res = open_file(sess2, env.testname(t), access=OPEN4_SHARE_ACCESS_WRITE) > check(res) > >