Module Name:    src
Committed By:   martin
Date:           Tue Aug 13 14:27:22 UTC 2019

Modified Files:
        src/lib/libperfuse [netbsd-8]: ops.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #1335):

        lib/libperfuse/ops.c: revision 1.87

Rollback directory filehandle screening for FUSE lock operations
libfuse has a different usage of filehandles for files and directories.

A directory filehandle is valid only for directory operations such
as OPENDIR, READDIR, RELEASEDIR, FSYNCDIR. Change of src/lib/libperfuse/ops.c
1.85-1.86 made sure filehandles of directories were only sent for that
operations.

However, the status of lock operations GETLK, SETLK, SETLKW was overlooked.
The only FUSE filesystem I found using locks is GlusterFS, and it needs
directory filehandles to be provided on lock operations, otherwise locking
crashes the filesystem. Hence this change brings back filehandles for
lock operations on directories.


To generate a diff of this commit:
cvs rdiff -u -r1.84.8.1 -r1.84.8.2 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libperfuse/ops.c
diff -u src/lib/libperfuse/ops.c:1.84.8.1 src/lib/libperfuse/ops.c:1.84.8.2
--- src/lib/libperfuse/ops.c:1.84.8.1	Sun Feb 10 13:40:41 2019
+++ src/lib/libperfuse/ops.c	Tue Aug 13 14:27:22 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.84.8.1 2019/02/10 13:40:41 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.84.8.2 2019/08/13 14:27:22 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -2976,24 +2976,15 @@ perfuse_node_advlock(struct puffs_usermo
 	 * expect one. E.g.: if we provide none, GlusterFS logs an error
 	 * "0-glusterfs-fuse: xl is NULL"
 	 *
-	 * There is one exception with directories where filehandle
-	 * is not included, because libfuse uses different filehandle
-	 * in opendir/releasedir/readdir/fsyncdir compared to other 
-	 * operations. Who locks a directory anyway?
-	 *
 	 * We need the read file handle if the file is open read only,
 	 * in order to support shared locks on read-only files.
 	 * NB: The kernel always sends advlock for read-only
 	 * files at exit time when the process used lock, see
 	 * sys_exit -> exit1 -> fd_free -> fd_close -> VOP_ADVLOCK
 	 */
-	if (!PN_ISDIR(opc)) {
-		if ((fh = perfuse_get_fh(opc, FREAD)) == FUSE_UNKNOWN_FH) {
-			error = EBADF;
-			goto out;
-		}
-	} else {
-		fh = FUSE_UNKNOWN_FH;
+	if ((fh = perfuse_get_fh(opc, FREAD)) == FUSE_UNKNOWN_FH) {
+		error = EBADF;
+		goto out;
 	}
 
 	ps = puffs_getspecific(pu);

Reply via email to