Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp415030pxb; Wed, 18 Nov 2020 07:44:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/Hn/Ltdq1cGHHSZwBdkHK1QsgjkIqczFihpzDMa5q1Ctdwz6/IxBGJnfeX+BRgZEqmUaJ X-Received: by 2002:a17:906:2742:: with SMTP id a2mr23617664ejd.219.1605714252171; Wed, 18 Nov 2020 07:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605714252; cv=none; d=google.com; s=arc-20160816; b=u6zJgdTrI7IOr7ch1GMBRvNDUPK/j7GQLB2s2x76xYjgyZt6p9hgIO6o3kzLSe302Y ttr5hSzIrCJ3QiGso1qYvsjuKC0tk/oX+ePGpbfUBvIk7IIHpP9bP52dK1mCtW+epbPA 1i6StfZ9fm6lw2k5BaDufVbuIwaw3o8oGci5AHH4D0Vlo1S9sRVS3p3cZVTG4luhl58Y r3nDO/NZukObfxcG9FSs6mZwLugCvGiuUq8kpq6TO7YuHBB8cqRFircG6+Bhs/uouXPA vyTi2Qen4CHofKcvivzHFT/MJYkv0sruqn9AuVvyv2TYeel1gL7zzAB0EZOQKGpe3z13 w1vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=GjJeR3HmrSAYgbKKIohYNzytTHCLPFhyiKxa4ICxu0I=; b=GAEWtJ2nT6Gwn9aFWqDGjW5c52PUzdJe5ebKgucc1ZPbKrluRS5wsibsyLeubs6o6q 8GOnZW3P4coglkkiBjDYu/MFVx1DpxfDlGWVGTgllJiI7aJMSS/mJAMfQNe40nDAtklR 4ylqhpGDHZWVwaUuq/sYYOK/g3nuKrs68D9U27xEBNW35AB4fTha9T2GdFcLwgScyeLP orsgUidG9KWtibtSJ/OZ9GFKFEW8swcAG/NYo8PI7KmKJOJpgeaG5TLhqGaoD21EGyuj 1gMYtsCv9XdaxV3bZGTkP72G9DRwXJk4AGJew8WEPC0caQRdaQV3cyH3FGdvJOB1786t fDAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FHWYN3OW; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si18365900ejb.290.2020.11.18.07.43.48; Wed, 18 Nov 2020 07:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FHWYN3OW; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbgKRPl4 (ORCPT + 99 others); Wed, 18 Nov 2020 10:41:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbgKRPly (ORCPT ); Wed, 18 Nov 2020 10:41:54 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBDC1C0613D4 for ; Wed, 18 Nov 2020 07:41:54 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id i6so1514951pgg.10 for ; Wed, 18 Nov 2020 07:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=GjJeR3HmrSAYgbKKIohYNzytTHCLPFhyiKxa4ICxu0I=; b=FHWYN3OWgUJiszB8swLc52iCR910jAwz6e23BtVOWyZdVt9Qe++6yMOlUkzDepEz7X TJ9GaUm6pkaKLgozHBJhlhVhJ3mmxIcSUfoKrq/LC7f3AWT9rcxOoelaJ3Yfn+jyDrO3 1Jh7UrOev9o6HRr5/N8kst/I5TCHywlDq8CmHANJMTf5egkN3sShG6BIlnChqr/EkoNJ C8GB7eEq/Pt8/cMO/gYGqXt7lpOFtFY3tDfUdJSIDOuOf9ITHmQ1ZRteav/CGl46Y1oA 1pHpyrD+6oliOsWbixPKe+/uj2g7lctdskwGGPLKlyjPWJeoh5UrfldGkWzSpS2fhRDu s65A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=GjJeR3HmrSAYgbKKIohYNzytTHCLPFhyiKxa4ICxu0I=; b=VnkURGYIB0dp6I3avHfhrk/Isd0anIC+4kZFmqqqNVNY8WQqLfjvfDgm7LLCDx/chA s1dN0fzWTNpM5LNGgo6VnzuE81979HRmtXwZ5/cL7YQutvEX5vtyobEdU1CcQgwPqPYs BtvjyK0WCYIdOdOTDV1DZ5zwnVC3aKpfIFzw1T3mLsu7jeIuu2JfMyauVITqc7cgiDHJ 9g8rBv6onKqiWRgQ56i5ECv3ktcA8LN9vP5z5q3AKyM+8hsA27IkQCWbcaVTzS5OpGlP 5FdRfKbAHP9q9IunfppJL7NJoX6er4XEYax/yETpYSmoS06jo9xeAZR8scG/tT5GGF8x CA7Q== X-Gm-Message-State: AOAM533V6lvYQpS7ZvE5CPSCHfYXa/DrfaPbAeaTr7A2pdfnOI9N50ts XAKQLY1fYjiDpTdOgaWfPnemqpomAYKxUhLEBxSkQ7hkfvPebN6ZIVjNhbo6S81IyNN5L8ycxCR TgKjrUl5WgAMvo7cKf1aj3/zlbmeFsijOE+YbNmy+yvA2TCRY9Cp1ZyqjAS4P5udpdz2xNCwOFW yq9lmda7U= Sender: "saranyamohan via sendgmr" X-Received: from saranyamohan.svl.corp.google.com ([100.116.76.178]) (user=saranyamohan job=sendgmr) by 2002:a17:90b:e04:: with SMTP id ge4mr46486pjb.0.1605714113740; Wed, 18 Nov 2020 07:41:53 -0800 (PST) Date: Wed, 18 Nov 2020 07:39:33 -0800 In-Reply-To: <20201118153947.3394530-1-saranyamohan@google.com> Message-Id: <20201118153947.3394530-48-saranyamohan@google.com> Mime-Version: 1.0 References: <20201118153947.3394530-1-saranyamohan@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [RFC PATCH v3 47/61] e2fsck: update mmp block in one thread From: Saranya Muruganandam To: linux-ext4@vger.kernel.org, tytso@mit.edu Cc: adilger.kernel@dilger.ca, Wang Shilong , Saranya Muruganandam Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Wang Shilong For multiple threads, different threads will try to update mmp block at the same time, only allow one thread to update it. Signed-off-by: Wang Shilong Signed-off-by: Saranya Muruganandam --- e2fsck/e2fsck.h | 1 + e2fsck/pass1.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index a66772c1..1469c3e1 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -451,6 +451,7 @@ struct e2fsck_struct { char *undo_file; #ifdef CONFIG_PFSCK __u32 fs_num_threads; + __u32 mmp_update_thread; int fs_need_locking; /* serialize fix operation for multiple threads */ pthread_rwlock_t fs_fix_rwlock; diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 60f70111..e98cda9f 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1497,7 +1497,7 @@ void e2fsck_pass1_run(e2fsck_t ctx) dgrp_t ra_group = 0; struct ea_quota ea_ibody_quota; struct process_inode_block *inodes_to_process; - int process_inode_count; + int process_inode_count, check_mmp; init_resource_track(&rtrack, ctx->fs->io); clear_problem_context(&pctx); @@ -1646,8 +1646,33 @@ void e2fsck_pass1_run(e2fsck_t ctx) #endif while (1) { + check_mmp = 0; e2fsck_pass1_check_lock(ctx); - if (ino % (fs->super->s_inodes_per_group * 4) == 1) { +#ifdef CONFIG_PFSCK + if (!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; + check_mmp = 1; + } + e2fsck_pass1_block_map_w_unlock(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)) + check_mmp = 1; + e2fsck_pass1_block_map_r_unlock(ctx); +#else + check_mmp = 1; +#endif + + if (check_mmp && (ino % (fs->super->s_inodes_per_group * 4) == 1)) { if (e2fsck_mmp_update(fs)) fatal_error(ctx, 0); } @@ -2365,6 +2390,13 @@ endit: print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io); else ctx->invalid_bitmaps++; +#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; + e2fsck_pass1_block_map_w_unlock(ctx); +#endif } #ifdef CONFIG_PFSCK -- 2.29.2.299.gdc1121823c-goog