From: Sun YangKai <sunk67188@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Sun YangKai <sunk67188@gmail.com>
Subject: [PATCH 0/3] btrfs: remove unused return_any parameter from btrfs_search_slot_for_read()
Date: Sun, 8 Feb 2026 11:19:35 +0800 [thread overview]
Message-ID: <20260208032705.27040-3-sunk67188@gmail.com> (raw)
The return_any parameter in btrfs_search_slot_for_read() was designed
to allow falling back to the opposite search direction when no item
is found in the requested direction. However, analysis shows that:
- The vast majority of callers pass return_any=0, meaning the fallback
logic is effectively dead code for the common case.
- The few callers that did pass return_any=1 were doing so unnecessarily
- get_last_extent() in send.c: There is always a previous item (at
minimum the inode_item) before an extent data item, making the fallback
impossible to trigger.
- btrfs_read_qgroup_config() in qgroup.c: When searching from the
zeroed key (0,0,0) with find_higher=1, there cannot possibly be a
lower key to fall back to, making return_any=1 logically nonsensical.
This series removes these unnecessary return_any=1 usages (patches 1-2),
then removes the now-unused parameter and associated dead code from
btrfs_search_slot_for_read() (patch 3).
The final result is a significantly simplified interface and implementation,
with no functional change for any existing code path.
Patch 1: Drop pointless return_any fallback in qgroup config reading
Patch 2: Drop unnecessary return_any search in send's get_last_extent()
Patch 3: Remove return_any parameter and simplify implementation
Sun YangKai (3):
btrfs: qgroup: drop pointless return_any fallback when reading qgroup
config
btrfs: send: drop unnecessary return_any search in get_last_extent()
btrfs: simplify btrfs_search_slot_for_read() by removing return_any
parameter
fs/btrfs/ctree.c | 48 +++++++-------------------------------
fs/btrfs/ctree.h | 3 +--
fs/btrfs/free-space-tree.c | 2 +-
fs/btrfs/qgroup.c | 10 ++++----
fs/btrfs/send.c | 22 ++++++++---------
5 files changed, 25 insertions(+), 60 deletions(-)
--
2.52.0
next reply other threads:[~2026-02-08 3:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-08 3:19 Sun YangKai [this message]
2026-02-08 3:19 ` [PATCH 1/3] btrfs: qgroup: drop pointless return_any fallback when reading qgroup config Sun YangKai
2026-02-08 3:38 ` [PATCH 2/3] btrfs: send: drop unnecessary return_any search in get_last_extent() Sun YangKai
2026-02-08 3:40 ` [PATCH 3/3] btrfs: simplify btrfs_search_slot_for_read() by removing return_any parameter Sun YangKai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260208032705.27040-3-sunk67188@gmail.com \
--to=sunk67188@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox