diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-28 07:16:37 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:55 +0300 |
commit | 11bb67a4a31d9581a3148a75e023e680197f25fe (patch) | |
tree | d873e85668670c536cb6f65cc98f8e3b86b558f7 /fs | |
parent | a64adedb8663ded044e535159b2e723a04396845 (diff) | |
download | linux-11bb67a4a31d9581a3148a75e023e680197f25fe.tar.xz |
bcachefs: bch2_data_update_init() considers ptr durability
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/data_update.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index 84c2963d4069..b3216f50bb3c 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -425,7 +425,7 @@ int bch2_data_update_init(struct btree_trans *trans, struct extent_ptr_decoded p; const struct bch_extent_ptr *ptr; unsigned i, reserve_sectors = k.k->size * data_opts.extra_replicas; - unsigned int ptrs_locked = 0; + unsigned ptrs_locked = 0; int ret; bch2_bkey_buf_init(&m->k); @@ -438,6 +438,7 @@ int bch2_data_update_init(struct btree_trans *trans, m->op.version = k.k->version; m->op.target = data_opts.target; m->op.write_point = wp; + m->op.nr_replicas = 0; m->op.flags |= BCH_WRITE_PAGES_STABLE| BCH_WRITE_PAGES_OWNED| BCH_WRITE_DATA_ENCODED| @@ -456,17 +457,16 @@ int bch2_data_update_init(struct btree_trans *trans, bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { bool locked; - if (((1U << i) & m->data_opts.rewrite_ptrs) && - p.ptr.cached) - BUG(); + if (((1U << i) & m->data_opts.rewrite_ptrs)) { + BUG_ON(p.ptr.cached); - if (!((1U << i) & m->data_opts.rewrite_ptrs) && - !p.ptr.cached) - bch2_dev_list_add_dev(&m->op.devs_have, p.ptr.dev); + if (crc_is_compressed(p.crc)) + reserve_sectors += k.k->size; - if (((1U << i) & m->data_opts.rewrite_ptrs) && - crc_is_compressed(p.crc)) - reserve_sectors += k.k->size; + m->op.nr_replicas += bch2_extent_ptr_durability(c, &p); + } else if (!p.ptr.cached) { + bch2_dev_list_add_dev(&m->op.devs_have, p.ptr.dev); + } /* * op->csum_type is normally initialized from the fs/file's @@ -513,8 +513,8 @@ int bch2_data_update_init(struct btree_trans *trans, goto err; } - m->op.nr_replicas = m->op.nr_replicas_required = - hweight32(m->data_opts.rewrite_ptrs) + m->data_opts.extra_replicas; + m->op.nr_replicas += m->data_opts.extra_replicas; + m->op.nr_replicas_required = m->op.nr_replicas; BUG_ON(!m->op.nr_replicas); |