diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-03-13 04:30:39 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:12 +0300 |
commit | 8c6d298ab22fc1b2912ccef4ffd4a01b35f9c5b4 (patch) | |
tree | 026aaa4b9aed72be98f92b1f615c342fc999fbc0 /fs/bcachefs/reflink.c | |
parent | ef1669ffc69c4926066451e1d0bc32e5ed6fc7d7 (diff) | |
download | linux-8c6d298ab22fc1b2912ccef4ffd4a01b35f9c5b4.tar.xz |
bcachefs: Convert io paths for snapshots
This plumbs around the subvolume ID as was done previously for other
filesystem code, but now for the IO paths - the control flow in the IO
paths is trickier so the changes in this patch are more involved.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/reflink.c')
-rw-r--r-- | fs/bcachefs/reflink.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c index be4b47bc7438..92ff609453b8 100644 --- a/fs/bcachefs/reflink.c +++ b/fs/bcachefs/reflink.c @@ -212,6 +212,7 @@ s64 bch2_remap_range(struct bch_fs *c, struct bpos dst_end = dst_start, src_end = src_start; struct bpos src_want; u64 dst_done; + u32 dst_snapshot, src_snapshot; int ret = 0, ret2 = 0; if (!percpu_ref_tryget(&c->writes)) @@ -243,15 +244,19 @@ s64 bch2_remap_range(struct bch_fs *c, } ret = bch2_subvolume_get_snapshot(&trans, src_inum.subvol, - &src_iter.snapshot); + &src_snapshot); if (ret) continue; + bch2_btree_iter_set_snapshot(&src_iter, src_snapshot); + ret = bch2_subvolume_get_snapshot(&trans, dst_inum.subvol, - &dst_iter.snapshot); + &dst_snapshot); if (ret) continue; + bch2_btree_iter_set_snapshot(&dst_iter, dst_snapshot); + dst_done = dst_iter.pos.offset - dst_start.offset; src_want = POS(src_start.inode, src_start.offset + dst_done); bch2_btree_iter_set_pos(&src_iter, src_want); @@ -262,11 +267,11 @@ s64 bch2_remap_range(struct bch_fs *c, continue; if (bkey_cmp(src_want, src_iter.pos) < 0) { - ret = bch2_fpunch_at(&trans, &dst_iter, - bpos_min(dst_end, - POS(dst_iter.pos.inode, dst_iter.pos.offset + - src_iter.pos.offset - src_want.offset)), - journal_seq, i_sectors_delta); + ret = bch2_fpunch_at(&trans, &dst_iter, dst_inum, + min(dst_end.offset, + dst_iter.pos.offset + + src_iter.pos.offset - src_want.offset), + journal_seq, i_sectors_delta); continue; } @@ -303,8 +308,9 @@ s64 bch2_remap_range(struct bch_fs *c, bch2_key_resize(&new_dst.k->k, min(src_k.k->p.offset - src_want.offset, dst_end.offset - dst_iter.pos.offset)); - ret = bch2_extent_update(&trans, &dst_iter, new_dst.k, - &disk_res, journal_seq, + + ret = bch2_extent_update(&trans, dst_inum, &dst_iter, + new_dst.k, &disk_res, journal_seq, new_i_size, i_sectors_delta, true); bch2_disk_reservation_put(c, &disk_res); |