diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-10-12 21:25:13 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:13 +0300 |
commit | 776eaddb2cef366b16dac8857899dbb4cc5dfdb1 (patch) | |
tree | c127b190ca5eb942cd7570a88e779235cf819e08 /fs/bcachefs/migrate.c | |
parent | 395576807555fa9ffb2ae038cae1fe2699f85b89 (diff) | |
download | linux-776eaddb2cef366b16dac8857899dbb4cc5dfdb1.tar.xz |
bcachefs: Fix deletion in __bch2_dev_usrdata_drop()
With snapshots, __bch2_dev_usr_data_drop() now uses an ALL_SNAPSHOTS
iterator, which isn't an extent iterator - meaning we shouldn't be
inserting whiteouts with nonzero size to delete. This fixes a bug where
we go RO because we tried to insert an invalid key in the device remove
path.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/migrate.c')
-rw-r--r-- | fs/bcachefs/migrate.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/bcachefs/migrate.c b/fs/bcachefs/migrate.c index 9f9eb799337e..94d5d99ffd2a 100644 --- a/fs/bcachefs/migrate.c +++ b/fs/bcachefs/migrate.c @@ -73,6 +73,15 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags */ bch2_extent_normalize(c, bkey_i_to_s(sk.k)); + /* + * Since we're not inserting through an extent iterator + * (BTREE_ITER_ALL_SNAPSHOTS iterators aren't extent iterators), + * we aren't using the extent overwrite path to delete, we're + * just using the normal key deletion path: + */ + if (bkey_deleted(&sk.k->k)) + sk.k->k.size = 0; + ret = bch2_btree_iter_traverse(&iter) ?: bch2_trans_update(&trans, &iter, sk.k, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: |