Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4607073rdb; Tue, 12 Dec 2023 04:39:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGN6XjWjOwZAi2ZSdtng/cxk9Zs7KSo3vJQCXYh8YnMbTsf5NHu/Q2oJdl5qeJjf1UlEr1k X-Received: by 2002:a05:6a20:7344:b0:18b:d31d:c460 with SMTP id v4-20020a056a20734400b0018bd31dc460mr3388479pzc.2.1702384774422; Tue, 12 Dec 2023 04:39:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702384774; cv=none; d=google.com; s=arc-20160816; b=Rgct0LD5MkR7JlPIV2AIxF4Ezdp+MF95HX+M7TYHYUiYCyY4mcZRVmNBrdq6Erb7Nu DG0eb0khCmUMygM46r33lpvtjWxaJ8ldM49fROn3VtNxJ7hS1SvXu33Wph9F4aUizMa/ DKJ4MKekOQHb8kuzziRmifGstlmfj/z4J5IstJcVF0OqACca/+IjynVbXFCXDmPpk9ru nU9SM29e2n5YMRMGqoN+t2MfDQhOtLYuzjYW7MnW9+ry4V44kFB8RzMSjMRtRT/snfU0 0kNg4TfLQqKBYdP+3vPT+ht79QJ6ySgmEdBYBdR+yYcP986pZ/pPoy2RiEVrIS+qZPPx q0JA== 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=qHecm+dxvI2XKllHe8WDRDBv4BcI4iAido1K2H4VKao=; fh=RkzPy8j9Bgyvxc5aNhoOEUjthII6WQwvTfVAiEIVvUg=; b=OUcwqc8/KN7G8KQ6oeSP945gcUaYvuh//vqQy3MD9u3LfvUo2Q/LERXU/nm+JzMsyq 9zkttWuoWUPQdwFStQkIr/1tKDcEv3BrfsDM44L7t1Hhw40xKBq6EORrpcI0Mky48POg VedgUfcFghoTFy5f4Ne5oCrlLjCQDIAZ/6SeASyzVCwkZWdC7iB3cekxsfadP9RW5atc cX1ta6HMJIhvvmWwJn5eL3XIvUZa7CsiGVcyPAvq4KxRMTCG/F9h9HybHOH2+V2kDcD1 yKaeAFKgWRvgyfpgvjrgp3PE5MX2F5EBDbcdx+vOJteqgAaY/nC1hznwGXGgwX+XJTDd /S3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=f6E0fY25; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e4-20020a17090a728400b002869c7e8d4fsi7837834pjg.1.2023.12.12.04.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 04:39:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=f6E0fY25; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 64DBE804C492; Tue, 12 Dec 2023 04:39:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346742AbjLLMjP (ORCPT + 99 others); Tue, 12 Dec 2023 07:39:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346689AbjLLMim (ORCPT ); Tue, 12 Dec 2023 07:38:42 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB83D41; Tue, 12 Dec 2023 04:38:39 -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=1702384719; x=1733920719; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=1sx5hgMgPsSIl/PcKUCTomxYnHRlrjaft92+/rRZzms=; b=f6E0fY25hsnP2yga+ylQzbCqK/UR6X2Xsb0mnfiiCBSuo97fbGxhQ87+ OxguKuR5afnkNYdo9wXe5VMqSGECNIKNvtFuSpENv37EYncU1MPgvorU5 1YWmGEaQ9/tNH4wSES01LO10XzVtvUp6s0PKq4oy+fBYx+WoArG0RUGar AMJSncZXtvxRX6oOmh6MNVA+MU9PZXn5875GZimBZp6oQB2CCud/vWZ6b Wp0dTRAx4jYevY8OIIrGj/tJFCO3iulRJgfLW+2ltcwrJHpXej+nvbU3j 6SV51u1qLu6P+HhUyGngrJ4Ctmo164++FA1Syf7oEgMCV0w37ab+av9/V A==; X-CSE-ConnectionGUID: /qRWF+KnSwCFVKLRZIxa8g== X-CSE-MsgGUID: bH/lDlXUSBm7uax+SJcjLQ== X-IronPort-AV: E=Sophos;i="6.04,270,1695657600"; d="scan'208";a="4629812" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 12 Dec 2023 20:38:31 +0800 IronPort-SDR: Zcu8iEFG+rshvP99Jva+7UOWTUW2pfp3Tjhvk9MgZC+WdDKXeOGdqFS1djHiDpDwiJQSzODyVu aPiWG1WmSbWw== 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; 12 Dec 2023 03:43:44 -0800 IronPort-SDR: IF2uB1LFDxBsYDMIIthw1UW5SVEX6aIqG9iwKBTbl9ammZcgmjnlKLZ89KLkv9sYvZI4S8eqmc gmn75I9LcGRw== WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 12 Dec 2023 04:38:30 -0800 From: Johannes Thumshirn Date: Tue, 12 Dec 2023 04:38:11 -0800 Subject: [PATCH 13/13] btrfs: pass btrfs_io_geometry into btrfs_max_io_len MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231212-btrfs_map_block-cleanup-v1-13-b2d954d9a55b@wdc.com> References: <20231212-btrfs_map_block-cleanup-v1-0-b2d954d9a55b@wdc.com> In-Reply-To: <20231212-btrfs_map_block-cleanup-v1-0-b2d954d9a55b@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=1702384691; l=3139; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=1sx5hgMgPsSIl/PcKUCTomxYnHRlrjaft92+/rRZzms=; b=98BGK4uRkR7z1XT2ETsJTcnrBi4ui/+ejviC/yhcIxHKydQ9dXB3nF8e80OyU079RRKSHXrc2 Id1MqTJEVTND+oxJjoxLazKkYbIjiFrraK+hyESN0v8aoNUkknEiHC+ 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 12 Dec 2023 04:39:31 -0800 (PST) Instead of passing three individual members of 'struct btrfs_io_geometry' into btrfs_max_io_len(), pass a pointer to btrfs_io_geometry. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c1fefe34a194..166750d279ee 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6277,16 +6277,15 @@ static void handle_ops_on_dev_replace(enum btrfs_map_op op, } static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op, - u64 offset, u32 *stripe_nr, u64 *stripe_offset, - u64 *full_stripe_start) + u64 offset, struct btrfs_io_geometry *io_geom) { /* * Stripe_nr is the stripe where this block falls. stripe_offset is * the offset of this block in its stripe. */ - *stripe_offset = offset & BTRFS_STRIPE_LEN_MASK; - *stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT; - ASSERT(*stripe_offset < U32_MAX); + io_geom->stripe_offset = offset & BTRFS_STRIPE_LEN_MASK; + io_geom->stripe_nr = offset >> BTRFS_STRIPE_LEN_SHIFT; + ASSERT(io_geom->stripe_offset < U32_MAX); if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { unsigned long full_stripe_len = @@ -6301,18 +6300,19 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op, * to go rounddown(), not round_down(), as nr_data_stripes is * not ensured to be power of 2. */ - *full_stripe_start = - btrfs_stripe_nr_to_offset( - rounddown(*stripe_nr, nr_data_stripes(map))); + io_geom->raid56_full_stripe_start = btrfs_stripe_nr_to_offset( + rounddown(io_geom->stripe_nr, nr_data_stripes(map))); - ASSERT(*full_stripe_start + full_stripe_len > offset); - ASSERT(*full_stripe_start <= offset); + ASSERT(io_geom->raid56_full_stripe_start + full_stripe_len > + offset); + ASSERT(io_geom->raid56_full_stripe_start <= offset); /* * For writes to RAID56, allow to write a full stripe set, but * no straddling of stripe sets. */ if (op == BTRFS_MAP_WRITE) - return full_stripe_len - (offset - *full_stripe_start); + return full_stripe_len - + (offset - io_geom->raid56_full_stripe_start); } /* @@ -6320,7 +6320,7 @@ static u64 btrfs_max_io_len(struct btrfs_chunk_map *map, enum btrfs_map_op op, * a single disk). */ if (map->type & BTRFS_BLOCK_GROUP_STRIPE_MASK) - return BTRFS_STRIPE_LEN - *stripe_offset; + return BTRFS_STRIPE_LEN - io_geom->stripe_offset; return U64_MAX; } @@ -6559,9 +6559,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, map_offset = logical - map->start; io_geom.raid56_full_stripe_start = (u64)-1; - max_len = btrfs_max_io_len(map, op, map_offset, &io_geom.stripe_nr, - &io_geom.stripe_offset, - &io_geom.raid56_full_stripe_start); + max_len = btrfs_max_io_len(map, op, map_offset, &io_geom); *length = min_t(u64, map->chunk_len - map_offset, max_len); down_read(&dev_replace->rwsem); -- 2.43.0