public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: remove unused return_any parameter from btrfs_search_slot_for_read()
@ 2026-02-08  3:19 Sun YangKai
  2026-02-08  3:19 ` [PATCH 1/3] btrfs: qgroup: drop pointless return_any fallback when reading qgroup config Sun YangKai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sun YangKai @ 2026-02-08  3:19 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Sun YangKai

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-08  3:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-08  3:19 [PATCH 0/3] btrfs: remove unused return_any parameter from btrfs_search_slot_for_read() Sun YangKai
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox