Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2014 15:04:22 +0200
From:      Ivan Voras <ivoras@freebsd.org>
To:        freebsd-fs@freebsd.org
Subject:   lockf(1) and NFS
Message-ID:  <ltptp4$aaq$1@ger.gmane.org>

next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--7dC5RRDARlPrAJvalGUKMh7CMnWCFA4Fn
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,

I had some fun troubleshooting NFS locking and among other things, found
that lockf(1) doesn't really work on NFSv4 mounts. Googling around (so
correct me if I'm wrong), it looks like this is because NFS quietly
translates the old-style locks into POSIX range locks, and those cannot
be acquired exclusively if the file is opened read-only.

I've tested the following patch and it works.
Any objections to committing it?

--- a/lockf.c	Fri Aug 29 14:58:10 2014 +0200
+++ b/lockf.c	Fri Aug 29 14:59:12 2014 +0200
@@ -169,7 +169,7 @@
 {
 	int fd;

-	if ((fd =3D open(name, flags|O_RDONLY|O_EXLOCK|flags, 0666)) =3D=3D -1)=
 {
+	if ((fd =3D open(name, flags|O_RDWR|O_EXLOCK|flags, 0666)) =3D=3D -1) {=

 		if (errno =3D=3D EAGAIN || errno =3D=3D EINTR)
 			return (-1);
 		err(EX_CANTCREAT, "cannot open %s", name);


--7dC5RRDARlPrAJvalGUKMh7CMnWCFA4Fn
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iKYEARECAGYFAlQAemRfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl
bnBncC5maWZ0aGhvcnNlbWFuLm5ldDYxNDE4MkQ3ODMwNDAwMDJFRUIzNDhFNUZE
MDhENTA2M0RGRjFEMkMACgkQ/QjVBj3/HSwlVgCeOAIZdpnVbarFltjwPm9SPeH7
VakAnAmzt1PF8iLCMfoTRgoOx9OVzn3V
=Ii34
-----END PGP SIGNATURE-----

--7dC5RRDARlPrAJvalGUKMh7CMnWCFA4Fn--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ltptp4$aaq$1>