From ad06e5506388a02ee388fe47bbf8e8bc048d705e Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Tue, 18 Nov 2014 18:36:32 -0800 Subject: [PATCH] LU-5443 ldiskfs: replace direct HZ access with kernel APIs On some customer's systems, kernel was compiled with HZ defined to 100, instead of 1000. This improves performance for HPC applications. However, to use these systems with Lustre, customers have to re-build Lustre for the kernel because Lustre directly uses the defined constant HZ. Since kernel 2.6.21, some non-HZ dependent timing APIs become non- inline functions, which can be used in Lustre codes to replace the direct HZ access. These kernel APIs include: jiffies_to_msecs() jiffies_to_usecs() jiffies_to_timespec() msecs_to_jiffies() usecs_to_jiffies() timespec_to_jiffies() And here are some samples of the replacement: HZ -> msecs_to_jiffies(MSEC_PER_SEC) n * HZ -> msecs_to_jiffies(n * MSEC_PER_SEC) HZ / n -> msecs_to_jiffies(MSEC_PER_SEC / n) n / HZ -> jiffies_to_msecs(n) / MSEC_PER_SEC n / HZ * 1000 -> jiffies_to_msecs(n) This patch replaces the direct HZ access in ldiskfs module. Test-Parameters: alwaysuploadlogs envdefinitions=SLOW=yes,MMP_EXCEPT=5 \ mdtfilesystemtype=ldiskfs mdsfilesystemtype=ldiskfs ostfilesystemtype=ldiskfs \ clientcount=4 osscount=2 mdscount=2 austeroptions=-R failover=true iscsi=1 \ testlist=mmp Signed-off-by: Jian Yu Change-Id: Ic111360083bd6d8973e47767cb1b291915613727 Reviewed-on: http://review.whamcloud.com/12779 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- .../kernel_patches/patches/rhel6.3/ext4-mmp.patch | 57 ++++++++++++---------- .../kernel_patches/patches/rhel6.4/ext4-mmp.patch | 57 ++++++++++++---------- 2 files changed, 60 insertions(+), 54 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch index 17e0914..8396e93 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch @@ -12,9 +12,9 @@ Signed-off-by: Johann Lombardi whamcloud.com> --- fs/ext4/Makefile | 3 +- fs/ext4/ext4.h | 76 ++++++++++++- - fs/ext4/mmp.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + fs/ext4/mmp.c | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/super.c | 18 +++- - 4 files changed, 444 insertions(+), 4 deletions(-) + 4 files changed, 447 insertions(+), 4 deletions(-) create mode 100644 fs/ext4/mmp.c Index: linux-stage/fs/ext4/Makefile @@ -156,7 +156,7 @@ Index: linux-stage/fs/ext4/mmp.c =================================================================== --- /dev/null +++ linux-stage/fs/ext4/mmp.c -@@ -0,0 +1,351 @@ +@@ -0,0 +1,354 @@ +#include +#include +#include @@ -305,10 +305,10 @@ Index: linux-stage/fs/ext4/mmp.c + goto failed; + } + -+ diff = jiffies - last_update_time; -+ if (diff < mmp_update_interval * HZ) -+ schedule_timeout_interruptible(mmp_update_interval * -+ HZ - diff); ++ diff = jiffies - last_update_time; ++ if (diff < mmp_update_interval * msecs_to_jiffies(MSEC_PER_SEC)) ++ schedule_timeout_interruptible(mmp_update_interval * ++ msecs_to_jiffies(MSEC_PER_SEC) - diff); + + /* + * We need to make sure that more than mmp_check_interval @@ -316,7 +316,7 @@ Index: linux-stage/fs/ext4/mmp.c + * we need to check if the MMP block is as we left it. + */ + diff = jiffies - last_update_time; -+ if (diff > mmp_check_interval * HZ) { ++ if (diff > mmp_check_interval * msecs_to_jiffies(MSEC_PER_SEC)) { + struct buffer_head *bh_check = NULL; + struct mmp_struct *mmp_check; + @@ -343,14 +343,15 @@ Index: linux-stage/fs/ext4/mmp.c + put_bh(bh_check); + } + -+ /* -+ * Adjust the mmp_check_interval depending on how much time -+ * it took for the MMP block to be written. -+ */ -+ mmp_check_interval = max(min(EXT4_MMP_CHECK_MULT * diff / HZ, -+ EXT4_MMP_MAX_CHECK_INTERVAL), -+ EXT4_MMP_MIN_CHECK_INTERVAL); -+ mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval); ++ /* ++ * Adjust the mmp_check_interval depending on how much time ++ * it took for the MMP block to be written. ++ */ ++ mmp_check_interval = max(min(EXT4_MMP_CHECK_MULT * diff / ++ msecs_to_jiffies(MSEC_PER_SEC), ++ EXT4_MMP_MAX_CHECK_INTERVAL), ++ EXT4_MMP_MIN_CHECK_INTERVAL); ++ mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval); + } + + /* @@ -436,10 +437,11 @@ Index: linux-stage/fs/ext4/mmp.c + ext4_warning(sb, "MMP interval %u higher than expected, please" + " wait.\n", wait_time * 2); + -+ if (schedule_timeout_interruptible(HZ * wait_time) != 0) { -+ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); -+ goto failed; -+ } ++ if (schedule_timeout_interruptible(msecs_to_jiffies(MSEC_PER_SEC) * ++ wait_time) != 0) { ++ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); ++ goto failed; ++ } + + retval = read_mmp_block(sb, &bh, mmp_block); + if (retval) @@ -461,13 +463,14 @@ Index: linux-stage/fs/ext4/mmp.c + if (retval) + goto failed; + -+ /* -+ * wait for MMP interval and check mmp_seq. -+ */ -+ if (schedule_timeout_interruptible(HZ * wait_time) != 0) { -+ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); -+ goto failed; -+ } ++ /* ++ * wait for MMP interval and check mmp_seq. ++ */ ++ if (schedule_timeout_interruptible(msecs_to_jiffies(MSEC_PER_SEC) * ++ wait_time) != 0) { ++ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); ++ goto failed; ++ } + + retval = read_mmp_block(sb, &bh, mmp_block); + if (retval) diff --git a/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch b/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch index 9fcf40f..fd60b3b 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch @@ -12,9 +12,9 @@ Signed-off-by: Johann Lombardi whamcloud.com> --- fs/ext4/Makefile | 3 +- fs/ext4/ext4.h | 76 ++++++++++++- - fs/ext4/mmp.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + fs/ext4/mmp.c | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/super.c | 18 +++- - 4 files changed, 444 insertions(+), 4 deletions(-) + 4 files changed, 447 insertions(+), 4 deletions(-) create mode 100644 fs/ext4/mmp.c Index: linux-stage/fs/ext4/Makefile @@ -156,7 +156,7 @@ Index: linux-stage/fs/ext4/mmp.c =================================================================== --- /dev/null +++ linux-stage/fs/ext4/mmp.c -@@ -0,0 +1,351 @@ +@@ -0,0 +1,354 @@ +#include +#include +#include @@ -305,10 +305,10 @@ Index: linux-stage/fs/ext4/mmp.c + goto failed; + } + -+ diff = jiffies - last_update_time; -+ if (diff < mmp_update_interval * HZ) -+ schedule_timeout_interruptible(mmp_update_interval * -+ HZ - diff); ++ diff = jiffies - last_update_time; ++ if (diff < mmp_update_interval * msecs_to_jiffies(MSEC_PER_SEC)) ++ schedule_timeout_interruptible(mmp_update_interval * ++ msecs_to_jiffies(MSEC_PER_SEC) - diff); + + /* + * We need to make sure that more than mmp_check_interval @@ -316,7 +316,7 @@ Index: linux-stage/fs/ext4/mmp.c + * we need to check if the MMP block is as we left it. + */ + diff = jiffies - last_update_time; -+ if (diff > mmp_check_interval * HZ) { ++ if (diff > mmp_check_interval * msecs_to_jiffies(MSEC_PER_SEC)) { + struct buffer_head *bh_check = NULL; + struct mmp_struct *mmp_check; + @@ -343,14 +343,15 @@ Index: linux-stage/fs/ext4/mmp.c + put_bh(bh_check); + } + -+ /* -+ * Adjust the mmp_check_interval depending on how much time -+ * it took for the MMP block to be written. -+ */ -+ mmp_check_interval = max(min(EXT4_MMP_CHECK_MULT * diff / HZ, -+ EXT4_MMP_MAX_CHECK_INTERVAL), -+ EXT4_MMP_MIN_CHECK_INTERVAL); -+ mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval); ++ /* ++ * Adjust the mmp_check_interval depending on how much time ++ * it took for the MMP block to be written. ++ */ ++ mmp_check_interval = max(min(EXT4_MMP_CHECK_MULT * diff / ++ msecs_to_jiffies(MSEC_PER_SEC), ++ EXT4_MMP_MAX_CHECK_INTERVAL), ++ EXT4_MMP_MIN_CHECK_INTERVAL); ++ mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval); + } + + /* @@ -436,10 +437,11 @@ Index: linux-stage/fs/ext4/mmp.c + ext4_warning(sb, "MMP interval %u higher than expected, please" + " wait.\n", wait_time * 2); + -+ if (schedule_timeout_interruptible(HZ * wait_time) != 0) { -+ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); -+ goto failed; -+ } ++ if (schedule_timeout_interruptible(msecs_to_jiffies(MSEC_PER_SEC) * ++ wait_time) != 0) { ++ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); ++ goto failed; ++ } + + retval = read_mmp_block(sb, &bh, mmp_block); + if (retval) @@ -461,13 +463,14 @@ Index: linux-stage/fs/ext4/mmp.c + if (retval) + goto failed; + -+ /* -+ * wait for MMP interval and check mmp_seq. -+ */ -+ if (schedule_timeout_interruptible(HZ * wait_time) != 0) { -+ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); -+ goto failed; -+ } ++ /* ++ * wait for MMP interval and check mmp_seq. ++ */ ++ if (schedule_timeout_interruptible(msecs_to_jiffies(MSEC_PER_SEC) * ++ wait_time) != 0) { ++ ext4_warning(sb, "MMP startup interrupted, failing mount\n"); ++ goto failed; ++ } + + retval = read_mmp_block(sb, &bh, mmp_block); + if (retval) -- 1.8.3.1