Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5182353rdb; Wed, 13 Dec 2023 00:58:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4EKYnVT+nwGLIk5hOzIoEXCT1Qr7eAyQkyitJditNbZyrsYu6ZbC5KTbIbv0q324dr6mZ X-Received: by 2002:a05:6830:314e:b0:6da:9f4:b8ae with SMTP id c14-20020a056830314e00b006da09f4b8aemr7817822ots.56.1702457932433; Wed, 13 Dec 2023 00:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702457932; cv=none; d=google.com; s=arc-20160816; b=MQBbtmpw2gGhiZz87jbZ4KIY27zkb8fo9EZdvHP6USCy4bfryWzBND6hs63PqqbyVa 8asA0+4tVGCxZSeIICZW2lbgYldVL5BAbHncpWnT5qgpCr8NMghTSS/u3GDxGeurZVat A2kHf0Jwqf0rpEheKarRr6VMWGlECNhvYrFM2i4AgGi2ufk0C+fd42osvOZJ8gbT/NbK v/YtQpkIH/yrYNOGL/jFz7kIVZkFw2aP1ZAvtnJ83qCfWcf3kVhAvk5jTRp9MgK3QGHM iOZBOILZtnA0fYSwtS1d2VCjWzimMlYxomOTuYfhPvGvw1uda+wLWVOb2zhQ2+knYOHx SM6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KOXFx/9HdBZDWCya+V7EM00JHK64SSnJ0Yck8gKE+VY=; fh=xaAShxbj3efqtEWl5ZkjHsBp46G7+aOmrqQwTETNik0=; b=kY91EJ2IsuSSg5+3Lp5kByrh2x3NDq3tBgVf+T579VLmcj/vgLgVNjiwYqv2APMB5T MfnL9VsaOXpJXnUx2uv2CfL8BJTmG5GWt8CF1aNLUDzAO/UBAw+3+XTYQcN1BHpzMymH NE6JV7gko+6AKfHz56fbarhlbi6iV/omIDgEk/cAa4wYWt3ITjMqaaXR6Yn4eyNMfry/ HF5mD/xIc/6Jd05lAve+zHFaBWGVdHTovP4xgRVvAlZqdeLcnllK7U6+Xo4DTtOPpqiQ dmLMw6K+u8RsfKviuKmm9x+feKYBAzF5ZfXqFC9W9usMQD8mZVcBrloEGMlw2kSvLej2 6wJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=B+v7+9tI; 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 Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j3-20020a056a00130300b006ce70be4c40si9218028pfu.349.2023.12.13.00.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 00:58:52 -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=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=B+v7+9tI; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EE7FA81CB0E8; Wed, 13 Dec 2023 00:58:49 -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 S230404AbjLMI6e (ORCPT + 99 others); Wed, 13 Dec 2023 03:58:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjLMI6d (ORCPT ); Wed, 13 Dec 2023 03:58:33 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BCBDAC; Wed, 13 Dec 2023 00:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KOXFx/9HdBZDWCya+V7EM00JHK64SSnJ0Yck8gKE+VY=; b=B+v7+9tI8rI6SJOeeIOWu5vk/d fb1bmNF1PqnTch/mw+kob+ok/BfNqq3gRQJ+wIuFiNq1rxRP+eWuP/cB+x88Q0tGliGIyt5ewjoBe LavDbnHNgM+qGVd5eF9/vKTL9GdlIJj96qRsGsxfI9miaauAHjfTGPGRT3LnB1jHD6AMa7gN88Gco 0g503PydASF7X2oac+/HV+popb2v5kB4aPy2HKB0ZWQw/qyHk004SdQP9kQbfh74DPD2fpyXQ/jcP IMVJQVUr6+A/z4LT+hzSeFmvO/Zej0nCSnT1p9Q0jOpiWlgQNppbihtAPr+KdaMqpC/oyn3ImR/MJ Bj68k7pw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1rDL4g-00E5ub-0v; Wed, 13 Dec 2023 08:58:38 +0000 Date: Wed, 13 Dec 2023 00:58:38 -0800 From: Christoph Hellwig To: Johannes Thumshirn Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/13] btrfs: open code set_io_stripe for RAID56 Message-ID: References: <20231212-btrfs_map_block-cleanup-v1-0-b2d954d9a55b@wdc.com> <20231212-btrfs_map_block-cleanup-v1-11-b2d954d9a55b@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212-btrfs_map_block-cleanup-v1-11-b2d954d9a55b@wdc.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 00:58:50 -0800 (PST) On Tue, Dec 12, 2023 at 04:38:09AM -0800, Johannes Thumshirn wrote: > Open code set_io_stripe() for RAID56, as it a) uses a different method to > calculate the stripe_index and b) doesn't need to go through raid-stripe-tree > mapping code. Looks good: Reviewed-by: Christoph Hellwig I think raid stripe tree handling also really should move out of set_io_stripe. Below is the latest I have, although it probably won't apply to your tree: --- From ac208da48d7f9d11eef8a01ac0c6fbf9681665b5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 22 Jun 2023 05:53:13 +0200 Subject: btrfs: move raid-stripe-tree handling out of set_io_stripe set_io_stripe gets a little too complicated with the raid-stripe-tree handling. Move it out into the only callers that actually needs it. The only reads with more than a single stripe is the parity raid recovery case thast will need very special handling anyway once implemented. Signed-off-by: Christoph Hellwig --- fs/btrfs/volumes.c | 61 ++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 30ee5d1670d034..e32eefa242b0a4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6233,22 +6233,12 @@ static u64 btrfs_max_io_len(struct map_lookup *map, enum btrfs_map_op op, return U64_MAX; } -static int set_io_stripe(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, - u64 logical, u64 *length, struct btrfs_io_stripe *dst, - struct map_lookup *map, u32 stripe_index, - u64 stripe_offset, u64 stripe_nr) +static void set_io_stripe(struct btrfs_io_stripe *dst, const struct map_lookup *map, + u32 stripe_index, u64 stripe_offset, u32 stripe_nr) { dst->dev = map->stripes[stripe_index].dev; - - if (op == BTRFS_MAP_READ && - btrfs_use_raid_stripe_tree(fs_info, map->type)) - return btrfs_get_raid_extent_offset(fs_info, logical, length, - map->type, stripe_index, - dst); - dst->physical = map->stripes[stripe_index].physical + stripe_offset + ((u64)stripe_nr << BTRFS_STRIPE_LEN_SHIFT); - return 0; } int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, @@ -6423,15 +6413,24 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, * physical block information on the stack instead of allocating an * I/O context structure. */ - if (smap && num_alloc_stripes == 1 && - !(btrfs_use_raid_stripe_tree(fs_info, map->type) && - op != BTRFS_MAP_READ) && - !((map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) && mirror_num > 1)) { - ret = set_io_stripe(fs_info, op, logical, length, smap, map, - stripe_index, stripe_offset, stripe_nr); - *mirror_num_ret = mirror_num; - *bioc_ret = NULL; - goto out; + if (smap && num_alloc_stripes == 1) { + if (op == BTRFS_MAP_READ && + btrfs_use_raid_stripe_tree(fs_info, map->type)) { + ret = btrfs_get_raid_extent_offset(fs_info, logical, + length, map->type, + stripe_index, smap); + *mirror_num_ret = mirror_num; + *bioc_ret = NULL; + goto out; + } else if (!(map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) || + mirror_num == 0) { + set_io_stripe(smap, map, stripe_index, stripe_offset, + stripe_nr); + *mirror_num_ret = mirror_num; + *bioc_ret = NULL; + ret = 0; + goto out; + } } bioc = alloc_btrfs_io_context(fs_info, logical, num_alloc_stripes); @@ -6448,6 +6447,8 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, * * It's still mostly the same as other profiles, just with extra rotation. */ + ASSERT(op != BTRFS_MAP_READ || + btrfs_use_raid_stripe_tree(fs_info, map->type)); if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK && need_raid_map && (op != BTRFS_MAP_READ || mirror_num > 1)) { /* @@ -6461,29 +6462,21 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, bioc->full_stripe_logical = em->start + ((stripe_nr * data_stripes) << BTRFS_STRIPE_LEN_SHIFT); for (i = 0; i < num_stripes; i++) - ret = set_io_stripe(fs_info, op, logical, length, - &bioc->stripes[i], map, - (i + stripe_nr) % num_stripes, - stripe_offset, stripe_nr); + set_io_stripe(&bioc->stripes[i], map, + (i + stripe_nr) % num_stripes, + stripe_offset, stripe_nr); } else { /* * For all other non-RAID56 profiles, just copy the target * stripe into the bioc. */ for (i = 0; i < num_stripes; i++) { - ret = set_io_stripe(fs_info, op, logical, length, - &bioc->stripes[i], map, stripe_index, - stripe_offset, stripe_nr); + set_io_stripe(&bioc->stripes[i], map, stripe_index, + stripe_offset, stripe_nr); stripe_index++; } } - if (ret) { - *bioc_ret = NULL; - btrfs_put_bioc(bioc); - goto out; - } - if (op != BTRFS_MAP_READ) max_errors = btrfs_chunk_max_errors(map); -- 2.39.2