aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/fs/nfsclient/nfs_clvfsops.c4
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c52
2 files changed, 28 insertions, 28 deletions
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index 8dc7036242e1..7635835ef0e0 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -2131,8 +2131,8 @@ void nfscl_retopts(struct nfsmount *nmp, char *buffer, size_t buflen)
",noncontigwr", &buf, &blen);
nfscl_printopt(nmp, (nmp->nm_flag & (NFSMNT_NOLOCKD | NFSMNT_NFSV4)) ==
0, ",lockd", &buf, &blen);
- nfscl_printopt(nmp, (nmp->nm_flag & (NFSMNT_NOLOCKD | NFSMNT_NFSV4)) ==
- NFSMNT_NOLOCKD, ",nolockd", &buf, &blen);
+ nfscl_printopt(nmp, (nmp->nm_flag & NFSMNT_NOLOCKD) != 0, ",nolockd",
+ &buf, &blen);
nfscl_printopt(nmp, (nmp->nm_flag & NFSMNT_RDIRPLUS) != 0, ",rdirplus",
&buf, &blen);
nfscl_printopt(nmp, (nmp->nm_flag & NFSMNT_KERB) == 0, ",sec=sys",
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index d72c2542f32f..b1a174f171fa 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3289,7 +3289,32 @@ nfs_advlock(struct vop_advlock_args *ap)
error = NFSVOPLOCK(vp, LK_SHARED);
if (error != 0)
return (EBADF);
- if (NFS_ISV4(vp) && (ap->a_flags & (F_POSIX | F_FLOCK)) != 0) {
+ nmp = VFSTONFS(vp->v_mount);
+ if (!NFS_ISV4(vp) || (nmp->nm_flag & NFSMNT_NOLOCKD) != 0) {
+ if ((nmp->nm_flag & NFSMNT_NOLOCKD) != 0) {
+ size = np->n_size;
+ NFSVOPUNLOCK(vp);
+ error = lf_advlock(ap, &(vp->v_lockf), size);
+ } else {
+ if (nfs_advlock_p != NULL)
+ error = nfs_advlock_p(ap);
+ else {
+ NFSVOPUNLOCK(vp);
+ error = ENOLCK;
+ }
+ }
+ if (error == 0 && ap->a_op == F_SETLK) {
+ error = NFSVOPLOCK(vp, LK_SHARED);
+ if (error == 0) {
+ /* Mark that a file lock has been acquired. */
+ NFSLOCKNODE(np);
+ np->n_flag |= NHASBEENLOCKED;
+ NFSUNLOCKNODE(np);
+ NFSVOPUNLOCK(vp);
+ }
+ }
+ return (error);
+ } else if ((ap->a_flags & (F_POSIX | F_FLOCK)) != 0) {
if (vp->v_type != VREG) {
error = EINVAL;
goto out;
@@ -3323,7 +3348,6 @@ nfs_advlock(struct vop_advlock_args *ap)
* state structure cannot exist for the file.
* Only done for "oneopenown" NFSv4.1/4.2 mounts.
*/
- nmp = VFSTONFS(vp->v_mount);
if (NFSHASNFSV4N(nmp) && NFSHASONEOPENOWN(nmp)) {
NFSLOCKNODE(np);
np->n_flag |= NMIGHTBELOCKED;
@@ -3390,30 +3414,6 @@ nfs_advlock(struct vop_advlock_args *ap)
np->n_flag |= NHASBEENLOCKED;
NFSUNLOCKNODE(np);
}
- } else if (!NFS_ISV4(vp)) {
- if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
- size = VTONFS(vp)->n_size;
- NFSVOPUNLOCK(vp);
- error = lf_advlock(ap, &(vp->v_lockf), size);
- } else {
- if (nfs_advlock_p != NULL)
- error = nfs_advlock_p(ap);
- else {
- NFSVOPUNLOCK(vp);
- error = ENOLCK;
- }
- }
- if (error == 0 && ap->a_op == F_SETLK) {
- error = NFSVOPLOCK(vp, LK_SHARED);
- if (error == 0) {
- /* Mark that a file lock has been acquired. */
- NFSLOCKNODE(np);
- np->n_flag |= NHASBEENLOCKED;
- NFSUNLOCKNODE(np);
- NFSVOPUNLOCK(vp);
- }
- }
- return (error);
} else
error = EOPNOTSUPP;
out: