From dcc1dd39a67f15de9174e7acdda599e3c54c1421 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Wed, 16 Aug 2023 00:02:22 -0400 Subject: [PATCH] LU-16954 llite: add SB_I_CGROUPWB on super block for cgroup Cgroup support can be enabled per super_block by setting SB_I_CGROUPWB in ->s_iflags. Cgroup writeback requires support from both the bdi and filesystem. This patch adds SB_I_CGROUPWB flag on super block for Lustre. This is required by the subsequent patch series to support cgroup in Lustre. Adding this flags for Lustre super block will cause the remount failure on Maloo testing on Unbutu 2204 v5.15 kernel due to the duplicate filename (sysfs) for bdi device. To avoid remount failure, we explicitly unregister the sysfs for the @bdi. Test-Parameters: clientdistro=ubuntu2204 testlist=sanity-sec Signed-off-by: Qian Yingjin Change-Id: I7fff4f26aa1bfdb0e5de0c4bdbff44ed74d18c2d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51955 Reviewed-by: Patrick Farrell Reviewed-by: Shaun Tancheff Reviewed-by: Li Dongyang Reviewed-by: Oleg Drokin Reviewed-by: James Simmons Tested-by: Maloo Tested-by: jenkins --- lustre/autoconf/lustre-core.m4 | 26 ++++++++++++++++++++++++++ lustre/llite/llite_lib.c | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 55dcc3a..d09f68e 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3059,6 +3059,30 @@ AC_DEFUN([LC_HAVE_ITER_FILE_SPLICE_WRITE], [ ]) # LC_HAVE_ITER_FILE_SPLICE_WRITE # +# LC_HAVE_BDI_DEBUG_STATS +# +# Linux kernel v5.10 commit 2d146b924ec3c0873f06308d149684dc1105d9a3 +# backing-dev: no need to check return value of debugfs_create functions +# backing_dev_info.debug_stats was remove. +# +AC_DEFUN([LC_SRC_HAVE_BDI_DEBUG_STATS], [ + LB2_LINUX_TEST_SRC([bdi_has_debug_stats], [ + #include + ],[ + struct backing_dev_info info; + + info.debug_stats = NULL; + ],[-Werror]) +]) +AC_DEFUN([LC_HAVE_BDI_DEBUG_STATS], [ + AC_MSG_CHECKING([if 'struct backing_dev_info' has 'debug_stats' field]) + LB2_LINUX_TEST_RESULT([bdi_has_debug_stats], [ + AC_DEFINE(HAVE_BDI_DEBUG_STATS, 1, + [backing_dev_info has debug_stats]) + ]) +]) # LC_HAVE_BDI_DEBUG_STATS + +# # LC_FSCRYPT_IS_NOKEY_NAME # # Kernel 5.10-rc4 159e1de201b6fca10bfec50405a3b53a561096a8 @@ -4160,6 +4184,7 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ LC_SRC_HAVE_ITER_FILE_SPLICE_WRITE # 5.10 + LC_SRC_HAVE_BDI_DEBUG_STATS LC_SRC_FSCRYPT_IS_NOKEY_NAME LC_SRC_FSCRYPT_PREPARE_READDIR @@ -4431,6 +4456,7 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ LC_FSCRYPT_DUMMY_POLICY # 5.10 + LC_HAVE_BDI_DEBUG_STATS LC_FSCRYPT_IS_NOKEY_NAME LC_FSCRYPT_PREPARE_READDIR diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 918e867..f0b8dec 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1401,6 +1401,9 @@ int ll_fill_super(struct super_block *sb) sb->s_bdi->io_pages = 0; #endif sb->s_bdi->capabilities |= LL_BDI_CAP_FLAGS; +#ifdef SB_I_CGROUPWB + sb->s_iflags |= SB_I_CGROUPWB; +#endif /* Call ll_debugfs_register_super() before lustre_process_log() * so that "llite.*.*" params can be processed correctly. @@ -1478,6 +1481,23 @@ out_free_cfg: RETURN(err); } /* ll_fill_super */ +static void ll_bdi_device_unregister(struct backing_dev_info *bdi) +{ + if (bdi->dev == NULL) + return; + +#if defined(SB_I_CGROUPWB) && !defined(SB_I_PERSB_BDI) +#ifdef HAVE_BDI_DEBUG_STATS + debugfs_remove(bdi->debug_stats); + debugfs_remove(bdi->debug_dir); +#else + debugfs_remove_recursive(bdi->debug_dir); +#endif + device_unregister(bdi->dev); + bdi->dev = NULL; +#endif +} + void ll_put_super(struct super_block *sb) { struct config_llog_instance cfg, params_cfg; @@ -1540,6 +1560,8 @@ skip_cleanup: if (profilenm) class_del_profile(profilenm); + ll_bdi_device_unregister(sb->s_bdi); + #ifndef HAVE_SUPER_SETUP_BDI_NAME if (lsi->lsi_flags & LSI_BDI_INITIALIZED) { bdi_destroy(&lsi->lsi_bdi); -- 1.8.3.1