Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1660118rwb; Mon, 7 Nov 2022 04:26:52 -0800 (PST) X-Google-Smtp-Source: AMsMyM62jjNC/1R21k0dpNJEKqmruDYG6+za6gitd106vQc/Q8IbPSfwy+5sKdefB8VF2Y3TWb9t X-Received: by 2002:a17:906:eecb:b0:73c:5c85:142b with SMTP id wu11-20020a170906eecb00b0073c5c85142bmr48151566ejb.433.1667824011909; Mon, 07 Nov 2022 04:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667824011; cv=none; d=google.com; s=arc-20160816; b=GmbsVh4TDggEonZVQiWkmqAvNrOwPIL8aMLuBbL0ku7y+nRvP6IzX9NwsCYx8OTUzZ d3dza3oQgqBU4T1psepi9mtGBSGdPysoxSwPwgKsJX5z5vUOBWYLUOixW3yq1nx1Zg/z lNlvp+AlyfypbHQld8FoHQXAq0PVl+HbIvmsklkp+06Kz4vmxgPvChhhHzPGvKlprHsa gza0IIOI6hZ/v4U94XNb9PXCQCisbwSZu/61Zpp/xlrWnduP8OTDbtltCNdhSjav6pmM BVO6ITO1Ey7wFZno4mpp1m/xxyQWvSYPkqI4Pkg+4vUP63mwNn+R3aD1XDlwZaCwKxGC Vrbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=geMLgKNDbiQNg64oeoK/gVcmbGzDD8oHWu7l5dRAT/E=; b=Pa6WQOK9e57DB/W3nJ1nyOAu3UbpSW2ez/PqBvYUV3jlUOkd6fuz26viduWpCIFgl7 xMlweI7iAz2oU8KkZUlpFgRF2jNPD2EnsAL/ZhjnE4iPavonZONGCHO+6iov/OfBFYuv 0oNn+Axf08BKTeqCGtG/ZZEs/RF3sdfaYPUC0FC20yM0agllspTxw13TlAKvgaMng7Ad VOmhdpkQqtfFfuxNAMnarOvabePuA5SjwJTzL+sf8cqUMco4FlYbkVGodYBFwRrQdxMP 06WhCWQC2rVwD34KVj5YU08dWY+UnpreMEbXDPi41HI4xha1WniuMqSqVihA1kUsDkiz sFlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NNQILbdm; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a1709063b8200b007429f0c69ccsi7349727ejf.579.2022.11.07.04.26.28; Mon, 07 Nov 2022 04:26:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NNQILbdm; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232132AbiKGMZn (ORCPT + 99 others); Mon, 7 Nov 2022 07:25:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbiKGMZb (ORCPT ); Mon, 7 Nov 2022 07:25:31 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6390E1B7AA for ; Mon, 7 Nov 2022 04:25:29 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id s196so10319033pgs.3 for ; Mon, 07 Nov 2022 04:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=geMLgKNDbiQNg64oeoK/gVcmbGzDD8oHWu7l5dRAT/E=; b=NNQILbdmsGX5BuTvxqmvMfvJCElYOCI9m3KEDIMg3F2+HRoy3hBn5LFew4knl3XL2x yv19H/vg8JWTvrFnTe83cKhA6PoQoX+SktaP/jANF+OU9tQe5BaPrn+8Sj9k1Dg9EOm9 iKdsXG4zpxWIwHglWtQ8Qo6z30FqFXpMzq/4toDPoh67QnTxdDGz8o3vtUL+443ol7IN b+hnWBSBmNIwQuD0SC406/48xtmTHK9dRC3y5I9qv3URo21QLE/iQVpw4pL9oDWL81aC 90KDpCh4+g2+prisSYoArVj5FATXxYuD0K6BzXouZgHh3/nxPmRe7DJ9S6ezBST7Tnoc GU6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=geMLgKNDbiQNg64oeoK/gVcmbGzDD8oHWu7l5dRAT/E=; b=x2a3v3GAVzRbJiWDGMwLuclrPsNJbUu49axAVLj8RaBrZBEgddKw+ucWBG8R/XuOl7 alDAgPqmCCgztYCvoaMygFeiE8V22A52IoEj5Udt2Q5HwY+8m+6mwrSIjxVzSowqffH7 xpxb9uaQfPWOK5RMveQASteHWLmQSv6nFhyMDmQzS4B96nz6hCtz81kCd6njHM+jBpup 5GUMIEDlbY6dPKzqlM0Z8UYs8wFDKQbi14gkCrp0FkyUQbEBPWofqSUAQhIaQr/LoyIa QymPk+vChyecW3WAtGF6F39Tiuo4xX24ozqpYksNkB4jHCgfDDzbqprUvRQX/MSqFMS/ 7mGQ== X-Gm-Message-State: ACrzQf3tw3Z3VI4gyhigncL63NDDBCzIWp4YC8DAaKVzkKjK7pOL/zl8 AyK2Z9JTnhyDjyh0pnhPm2CUheuhRdI= X-Received: by 2002:a05:6a00:170d:b0:56e:55de:9858 with SMTP id h13-20020a056a00170d00b0056e55de9858mr22360715pfc.17.1667823928924; Mon, 07 Nov 2022 04:25:28 -0800 (PST) Received: from localhost ([2406:7400:63:f20b:312d:45b2:85c1:c486]) by smtp.gmail.com with ESMTPSA id i4-20020a056a00004400b0056164b52bd8sm4391441pfk.32.2022.11.07.04.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 04:25:28 -0800 (PST) From: "Ritesh Harjani (IBM)" To: Theodore Ts'o Cc: linux-ext4@vger.kernel.org, Harshad Shirwadkar , Wang Shilong , Andreas Dilger , Li Xi , Ritesh Harjani Subject: [RFCv1 30/72] e2fsck: split groups to different threads Date: Mon, 7 Nov 2022 17:51:18 +0530 Message-Id: <42bd4ff9929e4166ad5e7b2e36204c995521c9e4.1667822611.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Li Xi The start/end groups of a thread is calculated according to the thread number. But still, only one thread is used to check. Signed-off-by: Li Xi Signed-off-by: Wang Shilong Signed-off-by: Ritesh Harjani (IBM) --- e2fsck/pass1.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 3bb87669..3b411b70 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -2231,13 +2231,14 @@ static errcode_t e2fsck_open_channel_fs(ext2_filsys dest, e2fsck_t dest_context, } static errcode_t e2fsck_pass1_thread_prepare(e2fsck_t global_ctx, e2fsck_t *thread_ctx, - int thread_index) + int thread_index, int num_threads) { errcode_t retval; e2fsck_t thread_context; ext2_filsys thread_fs; ext2_filsys global_fs = global_ctx->fs; struct e2fsck_thread *tinfo; + dgrp_t average_group; assert(global_ctx->inode_used_map == NULL); assert(global_ctx->inode_dir_map == NULL); @@ -2276,11 +2277,20 @@ static errcode_t e2fsck_pass1_thread_prepare(e2fsck_t global_ctx, e2fsck_t *thre thread_context->thread_info.et_thread_index = thread_index; set_up_logging(thread_context); - assert(thread_index == 0); + /* + * Distribute work to multiple threads: + * Each thread work on fs->group_desc_count / nthread groups. + */ tinfo = &thread_context->thread_info; - tinfo->et_group_start = 0; - tinfo->et_group_next = 0; - tinfo->et_group_end = thread_fs->group_desc_count; + average_group = thread_fs->group_desc_count / num_threads; + if (average_group == 0) + average_group = 1; + tinfo->et_group_start = average_group * thread_index; + if (thread_index == num_threads - 1) + tinfo->et_group_end = thread_fs->group_desc_count; + else + tinfo->et_group_end = average_group * (thread_index + 1); + tinfo->et_group_next = tinfo->et_group_start; *thread_ctx = thread_context; return 0; @@ -2523,7 +2533,8 @@ static int e2fsck_pass1_threads_start(struct e2fsck_thread_info **pinfo, for (i = 0; i < num_threads; i++) { tmp_pinfo = &infos[i]; tmp_pinfo->eti_thread_index = i; - retval = e2fsck_pass1_thread_prepare(global_ctx, &thread_ctx, i); + retval = e2fsck_pass1_thread_prepare(global_ctx, &thread_ctx, + i, num_threads); if (retval) { com_err(global_ctx->program_name, retval, _("while preparing pass1 thread\n")); -- 2.37.3