Deleted Added
full compact
nfs_clrpcops.c (222289) nfs_clrpcops.c (222719)
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clrpcops.c 222289 2011-05-25 20:53:08Z rmacklem $");
35__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clrpcops.c 222719 2011-06-05 18:17:37Z rmacklem $");
36
37/*
38 * Rpc op calls, generally called from the vnode op calls or through the
39 * buffer cache, for NFS v2, 3 and 4.
40 * These do not normally make any changes to vnode arguments or use
41 * structures that might change between the VFS variants. The returned
42 * arguments are all at the end, after the NFSPROC_T *p one.
43 */

--- 3410 unchanged lines hidden (view full) ---

3454}
3455
3456/*
3457 * NFS byte range lock rpc.
3458 * (Mostly just calls one of the three lower level RPC routines.)
3459 */
3460APPLESTATIC int
3461nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl,
36
37/*
38 * Rpc op calls, generally called from the vnode op calls or through the
39 * buffer cache, for NFS v2, 3 and 4.
40 * These do not normally make any changes to vnode arguments or use
41 * structures that might change between the VFS variants. The returned
42 * arguments are all at the end, after the NFSPROC_T *p one.
43 */

--- 3410 unchanged lines hidden (view full) ---

3454}
3455
3456/*
3457 * NFS byte range lock rpc.
3458 * (Mostly just calls one of the three lower level RPC routines.)
3459 */
3460APPLESTATIC int
3461nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl,
3462 int reclaim, struct ucred *cred, NFSPROC_T *p)
3462 int reclaim, struct ucred *cred, NFSPROC_T *p, void *id, int flags)
3463{
3464 struct nfscllockowner *lp;
3465 struct nfsclclient *clp;
3466 struct nfsfh *nfhp;
3467 struct nfsrv_descript nfsd, *nd = &nfsd;
3468 struct nfsmount *nmp = VFSTONFS(vnode_mount(vp));
3469 u_int64_t off, len;
3470 off_t start, end;

--- 35 unchanged lines hidden (view full) ---

3506 len = NFS64BITSSET;
3507 retrycnt = 0;
3508 do {
3509 nd->nd_repstat = 0;
3510 if (op == F_GETLK) {
3511 error = nfscl_getcl(vp, cred, p, &clp);
3512 if (error)
3513 return (error);
3463{
3464 struct nfscllockowner *lp;
3465 struct nfsclclient *clp;
3466 struct nfsfh *nfhp;
3467 struct nfsrv_descript nfsd, *nd = &nfsd;
3468 struct nfsmount *nmp = VFSTONFS(vnode_mount(vp));
3469 u_int64_t off, len;
3470 off_t start, end;

--- 35 unchanged lines hidden (view full) ---

3506 len = NFS64BITSSET;
3507 retrycnt = 0;
3508 do {
3509 nd->nd_repstat = 0;
3510 if (op == F_GETLK) {
3511 error = nfscl_getcl(vp, cred, p, &clp);
3512 if (error)
3513 return (error);
3514 error = nfscl_lockt(vp, clp, off, len, fl, p);
3514 error = nfscl_lockt(vp, clp, off, len, fl, p, id, flags);
3515 if (!error) {
3516 clidrev = clp->nfsc_clientidrev;
3517 error = nfsrpc_lockt(nd, vp, clp, off, len, fl, cred,
3515 if (!error) {
3516 clidrev = clp->nfsc_clientidrev;
3517 error = nfsrpc_lockt(nd, vp, clp, off, len, fl, cred,
3518 p);
3518 p, id, flags);
3519 } else if (error == -1) {
3520 error = 0;
3521 }
3522 nfscl_clientrelease(clp);
3523 } else if (op == F_UNLCK && fl->l_type == F_UNLCK) {
3524 /*
3525 * We must loop around for all lockowner cases.
3526 */
3527 callcnt = 0;
3528 error = nfscl_getcl(vp, cred, p, &clp);
3529 if (error)
3530 return (error);
3531 do {
3532 error = nfscl_relbytelock(vp, off, len, cred, p, callcnt,
3519 } else if (error == -1) {
3520 error = 0;
3521 }
3522 nfscl_clientrelease(clp);
3523 } else if (op == F_UNLCK && fl->l_type == F_UNLCK) {
3524 /*
3525 * We must loop around for all lockowner cases.
3526 */
3527 callcnt = 0;
3528 error = nfscl_getcl(vp, cred, p, &clp);
3529 if (error)
3530 return (error);
3531 do {
3532 error = nfscl_relbytelock(vp, off, len, cred, p, callcnt,
3533 clp, &lp, &dorpc);
3533 clp, id, flags, &lp, &dorpc);
3534 /*
3535 * If it returns a NULL lp, we're done.
3536 */
3537 if (lp == NULL) {
3538 if (callcnt == 0)
3539 nfscl_clientrelease(clp);
3540 else
3534 /*
3535 * If it returns a NULL lp, we're done.
3536 */
3537 if (lp == NULL) {
3538 if (callcnt == 0)
3539 nfscl_clientrelease(clp);
3540 else
3541 nfscl_releasealllocks(clp, vp, p);
3541 nfscl_releasealllocks(clp, vp, p, id, flags);
3542 return (error);
3543 }
3544 if (nmp->nm_clp != NULL)
3545 clidrev = nmp->nm_clp->nfsc_clientidrev;
3546 else
3547 clidrev = 0;
3548 /*
3549 * If the server doesn't support Posix lock semantics,

--- 17 unchanged lines hidden (view full) ---

3567 error == 0)
3568 (void) nfs_catnap(PZERO, (int)nd->nd_repstat,
3569 "nfs_advlock");
3570 } while ((nd->nd_repstat == NFSERR_GRACE ||
3571 nd->nd_repstat == NFSERR_DELAY) && error == 0);
3572 }
3573 callcnt++;
3574 } while (error == 0 && nd->nd_repstat == 0);
3542 return (error);
3543 }
3544 if (nmp->nm_clp != NULL)
3545 clidrev = nmp->nm_clp->nfsc_clientidrev;
3546 else
3547 clidrev = 0;
3548 /*
3549 * If the server doesn't support Posix lock semantics,

--- 17 unchanged lines hidden (view full) ---

3567 error == 0)
3568 (void) nfs_catnap(PZERO, (int)nd->nd_repstat,
3569 "nfs_advlock");
3570 } while ((nd->nd_repstat == NFSERR_GRACE ||
3571 nd->nd_repstat == NFSERR_DELAY) && error == 0);
3572 }
3573 callcnt++;
3574 } while (error == 0 && nd->nd_repstat == 0);
3575 nfscl_releasealllocks(clp, vp, p);
3575 nfscl_releasealllocks(clp, vp, p, id, flags);
3576 } else if (op == F_SETLK) {
3577 error = nfscl_getbytelock(vp, off, len, fl->l_type, cred, p,
3576 } else if (op == F_SETLK) {
3577 error = nfscl_getbytelock(vp, off, len, fl->l_type, cred, p,
3578 NULL, 0, NULL, NULL, &lp, &newone, &donelocally);
3578 NULL, 0, id, flags, NULL, NULL, &lp, &newone, &donelocally);
3579 if (error || donelocally) {
3580 return (error);
3581 }
3582 if (nmp->nm_clp != NULL)
3583 clidrev = nmp->nm_clp->nfsc_clientidrev;
3584 else
3585 clidrev = 0;
3586 nfhp = VTONFS(vp)->n_fhp;

--- 33 unchanged lines hidden (view full) ---

3620}
3621
3622/*
3623 * The lower level routine for the LockT case.
3624 */
3625APPLESTATIC int
3626nfsrpc_lockt(struct nfsrv_descript *nd, vnode_t vp,
3627 struct nfsclclient *clp, u_int64_t off, u_int64_t len, struct flock *fl,
3579 if (error || donelocally) {
3580 return (error);
3581 }
3582 if (nmp->nm_clp != NULL)
3583 clidrev = nmp->nm_clp->nfsc_clientidrev;
3584 else
3585 clidrev = 0;
3586 nfhp = VTONFS(vp)->n_fhp;

--- 33 unchanged lines hidden (view full) ---

3620}
3621
3622/*
3623 * The lower level routine for the LockT case.
3624 */
3625APPLESTATIC int
3626nfsrpc_lockt(struct nfsrv_descript *nd, vnode_t vp,
3627 struct nfsclclient *clp, u_int64_t off, u_int64_t len, struct flock *fl,
3628 struct ucred *cred, NFSPROC_T *p)
3628 struct ucred *cred, NFSPROC_T *p, void *id, int flags)
3629{
3630 u_int32_t *tl;
3631 int error, type, size;
3632 u_int8_t own[NFSV4CL_LOCKNAMELEN];
3633
3634 NFSCL_REQSTART(nd, NFSPROC_LOCKT, vp);
3635 NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
3636 if (fl->l_type == F_RDLCK)
3637 *tl++ = txdr_unsigned(NFSV4LOCKT_READ);
3638 else
3639 *tl++ = txdr_unsigned(NFSV4LOCKT_WRITE);
3640 txdr_hyper(off, tl);
3641 tl += 2;
3642 txdr_hyper(len, tl);
3643 tl += 2;
3644 *tl++ = clp->nfsc_clientid.lval[0];
3645 *tl = clp->nfsc_clientid.lval[1];
3629{
3630 u_int32_t *tl;
3631 int error, type, size;
3632 u_int8_t own[NFSV4CL_LOCKNAMELEN];
3633
3634 NFSCL_REQSTART(nd, NFSPROC_LOCKT, vp);
3635 NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
3636 if (fl->l_type == F_RDLCK)
3637 *tl++ = txdr_unsigned(NFSV4LOCKT_READ);
3638 else
3639 *tl++ = txdr_unsigned(NFSV4LOCKT_WRITE);
3640 txdr_hyper(off, tl);
3641 tl += 2;
3642 txdr_hyper(len, tl);
3643 tl += 2;
3644 *tl++ = clp->nfsc_clientid.lval[0];
3645 *tl = clp->nfsc_clientid.lval[1];
3646 nfscl_filllockowner(p, own);
3646 nfscl_filllockowner(id, own, flags);
3647 (void) nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN);
3648 error = nfscl_request(nd, vp, p, cred, NULL);
3649 if (error)
3650 return (error);
3651 if (nd->nd_repstat == 0) {
3652 fl->l_type = F_UNLCK;
3653 } else if (nd->nd_repstat == NFSERR_DENIED) {
3654 nd->nd_repstat = 0;

--- 560 unchanged lines hidden ---
3647 (void) nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN);
3648 error = nfscl_request(nd, vp, p, cred, NULL);
3649 if (error)
3650 return (error);
3651 if (nd->nd_repstat == 0) {
3652 fl->l_type = F_UNLCK;
3653 } else if (nd->nd_repstat == NFSERR_DENIED) {
3654 nd->nd_repstat = 0;

--- 560 unchanged lines hidden ---