From 8c02a547b07bd8d5d705b5bd73bb30bd1e198d09 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Tue, 28 Jun 2022 05:39:21 -0400 Subject: [PATCH] LU-15969 pcc: use new ->fileattr_set for PCC project The new Ubuntu 2204 (since kernel 5.12) introduces a new inode VFS interface ->fileattr_set() and ->fileattr_get() to set/get project ID on a file. In PCC, we set the project ID for PCC copies on PCC backend file system via IOCTL FS_IOC_FSSETXATTR. However, the new kernel removed this IOCTL code, this results in that using this ioctl to set project ID for the PCC copy returns -ENOTTY and sanity-pcc test_39 failed. In this patch, we add compatibility check for this new VFS interface about project ID, and use the new VFS interface to set the project ID on the new kernel properly. Test-Parameters: clientdistro=ubuntu2204 env=SANITY_PCC_EXCEPT="101a" testlist=sanity-pcc Change-Id: I756f3d6fa97c60c416deca9e482270483ab06524 Signed-off-by: Qian Yingjin Reviewed-on: https://review.whamcloud.com/47811 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/autoconf/lustre-core.m4 | 23 +++++++++++++++++++++++ lustre/llite/pcc.c | 26 ++++++++++++++++++++++++++ lustre/tests/sanity-pcc.sh | 4 ++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index e7f0848..e94fc49 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2395,6 +2395,28 @@ EXTRA_KCFLAGS="$tmp_flags" ]) # LC_HAVE_USER_NAMESPACE_ARG # +# LC_HAVE_FILEATTR_OPS +# +# kernel 5.12 commit 4c5b479975212065ef39786e115fde42847e95a9 +# vfs: add fileattr ops +# Introduce a new internal API named "fileattr" (fsxattr can be confused with +# xattr, xflags is inappropriate, since this is more than just flags). +# +AC_DEFUN([LC_HAVE_FILEATTR_OPS], [ +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_CHECK_COMPILE([if 'inode_operations' members have fileattr ops], +fileattr_ops, [ + #include +],[ + ((struct inode_operations *)1)->fileattr_set(NULL, NULL, NULL); +],[ + AC_DEFINE(HAVE_FILEATTR_OPS, 1, + ['inode_operations' members have fileattr ops]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) # LC_HAVE_FILEATTR_OPS + # LC_HAVE_GET_ACL_RCU_ARG # # kernel 5.15 commit 0cad6246621b5887d5b33fea84219d2a71f2f99a @@ -2603,6 +2625,7 @@ AC_DEFUN([LC_PROG_LINUX], [ # 5.12 LC_HAVE_USER_NAMESPACE_ARG + LC_HAVE_FILEATTR_OPS # 5.15 LC_HAVE_GET_ACL_RCU_ARG diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 6e8017f..5f8e37d 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -110,6 +110,10 @@ #include #include "llite_internal.h" +#ifdef HAVE_FILEATTR_OPS +#include +#endif + struct kmem_cache *pcc_inode_slab; int pcc_super_init(struct pcc_super *super) @@ -3508,6 +3512,27 @@ int pcc_inode_reset_iattr(struct inode *lustre_inode, struct dentry *dentry, int pcc_file_reset_projid(struct pcc_dataset *dataset, struct file *file, __u32 projid) { +#ifdef HAVE_FILEATTR_OPS + struct fileattr fa = { .fsx_projid = projid }; + struct dentry *dentry = file->f_path.dentry; + struct inode *inode = d_inode(dentry); + int rc; + + ENTRY; + + if (!(dataset->pccd_flags & PCC_DATASET_PROJ_QUOTA)) + RETURN(0); + + /* project quota not supported on backing filesystem */ + if (!inode->i_op->fileattr_set) { + CWARN("%s: cache fs project quota absent, disabling: rc = %d\n", + dataset->pccd_pathname, -ENOIOCTLCMD); + dataset->pccd_flags &= ~PCC_DATASET_PROJ_QUOTA; + RETURN(0); + } + + rc = inode->i_op->fileattr_set(&init_user_ns, dentry, &fa); +#else struct fsxattr fsx = { .fsx_projid = projid }; mm_segment_t old_fs; int rc; @@ -3529,6 +3554,7 @@ int pcc_file_reset_projid(struct pcc_dataset *dataset, struct file *file, rc = file->f_op->unlocked_ioctl(file, FS_IOC_FSSETXATTR, (unsigned long)&fsx); force_uaccess_end(old_fs); +#endif if (rc == -EOPNOTSUPP || rc == -ENOTTY) { CWARN("%s: cache fs project quota off, disabling: rc = %d\n", dataset->pccd_pathname, rc); diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index 45bd1f0..a8b5b2a 100644 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -12,8 +12,8 @@ export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/utils:$PATH:/sbin:/usr/sbin ONLY=${ONLY:-"$*"} ALWAYS_EXCEPT="$SANITY_PCC_EXCEPT " -# bug number for skipped test: EX-3763 LU-15969 -ALWAYS_EXCEPT+=" 44 39" +# bug number for skipped test: EX-3763 +ALWAYS_EXCEPT+=" 44 " # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true} -- 1.8.3.1