[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260203172357.65383-2-adarshdas950@gmail.com>
Date: Tue, 3 Feb 2026 22:53:56 +0530
From: Adarsh Das <adarshdas950@...il.com>
To: Chris Mason <clm@...com>,
David Sterba <dsterba@...e.com>
Cc: linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org,
Adarsh Das <adarshdas950@...il.com>
Subject: [PATCH 1/2] btrfs: handle unexpected exact match in btrfs_set_inode_index_count()
We search with offset (u64)-1 which should never match exactly.
Previously the code silently returned success without setting the index
count. Now logs an error and return -EUCLEAN instead.
Signed-off-by: Adarsh Das <adarshdas950@...il.com>
---
fs/btrfs/inode.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a2b5b440637e..9f46bfff1e4b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6105,9 +6105,18 @@ static int btrfs_set_inode_index_count(struct btrfs_inode *inode)
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
return ret;
- /* FIXME: we should be able to handle this */
- if (ret == 0)
- return ret;
+
+ if (unlikely(ret == 0)) {
+ /*
+ * Key with offset -1 found, there would have to exist a dir
+ * index item with such offset, but this is out of the valid
+ * range.
+ */
+ btrfs_err(root->fs_info,
+ "unexpected exact match for dir index key, inode %llu",
+ btrfs_ino(inode));
+ return -EUCLEAN;
+ }
if (path->slots[0] == 0) {
inode->index_cnt = BTRFS_DIR_START_INDEX;
--
2.53.0
Powered by blists - more mailing lists