diff options
author | Daniel Hill <daniel@gluo.nz> | 2022-12-09 12:37:56 +1300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:52 -0400 |
commit | f3a37e76cade1469871c4309584ebbc358becf40 (patch) | |
tree | 9dce0999433112973b65c41552cc017aea5a009d /fs/bcachefs/data_update.c | |
parent | 71fe14655f49f717b06d92192f2492c22da6b3af (diff) | |
download | linux-f3a37e76cade1469871c4309584ebbc358becf40.tar.gz linux-f3a37e76cade1469871c4309584ebbc358becf40.tar.bz2 linux-f3a37e76cade1469871c4309584ebbc358becf40.zip |
bcachefs: handle failed data_update_init cleanup
data_update_init allocates several resources, but we forget to clean
these up when it fails.
Signed-off-by: Daniel Hill <daniel@gluo.nz>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/data_update.c')
-rw-r--r-- | fs/bcachefs/data_update.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index c3f12b3adb14..190ad03910af 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -469,7 +469,7 @@ int bch2_data_update_init(struct bch_fs *c, struct data_update *m, ? 0 : BCH_DISK_RESERVATION_NOFAIL); if (ret) - return ret; + goto err; } m->op.nr_replicas = m->op.nr_replicas_required = @@ -481,6 +481,14 @@ int bch2_data_update_init(struct bch_fs *c, struct data_update *m, if (bkey_extent_is_unwritten(k)) return -BCH_ERR_unwritten_extent_update; return 0; +err: + bkey_for_each_ptr_decode(k.k, ptrs, p, entry) + bch2_bucket_nocow_unlock(&c->nocow_locks, + PTR_BUCKET_POS(c, &p.ptr), 0); + + bch2_bkey_buf_exit(&m->k, c); + bch2_bio_free_pages_pool(c, &m->op.wbio.bio); + return ret; } void bch2_data_update_opts_normalize(struct bkey_s_c k, struct data_update_opts *opts) |