diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8 index 88110bfd6480..57b9544e807b 100644 --- a/sbin/mount_nfs/mount_nfs.8 +++ b/sbin/mount_nfs/mount_nfs.8 @@ -41,7 +41,7 @@ .Nd mount nfs file systems .Sh SYNOPSIS .Nm -.Op Fl 23NPTUbcdils +.Op Fl 23NPTUbcdiLls .Op Fl D Ar deadthresh .Op Fl I Ar readdirsize .Op Fl R Ar retrycnt @@ -109,6 +109,21 @@ message is displayed. Set the readdir read size to the specified value. The value should normally be a multiple of DIRBLKSIZ that is <= the read size for the mount. +.It Fl L +Do +.Em not +forward +.Xr fcntl 2 +locks over the wire. +All locks will be local and not seen by the server +and likewise not seen by other NFS clients. This removes +the need to run the +.Xr rpcbind 8 +service and the +.Xr rpc.statd 8 +and +.Xr rpc.lockd 8 +servers on the client. .It Fl N Do .Em not @@ -226,6 +241,9 @@ Same as .It intr Same as .Fl i . +.It lockd +Same as not specifying +.Fl L . .It nfsv2 Same as .Fl 2 . diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 778bdd963cd3..8889d07f00fc 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -96,6 +96,7 @@ static const char rcsid[] = #define ALTF_ACREGMAX 0x10000 #define ALTF_ACDIRMIN 0x20000 #define ALTF_ACDIRMAX 0x40000 +#define ALTF_NOLOCKD 0x80000 struct mntopt mopts[] = { MOPT_STDOPTS, @@ -118,6 +119,7 @@ struct mntopt mopts[] = { { "acregmax=", 0, ALTF_ACREGMAX, 1 }, { "acdirmin=", 0, ALTF_ACDIRMIN, 1 }, { "acdirmax=", 0, ALTF_ACDIRMAX, 1 }, + { "lockd", 1, ALTF_NOLOCKD, 1 }, { NULL } }; @@ -228,6 +230,7 @@ set_flags(int* altflags, int* nfsflags, int dir) F(RDIRPLUS); F(RESVPORT); F(SOFT); + F(NOLOCKD); #undef F #undef F2 @@ -252,7 +255,7 @@ main(argc, argv) nfsargs = nfsdefargs; nfsargsp = &nfsargs; while ((c = getopt(argc, argv, - "23a:bcdD:g:I:il:No:PpR:r:sTt:w:x:U")) != -1) + "23a:bcdD:g:I:iLl:No:PpR:r:sTt:w:x:U")) != -1) switch (c) { case '2': mountmode = V2; @@ -303,6 +306,9 @@ main(argc, argv) case 'i': nfsargsp->flags |= NFSMNT_INT; break; + case 'L': + nfsargsp->flags |= NFSMNT_NOLOCKD; + break; case 'l': nfsargsp->flags |= NFSMNT_RDIRPLUS; break; diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index e80adad331d5..f49d56a15240 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -763,12 +763,12 @@ nfs_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, return (EIO); /* * When doing an update, we can't change from or to - * v3, or change cookie translation + * v3, switch lockd strategies or change cookie translation */ args.flags = (args.flags & - ~(NFSMNT_NFSV3 /*|NFSMNT_XLATECOOKIE*/)) | + ~(NFSMNT_NFSV3 | NFSMNT_NOLOCKD /*|NFSMNT_XLATECOOKIE*/)) | (nmp->nm_flag & - (NFSMNT_NFSV3 /*|NFSMNT_XLATECOOKIE*/)); + (NFSMNT_NFSV3 | NFSMNT_NOLOCKD /*|NFSMNT_XLATECOOKIE*/)); nfs_decode_args(nmp, &args); return (0); } diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index fdb0fca80390..ae81f0f9a210 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -2838,6 +2838,11 @@ static int nfs_advlock(struct vop_advlock_args *ap) { + if ((VFSTONFS(ap->a_vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) { + struct nfsnode *np = VTONFS(ap->a_vp); + + return (lf_advlock(ap, &(np->n_lockf), np->n_size)); + } return (nfs_dolock(ap)); } diff --git a/sys/nfsclient/nfsargs.h b/sys/nfsclient/nfsargs.h index d53e4e090270..7f4c636cb610 100644 --- a/sys/nfsclient/nfsargs.h +++ b/sys/nfsclient/nfsargs.h @@ -94,5 +94,6 @@ struct nfs_args { #define NFSMNT_ACREGMAX 0x00080000 #define NFSMNT_ACDIRMIN 0x00100000 #define NFSMNT_ACDIRMAX 0x00200000 +#define NFSMNT_NOLOCKD 0x00400000 /* Locks are local */ #endif