Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2476632lqp; Sun, 24 Mar 2024 22:31:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRyf8eqoTzSHqA4TR9EgXLlznFYyPSYwYYDASVGGF1gXenW+VP0QKFe/nAFWnix4/XzoeJ2LjMgn/1SojM2B3BrsDoN50KB5AKpK4m0Q== X-Google-Smtp-Source: AGHT+IE+8o2cgXozaJ1baqCKHzot81meaD1x5u3OGQ4KTg4yJCTSMA3HCoaMYTuBXD8pXZVA2Bnv X-Received: by 2002:a05:6122:3647:b0:4d4:2398:51a2 with SMTP id dv7-20020a056122364700b004d4239851a2mr2212033vkb.8.1711344680233; Sun, 24 Mar 2024 22:31:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711344680; cv=pass; d=google.com; s=arc-20160816; b=GzB9qUvdq50PMTy4oeWZKbER5BphZrBAbmP3RodM19dyE/5catRaYCW/AOD4ZHZGZD rXZHPK7jAloKG/MWZMA4vWgEIbsoRzU5p3XPJoYqFjI9NYYsBmj56URtq6FJKo17QQqR jsSnqOB9H9BGuuaD6mV/+xsoLbzFRkjZ+kKvxzoDqY/jl1z4H9N0V/xAMjjKvTZ+lI4b gUclP66rIVTVDGhVWxIGsTWF6z7/Ibi4YlhYJLprgvvl4fTfeRVFD6qlSS/Qi62E/dOV +7Shn4XdfI+kBcsIDGHgHz4Ij5arro/Cdo2IUMMZCu0Ptb+xeyX/0ywSXUNqje589Tb9 NZzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NTUnWqYhZxleFn+x1nzQ9SKdHlzJJthnMo3ZJvaJy6A=; fh=AfRCL1xIa3x1T2i/5y5pOUvN0PVAV8AX/gzD1FbEG1E=; b=JQvpfPW754Vx1LZlGGOAICykaMBrfErSnfr0fB2gXZSormCjkxMbl6p89qRctRxkLD 2urFBRP0zlsYw3ia9im99gW/Lpkz5YLiDgUYMFlY4a3PfevaB+bkYPdWbSA38qjdUVQX 94+RSCJEIk2Icpx4Bg48ou+YdO/HuKdIw/7+AG1OzmhdUcCyj3M7Ttg34+hhN4FQ+R2p zdClig1BADtvhuOKjV2AIcHsTOThR/bN7B08JahG5SEhysw0E8DQtZRmoLirGgTCJckS /nhtvuboNZUMvXYJbB6da7EAlNAi4DTwJo0O7C63qS8VGo9Y8XWa3aOeMSUT+fxl23U3 7k6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A/+tJD4C"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113947-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e1-20020a0562140d8100b006960f798922si7250557qve.522.2024.03.24.22.31.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 22:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113947-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A/+tJD4C"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113947-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id ECE441C27436 for ; Mon, 25 Mar 2024 05:31:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F9A71EF7F9; Sun, 24 Mar 2024 23:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A/+tJD4C" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED35F1EFE4B; Sun, 24 Mar 2024 22:57:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321052; cv=none; b=fCqk0OSVUPz8ekABfHX1LlUDb2Dl/vA4fYd+CgtuK6EYXe2Y/YMhS1hyI54FrL7/mMsdSl2BcqYZ2Xkmknukm4gjeYRcFoGhRe+Yv0d/noteiKFmmKHydOyjNHn6w2ROKEK5KXy1FlPQh9CpUnahmZkF3vMGgVFTqyyiN5DC/oo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321052; c=relaxed/simple; bh=EKeavYQEZFDvRJNtVtMfsm98ElmzCnmdX0039Xcx5Kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TMlHqzwDUmgkxoe1f6OszOX0+6rR4sHctIwkuWn7dIFnV/yXw7/g+m889HeFfPz8qGm9can4/xHiWWB5veIJ+uKPH5Xc4cJz5XOIZXo23/1unaUdIZO4lQzlz4KPdHsL9of4p1+mSJHaK1f+3+j/IdbQEAkmsH4gm67TQAV2qyc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A/+tJD4C; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50885C433F1; Sun, 24 Mar 2024 22:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321051; bh=EKeavYQEZFDvRJNtVtMfsm98ElmzCnmdX0039Xcx5Kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/+tJD4CJmSCms+JYlZSUWM+bgPZ+At36FnekqBs33XG+8sURgz4JEKwl77KF5JQW 84cBv/jFPybKWJozkOwZkUH1Bz7bh2zK0OkrTGlsb0SXmC2sPcQrSZcGtwc8ES2lwb oEXkjtjkxBj7C5ZGZknoNIZ4O33XqHeEscbA/cWz38aGrMpuulFjIrAZiBv+2ByruS 3uZakUsJOx9vB1IH3cWvVzn+LNkWyQtgRrA59QGMxMa8f+hWZlySJbQwAUivNHYZAJ 4ufUsPKTfQNosC1XBE+5bOSKnquoSWVUJZKq6wRE4TGm1gU0D1xcv9TDkybNt5S/FG Cr7L3TfbHNtlQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kent Overstreet , Greg Kroah-Hartman Subject: [PATCH 6.7 615/713] bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree Date: Sun, 24 Mar 2024 18:45:41 -0400 Message-ID: <20240324224720.1345309-616-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Kent Overstreet commit 204f45140faa0772d2ca1b3de96d1c0fb3db8e77 upstream. If we're in FILTER_SNAPSHOTS mode and we start scanning a range of the keyspace where no keys are visible in the current snapshot, we have a problem - we'll scan for a very long time before scanning terminates. Awhile back, this was fixed for most cases with peek_upto() (and assertions that enforce that it's being used). But the fix missed the fact that the inodes btree is different - every key offset is in a different snapshot tree, not just the inode field. Fixes: Signed-off-by: Kent Overstreet Signed-off-by: Greg Kroah-Hartman --- fs/bcachefs/btree_iter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index da594e0067697..816ecc3375196 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2094,7 +2094,9 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e * isn't monotonically increasing before FILTER_SNAPSHOTS, and * that's what we check against in extents mode: */ - if (k.k->p.inode > end.inode) + if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS) + ? bkey_gt(k.k->p, end) + : k.k->p.inode > end.inode)) goto end; if (iter->update_path && -- 2.43.0