From patchwork Mon Jul 29 12:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13744793 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47224146580; Mon, 29 Jul 2024 12:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254414; cv=none; b=ZyTdF06Zc95wFLrmKS7T6MkhbX+Ra7bdp5B7hMbZm21Br+c3a64hPKsapIJzpnrYQxJvIvBtgQOowJvYRSutrNZvU7sYd4G9d2lbiYAxXdQB7f75p2SwC93iGeUMHaBhyDel1P0GbXvcspCIrpn09I2J0ZBustTUgdlLjmdL+GU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254414; c=relaxed/simple; bh=7z9b6DSEEd3AS7TAf2EEFdpb8JBFUBPJjjKwMcTk1bM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=STdMptkS3T0UisBC6r4hxcWB6V9VDkOV/QWC5806idXfIYFEzm+Dn+ArsQdykSjFgldhF4HashMmfu/8CVkrJZB5qSQ4YsnafrwvPlqMap4VshjF/V2NAXnvEsjzo1goNVH0MR1SgzukC5S0wADWCSOdd4T4MRqqU21J3fIOEMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a7d26c2297eso395246066b.2; Mon, 29 Jul 2024 05:00:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722254411; x=1722859211; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zGN/kk6WdhdWkkFKRFXP8WuazD2BEVj2C7KF2uk7+UY=; b=ntObzTs08jgwsUBZVCenDWr4isQ8BlY5pQY3tpWMtfBSi0xvgXDZR/c28FQ13i5Pch c552XhhRwP7YPvuQyeWkSeHRdm+nLiC71Bf2/qNr861zkWhAYrPtZAcF0cJQ98eNVKrb UUeqKuMBGKwKkxrxA96/wYlCg7m58OgtkiOiNZoJbxnoc4nejo+vCcm2ZYbXOf2U8tnT bpo8AbdthsXQbYwl9q1PfJNwb11rQIqitU24J2m/gtd4vhu6iy0AsiaaLfJadN2vTXwG ngfbJrnj43edEX6CFfJy39LgiEmbaLDjGnmByfQ8t3S6ppYsEv5WcZtLfySKsYWg7ipW f3Jg== X-Forwarded-Encrypted: i=1; AJvYcCVKLWFzWFnzl08m7jMdlJw2vPYhgP9BT/E/Zg1O736RN8rtCb4yv/qUhv6Az0JM5liGLReE+FFvE0Mkz0MomKGJ24IL4qxBQh1BDbuI X-Gm-Message-State: AOJu0YybxjY+1foctwvEsszGrvQ/VAXc9iH41cHz5rPKAVRctbELWk5X ZUqLJUxp+2kj1Dg8UFwePOMLv80arL5m6M1UrxWPhMyOu6DHyd94GCT6QQ== X-Google-Smtp-Source: AGHT+IE9AxVBSVkSTYFKVJohns5FWVZFoGL3k8kvpXxxgN2d7QBQJpUmdX1VNeyPpLHVIp01Q7opGA== X-Received: by 2002:a17:907:2da0:b0:a7a:acae:340c with SMTP id a640c23a62f3a-a7d3ffadb71mr558795266b.13.1722254411418; Mon, 29 Jul 2024 05:00:11 -0700 (PDT) Received: from [127.0.0.1] (p200300f6f732f200fa633ffffe02074c.dip0.t-ipconnect.de. [2003:f6:f732:f200:fa63:3fff:fe02:74c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab2311asm508136266b.18.2024.07.29.05.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:00:11 -0700 (PDT) From: Johannes Thumshirn Date: Mon, 29 Jul 2024 14:00:02 +0200 Subject: [PATCH 1/4] btrfs: don't dump stripe-tree on lookup error Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240729-debug-v1-1-f0b3d78d9438@kernel.org> References: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> In-Reply-To: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> 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.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=859; i=jth@kernel.org; h=from:subject:message-id; bh=hwc/5qBk/m03Fn+onMcecnGBzxZqVF2km5Mrm9HY6u4=; b=owGbwMvMwCV2ad4npfVdsu8YT6slMaQtb/G41SzC1s9XKcVdo/yf2Vo95tS85j0nZEp6ZaQbj npP17jVUcrCIMbFICumyHI81Ha/hOkR9imHXpvBzGFlAhnCwMUpABP5dp2RYd2UXTNSd+0/9do5 rvhISKJkFt+3umtu7qnpGSKsrkYtagz/6/f90la4IJ30v1Wed1ayoXO9ZaQew1Y2tnKLyYf71gU xAAA= X-Developer-Key: i=jth@kernel.org; a=openpgp; fpr=EC389CABC2C4F25D8600D0D00393969D2D760850 From: Johannes Thumshirn This just creates unnecessary noise and doesn't provide any insights into debugging RAID stripe-tree related issues. Signed-off-by: Johannes Thumshirn --- fs/btrfs/raid-stripe-tree.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 684d4744f02d..97430918e923 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -284,8 +284,6 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, if (ret > 0) ret = -ENOENT; if (ret && ret != -EIO && !stripe->is_scrub) { - if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) - btrfs_print_tree(leaf, 1); btrfs_err(fs_info, "cannot find raid-stripe for logical [%llu, %llu] devid %llu, profile %s", logical, logical + *length, stripe->dev->devid, From patchwork Mon Jul 29 12:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13744795 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F57F145B0B; Mon, 29 Jul 2024 12:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254417; cv=none; b=LTrT9iBmSQ68M84wxASIIMeBZ2GLv/dEJlA0/1pgRfgKlDrP48z4uOJFL1RsJyDMIDJnoJ11aoBUU6DDzI/EwEI9AifJwpTMarFXzWyUatiaznxb2linf/VUqjjL0c9w3jEEEGtU70cjEIqMi/1bqXbo8orrVjV5KHei9lCNqEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254417; c=relaxed/simple; bh=V2/wyFM3bPaGJfPQmLX/sluxJRKr7lvIOzPidOT0y/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ajjeafd1fvGCgzR57suqafAXC07Lf9lnuaZl4Wre9a7QfwFcaT7E3GmAzdfNfAjNMGgdf4G1MDw+B9b/DO9QWqmHZh4Pta63IcamRnvJXNp01o8U5k+cGWOU/0uimzWVUXYchU/kerQt92j/GArZWDw7hrIWY5s5nQ6QxnG76rc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-52efd855adbso5142415e87.2; Mon, 29 Jul 2024 05:00:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722254412; x=1722859212; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3LuI4Ztw0QlpRT70UGqlhNtTpM0k62lG+oH/v547owU=; b=npaH2VPx6x8PvFhNNONPFz8wLQixyNT/AJGldNT+bkXCSmJDv60kETl4YEeQo+KqSN gdK0MMUHLhcOgaYI63VCruYXfzaTw/Pq5xmUViHLew8Pnbz7g8LrP0cUGMSbvdP+L1gn xEtGI+pDApbjDP/nPraqFDMz+/Oz9fpfAVRH3NSbxBBWpheFnJobEErW0FzC2fbOWdtz vNUs3CAEhMK2IxaOMdhx3lKn1SIAEnC8khgQag1VwkvUAHVlj6YSwmplymlMHijO6hYF 9DyH80FlSU1OIY3TkaTOjJuFhajk7Wby120Qtyu0s6Sc7TgC7WZzaDiaDns7luVnjWiN tApA== X-Forwarded-Encrypted: i=1; AJvYcCVu3BSTxWxapvrwdB/3ePsAaVptGLyRQWmo+zf/DRG6Qo3aUo6G2c3+5tkCnibGCllSS4TfVITI728V8ZifQVL1hHBPM5RWqCRKh+Gt X-Gm-Message-State: AOJu0Yyc2/bgWhZK17Os8SaQm1trbb+yLPKldigI0A2Ejzz26mp72OE/ iieS7nahCudsKu+rDvSMCBZ2+4D9d41hAObG0C/jB0E/Y5Gx8U/pua38RQ== X-Google-Smtp-Source: AGHT+IFw17vz6wvXaqgDgsK/XkKKX/l2xE03S8Vjxb4Ugyre4iGkQtr60Zs6wR7ZuinghQ1zDriOwg== X-Received: by 2002:a05:6512:3056:b0:52c:cd4f:b95b with SMTP id 2adb3069b0e04-5309b27a467mr5327231e87.22.1722254412296; Mon, 29 Jul 2024 05:00:12 -0700 (PDT) Received: from [127.0.0.1] (p200300f6f732f200fa633ffffe02074c.dip0.t-ipconnect.de. [2003:f6:f732:f200:fa63:3fff:fe02:74c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab2311asm508136266b.18.2024.07.29.05.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:00:11 -0700 (PDT) From: Johannes Thumshirn Date: Mon, 29 Jul 2024 14:00:03 +0200 Subject: [PATCH 2/4] btrfs: rename btrfs_io_stripe::is_scrub to rst_search_commit_root Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240729-debug-v1-2-f0b3d78d9438@kernel.org> References: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> In-Reply-To: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> 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.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2799; i=jth@kernel.org; h=from:subject:message-id; bh=GLCvjYyujrbk7qMrFGW/JRXoGw+aEQQjKxibIwWDeQ4=; b=owGbwMvMwCV2ad4npfVdsu8YT6slMaQtb/FcYiw2wYZvw9LayKvpldv/zjnTOffdAVuJE5MO9 bre26Rn1lHKwiDGxSArpshyPNR2v4TpEfYph16bwcxhZQIZwsDFKQATibjG8D9jk0fVuv6T4fKp 7cZbjtfbFtZkH84/Ln21dn22zMTFnVGMDNPumbrrH+Bhu8Iz2dQ/+cLxg71ClwObNPb83/Jxl9S kBcwA X-Developer-Key: i=jth@kernel.org; a=openpgp; fpr=EC389CABC2C4F25D8600D0D00393969D2D760850 From: Johannes Thumshirn Rename 'btrfs_io_stripe::is_scrub' to 'rst_search_commit_root'. While 'is_scrub' describes the state of the io_stripe (it is a stripe submitted by scrub) it does not describe the purpose, namely looking at the commit root when searching RAID stripe-tree entries. Renaming the stripe to rst_search_commit_root describes this purpose. Signed-off-by: Johannes Thumshirn --- fs/btrfs/bio.c | 2 +- fs/btrfs/raid-stripe-tree.c | 4 ++-- fs/btrfs/scrub.c | 2 +- fs/btrfs/volumes.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index f04d93109960..dfb32f7d3fc2 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -679,7 +679,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) blk_status_t ret; int error; - smap.is_scrub = !bbio->inode; + smap.rst_search_commit_root = !bbio->inode; btrfs_bio_counter_inc_blocked(fs_info); error = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length, diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c index 97430918e923..bfb567f602b1 100644 --- a/fs/btrfs/raid-stripe-tree.c +++ b/fs/btrfs/raid-stripe-tree.c @@ -210,7 +210,7 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, if (!path) return -ENOMEM; - if (stripe->is_scrub) { + if (stripe->rst_search_commit_root) { path->skip_locking = 1; path->search_commit_root = 1; } @@ -283,7 +283,7 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, out: if (ret > 0) ret = -ENOENT; - if (ret && ret != -EIO && !stripe->is_scrub) { + if (ret && ret != -EIO && !stripe->rst_search_commit_root) { btrfs_err(fs_info, "cannot find raid-stripe for logical [%llu, %llu] devid %llu, profile %s", logical, logical + *length, stripe->dev->devid, diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 0f15f5139896..a1f41e8b00cd 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1695,7 +1695,7 @@ static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx, (i << fs_info->sectorsize_bits); int err; - io_stripe.is_scrub = true; + io_stripe.rst_search_commit_root = true; stripe_len = (nr_sectors - i) << fs_info->sectorsize_bits; /* * For RST cases, we need to manually split the bbio to diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index c947187539dd..03d2d60afe0c 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -444,7 +444,7 @@ struct btrfs_io_stripe { /* Block mapping. */ u64 physical; u64 length; - bool is_scrub; + bool rst_search_commit_root; /* For the endio handler. */ struct btrfs_io_context *bioc; }; From patchwork Mon Jul 29 12:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13744794 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A179146D63; Mon, 29 Jul 2024 12:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254416; cv=none; b=cYgYKxKxW5sWLhBspIwQlRemGd42khQJnFB4Bt5pPw8APxyoP3b3t2YSFoH+DrXzO2NTWoJcq9QN+HvtA98gLQ0NxX5SpmLIp+dOP0rWTAxNWPxJKGXGKk33nr+2XZDUxaYClvvwjwYmlSZFME3K3aog/Y/vO1s1VmCaKI5yEAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254416; c=relaxed/simple; bh=/IcSJYYXJNCnwyGW/xg7CQHiY002W+thsnUAs/eIUL4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KrBT1wMyd26/AJIQW4mq2Fk01GW6KDSgibEYGwF4/3bUW+s+Mf2emd7IF8TcKnCu4cGSkAkO1C5qbiqYSzIX7Zut0o8yIeTNVI6jO+ki+IGd/kPKOTRsZg8AsgNgI/U+UOE9ACBojY5CXuVFR2SY8WG+5mR7ybLnkH0ASqgSLsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a7a9a7af0d0so449912566b.3; Mon, 29 Jul 2024 05:00:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722254414; x=1722859214; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WJWlRDxSJTNdG19sMCqs4ElfI/UMNfe1NBY5LQ2S1jo=; b=MF9kVmj1PFYpz71srRsxcIhbPgr41r93Q8xO5oEpglenIBgzXUoer9boIBX2z5Py6R o+MJ7nx8FjNlzosdtxfwYHDqJT+OpVOwngeibJo1xQ1MxJN6GjBPfeJijzoJPXJAo0B3 8g+LfohmIVm6hXekwZSVw7NBMJN6qNSfRLZNySndrOzGXJHA7O8I5/FKvczCvpIkErV1 snjS0KMJ0rT2kVCZiOlqpZzbgbhETvA7HMbYD7JISIURiQokwKapf+YPnciTC1TPjQ/9 t+DLpGwet8uJE3YuSvqmQ0/FYvM6D4RNP6dUzGSC3lfafyLFlH0XwkI4ARsKE7BGsk2O zGIA== X-Forwarded-Encrypted: i=1; AJvYcCUnsdPFtbkkWzzF6BUrjj74naXopgd/UQw/Lyd+EmJUyhW9ihKRX1/Mfpt+RQo3m5BCEdc0+G4Si7tD/V8/o3kKHi+FEVQmbl6/hyV7 X-Gm-Message-State: AOJu0YzOroHo38KYeLQTuSylNF8rIVSNfoxLEQYmE4KPmouMRmHo3vvJ JpDeKh3+yYd0dcGDzi9Eri/Wl1QH7ohEY8goBHDKALVRqKGRGATO4xmNWg== X-Google-Smtp-Source: AGHT+IHQz/cs4BNgOjsZ7NScCJNoUR0po1I68N/2lTCAbnlRYFbs6SDsccisgH2AtWk9x8CcybNVMg== X-Received: by 2002:a17:907:608c:b0:a7a:b643:654f with SMTP id a640c23a62f3a-a7d3ffb67cbmr414133466b.15.1722254413467; Mon, 29 Jul 2024 05:00:13 -0700 (PDT) Received: from [127.0.0.1] (p200300f6f732f200fa633ffffe02074c.dip0.t-ipconnect.de. [2003:f6:f732:f200:fa63:3fff:fe02:74c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab2311asm508136266b.18.2024.07.29.05.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:00:13 -0700 (PDT) From: Johannes Thumshirn Date: Mon, 29 Jul 2024 14:00:04 +0200 Subject: [PATCH 3/4] btrfs: set rst_search_commit_root in case of relocation Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240729-debug-v1-3-f0b3d78d9438@kernel.org> References: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> In-Reply-To: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> 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.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=807; i=jth@kernel.org; h=from:subject:message-id; bh=b0Pb+uSMgNZdT9sxeeZ9pRVHoEwmmPaSc/gj9kZGk3k=; b=owGbwMvMwCV2ad4npfVdsu8YT6slMaQtb/FcYpRSlnGFj+FipserpPULs85GfdeV1jhjI1w9e 3Zm/X31jlIWBjEuBlkxRZbjobb7JUyPsE859NoMZg4rE8gQBi5OAZiI/DaG/8Gm8Q73Dx7l0cle uX6z/uGPUu4b3y8Stfcq3cd3bZFY/3mGf+ZnTlmePf7QiDVYv6fu3uNVlyQm2G95q+OjuMvM9q6 FMTMA X-Developer-Key: i=jth@kernel.org; a=openpgp; fpr=EC389CABC2C4F25D8600D0D00393969D2D760850 From: Johannes Thumshirn Set rst_search_commit_root in the btrfs_io_stripe we're passing to btrfs_map_block() in case we're doing data relocation. Signed-off-by: Johannes Thumshirn --- fs/btrfs/bio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index dfb32f7d3fc2..c6563616c813 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -679,7 +679,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) blk_status_t ret; int error; - smap.rst_search_commit_root = !bbio->inode; + smap.rst_search_commit_root = + (!bbio->inode || btrfs_is_data_reloc_root(inode->root)); btrfs_bio_counter_inc_blocked(fs_info); error = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length, From patchwork Mon Jul 29 12:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13744796 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C711474D9; Mon, 29 Jul 2024 12:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254418; cv=none; b=t6ViAYozRL+RyZkcO3jrtxAFOp2EP0WqyiOTcjzoq4g1s8v6tEYsW+dIly18h6PX85Tsh7LQHd9Mr+wHP0ydVUFTOm1zFtvNXUjH3K0JMSdE8yroQNTMB5L0MYbkDtYVXVCct46b0qJh4PeejF2/pGzDTTLvOrd9QODSU3XXBDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722254418; c=relaxed/simple; bh=inXac3o0DMNwtWuz/S+UQ8nNGZTrTw9eBeIrM2lygBw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rEsBubLnYfSTMYcNlP4Ah+/3rhjVvoNZm5VqaVRdVydampNnRtCZ/P4djVFmnBPeYSf+BcYiP4MqAr7FEArSBoAsljWn6r6bqgEMxY6OGV/XtUaoO3IfJcn4SrhYyIqPnEgpn3StQUK6/aSQbJJ/nVkNkFmNRc4k1mNB6QIdDvc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52efbc57456so3515086e87.1; Mon, 29 Jul 2024 05:00:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722254414; x=1722859214; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/JXRICrVSgwEXzupbqfI6N6cbUtwrkjonRVE0qX8bW0=; b=dTs9S5ZipmfLpIchfyovdLcoI1Zj3cIWdXx9TA6e/HT19JDtqxo9YBKEMW6b35tyr/ esm/bsBNS3kngTnDngM8T/rasW7SUURDnMrmcPfvvS05jwjeokQUSL3IOdfb88CVVI5F A5Wu1Afcf0pJBexaDf/FFcOjKAYAQyEJBobkmBFFMaoPN/wvQ35uj66ymvMjRXyXi3wx mj0BsIB7r0Us5bLRRIanV1rnrisoBZ3aw2H/9SPRxbnaCHEqvFSwB+zEuUKquDFM/rTj V0+QMxB8BKooGik46u8RcSPts7tPgvKuauDSEYZHzxKtTUyf8MZX5zqaOVjXRrUI6Uz0 2rMA== X-Forwarded-Encrypted: i=1; AJvYcCXZKGraBC3CoM12lga1f/KIA5IfWum40wkOXQCXUgdaYRILJy5ClMm1z6Wvi36IAUtAYnJacqFNdysBDy8SksykRHgR73xcUocs03uY X-Gm-Message-State: AOJu0Yz3qG9p990qISzrCM+5kxUKNg9hXH9JX7urQWu6XZ8DUsHxrNW8 0vH3jiyvI9aYQaLCxEn/GLx/NJdVrdSkzMHB+4O/Kv/CPy5IBEPFsUirLQ== X-Google-Smtp-Source: AGHT+IFYlL2IQFhyuBafJblUyBmfmGapaaK+5VmhiLUrObv8+5c9f1lSgoPrQmYmRLyvetwDiwXlRQ== X-Received: by 2002:a05:6512:1043:b0:52e:987f:cfc6 with SMTP id 2adb3069b0e04-5309b2ce440mr5150158e87.51.1722254414462; Mon, 29 Jul 2024 05:00:14 -0700 (PDT) Received: from [127.0.0.1] (p200300f6f732f200fa633ffffe02074c.dip0.t-ipconnect.de. [2003:f6:f732:f200:fa63:3fff:fe02:74c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab2311asm508136266b.18.2024.07.29.05.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:00:14 -0700 (PDT) From: Johannes Thumshirn Date: Mon, 29 Jul 2024 14:00:05 +0200 Subject: [PATCH 4/4] btrfs: don't readahead the relocation inode on RST Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240729-debug-v1-4-f0b3d78d9438@kernel.org> References: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> In-Reply-To: <20240729-debug-v1-0-f0b3d78d9438@kernel.org> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Johannes Thumshirn , Johannes Thumshirn , Filipe Manana X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=5703; i=jth@kernel.org; h=from:subject:message-id; bh=8m/cLckIEbQtJPusx/1iIS9tmFdurtQoeVckBLSN0yo=; b=owGbwMvMwCV2ad4npfVdsu8YT6slMaQtb/EMW5KS/oHFtUYr/OOiRXm7ErbrXb4qpdC03y135 my32XXmHaUsDGJcDLJiiizHQ233S5geYZ9y6LUZzBxWJpAhDFycAjCRN0kM/93ECq6qG9b0FpcJ Z72t+FfSEvC4dYv8t3e+tzib7exUDjEyPLjw2vLN0qR/7lGm67ja1rGVyP2tto67qBMSZdz4YaU EFwA= X-Developer-Key: i=jth@kernel.org; a=openpgp; fpr=EC389CABC2C4F25D8600D0D00393969D2D760850 From: Johannes Thumshirn On relocation we're doing readahead on the relocation inode, but if the filesystem is backed by a RAID stripe tree we can get ENOENT from the lookup. But readahead doesn't handle the error and submits invalid reads to the device, causing an assertion in the scatter-gather list code: BTRFS info (device nvme1n1): balance: start -d -m -s BTRFS info (device nvme1n1): relocating block group 6480920576 flags data|raid0 BTRFS error (device nvme1n1): cannot find raid-stripe for logical [6481928192, 6481969152] devid 2, profile raid0 ------------[ cut here ]------------ kernel BUG at include/linux/scatterlist.h:115! Oops: invalid opcode: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 1012 Comm: btrfs Not tainted 6.10.0-rc7+ #567 RIP: 0010:__blk_rq_map_sg+0x339/0x4a0 RSP: 0018:ffffc90001a43820 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffea00045d4802 RDX: 0000000117520000 RSI: 0000000000000000 RDI: ffff8881027d1000 RBP: 0000000000003000 R08: ffffea00045d4902 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000001000 R12: ffff8881003d10b8 R13: ffffc90001a438f0 R14: 0000000000000000 R15: 0000000000003000 FS: 00007fcc048a6900(0000) GS:ffff88813bc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000002cd11000 CR3: 00000001109ea001 CR4: 0000000000370eb0 Call Trace: ? __die_body.cold+0x14/0x25 ? die+0x2e/0x50 ? do_trap+0xca/0x110 ? do_error_trap+0x65/0x80 ? __blk_rq_map_sg+0x339/0x4a0 ? exc_invalid_op+0x50/0x70 ? __blk_rq_map_sg+0x339/0x4a0 ? asm_exc_invalid_op+0x1a/0x20 ? __blk_rq_map_sg+0x339/0x4a0 nvme_prep_rq.part.0+0x9d/0x770 nvme_queue_rq+0x7d/0x1e0 __blk_mq_issue_directly+0x2a/0x90 ? blk_mq_get_budget_and_tag+0x61/0x90 blk_mq_try_issue_list_directly+0x56/0xf0 blk_mq_flush_plug_list.part.0+0x52b/0x5d0 __blk_flush_plug+0xc6/0x110 blk_finish_plug+0x28/0x40 read_pages+0x160/0x1c0 page_cache_ra_unbounded+0x109/0x180 relocate_file_extent_cluster+0x611/0x6a0 ? btrfs_search_slot+0xba4/0xd20 ? balance_dirty_pages_ratelimited_flags+0x26/0xb00 relocate_data_extent.constprop.0+0x134/0x160 relocate_block_group+0x3f2/0x500 btrfs_relocate_block_group+0x250/0x430 btrfs_relocate_chunk+0x3f/0x130 btrfs_balance+0x71b/0xef0 ? kmalloc_trace_noprof+0x13b/0x280 btrfs_ioctl+0x2c2e/0x3030 ? kvfree_call_rcu+0x1e6/0x340 ? list_lru_add_obj+0x66/0x80 ? mntput_no_expire+0x3a/0x220 __x64_sys_ioctl+0x96/0xc0 do_syscall_64+0x54/0x110 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7fcc04514f9b Code: Unable to access opcode bytes at 0x7fcc04514f71. RSP: 002b:00007ffeba923370 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fcc04514f9b RDX: 00007ffeba923460 RSI: 00000000c4009420 RDI: 0000000000000003 RBP: 0000000000000000 R08: 0000000000000013 R09: 0000000000000001 R10: 00007fcc043fbba8 R11: 0000000000000246 R12: 00007ffeba924fc5 R13: 00007ffeba923460 R14: 0000000000000002 R15: 00000000004d4bb0 Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:__blk_rq_map_sg+0x339/0x4a0 RSP: 0018:ffffc90001a43820 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffea00045d4802 RDX: 0000000117520000 RSI: 0000000000000000 RDI: ffff8881027d1000 RBP: 0000000000003000 R08: ffffea00045d4902 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000001000 R12: ffff8881003d10b8 R13: ffffc90001a438f0 R14: 0000000000000000 R15: 0000000000003000 FS: 00007fcc048a6900(0000) GS:ffff88813bc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fcc04514f71 CR3: 00000001109ea001 CR4: 0000000000370eb0 Kernel panic - not syncing: Fatal exception Kernel Offset: disabled ---[ end Kernel panic - not syncing: Fatal exception ]--- So in case of a relocation on a RAID stripe-tree based file system, skip the readahead. Signed-off-by: Johannes Thumshirn Cc: Josef Bacik Cc: Filipe Manana --- fs/btrfs/relocation.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index b592fc8cf368..5a6066f6db42 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -36,6 +36,7 @@ #include "relocation.h" #include "super.h" #include "tree-checker.h" +#include "raid-stripe-tree.h" /* * Relocation overview @@ -2965,21 +2966,26 @@ static int relocate_one_folio(struct reloc_control *rc, u64 folio_end; u64 cur; int ret; + bool use_rst = + btrfs_need_stripe_tree_update(fs_info, rc->block_group->flags); ASSERT(index <= last_index); folio = filemap_lock_folio(inode->i_mapping, index); if (IS_ERR(folio)) { - page_cache_sync_readahead(inode->i_mapping, ra, NULL, - index, last_index + 1 - index); + if (!use_rst) + page_cache_sync_readahead(inode->i_mapping, ra, NULL, + index, + last_index + 1 - index); folio = __filemap_get_folio(inode->i_mapping, index, - FGP_LOCK | FGP_ACCESSED | FGP_CREAT, mask); + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mask); if (IS_ERR(folio)) return PTR_ERR(folio); } WARN_ON(folio_order(folio)); - if (folio_test_readahead(folio)) + if (folio_test_readahead(folio) && !use_rst) page_cache_async_readahead(inode->i_mapping, ra, NULL, folio, index, last_index + 1 - index);