diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-08-05 00:41:41 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:12 -0400 |
commit | 18443cb9f005b5563e2e3da9b8ccd374a552c3b1 (patch) | |
tree | fb5acd81fb8562bd790263562c65d3cdf45a02d4 /fs/bcachefs/fsck.c | |
parent | 7a7d17b2f7c23c0891b0cbd13fafd3bc805b1b29 (diff) |
bcachefs: Update data move path for snapshots
The data move path operates on existing extents, and not within a
subvolume as the regular IO paths do. It needs to change because it may
cause existing extents to be split, and when splitting an existing
extent in an ancestor snapshot we need to make sure the new split has
the same visibility in child snapshots as the existing extent.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/fsck.c')
-rw-r--r-- | fs/bcachefs/fsck.c | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index b4a6b3d2ed07..f9a6a0b3ce7a 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -473,24 +473,6 @@ out: return ret; } -struct snapshots_seen { - struct bpos pos; - size_t nr; - size_t size; - u32 *d; -}; - -static void snapshots_seen_exit(struct snapshots_seen *s) -{ - kfree(s->d); - s->d = NULL; -} - -static void snapshots_seen_init(struct snapshots_seen *s) -{ - memset(s, 0, sizeof(*s)); -} - static int snapshots_seen_update(struct bch_fs *c, struct snapshots_seen *s, struct bpos pos) { pos.snapshot = snapshot_t(c, pos.snapshot)->equiv; @@ -499,26 +481,11 @@ static int snapshots_seen_update(struct bch_fs *c, struct snapshots_seen *s, str s->nr = 0; s->pos = pos; - if (s->nr == s->size) { - size_t new_size = max(s->size, 128UL) * 2; - u32 *d = krealloc(s->d, new_size * sizeof(s->d[0]), GFP_KERNEL); - - if (!d) { - bch_err(c, "error reallocating snapshots_seen table (new size %zu)", - new_size); - return -ENOMEM; - } - - s->size = new_size; - s->d = d; - } - /* Might get called multiple times due to lock restarts */ if (s->nr && s->d[s->nr - 1] == pos.snapshot) return 0; - s->d[s->nr++] = pos.snapshot; - return 0; + return snapshots_seen_add(c, s, pos.snapshot); } /** |