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: 141457 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2760613vqi; Mon, 18 Sep 2023 08:53:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfRhQKPbTvQqxho9S4ys21yNYDAgyWq2g/nwP4kPun2tsrkgLvN5NehXXWDluNbOG+Fvs2 X-Received: by 2002:a05:6a00:b4a:b0:68f:f0bb:7de1 with SMTP id p10-20020a056a000b4a00b0068ff0bb7de1mr8558598pfo.11.1695052413576; Mon, 18 Sep 2023 08:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695052413; cv=none; d=google.com; s=arc-20160816; b=cTjTpCwUec5GLmBzqdJeVlYEYMLZ9ZVeI+rr9vO9AwlJvwNPWuO9BlLcifN0glaDxC Cp6hZsAlZ3XvQaqQyyeA/ru7QHgI+blwE/uj1p2FA2s28O1FiagUH4pXCvKu9Wc1/2q3 YKfoLgF69T31kgrnzQrU0HJZZpHUWp+u1aOns70a3j35lePoD50wrV8K18F1uCeuYadP kagU2S5W8sgJkVEVGZiMYAtvgpGhVViplaBuo98YyagMcsVrzCikXf5NtsbO4BXv/i7j 9dL9kTG2NUGQrmcQy2vV5zoPFOEv/qBxTRsxrl96OhFl4V5/gjEhwv80Xkf8DeaBAw+P HH5g== 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=mDvesXG1eLDencH9a7UnLzJsfG+QdHX+nSGDmB7OQmk=; fh=J9Pn6g7IEAJF/tG+9dB20Bqd3t5UpF3izTf4NFk9Dtk=; b=eYH5lclxzvwG5gA1QWSBtrZcv5HL1egVTp/IV+oJqcNP/X4AaN/JXOcCJuCunDrlsa cce25xQuapS06bM8fyinKhjmwqwGoaMpz7Gb5ykn96ssIpGTPG9AFw3/+E4iOV+0VxqQ rXw/FZO9BdnB3+Etzum30wlrxAEXc2nGBcoBYEHG8IYSC1MEARrTT9H96DaX0bx4j3sp CTYHzCZkR/8YOHBGmTnBdjjMk3P8c5UeWnSVQfVkwIUb9vRrvb7UOSL8QbC5Ni3i/i1G lsc/gz3iB0bAwAJlhVm0ZgpvN/1dhqULXF/PT7MHFCGinjILWZx27+3vRkxbIVX8lWj/ kRjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=JtIho2RR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id ef6-20020a056a002c8600b0069029c49b66si8155919pfb.60.2023.09.18.08.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:53:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=JtIho2RR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 B6AA28050022; Mon, 18 Sep 2023 08:43:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbjIRPnG (ORCPT + 25 others); 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= 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 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]); Mon, 18 Sep 2023 08:43:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777389598295786098 X-GMAIL-MSGID: 1777391279971927159 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: 141475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2796015vqi; Mon, 18 Sep 2023 09:40:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHh2fdSVu+bdFVupBajG1RutbkZ6fYN5YfxZYym32eEtHkklQirVR9ZqipM2GPI3JXSeGX7 X-Received: by 2002:a17:90b:195:b0:26b:f67:9d1b with SMTP id t21-20020a17090b019500b0026b0f679d1bmr6897804pjs.30.1695055249702; Mon, 18 Sep 2023 09:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695055249; cv=none; d=google.com; s=arc-20160816; b=BMqvjM5lucXeu66J9Eknlp33IrqLrcy55/d+dvN6rQzGluLxAlBtCLz1DwUyBPgUOf osvms42tAm4eligSsK34hUExkYkMtHqwbO8ApmtU8X9lFAmxrnmzhVGN45Hix6KZLLVY l2oFYuC2ciXnYCGJHWO2vIPfykf6Vg6bqd9yVqel/Q5970ODBblZ/3CIO/TN4d1Fkk83 Nex4wcSWn2cO1iMbparJdAmEsZ0CaBgoN3a+sl9dlGmNNBhafJwL/iD7U5Se++AXQytI Hf9VY6NsDGjTZjUJa3q0NKqlI1eCIVE8A6oi1JlYI0z0N6NAugqfjw18SGurumHKqEfB oGTA== 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=MWqO7PN65pyZ67wK1HD0QFS/hYO6gMeqHoafSmfjqII=; fh=ZBIeESkUb/iidfG45mvqtPm0vhj4bdZnQPzR057sc1k=; b=mzxZKLjAx46+jIAAXTDv7PH2XHBpSHb14wsF0n1JjLHnZ34t9VzNdRi804bDORm65V SbEyWnlJTUTvM7QFi9NflUd0MjxFysXg1tn7oR1E/0Ztx90+b1vBzMcATU8hRzUwX9AH KDdKr7UBAh42CcBPi26gvm3n1dMglKtnTOF7AwewrA769zc589xq/e5dBzryFByPcrlI hqK7pX9UVqtlK7N9ZlaTCFPPizdPq6DR9YMTHGt4gdFUQJ4im7whEBt5k8gbEKJJIxqo g4pW3vjvaS40+KSjQ3bZ3P5boWTe+BSOEcgzg6qkCOINm709XxfsWDY/wbmIUtsy0CnK V33w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Gr9+atfT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a19-20020a17090acb9300b00262ca5c4c12si8358021pju.178.2023.09.18.09.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:40:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Gr9+atfT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 D2411808A912; Mon, 18 Sep 2023 08:45:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjIRPpa (ORCPT + 25 others); Mon, 18 Sep 2023 11:45:30 -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= 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 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]); Mon, 18 Sep 2023 08:45:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777394253568132401 X-GMAIL-MSGID: 1777394253568132401 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: 141463 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2772008vqi; Mon, 18 Sep 2023 09:08:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkmlF1wDcvG35u67G9XRKK5QfX81e0/MRYv662i3gsgqC+krRMQDln3nGPsqu2MctDpyqV X-Received: by 2002:a17:902:c24d:b0:1bd:edac:af44 with SMTP id 13-20020a170902c24d00b001bdedacaf44mr7285603plg.51.1695053304687; Mon, 18 Sep 2023 09:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695053304; cv=none; d=google.com; s=arc-20160816; b=CTI7uZ9PqPtcUm6Xn11IDFfFDdPnyIbcvPNTgk6/bZ7u0R7KqNfdarT0etU6NY4tKL KAWqaS/MarSmUIIoPxwEc7WPM1QMqJyvWBwalw2wKKd9E2WSHOzKvLvimhCXqes9pEFd lIvV0k6w9KVbiKR13+3A0ksLeEA8zdL7KXtn7dgtNaI3Y8phsj9dxE/mg+UVPa87t43v 5NUd2h7PTa03fAtqNXON/iirgRDYavZz5a6Sk+jjdA/fw3hnyGc2pB+lokVFJ1pOFYqj NIi9UPkhtD0i/6Z1gf5cYCC5iq88TEHMw0n/bn31JGGwoHScSeJmYoH7+GDi/eWMEaz8 lkQA== 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=bogRZaoczwI2BToouy6SlBbvPgxJVbpgfhqNZb0lxNg=; fh=ZBIeESkUb/iidfG45mvqtPm0vhj4bdZnQPzR057sc1k=; b=rgakcB/XV5UtxluCxTKfVuiIZFI6wSc3wrfJqGQ4NswOi+eyKMwapPuIs5b2bn4DaA FoHAsjWsWfwcImXX0YBIgspf8V1t/nM8GJFHblCh0as+sy/enbfmSOqK1UkHV/lMXtY6 7WqweJkwhjfSq3nJhFD+ZrhF5nNEUDE+KXzMOhRIyC2Vh76NQ0q6eux+Odu076BILMkz L2Oi7PcvOe0EbMtI6H65eNSWmS0XX81gYtW1ZScKLPBSTNevJ2GEvs/9L0UG7hPTNysR XWM6vySv0wZbp3RckpwxKc0XrTB1AnfqVVHHlB+UhSwNiKDkVN51ANtJZav/r+VReT/F nU9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dj4aIh7c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q4-20020a170902dac400b001bdba87ad54si8759068plx.603.2023.09.18.09.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dj4aIh7c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 2671C8127251; Mon, 18 Sep 2023 08:49:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbjIRPs2 (ORCPT + 25 others); 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= 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:49:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777392213699304106 X-GMAIL-MSGID: 1777392213699304106 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: 141468 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2783039vqi; Mon, 18 Sep 2023 09:22:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNjfSMvztxmJp/9Su7EIqIMColrLdDTrt4A0euXz2OxI0kb3wBaxz/zX1a9oz2f8uXgND2 X-Received: by 2002:a05:6a00:2d8c:b0:690:3793:17e5 with SMTP id fb12-20020a056a002d8c00b00690379317e5mr10838112pfb.4.1695054159651; Mon, 18 Sep 2023 09:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695054159; cv=none; d=google.com; s=arc-20160816; b=qrc1SH71Da6HrImNsxuae6GIdQcC3f9IdIrSrEh+jFuQYG7eHfRM+4ozHGY1CPDV9u zdtHhReTnetJZ7RhK8hPMps24avRS7JhP3lcvpDunT+0ip78LneCjTiw3PamnXDmO9++ iBxpx04dZJWGbrID3a9EUvYQ4c0eyvj2jefWL+2/EASDMIPeDztOIjg6Rpuon1MOwv2s jakyXEKNif4efG1WTSWF8ThKdtfRQsH7ZYfoG6/22t3MqmrwwHJ9K9Ilz1idMmE0VTrL SSEVSv2Y9IpYLTyT0uJ8jBv9aXyHWvhNldijMalhAaUB3j1DVG7yRsClppTfQSory8AG wnMQ== 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=L9A6StMeA9Seanwpxo4HOH2h882p/dNcplp0ng8Ln8w=; fh=ZBIeESkUb/iidfG45mvqtPm0vhj4bdZnQPzR057sc1k=; b=LncE7MZwV+0cpuJaiuIzldolXpmdyhmkT018ItnNXiIVP1RO+nH21IVfGYsumcLIsf QodyIQkcXKiFCHh91mT++PBjXUybOh3GaX2PbV9JCPEsZof39rzWCOJwF/waqxUG2sA4 O4oOJRYcc7Y0TNl5xeZpACmstt7wgTSeDgHKjCw2AM6epRtNMhgH1PxJQ3puw7VM+GfH 7f2YrizAQn2F7W8rZyQT0BK8kkLPe6AAPxKiE2YbeZsvm8VqgMhOsSKGkOiwhN5cAIoX MCaToGj8MN8ibzdv8/tlcJ5uDSwOF5UKZKgPgvnW13RV/UyTMZ/8e/KtHz/teaKLQLEm Y+zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="K/tpf7E3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f20-20020a056a0022d400b00690b8b03454si381608pfj.234.2023.09.18.09.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="K/tpf7E3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 365D280B12C3; Mon, 18 Sep 2023 08:52:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjIRPvu (ORCPT + 25 others); Mon, 18 Sep 2023 11:51:50 -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= 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:52:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777393110602820644 X-GMAIL-MSGID: 1777393110602820644 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)