File 0306f3fdac736e15620f5802bdce510d25bb2450.patch of Package openafs

commit 0306f3fdac736e15620f5802bdce510d25bb2450
Author: Cheyenne Wills <cwills@sinenomine.net>
Date:   Fri Feb 7 11:10:27 2025 -0700

    Linux-6.14: Handle dops.d_revalidate with parent
    
    The Linux 6.14 commit:
      '5be1fa8abd7b0 Pass parent directory inode and expected name to
        ->d_revalidate()'
    added 2 parameters to the dentry_operations.d_revalidate method.  These
    new parameters are being provided as a convenience so a filesystem's
    d_revalidate function can avoid some boilerplate code for obtaining the
    dentry's ->d_parent and ->d_name.  The caller ensures that these two
    values are stable.
    
    Add a new autoconf test to determine if dentry_operations.d_revalidate
    has the new parameters.
    
    Update afs_linux_dentry_revalidate() to accept the new parameters.
    
    Change-Id: I7676ce9ae6ac48e37c8d9fbb3fefc455f80c41e1
    Reviewed-on: https://gerrit.openafs.org/16253
    Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
    Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
    Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
    Tested-by: Cheyenne Wills <cwills@sinenomine.net>
    Tested-by: BuildBot <buildbot@rampaginggeek.com>
    Reviewed-by: Andrew Deason <adeason@sinenomine.net>
    Tested-by: Andrew Deason <adeason@sinenomine.net>

diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index afd2f8112..82c74c431 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -1592,32 +1592,43 @@ dentry_revalidate_common(struct vcache *pvcp, const char *name, struct dentry *d
 #endif
 }
 
-#if defined(DOP_REVALIDATE_TAKES_UNSIGNED)
+#if defined(DOP_REVALIDATE_TAKES_PARENT_INODE)
+static int
+afs_linux_dentry_revalidate(struct inode *parent_inode, const struct qstr *name,
+			    struct dentry *dp, unsigned int flags)
+{
+    if ((flags & LOOKUP_RCU) != 0) {
+	return -ECHILD;
+    }
+    return dentry_revalidate_common(VTOAFS(parent_inode), name->name, dp);
+}
+#else
+# if defined(DOP_REVALIDATE_TAKES_UNSIGNED)
 static int
 afs_linux_dentry_revalidate(struct dentry *dp, unsigned int flags)
-#elif defined(DOP_REVALIDATE_TAKES_NAMEIDATA)
+# elif defined(DOP_REVALIDATE_TAKES_NAMEIDATA)
 static int
 afs_linux_dentry_revalidate(struct dentry *dp, struct nameidata *nd)
-#else
+# else
 static int
 afs_linux_dentry_revalidate(struct dentry *dp, int flags)
-#endif
+# endif
 {
     int code;
     struct dentry *parent;
 
-#ifdef LOOKUP_RCU
+# ifdef LOOKUP_RCU
     /* We don't support RCU path walking */
-# if defined(DOP_REVALIDATE_TAKES_UNSIGNED)
+#  if defined(DOP_REVALIDATE_TAKES_UNSIGNED)
     if ((flags & LOOKUP_RCU) != 0) {
        return -ECHILD;
     }
-# else
+#  else
     if ((nd->flags & LOOKUP_RCU) != 0) {
        return -ECHILD;
     }
+#  endif
 # endif
-#endif
 
     parent = dget_parent(dp);
     code = dentry_revalidate_common(VTOAFS(parent->d_inode),
@@ -1626,6 +1637,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
 
     return code;
 }
+#endif /* DOP_REVALIDATE_TAKES_PARENT_INODE */
 
 static void
 afs_dentry_iput(struct dentry *dp, struct inode *ip)
diff --git a/src/cf/linux-kernel-assorted.m4 b/src/cf/linux-kernel-assorted.m4
index 88f9e1897..03459137f 100644
--- a/src/cf/linux-kernel-assorted.m4
+++ b/src/cf/linux-kernel-assorted.m4
@@ -17,6 +17,7 @@ LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA
 LINUX_IOP_I_PUT_LINK_TAKES_COOKIE
 LINUX_DOP_D_DELETE_TAKES_CONST
 LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA
+LINUX_DOP_D_REVALIDATE_TAKES_PARENT_INODE
 LINUX_FOP_F_FLUSH_TAKES_FL_OWNER_T
 LINUX_FOP_F_FSYNC_TAKES_DENTRY
 LINUX_FOP_F_FSYNC_TAKES_RANGE
diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4
index b22930690..c7c0c2318 100644
--- a/src/cf/linux-test4.m4
+++ b/src/cf/linux-test4.m4
@@ -885,3 +885,21 @@ AC_DEFUN([LINUX_FILE_LOCK_CORE], [
                        [define if file_lock_core exists],
                        [])
 ])
+
+dnl linux 6.14 updated dentry_operations.d_revalidate with 2 additional
+dnl parameters, the inode of the parent directory and the name the dentry
+dnl is expected to have.  Using these are optional.  Both parameters are
+dnl stable.
+AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_PARENT_INODE], [
+  AC_CHECK_LINUX_BUILD([whether dop.d_revalidate takes inode and qstr],
+                       [ac_cv_linux_func_d_revalidate_takes_parent_inode],
+                       [#include <linux/fs.h>
+                       #include <linux/namei.h>
+                       static int reval(struct inode  *parent_inode, const struct qstr *name,
+			                struct dentry *d, unsigned int flags) { return 0; }
+                       struct dentry_operations dops;],
+                       [dops.d_revalidate = reval;],
+                       [DOP_REVALIDATE_TAKES_PARENT_INODE],
+                       [define if your dops.d_revalidate takes a parent inode],
+                       [-Werror])
+])
\ No newline at end of file
openSUSE Build Service is sponsored by