From owner-freebsd-bugs@freebsd.org Thu Sep 24 09:39:09 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22D2D3F21DC for ; Thu, 24 Sep 2020 09:39:09 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BxqkP09bbz4CxX for ; Thu, 24 Sep 2020 09:39:09 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 05EE63F2423; Thu, 24 Sep 2020 09:39:09 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05B4E3F2341 for ; Thu, 24 Sep 2020 09:39:09 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BxqkN6RPXz4Clw for ; Thu, 24 Sep 2020 09:39:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C07FF1F6F2 for ; Thu, 24 Sep 2020 09:39:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 08O9d8WM027306 for ; Thu, 24 Sep 2020 09:39:08 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 08O9d8me027305 for bugs@FreeBSD.org; Thu, 24 Sep 2020 09:39:08 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 249567] NFSv4 server sometimes responds with NFSERR_INVAL to LOCK from Linux clients Date: Thu, 24 Sep 2020 09:39:08 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: bf@cebitec.uni-bielefeld.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.mimetype attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2020 09:39:09 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D249567 Bug ID: 249567 Summary: NFSv4 server sometimes responds with NFSERR_INVAL to LOCK from Linux clients Product: Base System Version: 11.4-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: bf@cebitec.uni-bielefeld.de Attachment #218237 text/plain mime type: Created attachment 218237 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D218237&action= =3Dedit fcntl F_SETLK test case We run an NFSv4 server with ZFS as backing store based on 11.4-RELEASE-p3. Clients are Solaris and Linux mostly. Sometimes "svn checkout" or "svn stat= us" fails with a disk I/O error on NFS volumes on Linux clients. We tracked down the problem to sqlite which quite intensively uses fcntl locking. From this= , we created a small test case which simply does res =3D fcntl(fd, F_SETLK, &lock); [...] res =3D fcntl(fd, F_SETLK, &unlock); in a loop (see attachment). This reliably triggers the problem: [me@linuxhost:~]$ fcntl_setlk F_SETLK F_RDLCK res =3D -1 (Invalid argument) Successful cycles: 431 So here fcntl fails after 431 succesful lock-unlock cycles. On the wire, we= can see the LOCK request as: Opcode: LOCK (12) locktype: READ_LT (1) reclaim?: No offset: 0 length: 1 new lock owner?: Yes seqid: 0x00000000 StateID [StateID Hash: 0xdf2d] StateID seqid: 1 StateID Other: d92b565f140000008c0c0000 [StateID Other hash: 0x15f7] lock_seqid: 0x00000000 Owner clientid: 0xd92b565f14000000 owner: length: 20 contents: Lock requests that succeed exactly look the same. On a fail case the FreeBSD NFS server replies: Opcode: LOCK (12) Status: NFS4ERR_INVAL (22) Using DTrace, we found the source of the NFS4ERR_INVL in nfsrv_lockctrl() at nfs_nfsdstate.c:1810: if (!error) nfsrv_getowner(&stp->ls_open, new_stp, &lckstp); if (lckstp) /*=20=20 * I believe this should be an error, but it * isn't obvious what NFSERR_xxx would be * appropriate, so I'll use NFSERR_INVAL for now. */=20=20 error =3D NFSERR_INVAL; else lckstp =3D new_stp; As a workaround we tried to simply comment out the setting of "error". With this change, the test case no longer triggers the problem: --- nfs_nfsdstate.c 2020/09/23 12:58:37 1.1 +++ nfs_nfsdstate.c 2020/09/23 14:16:19 @@ -1802,12 +1802,17 @@ if (!error) nfsrv_getowner(&stp->ls_open, new_stp, &lckstp); if (lckstp) +#ifdef DIAGNOSTIC + printf("nfs_nfsdstate.c:1805: I believe this sho= uld be an error\n"); +#else + ; +#endif /* * I believe this should be an error, but it * isn't obvious what NFSERR_xxx would be * appropriate, so I'll use NFSERR_INVAL for now. - */ error =3D NFSERR_INVAL; + */ else lckstp =3D new_stp; } else if (new_stp->ls_flags&(NFSLCK_LOCK|NFSLCK_UNLOCK)= ) { While this seems to work, I have a gut feeling that lckstp should be new_stp (unconditionally) instead of what nfsrv_getowner returns. Someone with a de= eper understandig of the NFS specification should look into this. --=20 You are receiving this mail because: You are the assignee for the bug.=