Whamcloud - gitweb
LU-9558 llite: port lustre to unified handling of bdi 11/28511/7
authorJan Kara <jack@suse.cz>
Wed, 18 Oct 2017 16:26:19 +0000 (12:26 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 1 Nov 2017 04:57:32 +0000 (04:57 +0000)
For the linux 4.12 kernel the bdi handling was unified for all
file systems. This was done by allocating struct backing_dev_info
separately instead of embedding it inside superblock. For older
kernels we move all the bdi handling lustre does to the function
super_setup_bdi_name() which is what exist in the latest kernels.

Linux-commit: 9594caf216dc0fe3e318b34af0127276db661241

Change-Id: I5af60ea3661e3d3a97973fd99a79c28dcd1ce1cc
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/28511
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_disk.h
lustre/llite/llite_lib.c

index 1b86922..d49a4d2 100644 (file)
@@ -2653,6 +2653,24 @@ current_time, [
 ]) # LIBCFS_CURRENT_TIME
 
 #
+# LC_SUPER_SETUP_BDI_NAME
+#
+# Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241
+# unified bdi handling
+#
+AC_DEFUN([LC_SUPER_SETUP_BDI_NAME], [
+LB_CHECK_COMPILE([if 'super_setup_bdi_name' exist],
+super_setup_bdi_name, [
+       #include <linux/fs.h>
+],[
+       super_setup_bdi_name(NULL, "lustre");
+],[
+       AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1,
+               ['super_setup_bdi_name' is available])
+])
+]) # LC_SUPER_SETUP_BDI_NAME
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2873,6 +2891,7 @@ AC_DEFUN([LC_PROG_LINUX], [
 
        # 4.12
        LC_CURRENT_TIME
+       LC_SUPER_SETUP_BDI_NAME
 
        #
        AS_IF([test "x$enable_server" != xno], [
index 92206ef..d48aaba 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/list.h>
 #include <libcfs/libcfs.h>
 #include <uapi/linux/lustre/lustre_disk.h>
+#include <uapi/linux/lustre/lustre_idl.h>
 
 #define IS_MDT(data)           ((data)->lsi_flags & LDD_F_SV_TYPE_MDT)
 #define IS_OST(data)           ((data)->lsi_flags & LDD_F_SV_TYPE_OST)
@@ -132,7 +133,6 @@ struct lustre_sb_info {
 };
 
 #define LSI_UMOUNT_FAILOVER              0x00200000
-#define LSI_BDI_INITIALIZED              0x00400000
 
 #define     s2lsi(sb)        ((struct lustre_sb_info *)((sb)->s_fs_info))
 #define     s2lsi_nocast(sb) ((sb)->s_fs_info)
index 423e960..da145a4 100644 (file)
@@ -948,14 +948,41 @@ void ll_lli_init(struct ll_inode_info *lli)
        memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE);
 }
 
-static inline int ll_bdi_register(struct backing_dev_info *bdi)
+#ifndef HAVE_SUPER_SETUP_BDI_NAME
+
+#define LSI_BDI_INITIALIZED    0x00400000
+
+#ifndef HAVE_BDI_CAP_MAP_COPY
+# define BDI_CAP_MAP_COPY      0
+#endif
+
+#define MAX_STRING_SIZE 128
+
+static int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
 {
-       static atomic_t ll_bdi_num = ATOMIC_INIT(0);
+       struct  lustre_sb_info *lsi = s2lsi(sb);
+       char buf[MAX_STRING_SIZE];
+       va_list args;
+       int err;
+
+       err = bdi_init(&lsi->lsi_bdi);
+       if (err)
+               return err;
+
+       lsi->lsi_flags |= LSI_BDI_INITIALIZED;
+       lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
+       lsi->lsi_bdi.name = "lustre";
+       va_start(args, fmt);
+       vsnprintf(buf, MAX_STRING_SIZE, fmt, args);
+       va_end(args);
+       err = bdi_register(&lsi->lsi_bdi, NULL, "%s", buf);
+       va_end(args);
+       if (!err)
+               sb->s_bdi = &lsi->lsi_bdi;
 
-       bdi->name = "lustre";
-       return bdi_register(bdi, NULL, "lustre-%d",
-                           atomic_inc_return(&ll_bdi_num));
+       return err;
 }
+#endif /* !HAVE_SUPER_SETUP_BDI_NAME */
 
 int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
 {
@@ -992,20 +1019,10 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
        if (err)
                GOTO(out_free, err);
 
-       err = bdi_init(&lsi->lsi_bdi);
-       if (err)
-               GOTO(out_free, err);
-       lsi->lsi_flags |= LSI_BDI_INITIALIZED;
-#ifdef HAVE_BDI_CAP_MAP_COPY
-       lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
-#else
-       lsi->lsi_bdi.capabilities = 0;
-#endif
-       err = ll_bdi_register(&lsi->lsi_bdi);
+       err = super_setup_bdi_name(sb, "lustre-%p", sb);
        if (err)
                GOTO(out_free, err);
 
-       sb->s_bdi = &lsi->lsi_bdi;
 #ifndef HAVE_DCACHE_LOCK
        /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
        sb->s_d_op = &ll_d_ops;
@@ -1147,10 +1164,12 @@ void ll_put_super(struct super_block *sb)
         if (profilenm)
                 class_del_profile(profilenm);
 
+#ifndef HAVE_SUPER_SETUP_BDI_NAME
        if (lsi->lsi_flags & LSI_BDI_INITIALIZED) {
                bdi_destroy(&lsi->lsi_bdi);
                lsi->lsi_flags &= ~LSI_BDI_INITIALIZED;
        }
+#endif
 
         ll_free_sbi(sb);
         lsi->lsi_llsbi = NULL;