From owner-svn-src-all@FreeBSD.ORG Sun Jan 3 18:27:11 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40272106566C; Sun, 3 Jan 2010 18:27:11 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EB368FC14; Sun, 3 Jan 2010 18:27:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o03IRBMI015820; Sun, 3 Jan 2010 18:27:11 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o03IRBF5015818; Sun, 3 Jan 2010 18:27:11 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201001031827.o03IRBF5015818@svn.freebsd.org> From: Rick Macklem Date: Sun, 3 Jan 2010 18:27:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201439 - head/sys/fs/nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jan 2010 18:27:11 -0000 Author: rmacklem Date: Sun Jan 3 18:27:10 2010 New Revision: 201439 URL: http://svn.freebsd.org/changeset/base/201439 Log: Fix three related problems in the experimental nfs client when checking for conflicts w.r.t. byte range locks for NFSv4. 1 - Return 0 instead of EACCES when a conflict is found, for F_GETLK. 2 - Check for "same file" when checking for a conflict. 3 - Don't check for a conflict for the F_UNLCK case. Modified: head/sys/fs/nfsclient/nfs_clstate.c Modified: head/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clstate.c Sun Jan 3 17:19:14 2010 (r201438) +++ head/sys/fs/nfsclient/nfs_clstate.c Sun Jan 3 18:27:10 2010 (r201439) @@ -116,8 +116,8 @@ static int nfscl_checkconflict(struct nf u_int8_t *, struct nfscllock **); static void nfscl_freelockowner(struct nfscllockowner *, int); static void nfscl_freealllocks(struct nfscllockownerhead *, int); -static int nfscl_localconflict(struct nfsclclient *, struct nfscllock *, - u_int8_t *, struct nfscldeleg *, struct nfscllock **); +static int nfscl_localconflict(struct nfsclclient *, u_int8_t *, int, + struct nfscllock *, u_int8_t *, struct nfscldeleg *, struct nfscllock **); static void nfscl_newopen(struct nfsclclient *, struct nfscldeleg *, struct nfsclowner **, struct nfsclowner **, struct nfsclopen **, struct nfsclopen **, u_int8_t *, u_int8_t *, int, int *); @@ -955,7 +955,8 @@ nfscl_getbytelock(vnode_t vp, u_int64_t lhp = &op->nfso_lock; } if (!error && !recovery) - error = nfscl_localconflict(clp, nlop, ownp, ldp, NULL); + error = nfscl_localconflict(clp, np->n_fhp->nfh_fh, + np->n_fhp->nfh_len, nlop, ownp, ldp, NULL); if (error) { if (!recovery) { nfscl_clrelease(clp); @@ -1047,7 +1048,7 @@ nfscl_relbytelock(vnode_t vp, u_int64_t struct nfscldeleg *dp; struct nfsnode *np; u_int8_t own[NFSV4CL_LOCKNAMELEN]; - int ret = 0, fnd, error; + int ret = 0, fnd; np = VTONFS(vp); *lpp = NULL; @@ -1082,16 +1083,6 @@ nfscl_relbytelock(vnode_t vp, u_int64_t dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len); - /* Search for a local conflict. */ - error = nfscl_localconflict(clp, nlop, own, dp, NULL); - if (error) { - NFSUNLOCKCLSTATE(); - FREE((caddr_t)nlop, M_NFSCLLOCK); - if (other_lop != NULL) - FREE((caddr_t)other_lop, M_NFSCLLOCK); - return (error); - } - /* * First, unlock any local regions on a delegation. */ @@ -3169,8 +3160,9 @@ nfscl_getmnt(u_int32_t cbident) * a write lock or this is an unlock. */ static int -nfscl_localconflict(struct nfsclclient *clp, struct nfscllock *nlop, - u_int8_t *own, struct nfscldeleg *dp, struct nfscllock **lopp) +nfscl_localconflict(struct nfsclclient *clp, u_int8_t *fhp, int fhlen, + struct nfscllock *nlop, u_int8_t *own, struct nfscldeleg *dp, + struct nfscllock **lopp) { struct nfsclowner *owp; struct nfsclopen *op; @@ -3183,10 +3175,13 @@ nfscl_localconflict(struct nfsclclient * } LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) { LIST_FOREACH(op, &owp->nfsow_open, nfso_list) { - ret = nfscl_checkconflict(&op->nfso_lock, nlop, own, - lopp); - if (ret) - return (ret); + if (op->nfso_fhlen == fhlen && + !NFSBCMP(op->nfso_fh, fhp, fhlen)) { + ret = nfscl_checkconflict(&op->nfso_lock, nlop, + own, lopp); + if (ret) + return (ret); + } } } return (0); @@ -3245,10 +3240,9 @@ nfscl_lockt(vnode_t vp, struct nfsclclie nfscl_filllockowner(p, own); NFSLOCKCLSTATE(); dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len); - error = nfscl_localconflict(clp, &nlck, own, dp, &lop); - if (error == NFSERR_DENIED) - error = EACCES; - if (error) { + error = nfscl_localconflict(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len, + &nlck, own, dp, &lop); + if (error != 0) { fl->l_whence = SEEK_SET; fl->l_start = lop->nfslo_first; if (lop->nfslo_end == NFS64BITSSET) @@ -3257,6 +3251,7 @@ nfscl_lockt(vnode_t vp, struct nfsclclie fl->l_len = lop->nfslo_end - lop->nfslo_first; fl->l_pid = (pid_t)0; fl->l_type = lop->nfslo_type; + error = -1; /* no RPC required */ } else if (dp != NULL && ((dp->nfsdl_flags & NFSCLDL_WRITE) || fl->l_type == F_RDLCK)) { /*