From patchwork Wed Dec 13 14:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 178057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7824732dys; Wed, 13 Dec 2023 06:44:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbyjVaI2DO+FIXsIuEb867ok93PRe+yWaL+LQM6tFjCmB4OoDKwlOiup/CqimaA24IQZcM X-Received: by 2002:a17:902:ce8b:b0:1cf:fe32:632f with SMTP id f11-20020a170902ce8b00b001cffe32632fmr5288366plg.22.1702478641992; Wed, 13 Dec 2023 06:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702478641; cv=none; d=google.com; s=arc-20160816; b=fLl4lx09EG2yr1eNTjv0G4cTNzu00PJuBXMrNeGytBeSTx44ei9eJRwd+XvJGHfFSF LJlBbhNfnKWV440uNWQwBSvnrJ8eMVStOROcYlN2UWlvMbyxuMYg95PPeJzE1UoJL0AH dFedd9eI6vBC1H5/R3FXCm5PWksdb+imaKjVQwQNXbC9qvW3hh0VWr+kyAZhJxOIWBP2 991xpUXHaaEuL+rCCUcQY9L7Azn3sYs8bqbyPCxfZy9bdHzgyt24x79h9b1kSRlRSw2o E+MEyX2yF2ZiCtHU7C4OMcEAZot/ceisPnKAsjZrggb+BRLJb4BGtum2uNmy3WEASV5K GOuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=kJZBh/wzjpPt/HNhraCV9wYL/76mD0b5QzNqkE4RARU=; fh=RkzPy8j9Bgyvxc5aNhoOEUjthII6WQwvTfVAiEIVvUg=; b=VWUvriYIAHDjln+x1wjUfI0T3kHpbetQ4xBD8lCZxjvpRly9B3LscmkH7tuCjNjAdL nz8eEWHbFZixeQhQy1luCM9vHFwkA0vxS6x+W2ayQHgyDAceJQvb2Dc4UAHvHWPWCkqy +u5w2qlUNa7Tpr4qO0DmKM0b3r8gIYhIOkn2TCZxqVGEGNwwd5cZXzyVpfW945XlVlZn 10p67Shtesr65TR+apm4L3Y2DiHgJqY689y6Fji8XmP9AeJguYRrQ8t3zGlgvuDU5+5k ZFPj9P0u1RkGRJvxTCcF4X3VbKmvlMBLJqFhMNfDG/fRbVnu/cNxXmCeN71pJ5Rr5lv4 JlDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=ZQLgZOZC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id jw15-20020a170903278f00b001ca96a6eefesi9598631plb.577.2023.12.13.06.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:44:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=ZQLgZOZC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8212380BB1FE; Wed, 13 Dec 2023 06:43:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441900AbjLMOn2 (ORCPT + 99 others); Wed, 13 Dec 2023 09:43:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbjLMOnL (ORCPT ); Wed, 13 Dec 2023 09:43:11 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4594E91; Wed, 13 Dec 2023 06:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1702478598; x=1734014598; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=sLjwrenKmqHBOSqsM1KRhm85HG8IZyehA4bXrtvn4bM=; b=ZQLgZOZC275uLopqeMKgSMzkrMY8CtaqDrt3RU1a9H5cio0PV4VMXVrL H+D8ulphFAWtdoyQ29FON/YxeY2BD9jIKW6MkqdLUwxuts82KOiQSbFv2 KDL2Y4eFuvgXrRZCq5Hw9+f8IPZElgOvD8THCjxVOQ3WS3TpyY8cSySkE vm+UqBtLVvKI3E04m2xN0DEk9jEf9yRgr49y5GwxPmAfCAkq4adpvOpOf SKT8TZap/7uPtN4aYiDpaEtdeIFLv2ezwqbC0L1DvEYEKyFbx5jUCpVYY XL1VqxJpcSbgpLtrJjOyZ7in/Lh65Koq4l3zKmtfDEB1HBTDYkiQd/GGK g==; X-CSE-ConnectionGUID: EkFSIohuSm+ooJQ9K/Wkgw== X-CSE-MsgGUID: jPewL/rvQvi5Xyl14Xds4Q== X-IronPort-AV: E=Sophos;i="6.04,272,1695657600"; d="scan'208";a="4802972" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 13 Dec 2023 22:43:17 +0800 IronPort-SDR: yIkfoK9NMfQ5amNWjB7XCr1Y8+sZR0QjjSpLWtWKGqqujb6rc7nsn96UO5sSk+eg/aXk0q3iTQ c9wfDbRYckTQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 13 Dec 2023 05:48:29 -0800 IronPort-SDR: jPwWC4S6kGyM8dieutpeuowuWyiIVgIWCh6TWacQP2GwV9yx/q44p3bdBdHoxkLOd8Fc1bUdHW jdCeE/DcoJsw== WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Dec 2023 06:43:15 -0800 From: Johannes Thumshirn Date: Wed, 13 Dec 2023 06:43:02 -0800 Subject: [PATCH v2 07/13] btrfs: reduce scope of data_stripes in btrfs_map_block MIME-Version: 1.0 Message-Id: <20231213-btrfs_map_block-cleanup-v2-7-cf5cfb9e2400@wdc.com> References: <20231213-btrfs_map_block-cleanup-v2-0-cf5cfb9e2400@wdc.com> In-Reply-To: <20231213-btrfs_map_block-cleanup-v2-0-cf5cfb9e2400@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702478586; l=1985; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=sLjwrenKmqHBOSqsM1KRhm85HG8IZyehA4bXrtvn4bM=; b=QCzPri8RzAPG0gQUjoB9ReI3jAolOkhuz/CxGWfC4Z32Nu4ABb2QM8e69FhqOPars7B46FJ2F 0S1GI3+M2PSD6ncphJIeR8ono5Xs/VBqXt7ixv/kwKsS2xRsAZC2ESr X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 06:43:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785178244436489900 X-GMAIL-MSGID: 1785178244436489900 Reduce the scope of 'data_stripes' in btrfs_map_block(). While the change allone doesn't make too much sense, it helps us factoring out a helper function for the block mapping of RAID56 I/O. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 4c9c130cdfd0..3a6a2f71d364 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6480,7 +6480,6 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, struct btrfs_chunk_map *map; struct btrfs_io_geometry io_geom = { }; u64 map_offset; - int data_stripes; int i; int ret = 0; int num_copies; @@ -6505,8 +6504,6 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, if (IS_ERR(map)) return PTR_ERR(map); - data_stripes = nr_data_stripes(map); - map_offset = logical - map->start; io_geom.raid56_full_stripe_start = (u64)-1; max_len = btrfs_max_io_len(map, io_geom.op, map_offset, &io_geom.stripe_nr, @@ -6534,6 +6531,8 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, map_blocks_raid10(fs_info, map, &io_geom, dev_replace_is_ongoing); } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { + int data_stripes = nr_data_stripes(map); + if (op != BTRFS_MAP_READ || io_geom.mirror_num > 1) { /* * Needs full stripe mapping. @@ -6645,7 +6644,8 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, * modulo, to reduce one modulo call. */ bioc->full_stripe_logical = map->start + - btrfs_stripe_nr_to_offset(io_geom.stripe_nr * data_stripes); + btrfs_stripe_nr_to_offset(io_geom.stripe_nr * + nr_data_stripes(map)); for (int i = 0; i < io_geom.num_stripes; i++) { ret = set_io_stripe(fs_info, op, logical, length, &bioc->stripes[i], map,