1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
From fea2bd506b40543d6d9ec862acafb6622fb97ff8 Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Tue, 29 Aug 2023 14:58:10 -0600
Subject: [PATCH 5/6] linux: Replace fop iterate with fop iterate_shared
The Linux 6.5 commit:
'vfs: get rid of old '->iterate' directory operation' (3e32715496)
removed the filesystem_operations iterate method. The replacement
method, iterate_shared, was introduced with the Linux 4.6 commit:
'introduce a parallel variant of ->iterate()' (6192269444)
The above commits indicate that the iterate_shared is an "almost"
drop-in replacement for iterate. The vfs documentation for
iterate_shared has caveats on the implementation (serializing in-core
per-inode or per-dentry modifications and using d_alloc_parallel if
doing dcache pre-seeding). A wrapper is provided to assist filesystems
with the migration from iterate to iterate_shared. Until it can be
verified that afs_linux_readdir meets the above requirements, we will
use the wrapper (ref 3e32715496 commit)
Add configure tests for the iterate_shared file_operations member and
for the wrap_directory_iterator function.
Update osi_vnodeops.c to use iterate_shared and the wrapper if they are
both available.
Reviewed-on: https://gerrit.openafs.org/15528
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 7437f4d37719ea53711e06ac9675dad1abd6769e)
Change-Id: Id00cfab2c0b51c2167fe19cd9cf7f136450ff174
---
src/afs/LINUX/osi_vnodeops.c | 19 +++++++++++++++----
src/cf/linux-kernel-func.m4 | 10 ++++++++++
src/cf/linux-kernel-struct.m4 | 1 +
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index dd8b39d5d..fb62752e6 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -54,14 +54,16 @@
# define D_SPLICE_ALIAS_RACE
#endif
+#if defined(STRUCT_FILE_OPERATIONS_HAS_ITERATE_SHARED) && defined(HAVE_LINUX_WRAP_DIRECTORY_ITERATOR)
+# define USE_FOP_ITERATE 1
+#elif defined(STRUCT_FILE_OPERATIONS_HAS_ITERATE) && !defined(FMODE_KABI_ITERATE)
/* Workaround for RH 7.5 which introduced file operation iterate() but requires
* each file->f_mode to be marked with FMODE_KABI_ITERATE. Instead OpenAFS will
* continue to use file opearation readdir() in this case.
*/
-#if defined(STRUCT_FILE_OPERATIONS_HAS_ITERATE) && !defined(FMODE_KABI_ITERATE)
-#define USE_FOP_ITERATE 1
+# define USE_FOP_ITERATE 1
#else
-#undef USE_FOP_ITERATE
+# undef USE_FOP_ITERATE
#endif
/* Kernels from before 2.6.19 may not be able to return errors from
@@ -909,10 +911,19 @@ out:
crfree(credp);
return afs_convert_code(code);
}
+#if defined(STRUCT_FILE_OPERATIONS_HAS_ITERATE_SHARED) && defined(HAVE_LINUX_WRAP_DIRECTORY_ITERATOR)
+# if defined(WRAP_DIR_ITER)
+WRAP_DIR_ITER(afs_linux_readdir) /* Adds necessary locking for iterate_shared */
+# else
+# error the Linux provided macro WRAP_DIR_ITER is not available
+# endif
+#endif
struct file_operations afs_dir_fops = {
.read = generic_read_dir,
-#if defined(USE_FOP_ITERATE)
+#if defined(STRUCT_FILE_OPERATIONS_HAS_ITERATE_SHARED) && defined(HAVE_LINUX_WRAP_DIRECTORY_ITERATOR)
+ .iterate_shared = shared_afs_linux_readdir,
+#elif defined(USE_FOP_ITERATE)
.iterate = afs_linux_readdir,
#else
.readdir = afs_linux_readdir,
diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4
index 811954915..145725575 100644
--- a/src/cf/linux-kernel-func.m4
+++ b/src/cf/linux-kernel-func.m4
@@ -225,6 +225,16 @@ AC_CHECK_LINUX_FUNC([register_sysctl],
#include <linux/sysctl.h>],
[(void)register_sysctl(NULL, NULL);])
+dnl Linux 6.5 removed the file_operations method 'iterate'. Filesystems should
+dnl using the iterate_shared method (introduced in linux 4.6). Linux 6.4
+dnl provides a wrapper that can be used for filesystems that haven't fully
+dnl converted to meet the iterate_shared requirements.
+
+AC_CHECK_LINUX_FUNC([wrap_directory_iterator],
+ [#include <linux/kernel.h>
+ #include <linux/fs.h>],
+ [(void)wrap_directory_iterator(NULL, NULL, NULL);])
+
dnl Consequences - things which get set as a result of the
dnl above tests
AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
diff --git a/src/cf/linux-kernel-struct.m4 b/src/cf/linux-kernel-struct.m4
index 8082308e8..52e10acb8 100644
--- a/src/cf/linux-kernel-struct.m4
+++ b/src/cf/linux-kernel-struct.m4
@@ -23,6 +23,7 @@ AC_CHECK_LINUX_STRUCT([inode], [i_mutex], [fs.h])
AC_CHECK_LINUX_STRUCT([inode], [i_security], [fs.h])
AC_CHECK_LINUX_STRUCT([file], [f_path], [fs.h])
AC_CHECK_LINUX_STRUCT([file_operations], [flock], [fs.h])
+AC_CHECK_LINUX_STRUCT([file_operations], [iterate_shared], [fs.h])
AC_CHECK_LINUX_STRUCT([file_operations], [iterate], [fs.h])
AC_CHECK_LINUX_STRUCT([file_operations], [read_iter], [fs.h])
AC_CHECK_LINUX_STRUCT([file_operations], [sendfile], [fs.h])
--
2.42.0
|