aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2020-09-26 23:05:38 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2020-09-26 23:05:38 +0000
commitff45b9fc1a8c508690054b4f8e33608353c4d4c9 (patch)
treee3831f1b8c47f80b8e15cb7c8603f6c4c913f2ff
parentb2668f7b497fecbaf663b993730287ba49c635c3 (diff)
Bjorn reported a problem where the Linux NFSv4.1 client is
using an open_to_lock_owner4 when that lock_owner4 has already been created by a previous open_to_lock_owner4. This caused the NFS server to reply NFSERR_INVAL. For NFSv4.0, this is an error, although the updated NFSv4.0 RFC7530 notes that the correct error reply is NFSERR_BADSEQID (RFC3530 did not specify what error to return). For NFSv4.1, it is not obvious whether or not this is allowed by RFC5661, but the NFSv4.1 server can handle this case without error. This patch changes the NFSv4.1 (and NFSv4.2) server to handle multiple uses of the same lock_owner in open_to_lock_owner so that it now correctly interoperates with the Linux NFS client. It also changes the error returned for NFSv4.0 to be NFSERR_BADSEQID. Thanks go to Bjorn for diagnosing this and testing the patch. He also provided a program that I could use to reproduce the problem. Tested by: bj@cebitec.uni-bielefeld.de (Bjorn Fischer) PR: 249567 Reported by: bj@cebitec.uni-bielefeld.de (Bjorn Fischer) MFC after: 3 days
Notes
svn path=/head/; revision=366189
-rw-r--r--sys/fs/nfsserver/nfs_nfsdstate.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c
index 15e2b8fea275..f80b386ae839 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -1870,14 +1870,20 @@ tryagain:
}
if (!error)
nfsrv_getowner(&stp->ls_open, new_stp, &lckstp);
- if (lckstp)
+ if (lckstp) {
/*
- * 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.
+ * For NFSv4.1 and NFSv4.2 allow an
+ * open_to_lock_owner when the lock_owner already
+ * exists. Just clear NFSLCK_OPENTOLOCK so that
+ * a new lock_owner will not be created.
+ * RFC7530 states that the error for NFSv4.0
+ * is NFS4ERR_BAD_SEQID.
*/
- error = NFSERR_INVAL;
- else
+ if ((nd->nd_flag & ND_NFSV41) != 0)
+ new_stp->ls_flags &= ~NFSLCK_OPENTOLOCK;
+ else
+ error = NFSERR_BADSEQID;
+ } else
lckstp = new_stp;
} else if (new_stp->ls_flags&(NFSLCK_LOCK|NFSLCK_UNLOCK)) {
/*