diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-14 02:47:36 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:35 -0400 |
commit | 49124d8a7f3bc0f2bd33ba6cdfa2e9514a74b109 (patch) | |
tree | 59645c4ec1ba715ab4eac85f0cb69fa42dc698c3 /fs/bcachefs/subvolume.h | |
parent | 4ab35c34d5ab258fdd7325315fe5d94699e51eb4 (diff) |
bcachefs: Improve snapshots_seen
This makes the snapshots_seen data structure fsck private and improves
it; we now also track the equivalence class for each snapshot id we've
seen, which means we can detect when snapshot deletion hasn't finished
or run correctly (which will otherwise confuse fsck).
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/subvolume.h')
-rw-r--r-- | fs/bcachefs/subvolume.h | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/fs/bcachefs/subvolume.h b/fs/bcachefs/subvolume.h index 7823040c9641..02a636644988 100644 --- a/fs/bcachefs/subvolume.h +++ b/fs/bcachefs/subvolume.h @@ -27,6 +27,16 @@ static inline u32 bch2_snapshot_parent(struct bch_fs *c, u32 id) return snapshot_t(c, id)->parent; } +static inline u32 bch2_snapshot_equiv(struct bch_fs *c, u32 id) +{ + return snapshot_t(c, id)->equiv; +} + +static inline bool bch2_snapshot_is_equiv(struct bch_fs *c, u32 id) +{ + return id == snapshot_t(c, id)->equiv; +} + static inline u32 bch2_snapshot_internal_node(struct bch_fs *c, u32 id) { struct snapshot_t *s = snapshot_t(c, id); @@ -58,31 +68,6 @@ static inline bool bch2_snapshot_is_ancestor(struct bch_fs *c, u32 id, u32 ances return id == ancestor; } -struct snapshots_seen { - struct bpos pos; - DARRAY(u32) ids; -}; - -static inline void snapshots_seen_exit(struct snapshots_seen *s) -{ - kfree(s->ids.data); - s->ids.data = NULL; -} - -static inline void snapshots_seen_init(struct snapshots_seen *s) -{ - memset(s, 0, sizeof(*s)); -} - -static inline int snapshots_seen_add(struct bch_fs *c, struct snapshots_seen *s, u32 id) -{ - int ret = darray_push(&s->ids, id); - if (ret) - bch_err(c, "error reallocating snapshots_seen table (size %zu)", - s->ids.size); - return ret; -} - static inline bool snapshot_list_has_id(snapshot_id_list *s, u32 id) { u32 *i; |