Skip to content

Commit 01d00df

Browse files
ckanebehlendorf
authored andcommitted
Linux 6.6 compat: generic_fillattr has a new u32 request_mask added at arg2
In commit 0d72b92883c651a11059d93335f33d65c6eb653b, a new u32 argument for the request_mask was added to generic_fillattr. This is the same request_mask for statx that's present in the most recent API implemented by zpl_getattr_impl. This commit conditionally adds it to the zpl_generic_fillattr(...) macro, as well as the zfs_getattr_fast(...) implementation, when configure determines it's present in the kernel's generic_fillattr(...). Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes #15263
1 parent b37f293 commit 01d00df

File tree

6 files changed

+63
-11
lines changed

6 files changed

+63
-11
lines changed

config/kernel-generic_fillattr.m4

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ dnl #
77
dnl # 6.3 API
88
dnl # generic_fillattr() now takes struct mnt_idmap* as the first argument
99
dnl #
10+
dnl # 6.6 API
11+
dnl # generic_fillattr() now takes u32 as second argument, representing a
12+
dnl # request_mask for statx
13+
dnl #
1014
AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR], [
1115
ZFS_LINUX_TEST_SRC([generic_fillattr_userns], [
1216
#include <linux/fs.h>
@@ -25,22 +29,39 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR], [
2529
struct kstat *k = NULL;
2630
generic_fillattr(idmap, in, k);
2731
])
32+
33+
ZFS_LINUX_TEST_SRC([generic_fillattr_mnt_idmap_reqmask], [
34+
#include <linux/fs.h>
35+
],[
36+
struct mnt_idmap *idmap = NULL;
37+
struct inode *in = NULL;
38+
struct kstat *k = NULL;
39+
generic_fillattr(idmap, 0, in, k);
40+
])
2841
])
2942

3043
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_FILLATTR], [
31-
AC_MSG_CHECKING([whether generic_fillattr requires struct mnt_idmap*])
32-
ZFS_LINUX_TEST_RESULT([generic_fillattr_mnt_idmap], [
44+
AC_MSG_CHECKING(
45+
[whether generic_fillattr requires struct mnt_idmap* and request_mask])
46+
ZFS_LINUX_TEST_RESULT([generic_fillattr_mnt_idmap_reqmask], [
3347
AC_MSG_RESULT([yes])
34-
AC_DEFINE(HAVE_GENERIC_FILLATTR_IDMAP, 1,
35-
[generic_fillattr requires struct mnt_idmap*])
48+
AC_DEFINE(HAVE_GENERIC_FILLATTR_IDMAP_REQMASK, 1,
49+
[generic_fillattr requires struct mnt_idmap* and u32 request_mask])
3650
],[
37-
AC_MSG_CHECKING([whether generic_fillattr requires struct user_namespace*])
38-
ZFS_LINUX_TEST_RESULT([generic_fillattr_userns], [
51+
AC_MSG_CHECKING([whether generic_fillattr requires struct mnt_idmap*])
52+
ZFS_LINUX_TEST_RESULT([generic_fillattr_mnt_idmap], [
3953
AC_MSG_RESULT([yes])
40-
AC_DEFINE(HAVE_GENERIC_FILLATTR_USERNS, 1,
41-
[generic_fillattr requires struct user_namespace*])
54+
AC_DEFINE(HAVE_GENERIC_FILLATTR_IDMAP, 1,
55+
[generic_fillattr requires struct mnt_idmap*])
4256
],[
43-
AC_MSG_RESULT([no])
57+
AC_MSG_CHECKING([whether generic_fillattr requires struct user_namespace*])
58+
ZFS_LINUX_TEST_RESULT([generic_fillattr_userns], [
59+
AC_MSG_RESULT([yes])
60+
AC_DEFINE(HAVE_GENERIC_FILLATTR_USERNS, 1,
61+
[generic_fillattr requires struct user_namespace*])
62+
],[
63+
AC_MSG_RESULT([no])
64+
])
4465
])
4566
])
4667
])

include/os/linux/kernel/linux/vfs_compat.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,16 @@ zpl_is_32bit_api(void)
461461
* 6.3 API change
462462
* generic_fillattr() first arg is changed to struct mnt_idmap *
463463
*
464+
* 6.6 API change
465+
* generic_fillattr() gets new second arg request_mask, a u32 type
466+
*
464467
*/
465468
#ifdef HAVE_GENERIC_FILLATTR_IDMAP
466469
#define zpl_generic_fillattr(idmap, ip, sp) \
467470
generic_fillattr(idmap, ip, sp)
471+
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP_REQMASK)
472+
#define zpl_generic_fillattr(idmap, rqm, ip, sp) \
473+
generic_fillattr(idmap, rqm, ip, sp)
468474
#elif defined(HAVE_GENERIC_FILLATTR_USERNS)
469475
#define zpl_generic_fillattr(user_ns, ip, sp) \
470476
generic_fillattr(user_ns, ip, sp)

include/os/linux/zfs/sys/zfs_vnops_os.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ extern int zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap,
5656
extern int zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd,
5757
cred_t *cr, int flags);
5858
extern int zfs_readdir(struct inode *ip, zpl_dir_context_t *ctx, cred_t *cr);
59+
#ifdef HAVE_GENERIC_FILLATTR_IDMAP_REQMASK
60+
extern int zfs_getattr_fast(zidmap_t *, u32 request_mask, struct inode *ip,
61+
struct kstat *sp);
62+
#else
5963
extern int zfs_getattr_fast(zidmap_t *, struct inode *ip, struct kstat *sp);
64+
#endif
6065
extern int zfs_setattr(znode_t *zp, vattr_t *vap, int flag, cred_t *cr,
6166
zidmap_t *mnt_ns);
6267
extern int zfs_rename(znode_t *sdzp, char *snm, znode_t *tdzp,

module/os/linux/zfs/zfs_vnops_os.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,12 @@ zfs_readdir(struct inode *ip, zpl_dir_context_t *ctx, cred_t *cr)
16491649
* RETURN: 0 (always succeeds)
16501650
*/
16511651
int
1652+
#ifdef HAVE_GENERIC_FILLATTR_IDMAP_REQMASK
1653+
zfs_getattr_fast(zidmap_t *user_ns, u32 request_mask, struct inode *ip,
1654+
struct kstat *sp)
1655+
#else
16521656
zfs_getattr_fast(zidmap_t *user_ns, struct inode *ip, struct kstat *sp)
1657+
#endif
16531658
{
16541659
znode_t *zp = ITOZ(ip);
16551660
zfsvfs_t *zfsvfs = ITOZSB(ip);
@@ -1662,7 +1667,11 @@ zfs_getattr_fast(zidmap_t *user_ns, struct inode *ip, struct kstat *sp)
16621667

16631668
mutex_enter(&zp->z_lock);
16641669

1670+
#ifdef HAVE_GENERIC_FILLATTR_IDMAP_REQMASK
1671+
zpl_generic_fillattr(user_ns, request_mask, ip, sp);
1672+
#else
16651673
zpl_generic_fillattr(user_ns, ip, sp);
1674+
#endif
16661675
/*
16671676
* +1 link count for root inode with visible '.zfs' directory.
16681677
*/

module/os/linux/zfs/zpl_ctldir.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ zpl_root_getattr_impl(const struct path *path, struct kstat *stat,
124124
generic_fillattr(user_ns, ip, stat);
125125
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP)
126126
generic_fillattr(user_ns, ip, stat);
127+
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP_REQMASK)
128+
generic_fillattr(user_ns, request_mask, ip, stat);
127129
#else
128130
(void) user_ns;
129131
#endif
@@ -435,6 +437,8 @@ zpl_snapdir_getattr_impl(const struct path *path, struct kstat *stat,
435437
generic_fillattr(user_ns, ip, stat);
436438
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP)
437439
generic_fillattr(user_ns, ip, stat);
440+
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP_REQMASK)
441+
generic_fillattr(user_ns, request_mask, ip, stat);
438442
#else
439443
(void) user_ns;
440444
#endif
@@ -609,6 +613,8 @@ zpl_shares_getattr_impl(const struct path *path, struct kstat *stat,
609613
generic_fillattr(user_ns, path->dentry->d_inode, stat);
610614
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP)
611615
generic_fillattr(user_ns, path->dentry->d_inode, stat);
616+
#elif defined(HAVE_GENERIC_FILLATTR_IDMAP_REQMASK)
617+
generic_fillattr(user_ns, request_mask, ip, stat);
612618
#else
613619
(void) user_ns;
614620
#endif
@@ -623,7 +629,10 @@ zpl_shares_getattr_impl(const struct path *path, struct kstat *stat,
623629

624630
error = -zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp);
625631
if (error == 0) {
626-
#if (defined(HAVE_USERNS_IOPS_GETATTR) || defined(HAVE_IDMAP_IOPS_GETATTR))
632+
#ifdef HAVE_GENERIC_FILLATTR_IDMAP_REQMASK
633+
error = -zfs_getattr_fast(user_ns, request_mask, ZTOI(dzp),
634+
stat);
635+
#elif (defined(HAVE_USERNS_IOPS_GETATTR) || defined(HAVE_IDMAP_IOPS_GETATTR))
627636
error = -zfs_getattr_fast(user_ns, ZTOI(dzp), stat);
628637
#else
629638
error = -zfs_getattr_fast(kcred->user_ns, ZTOI(dzp), stat);

module/os/linux/zfs/zpl_inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,9 @@ zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
435435
* XXX query_flags currently ignored.
436436
*/
437437

438-
#if (defined(HAVE_USERNS_IOPS_GETATTR) || defined(HAVE_IDMAP_IOPS_GETATTR))
438+
#ifdef HAVE_GENERIC_FILLATTR_IDMAP_REQMASK
439+
error = -zfs_getattr_fast(user_ns, request_mask, ip, stat);
440+
#elif (defined(HAVE_USERNS_IOPS_GETATTR) || defined(HAVE_IDMAP_IOPS_GETATTR))
439441
error = -zfs_getattr_fast(user_ns, ip, stat);
440442
#else
441443
error = -zfs_getattr_fast(kcred->user_ns, ip, stat);

0 commit comments

Comments
 (0)