[PATCH] mmp race

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Vitaly Fertman <vitaly_fertman@xxxxxxxxxxx>

make sleep between reads twice in ext4_multi_mount_protect twice
longer than between write and read, make the later one equal to the
system check_interval

Xyratex-Bug-Id: MRP-390

Reviewed-by: Andrew Perepechko <Andrew_Perepechko@xxxxxxxxxxx>
---
 lib/ext2fs/mmp.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 9a771de7..cb968adf 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -296,6 +296,13 @@ errcode_t ext2fs_mmp_start(ext2_filsys fs)
 	if (mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
 		mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
 
+	/*
+	 * If check_interval in MMP block is larger, use that instead of
+	 * check_interval from the superblock.
+	 */
+	if (mmp_s->mmp_check_interval > mmp_check_interval)
+		mmp_check_interval = mmp_s->mmp_check_interval;
+
 	seq = mmp_s->mmp_seq;
 	if (seq == EXT4_MMP_SEQ_CLEAN)
 		goto clean_seq;
@@ -309,13 +316,6 @@ errcode_t ext2fs_mmp_start(ext2_filsys fs)
 		goto mmp_error;
 	}
 
-	/*
-	 * If check_interval in MMP block is larger, use that instead of
-	 * check_interval from the superblock.
-	 */
-	if (mmp_s->mmp_check_interval > mmp_check_interval)
-		mmp_check_interval = mmp_s->mmp_check_interval;
-
 	sleep(2 * mmp_check_interval + 1);
 
 	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
@@ -344,7 +344,10 @@ clean_seq:
 	if (retval)
 		goto mmp_error;
 
-	sleep(2 * mmp_check_interval + 1);
+	/* This sleep between write & read must be shorter than the previous
+	 * sleep between 2 reads, so that the check above of a racing thread
+	 * would never succeed between this write & read. */
+	sleep(mmp_check_interval + 1);
 
 	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
 	if (retval)
-- 
2.14.3 (Apple Git-98)




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux