Skip to content

Commit a861c72

Browse files
koverstreetKent Overstreet
authored and
Kent Overstreet
committed
bcachefs: Require snapshot id to be set
Now that all the existing code has been converted for snapshots, this patch changes the code for initializing a btree iterator to require a snapshot to be specified, and also change bkey_invalid() to allow for non U32_MAX snapshot IDs. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 6f83cb8 commit a861c72

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

fs/bcachefs/bkey_methods.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
182182

183183
if (type != BKEY_TYPE_btree &&
184184
btree_type_has_snapshots(type) &&
185-
k.k->p.snapshot != U32_MAX)
185+
!k.k->p.snapshot)
186186
return "invalid snapshot field";
187187

188188
if (type != BKEY_TYPE_btree &&

fs/bcachefs/btree_iter.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,9 @@ static void bch2_btree_iter_verify(struct btree_iter *iter)
677677

678678
static void bch2_btree_iter_verify_entry_exit(struct btree_iter *iter)
679679
{
680+
BUG_ON((iter->flags & BTREE_ITER_FILTER_SNAPSHOTS) &&
681+
!iter->pos.snapshot);
682+
680683
BUG_ON(!(iter->flags & BTREE_ITER_ALL_SNAPSHOTS) &&
681684
iter->pos.snapshot != iter->snapshot);
682685

@@ -2522,20 +2525,13 @@ static void __bch2_trans_iter_init(struct btree_trans *trans,
25222525
btree_node_type_is_extents(btree_id))
25232526
flags |= BTREE_ITER_IS_EXTENTS;
25242527

2525-
if (!btree_type_has_snapshots(btree_id) &&
2526-
!(flags & __BTREE_ITER_ALL_SNAPSHOTS))
2528+
if (!(flags & __BTREE_ITER_ALL_SNAPSHOTS) &&
2529+
!btree_type_has_snapshots(btree_id))
25272530
flags &= ~BTREE_ITER_ALL_SNAPSHOTS;
2528-
#if 0
2529-
/* let's have this be explicitly set: */
2530-
if ((flags & BTREE_ITER_TYPE) != BTREE_ITER_NODES &&
2531-
btree_type_has_snapshots(btree_id) &&
2532-
!(flags & BTREE_ITER_ALL_SNAPSHOTS))
2533-
flags |= BTREE_ITER_FILTER_SNAPSHOTS;
2534-
#endif
25352531

2536-
if (!(flags & BTREE_ITER_ALL_SNAPSHOTS))
2537-
pos.snapshot = btree_type_has_snapshots(btree_id)
2538-
? U32_MAX : 0;
2532+
if (!(flags & BTREE_ITER_ALL_SNAPSHOTS) &&
2533+
btree_type_has_snapshots(btree_id))
2534+
flags |= BTREE_ITER_FILTER_SNAPSHOTS;
25392535

25402536
iter->trans = trans;
25412537
iter->path = NULL;

0 commit comments

Comments
 (0)