Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libperfuse Rollback directory filehandle screening for F...



details:   https://anonhg.NetBSD.org/src/rev/92caa1facf70
branches:  trunk
changeset: 964635:92caa1facf70
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Aug 10 07:08:11 2019 +0000

description:
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.

diffstat:

 lib/libperfuse/ops.c |  17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diffs (37 lines):

diff -r b9ce717ff55f -r 92caa1facf70 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Sat Aug 10 06:30:26 2019 +0000
+++ b/lib/libperfuse/ops.c      Sat Aug 10 07:08:11 2019 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.86 2019/02/09 02:22:45 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.87 2019/08/10 07:08:11 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -2976,24 +2976,15 @@
         * 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);



Home | Main Index | Thread Index | Old Index