summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/snapshot.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-05-29 16:56:50 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-05-31 22:03:17 -0400
commit5802caf74fa5647a0e560b585bf7d1ac65b20e11 (patch)
treeca8a7918f2b62eabf165bf45cfbe0e5da92ada48 /fs/bcachefs/snapshot.c
parentbcachefs: Journal keys are retained until shutdown, or journal replay finishes (diff)
downloadlinux-5802caf74fa5647a0e560b585bf7d1ac65b20e11.tar.gz
linux-5802caf74fa5647a0e560b585bf7d1ac65b20e11.zip
bcachefs: darray_find(), darray_find_p()
New helpers to avoid open coded loops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/snapshot.c')
-rw-r--r--fs/bcachefs/snapshot.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/bcachefs/snapshot.c b/fs/bcachefs/snapshot.c
index f553fe095f61..cf9a65e858f6 100644
--- a/fs/bcachefs/snapshot.c
+++ b/fs/bcachefs/snapshot.c
@@ -947,10 +947,7 @@ static inline bool same_snapshot(struct snapshot_tree_reconstruct *r, struct bpo
static inline bool snapshot_id_lists_have_common(snapshot_id_list *l, snapshot_id_list *r)
{
- darray_for_each(*l, i)
- if (snapshot_list_has_id(r, *i))
- return true;
- return false;
+ return darray_find_p(*l, i, snapshot_list_has_id(r, *i)) != NULL;
}
static void snapshot_id_list_to_text(struct printbuf *out, snapshot_id_list *s)
@@ -1428,10 +1425,8 @@ int bch2_snapshot_node_create(struct btree_trans *trans, u32 parent,
static inline u32 interior_delete_has_id(interior_delete_list *l, u32 id)
{
- darray_for_each(*l, i)
- if (i->id == id)
- return i->live_child;
- return 0;
+ struct snapshot_interior_delete *i = darray_find_p(*l, i, i->id == id);
+ return i ? i->live_child : 0;
}
static unsigned __live_child(struct snapshot_table *t, u32 id,