Whamcloud - gitweb
LU-16954 llite: add SB_I_CGROUPWB on super block for cgroup
authorQian Yingjin <qian@ddn.com>
Wed, 16 Aug 2023 04:02:22 +0000 (00:02 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Mon, 2 Oct 2023 01:01:41 +0000 (01:01 +0000)
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.

Lustre-change: https://review.whamcloud.com/51955
Lustre-commit: dcc1dd39a67f15de9174e7acdda599e3c54c1421

Test-Parameters: clientdistro=ubuntu2204 testlist=sanity-sec
Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I7fff4f26aa1bfdb0e5de0c4bdbff44ed74d18c2d
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52538
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/llite/llite_lib.c

index 15b8fd6..4031274 100644 (file)
@@ -2865,6 +2865,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 <linux/backing-dev-defs.h>
+       ],[
+               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_SUPPORT
 #
 # 5.4 introduced fscrypt encryption policies v2
@@ -3763,6 +3787,9 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [
        # 5.9
        LC_SRC_HAVE_ITER_FILE_SPLICE_WRITE
 
+       # 5.10
+       LC_SRC_HAVE_BDI_DEBUG_STATS
+
        # 5.12
        LC_SRC_HAVE_USER_NAMESPACE_ARG
 
@@ -4008,6 +4035,7 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [
 
        # 5.10
        LC_HAVE_ITER_FILE_SPLICE_WRITE
+       LC_HAVE_BDI_DEBUG_STATS
 
        # 5.12
        LC_HAVE_USER_NAMESPACE_ARG
index 5832c9e..ef668ec 100644 (file)
@@ -1269,6 +1269,9 @@ int ll_fill_super(struct super_block *sb)
 #ifdef HAVE_BDI_IO_PAGES
        sb->s_bdi->io_pages = 0;
 #endif
+#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.
@@ -1346,6 +1349,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;
@@ -1419,6 +1439,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);