From 1defa62a19e71c021ec2cf9fc9e0481e9ab962e0 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 18 Oct 2017 12:26:19 -0400 Subject: [PATCH] LU-9558 llite: port lustre to unified handling of bdi 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 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28511 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 19 ++++++++++++++++ lustre/include/lustre_disk.h | 2 +- lustre/llite/llite_lib.c | 51 +++++++++++++++++++++++++++++------------- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 1b86922..d49a4d2 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + 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], [ diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 92206ef..d48aaba 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -49,6 +49,7 @@ #include #include #include +#include #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) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 423e960..da145a4 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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; -- 1.8.3.1