Commit f3a37e76 authored by Daniel Hill's avatar Daniel Hill Committed by Kent Overstreet

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: default avatarDaniel Hill <daniel@gluo.nz>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 71fe1465
...@@ -469,7 +469,7 @@ int bch2_data_update_init(struct bch_fs *c, struct data_update *m, ...@@ -469,7 +469,7 @@ int bch2_data_update_init(struct bch_fs *c, struct data_update *m,
? 0 ? 0
: BCH_DISK_RESERVATION_NOFAIL); : BCH_DISK_RESERVATION_NOFAIL);
if (ret) if (ret)
return ret; goto err;
} }
m->op.nr_replicas = m->op.nr_replicas_required = 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, ...@@ -481,6 +481,14 @@ int bch2_data_update_init(struct bch_fs *c, struct data_update *m,
if (bkey_extent_is_unwritten(k)) if (bkey_extent_is_unwritten(k))
return -BCH_ERR_unwritten_extent_update; return -BCH_ERR_unwritten_extent_update;
return 0; 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) void bch2_data_update_opts_normalize(struct bkey_s_c k, struct data_update_opts *opts)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment