[RFC PATCH v3 59/61] e2fsck: update mmp block race

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

 



From: Wang Shilong <wshilong@xxxxxxx>

Update mmp block is only expected in one thread, @mmp_update_thread
is used to get/set active thread number, however this should
be set globally shared with different threads rather than be private
per thread.

Signed-off-by: Wang Shilong <wshilong@xxxxxxx>
Signed-off-by: Saranya Muruganandam <saranyamohan@xxxxxxxxxx>
---
 e2fsck/pass1.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 8d4e2675..a51fe20f 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1501,6 +1501,7 @@ void e2fsck_pass1_run(e2fsck_t ctx)
 	struct ea_quota	ea_ibody_quota;
 	struct process_inode_block *inodes_to_process;
 	int		process_inode_count, check_mmp;
+	e2fsck_t	global_ctx = ctx->global_ctx ? ctx->global_ctx : ctx;
 
 	init_resource_track(&rtrack, ctx->fs->io);
 	clear_problem_context(&pctx);
@@ -1652,14 +1653,11 @@ void e2fsck_pass1_run(e2fsck_t ctx)
 		check_mmp = 0;
 		e2fsck_pass1_check_lock(ctx);
 #ifdef	CONFIG_PFSCK
-		if (!ctx->mmp_update_thread) {
+		if (!global_ctx->mmp_update_thread) {
 			e2fsck_pass1_block_map_w_lock(ctx);
-			if (!ctx->mmp_update_thread) {
-				if (ctx->global_ctx)
-					ctx->mmp_update_thread =
-						ctx->thread_info.et_thread_index + 1;
-				else
-					ctx->mmp_update_thread = 1;
+			if (!global_ctx->mmp_update_thread) {
+				global_ctx->mmp_update_thread =
+					ctx->thread_info.et_thread_index + 1;
 				check_mmp = 1;
 			}
 			e2fsck_pass1_block_map_w_unlock(ctx);
@@ -1667,8 +1665,8 @@ void e2fsck_pass1_run(e2fsck_t ctx)
 
 		/* only one active thread could update mmp block. */
 		e2fsck_pass1_block_map_r_lock(ctx);
-		if (!ctx->global_ctx || ctx->mmp_update_thread ==
-			(ctx->thread_info.et_thread_index + 1))
+		if (global_ctx->mmp_update_thread ==
+		    ctx->thread_info.et_thread_index + 1)
 			check_mmp = 1;
 		e2fsck_pass1_block_map_r_unlock(ctx);
 #else
@@ -2396,8 +2394,8 @@ endit:
 #ifdef	CONFIG_PFSCK
 	/* reset update_thread after this thread exit */
 	e2fsck_pass1_block_map_w_lock(ctx);
-	if (ctx->mmp_update_thread)
-		ctx->mmp_update_thread = 0;
+	if (check_mmp)
+		global_ctx->mmp_update_thread = 0;
 	e2fsck_pass1_block_map_w_unlock(ctx);
 #endif
 }
-- 
2.29.2.299.gdc1121823c-goog




[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