diff options
author | rwatson <rwatson@FreeBSD.org> | 2003-03-26 19:21:34 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2003-03-26 19:21:34 +0000 |
commit | 109543a3e517fa1fbb114875c6ca4e323d9d2486 (patch) | |
tree | d2077bef8ef19ff3babfd0b4fb08fd02532c5072 /sys/nfsclient | |
parent | d9da9de2571cfcb93b9f34cc09106cc13e31d72d (diff) | |
download | FreeBSD-src-109543a3e517fa1fbb114875c6ca4e323d9d2486.zip FreeBSD-src-109543a3e517fa1fbb114875c6ca4e323d9d2486.tar.gz |
Add O_NONBLOCK to the vn_open_cred() flags for NFS client locking when
opening the POSIX fifo; convert ENXIO error returns to EOPNOTSUPP.
This improves handling of the case where the /var/run/lock fifo exists
but there is no listener: we immediately return EOPNOTSUPP rather
than blocking until a listener turns up. This could occur during a
diskless boot before rpc.lockd is loaded, or if the lock file persists
across a reboot following the disabling of rpc.lockd. This may have
suddenly started to occur due to fifo blocking fixes--previously it
looks like attempts to read on a fifo with no listener would time out
due to insufficient resources.
Reviewed by: alfred
Diffstat (limited to 'sys/nfsclient')
-rw-r--r-- | sys/nfsclient/nfs_lock.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/nfsclient/nfs_lock.c b/sys/nfsclient/nfs_lock.c index 67f049a..550a133 100644 --- a/sys/nfsclient/nfs_lock.c +++ b/sys/nfsclient/nfs_lock.c @@ -143,10 +143,20 @@ nfs_dolock(struct vop_advlock_args *ap) */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, _PATH_LCKFIFO, td); - fmode = FFLAGS(O_WRONLY); + fmode = FFLAGS(O_WRONLY | O_NONBLOCK); error = vn_open_cred(&nd, &fmode, 0, thread0.td_ucred); - if (error != 0) { - return (error == ENOENT ? EOPNOTSUPP : error); + switch (error) { + case ENOENT: + case ENXIO: + /* + * Map a failure to find the fifo or no listener on the + * fifo to locking not being supported. + */ + return (EOPNOTSUPP); + case 0: + break; + default: + return (error); } wvp = nd.ni_vp; VOP_UNLOCK(wvp, 0, td); /* vn_open leaves it locked */ |