Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5361798rdb; Wed, 13 Dec 2023 06:43:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQwhRsTz2UzUyyR4z2Fa9fkAUyRn341JZ1EiuZ978SyxK8r9l43sYDZfB7zgvUpLXk+lJe X-Received: by 2002:a05:6e02:158c:b0:35f:575f:9f9c with SMTP id m12-20020a056e02158c00b0035f575f9f9cmr4559429ilu.110.1702478637689; Wed, 13 Dec 2023 06:43:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702478637; cv=none; d=google.com; s=arc-20160816; b=giiaAgRWauNXZVIDdQ3+9r0ztlVX04siB9bX16elm1aQZWr6qzXJwreJbJjHTlKWJI mzuF8iPiAzqcX5gFeyP9HH/Bv0JHMAWc1lu0cFeRWZEg/JBF8c7M+7BzZqjah4OsxG9Y nhDwxwBNVxhdg2pQ7Pbfj4uXJjTMavclZ1LZU5evRdHJmdqn9iV3hNqw3l5kU9CnimHT 6AS+AY5jzguIBflz/JF8CkNYargVYdV1HxNkTVySbjq+mg14/H7CmNPrOV1KyEIA8ji2 EgFTXDU2CGKQ8Nct+98zPzV1ou68rD/FETyodrsQ/ir4NLd3Mjn28yMcGtOkKKYKbZO/ QWTw== 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=5X/YXOPnsh3MUkHJu+m9TVkOt4yOKa0FHQYFxRSX268=; fh=RkzPy8j9Bgyvxc5aNhoOEUjthII6WQwvTfVAiEIVvUg=; b=zMQvA9n5u/mhauZ6jPurnacBzJXfSGy5o0j9BEPF/q89rK8sRlvZ4p5Ai4uYCDr+N+ gOrX6mVXkRu68VcKZPXctN2lgzgQCQGP1dxKXT0CBXOA1hH+bONWH0MxKBMi5Fmvh06Y CFdvsctCYAPqbAmw3oKmblR7OWZHVnG0ZCZd4CV+jsk8rKrPzTZgv0MTGcqGtkM/PgkT u1jMquk/zU6LRYQRs7YF1BQZOw326S9DisrwcXRhCnq2TcTGRXJwz6ejIwGO6FRkNNw9 /PqxHr1fx26UV1aBF6fOhogax2k+8/Yw0WEYYnSFWJm/EfZoCV9i1ZaXjgNJMvu9jhg7 BcOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rsq3ow2e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id t12-20020a6564cc000000b005c66b15ec25si9261183pgv.824.2023.12.13.06.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:43:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rsq3ow2e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 21A08826E32B; Wed, 13 Dec 2023 06:43:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441973AbjLMOng (ORCPT + 99 others); Wed, 13 Dec 2023 09:43:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378944AbjLMOnN (ORCPT ); Wed, 13 Dec 2023 09:43:13 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4D95DD; Wed, 13 Dec 2023 06:43:19 -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=1702478599; x=1734014599; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=qN9uFU57GBna2r1afgLudejpCt6oeNpZ8RYEEAbqQXg=; b=rsq3ow2eWmjEgFeyR0jpq8WGVr3aVBbipVvjQfs8g+QM/jxxDkmNYsun dchscET/rroFcnDmjXZ3CnM4PpCkoGtbe/zc327lsmXszDShDt0F+NY87 rUMQWE75TNobHNp5N3R+O9jnCvOkBk7EiMM2/zDOesmFFhtr57vqPnvbY Saz6MPtaL5uEAsMAsH3Sap6UTrsBjpOBAP1PMPzCewoVsNXPDIur8u4jU aN+2JEmbXxoy2fQRU5iaIQx4+PhacXxIIK74rqZf4oGzmvgB/EiYvdFYS wH9hLOQulVExhrQuKs53KDKuYaofX7ADa2iZBFXYrbbyBNgNo4sN9aBbD w==; X-CSE-ConnectionGUID: FSnTn6JcTaaJEa7Na8rxyg== X-CSE-MsgGUID: LInRM9QtT9iKNuNtPYzxhQ== X-IronPort-AV: E=Sophos;i="6.04,272,1695657600"; d="scan'208";a="4580759" 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:18 +0800 IronPort-SDR: lyt6xR+vykByqf1jWQA8GMQ/ft12tNXRgi7Z25mb2GJxiDgjA8doJhOOYCg+DgKQaPcQEHb3Ub TmQl6n7JXF2w== 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:30 -0800 IronPort-SDR: J2ayBnMfsZEDf/vIc07aK+WYzQeCZ/WpAJqHvaNHjQ2NotY1+NOxfWGl/LoOA44EUhCMHF8yW/ EwbcbU+id01g== 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:17 -0800 From: Johannes Thumshirn Date: Wed, 13 Dec 2023 06:43:04 -0800 Subject: [PATCH v2 09/13] btrfs: factor out block mapping for single profiles MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231213-btrfs_map_block-cleanup-v2-9-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=1479; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=qN9uFU57GBna2r1afgLudejpCt6oeNpZ8RYEEAbqQXg=; b=GNdQPNmiHfgl1oXaJa/IVRS0l3ajkT51NLCGozaz/MHqjMXwZZ1CW6t4MH4Jx3fi4CkpD97Ym g4JV3WNQke0Ce8JBP4/pBhcFu5cxQp3j3hu7Trc+B1uQk/QkogCGigQ 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 06:43:53 -0800 (PST) Now that we have a container for the I/O geometry that has all the needed information for the block mappings of SINGLE profiles, factor out a helper calculating this information. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 55614a9eb8a5..e23c7d2842a6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6487,6 +6487,14 @@ static void map_blocks_raid56_read(struct btrfs_chunk_map *map, io_geom->mirror_num = 1; } +static void map_blocks_single(struct btrfs_chunk_map *map, + struct btrfs_io_geometry *io_geom) +{ + io_geom->stripe_index = io_geom->stripe_nr % map->num_stripes; + io_geom->stripe_nr /= map->num_stripes; + io_geom->mirror_num = io_geom->stripe_index + 1; +} + /* * Map one logical range to one or more physical ranges. * @@ -6591,9 +6599,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, * device we have to walk to find the data, and stripe_index is * the number of our device in the stripe array */ - io_geom.stripe_index = io_geom.stripe_nr % map->num_stripes; - io_geom.stripe_nr /= map->num_stripes; - io_geom.mirror_num = io_geom.stripe_index + 1; + map_blocks_single(map, &io_geom); } if (io_geom.stripe_index >= map->num_stripes) { btrfs_crit(fs_info, -- 2.43.0