From patchwork Mon Sep 18 14:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13389865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B5AACD37B0 for ; Mon, 18 Sep 2023 15:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbjIRPnG (ORCPT ); Mon, 18 Sep 2023 11:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjIRPnE (ORCPT ); Mon, 18 Sep 2023 11:43:04 -0400 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673D510A; Mon, 18 Sep 2023 08:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1695051696; x=1726587696; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=U9qbeiDSJYQbLhJrQS7p5rADrDE7muaLT4aPGuFW2ps=; b=JtIho2RRfnFTsGpz1t8rHXoNXpOqd/8heWiRzww9WkGigtNT2yNhHlIw FjXnYB+A7NlPR50AQv2cRso7dubE5qa/A3sZsk5TUJSr3mO49z82w7A/7 DptpNT67rI1mOuG7HbN1twsplDzBV/DDNrOy3cGiUCIqeGxp9R1fdWOt4 V75iujvXdPtKjyeX8c4pnTFhVNFQOtXhnqe/rFo2z3iNW4Eay2pGGdlux VLrjMtrPfHn6/2ZFBiPLyLnQqUNPrdkljiEeZCiydAeh07qAWW3x+xLYq yxWWkCLl2HAWzd+rnjQO9HLVHgRYXVLOWSF+vTbK4Xg1VfdLACOWRcSMx w==; X-CSE-ConnectionGUID: HIKYJ9nFR1aDXHcwxUjuXg== X-CSE-MsgGUID: 5BPDJXQPR7izjc/wzRXV6A== X-IronPort-AV: E=Sophos;i="6.02,156,1688400000"; d="scan'208";a="242446870" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Sep 2023 22:14:38 +0800 IronPort-SDR: eW/FyVE0qniifqTZNYNMQa9ZTwKmi6ouo1gsHuAsYRY+2kq+uixvYHDx+JIkd5vsvJu89AChvc EuQKhmvYtH/e9Qiqqi8x1bBu+QgdMANDKQgkH5vuB0Nq/N9UZHmuIsh4lLfDqep6rnnjZW9+yY /+2nJeTWQMNkMvjGXyJF6cZCMwHirZnDBtqZWuoMi7ZpAYiWFg7umc+669PmoAd1I2RSaUf8H5 VW5TRyLlh+7AWHdmHfaRiDyLuwM1m8LC1x+D/GNm89/Q44fQ+3fgmjIf21U1ZJQeZqNLMWHHNA Rng= 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; 18 Sep 2023 06:21:35 -0700 IronPort-SDR: caD0NdUxqZHEWJI1EhPtt8NPYt9h7MBvKWfW6BhS621lYssSFF96kBAYbPslYMXkKXW2N/E1PT AUUd79mfF1fYFeDXtQ6ocmIk1y5a2Z2mTMFGtWJXwvW/rzGdg7tP09ZkZQ4gpHVq2q7385MNel FORX9RNYPLFPeQv+RHvNJCycQ14vabNkDZCmdaeFh95HeyWqSavf1A9ThNmImabk9bpzawxlhx BVZsvDdV5C+NM0Tb5zpvt+05wNGp3o2zCuV6lqcMCQ91z9qmkXjD1RNH3GOymbpv5M3ZxArXnV Iv0= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Sep 2023 07:14:37 -0700 From: Johannes Thumshirn Date: Mon, 18 Sep 2023 07:14:30 -0700 Subject: [PATCH 1/4] btrfs: fix 64bit division in btrfs_insert_striped_mirrored_raid_extents MIME-Version: 1.0 Message-Id: <20230918-rst-updates-v1-1-17686dc06859@wdc.com> References: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> In-Reply-To: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenru , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695046476; l=1280; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=U9qbeiDSJYQbLhJrQS7p5rADrDE7muaLT4aPGuFW2ps=; b=Ozf+ipDi8Mm7lWMbgnIb2J2c0Xah43hULZG86xBGVs9N4P1rloFXxWIWyhD3PxUWO5iq7boMl ZY4qteZM3HjCMd92H3qvA3wJDcSoSKQGvpEjKtOi7+d/G3Rh4NpBxC+ X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Fix modpost error due to 64bit division on 32bit systems in btrfs_insert_striped_mirrored_raid_extents. Cc: Geert Uytterhoeven Signed-off-by: Johannes Thumshirn --- fs/btrfs/raid-stripe-tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 85e8e389990f..0c0e620ed8b9 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -148,10 +148,10 @@ static int btrfs_insert_striped_mirrored_raid_extents( { struct btrfs_io_context *bioc; struct btrfs_io_context *rbioc; - const int nstripes = list_count_nodes(&ordered->bioc_list); - const int index = btrfs_bg_flags_to_raid_index(map_type); - const int substripes = btrfs_raid_array[index].sub_stripes; - const int max_stripes = trans->fs_info->fs_devices->rw_devices / substripes; + const size_t nstripes = list_count_nodes(&ordered->bioc_list); + const enum btrfs_raid_types index = btrfs_bg_flags_to_raid_index(map_type); + const u8 substripes = btrfs_raid_array[index].sub_stripes; + const int max_stripes = div_u64(trans->fs_info->fs_devices->rw_devices, substripes); int left = nstripes; int i; int ret = 0; From patchwork Mon Sep 18 14:14:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13389936 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 773FBCD37B0 for ; Mon, 18 Sep 2023 15:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229635AbjIRPp3 (ORCPT ); Mon, 18 Sep 2023 11:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjIRPp2 (ORCPT ); Mon, 18 Sep 2023 11:45:28 -0400 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C579E57; Mon, 18 Sep 2023 08:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1695051780; x=1726587780; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=n8+tXm3WHp7oNeBpa7q8p5M/w6ei7Q0/BVkj3CYejmg=; b=Gr9+atfTmB7EwrZb9+pbFOxhHgHRJEiKnrTupVpRqv5c3Yo2Ygh2LwrM cr2n0jGPWuZekyNRDn6coIfc+cmMkCTKkSdB80iUk60mpQ5su8w3FXATE eQJVpqhww/6cBCppyuW6sdkJw3oJeDi1kpR+MsS80pMV6631tYG7XSx39 rXC9rLX3806phRbsqaeJfO81KTSCQPjUAOYfQj1G938gUREtfrbYtEdn8 Vb7RUSNqGHM+ZGFyJ0G0UaFMuWmO0rxOQcotlVnqdZVT6tHp1XRpQfK74 dK/jisvIltx1gyrkOoD1VkhD97JjeV1aKNaoAK2e/sZ4CqulGYL8hA0Tx w==; X-CSE-ConnectionGUID: TYkyqP4ST3Oinu5Y6Uz+Eg== X-CSE-MsgGUID: /LIBPyh+QYa9ySrQXEYnVQ== X-IronPort-AV: E=Sophos;i="6.02,156,1688400000"; d="scan'208";a="242446874" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Sep 2023 22:14:39 +0800 IronPort-SDR: BDETJMeCR9OVFN3fa75w6fuparJXxluOmIVb26Td1akDletwb6N4kIAdTB3zd/h6IiF35VGnS7 elqbrX5GZhVgYzOlwU43/PGLfsWQNYpyeFAz1zuHdq7ngj6eZXbtgTvdeC4rj+cVN6fYFYj1+r f6++KLa5mAawaoU15Kge0jnaPQURg3uLx5B2aTB3shJF69i3xONuPCOdzUx/NLZgy0sWrTA3dh tTDHHOsFdWBumgh9y9V98kLg2ZChTYDyhRNdzvGcNWRUvqAaIqjPfrs7QRLfqOlwnoo5UwNXVg my4= 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; 18 Sep 2023 06:21:36 -0700 IronPort-SDR: cnBdLx5NHPQr919v73GaSxDzyljumcrn+rt1KiGGfwNhQRiePzknysAERfjPPE26puALZYLO4u 6TEcLoh40gsLH4KSgpHZXRVQhcLvBMpBiVkOmE2ahttWWA4QwvaUgmWkPtNbrpE0U1xovPb3m6 Q08d9BoP0wdITR7dWmC8cCVWDdih1toMdISHI+/MkpZZQoCxje4Qsbzp7Rg6PVOK+KmvRUZV/d a3BsOkloTJLCNtVV6HN0ktm0JRyHR3yl2sgQ77gJP0Z4G98PDuBrNxan48Pq85AZtDgG9PFFyD ABo= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Sep 2023 07:14:38 -0700 From: Johannes Thumshirn Date: Mon, 18 Sep 2023 07:14:31 -0700 Subject: [PATCH 2/4] btrfs: break loop in case set_io_stripe fails MIME-Version: 1.0 Message-Id: <20230918-rst-updates-v1-2-17686dc06859@wdc.com> References: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> In-Reply-To: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenru , 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=1695046476; l=1242; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=n8+tXm3WHp7oNeBpa7q8p5M/w6ei7Q0/BVkj3CYejmg=; b=DRXiyrPBfRUQuNzQ7pOQQSiNszDGICRsi9JCpNSyILcJ3Q+ng17Ove6cT33qIY9suFfj7WXT6 2WCCsmVGEizAdJx8CoDPdHgSzq+CB6L1c63L1m2qg6qkGl0t5I8XGmH X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Break out of the loop in case st_io_stripe() fails. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0c5bd8d2ea06..d2a0ae9d91c4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6576,11 +6576,15 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, */ bioc->full_stripe_logical = em->start + btrfs_stripe_nr_to_offset(stripe_nr * data_stripes); - for (i = 0; i < num_stripes; i++) + 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); + if (ret) + break; + } + } else { /* * For all other non-RAID56 profiles, just copy the target @@ -6590,6 +6594,8 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ret = set_io_stripe(fs_info, op, logical, length, &bioc->stripes[i], map, stripe_index, stripe_offset, stripe_nr); + if (ret) + break; stripe_index++; } } From patchwork Mon Sep 18 14:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13389937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72126CD37B0 for ; Mon, 18 Sep 2023 15:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbjIRPs2 (ORCPT ); Mon, 18 Sep 2023 11:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbjIRPs1 (ORCPT ); Mon, 18 Sep 2023 11:48:27 -0400 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CF8EE7F; Mon, 18 Sep 2023 08:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1695051924; x=1726587924; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=fQE6cYQTb7uEo6MPqo5w53bNOJZDe0ReEYNCQa7qqK0=; b=dj4aIh7cOBNX9/B/67QFuV9QI6tZ/MLTqykMPEBwymQclas54O+gZkQ/ Hs2uDnj3Oe6OcMZkSFKniGrmZcxdnwvYKu9gMcJoEQ65+BfPTUdKu5fka ns99rH8ayeixreIcU2uG1nX1sOHMUQIVG2rO6saTP3vlhtQNYWeuUySsC ntv1AQUwQcsghCXCy5eU1shKTCG2RkIPJA/HTkr/kseiFH9mBRGf/sfRF LULMreQ+FC7CZeFdNwukdewDJ3fmDFBYpKOCahszJdF0u3/B7N4uzcVIo M5HzNfv88De1y0DGwKJrXHdgV/PgDvekHUZM+6hpUhKyEiTE9UMIHB3He g==; X-CSE-ConnectionGUID: bYCu7FojQz2C3LXV5E01NA== X-CSE-MsgGUID: Jsf4kmMURdCGC9Lfjh8kWA== X-IronPort-AV: E=Sophos;i="6.02,156,1688400000"; d="scan'208";a="242446876" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Sep 2023 22:14:40 +0800 IronPort-SDR: CZL9P2IOib8kKyMNF8KdaY13Uoxi3zGnMA6b4ZZJUkQiQDXy7DjPTyziJzZodt6kVIDVUe57LZ jk8amtJF6jl6hjauhNbi80ITqBiZhiQHvGAlCLHCO5m15LGI9QHvfUcDuB0xmwvwewLMHcJSu7 CAwYhMQGbxILE6xGXskE9Qx6d0RR6+KzK36ZLCK5xYUersqSEFd7tlH4N8FY2m+HMHSRUSY++O wM31es4w7QRFiDvVrtbz0bsJbN9api+FQ9QnCJ0KWVMmajAkZEeDtBVYGDvRgse+6MXlaaGO1d nBY= 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; 18 Sep 2023 06:21:37 -0700 IronPort-SDR: 5TDNxe3i1yZJkY3LXwz/2hJ6fkynl70Mk7Z8Cn/pS7b7c3n2140f5iQQX08bNnMAV3KTIAQSnD VEqyVXHmrrDJtjcy3Km4CRJ16f3wZW0dbbPGuCjJoKus8x38lsahok+EJwNwdJR0I8G29pJDWT Fq3aH/eyY7fOTOleZY5qFDfAsPh7RTzOWBIwdkU3OdAY6B14rSfFF6BfsRtZapMYy9kzx2u5+J WRBMAmONz+eYRhrPu2LyAt1N4JlgONIqLL0utBzQFvL/BiqkPlNFehAbK4E19k6vtSxfwxVtxn 6rQ= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Sep 2023 07:14:39 -0700 From: Johannes Thumshirn Date: Mon, 18 Sep 2023 07:14:32 -0700 Subject: [PATCH 3/4] btrfs: rename ordered_enmtry in btrfs_io_context MIME-Version: 1.0 Message-Id: <20230918-rst-updates-v1-3-17686dc06859@wdc.com> References: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> In-Reply-To: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenru , 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=1695046476; l=4045; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=fQE6cYQTb7uEo6MPqo5w53bNOJZDe0ReEYNCQa7qqK0=; b=+/a05AvEaTYcyS3A7GhxaWi/TMosXPDU0WnXZkuQZ9q7eD4MBxhOivfkRqpzAz8wG008He9UN p8eK82/D+smA1kHjMfBeD+VOUFD3OqtPB/8qZEEKzW8DTSRnh62Iw95 X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Rename the 'ordered_entry' member of 'struct btrfs_io_context' to 'rst_ordered_entry' to make it clear, it is only there for updates to the raid-stripe-tree. Cc: Qu Wenru Signed-off-by: Johannes Thumshirn --- fs/btrfs/bio.c | 3 ++- fs/btrfs/raid-stripe-tree.c | 18 +++++++++--------- fs/btrfs/volumes.h | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 4c234024beae..d0a029c859e1 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -708,7 +708,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) * can't happen until after the last submission. */ btrfs_get_bioc(bioc); - list_add_tail(&bioc->ordered_entry, &bbio->ordered->bioc_list); + list_add_tail(&bioc->rst_ordered_entry, + &bbio->ordered->bioc_list); } /* diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 0c0e620ed8b9..1bf84258dbfa 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -132,7 +132,7 @@ static int btrfs_insert_mirrored_raid_extents(struct btrfs_trans_handle *trans, struct btrfs_io_context *bioc; int ret; - list_for_each_entry(bioc, &ordered->bioc_list, ordered_entry) { + list_for_each_entry(bioc, &ordered->bioc_list, rst_ordered_entry) { ret = btrfs_insert_one_raid_extent(trans, num_stripes, bioc); if (ret) return ret; @@ -167,12 +167,12 @@ static int btrfs_insert_striped_mirrored_raid_extents( rbioc->map_type = map_type; rbioc->logical = list_first_entry(&ordered->bioc_list, typeof(*rbioc), - ordered_entry)->logical; + rst_ordered_entry)->logical; stripe_end = rbioc->logical; prev_end = stripe_end; i = 0; - list_for_each_entry(bioc, &ordered->bioc_list, ordered_entry) { + list_for_each_entry(bioc, &ordered->bioc_list, rst_ordered_entry) { rbioc->size += bioc->size; for (int j = 0; j < substripes; j++) { int stripe = i + j; @@ -201,7 +201,7 @@ static int btrfs_insert_striped_mirrored_raid_extents( } if (left) { - bioc = list_prev_entry(bioc, ordered_entry); + bioc = list_prev_entry(bioc, rst_ordered_entry); ret = btrfs_insert_one_raid_extent(trans, substripes, bioc); } @@ -225,10 +225,10 @@ static int btrfs_insert_striped_raid_extents(struct btrfs_trans_handle *trans, return -ENOMEM; rbioc->map_type = map_type; rbioc->logical = list_first_entry(&ordered->bioc_list, typeof(*rbioc), - ordered_entry)->logical; + rst_ordered_entry)->logical; i = 0; - list_for_each_entry(bioc, &ordered->bioc_list, ordered_entry) { + list_for_each_entry(bioc, &ordered->bioc_list, rst_ordered_entry) { rbioc->size += bioc->size; rbioc->stripes[i].dev = bioc->stripes[0].dev; rbioc->stripes[i].physical = bioc->stripes[0].physical; @@ -266,7 +266,7 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans, return 0; map_type = list_first_entry(&ordered_extent->bioc_list, typeof(*bioc), - ordered_entry)->map_type; + rst_ordered_entry)->map_type; switch (map_type & BTRFS_BLOCK_GROUP_PROFILE_MASK) { case BTRFS_BLOCK_GROUP_DUP: @@ -291,8 +291,8 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans, while (!list_empty(&ordered_extent->bioc_list)) { bioc = list_first_entry(&ordered_extent->bioc_list, - typeof(*bioc), ordered_entry); - list_del(&bioc->ordered_entry); + typeof(*bioc), rst_ordered_entry); + list_del(&bioc->rst_ordered_entry); btrfs_put_bioc(bioc); } diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 54549e34a306..b511d17c6717 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -432,7 +432,7 @@ struct btrfs_io_context { u64 logical; u64 size; - struct list_head ordered_entry; + struct list_head rst_ordered_entry; /* * The total number of stripes, including the extra duplicated From patchwork Mon Sep 18 14:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13389948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3510ACD37B0 for ; Mon, 18 Sep 2023 15:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbjIRPvt (ORCPT ); Mon, 18 Sep 2023 11:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjIRPvs (ORCPT ); Mon, 18 Sep 2023 11:51:48 -0400 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432361BD3; Mon, 18 Sep 2023 08:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1695052103; x=1726588103; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=O5cyP50gwkgqOrwJ8rNm2QYmSxf1jQpq+qrkq1ID4oI=; b=K/tpf7E3WWc7h9ToygioqyLe9MoOnV6WM27uE3RyG7QRUBxJA86VTkx4 USZ2/uaHhMN93eTpaO6um/01ur32zPoxf0z2sz6R485pQpQhPM+tJjIgD 8VWlaDPX71sjmX7X1ByP9MSgLD3pacYLZtgqppKtJSxxUlNMHKQFoO2xg n8s/Q2zgfQgBjipK6RddWFHE05hr6hSvHqxZ6iiySUxloFtGsWOCdlgBw zuDubHgFKHS/NK19uuJTqbx/CU8tlXA0XOam9CzF5aC9C3V8HsOsmz9Ab FXdO43HLnCRetLoWohnIzEkaVWKBofKf2/L4LYweHLZ7qLj1PRdQIyXT4 A==; X-CSE-ConnectionGUID: lKz+FT6wQ5eSON19KL26/Q== X-CSE-MsgGUID: wY9+X9cuQPaaYK3mP0dPCg== X-IronPort-AV: E=Sophos;i="6.02,156,1688400000"; d="scan'208";a="242446879" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Sep 2023 22:14:41 +0800 IronPort-SDR: Ouna9XENkYlQz5mEXa4u3PTzlRlA3H3qigikWoBALLnzw9SzV5mHCAFgeCF/NRb6mB5IFizmMQ OLP9a6MmZH/jVqhQHWinVJ0eSe/1By0D8k5cJHbCkAc9llOKwEXnG+iCIkY3quRP+WSdzH+pth 9LRAMg2bsOG+HRK2onUhJP4lLaa4QRP2TSN38uRqOSQUdG1krLYX9SNaZ6QoeaWgVIcXndd4+W rb7i/lB2DTbBjmhVcdTIx6guzCQlw7HB4V6L9JgLsk6olKzeZOTMHVLKt1tOrFndnQw9KRbaB0 7ig= 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; 18 Sep 2023 06:21:38 -0700 IronPort-SDR: u/F+reRUu2JqSkfFbWoaVFsAGNifvNA7j9mwu9h7pjdIOLtEHcaKMo0rq49Ku6iR/xIvQXvruw KBQ6Jz6epg8ncR+TUvMyJkHLW69ZLCUtVJYiNN5AVjNw8NqgtS1+t+zYodxPgzTlX6ZmAC6E5I 0LlHiMTAgZYpwkOhtmTsQFsl9Q3IWt4BEmS4gAAxWrfjUmvGCQpTm/o35xnY1u+UG/XEB9Brjw kyfGmRtkrDJltWkDBGoHiBj2GmPiLFbHxCEATsZTPF1c/j3l30xbYAVpF3xntrZIZHES3eihmJ ZRQ= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Sep 2023 07:14:40 -0700 From: Johannes Thumshirn Date: Mon, 18 Sep 2023 07:14:33 -0700 Subject: [PATCH 4/4] btrfs: add tree-checker for RAID-stripe-tree MIME-Version: 1.0 Message-Id: <20230918-rst-updates-v1-4-17686dc06859@wdc.com> References: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> In-Reply-To: <20230918-rst-updates-v1-0-17686dc06859@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenru , 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=1695046476; l=2260; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=O5cyP50gwkgqOrwJ8rNm2QYmSxf1jQpq+qrkq1ID4oI=; b=bonYvCSYrgSNpci9AGiGelZCGtiU/flfpx/xM23TmCEjQ6OdlIrogeHl8xNi2YTrlHCqarbyQ n/LfiuhpTllDVQ5UCOSRpPJWG2AwpBCet/iQtoWeyzQgLn0iRaRqQli X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Add a tree checker for RAID stripe tree items. Signed-off-by: Johannes Thumshirn --- fs/btrfs/tree-checker.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index 01bba79165e7..ea84ca2767e9 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -30,6 +30,7 @@ #include "file-item.h" #include "inode-item.h" #include "dir-item.h" +#include "raid-stripe-tree.h" /* * Error message should follow the following format: @@ -1635,6 +1636,44 @@ static int check_inode_ref(struct extent_buffer *leaf, return 0; } +static int check_raid_stripe_extent(struct extent_buffer *leaf, + struct btrfs_key *key, int slot) +{ + struct btrfs_stripe_extent *stripe_extent = + btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent); + + if (unlikely(!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize))) { + generic_err(leaf, slot, +"invalid key objectid for raid stripe extent, have %llu expect aligned to %u", + key->objectid, leaf->fs_info->sectorsize); + return -EUCLEAN; + } + + if (unlikely(!btrfs_fs_incompat(leaf->fs_info, RAID_STRIPE_TREE))) { + generic_err(leaf, slot, + "RAID_STRIPE_EXTENT present but RAID_STRIPE_TREE incompat bit unset"); + return -EUCLEAN; + } + + switch (btrfs_stripe_extent_encoding(leaf, stripe_extent)) { + case BTRFS_STRIPE_RAID0: + case BTRFS_STRIPE_RAID1: + case BTRFS_STRIPE_DUP: + case BTRFS_STRIPE_RAID10: + case BTRFS_STRIPE_RAID5: + case BTRFS_STRIPE_RAID6: + case BTRFS_STRIPE_RAID1C3: + case BTRFS_STRIPE_RAID1C4: + break; + default: + generic_err(leaf, slot, "invalid raid stripe encoding %u", + btrfs_stripe_extent_encoding(leaf, stripe_extent)); + return -EUCLEAN; + } + + return 0; +} + /* * Common point to switch the item-specific validation. */ @@ -1689,6 +1728,9 @@ static enum btrfs_tree_block_status check_leaf_item(struct extent_buffer *leaf, case BTRFS_EXTENT_DATA_REF_KEY: ret = check_extent_data_ref(leaf, key, slot); break; + case BTRFS_RAID_STRIPE_KEY: + ret = check_raid_stripe_extent(leaf, key, slot); + break; } if (ret)