Commit 57af63b2 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: bch2_alloc_sectors_append_ptrs() now takes cached flag

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 04f0f77d
...@@ -866,7 +866,8 @@ struct write_point *bch2_alloc_sectors_start(struct bch_fs *c, ...@@ -866,7 +866,8 @@ struct write_point *bch2_alloc_sectors_start(struct bch_fs *c,
* as allocated out of @ob * as allocated out of @ob
*/ */
void bch2_alloc_sectors_append_ptrs(struct bch_fs *c, struct write_point *wp, void bch2_alloc_sectors_append_ptrs(struct bch_fs *c, struct write_point *wp,
struct bkey_i *k, unsigned sectors) struct bkey_i *k, unsigned sectors,
bool cached)
{ {
struct open_bucket *ob; struct open_bucket *ob;
...@@ -877,13 +878,14 @@ void bch2_alloc_sectors_append_ptrs(struct bch_fs *c, struct write_point *wp, ...@@ -877,13 +878,14 @@ void bch2_alloc_sectors_append_ptrs(struct bch_fs *c, struct write_point *wp,
open_bucket_for_each(c, &wp->ptrs, ob, i) { open_bucket_for_each(c, &wp->ptrs, ob, i) {
struct bch_dev *ca = bch_dev_bkey_exists(c, ob->ptr.dev); struct bch_dev *ca = bch_dev_bkey_exists(c, ob->ptr.dev);
struct bch_extent_ptr tmp = ob->ptr; struct bch_extent_ptr ptr = ob->ptr;
tmp.cached = !ca->mi.durability && ptr.cached = cached ||
wp->type == BCH_DATA_user; (!ca->mi.durability &&
wp->type == BCH_DATA_user);
tmp.offset += ca->mi.bucket_size - ob->sectors_free; ptr.offset += ca->mi.bucket_size - ob->sectors_free;
bch2_bkey_append_ptr(k, tmp); bch2_bkey_append_ptr(k, ptr);
BUG_ON(sectors > ob->sectors_free); BUG_ON(sectors > ob->sectors_free);
ob->sectors_free -= sectors; ob->sectors_free -= sectors;
......
...@@ -106,7 +106,7 @@ struct write_point *bch2_alloc_sectors_start(struct bch_fs *, ...@@ -106,7 +106,7 @@ struct write_point *bch2_alloc_sectors_start(struct bch_fs *,
struct closure *); struct closure *);
void bch2_alloc_sectors_append_ptrs(struct bch_fs *, struct write_point *, void bch2_alloc_sectors_append_ptrs(struct bch_fs *, struct write_point *,
struct bkey_i *, unsigned); struct bkey_i *, unsigned, bool);
void bch2_alloc_sectors_done(struct bch_fs *, struct write_point *); void bch2_alloc_sectors_done(struct bch_fs *, struct write_point *);
void bch2_open_buckets_stop_dev(struct bch_fs *, struct bch_dev *, void bch2_open_buckets_stop_dev(struct bch_fs *, struct bch_dev *,
......
...@@ -236,7 +236,7 @@ static struct btree *__bch2_btree_node_alloc(struct bch_fs *c, ...@@ -236,7 +236,7 @@ static struct btree *__bch2_btree_node_alloc(struct bch_fs *c,
} }
bkey_btree_ptr_v2_init(&tmp.k); bkey_btree_ptr_v2_init(&tmp.k);
bch2_alloc_sectors_append_ptrs(c, wp, &tmp.k, btree_sectors(c)); bch2_alloc_sectors_append_ptrs(c, wp, &tmp.k, btree_sectors(c), false);
bch2_open_bucket_get(c, wp, &ob); bch2_open_bucket_get(c, wp, &ob);
bch2_alloc_sectors_done(c, wp); bch2_alloc_sectors_done(c, wp);
......
...@@ -746,7 +746,6 @@ static void init_append_extent(struct bch_write_op *op, ...@@ -746,7 +746,6 @@ static void init_append_extent(struct bch_write_op *op,
struct bch_extent_crc_unpacked crc) struct bch_extent_crc_unpacked crc)
{ {
struct bkey_i_extent *e; struct bkey_i_extent *e;
struct bch_extent_ptr *ptr;
op->pos.offset += crc.uncompressed_size; op->pos.offset += crc.uncompressed_size;
...@@ -760,11 +759,8 @@ static void init_append_extent(struct bch_write_op *op, ...@@ -760,11 +759,8 @@ static void init_append_extent(struct bch_write_op *op,
crc.nonce) crc.nonce)
bch2_extent_crc_append(&e->k_i, crc); bch2_extent_crc_append(&e->k_i, crc);
bch2_alloc_sectors_append_ptrs(op->c, wp, &e->k_i, crc.compressed_size); bch2_alloc_sectors_append_ptrs(op->c, wp, &e->k_i, crc.compressed_size,
op->flags & BCH_WRITE_CACHED);
if (op->flags & BCH_WRITE_CACHED)
extent_for_each_ptr(extent_i_to_s(e), ptr)
ptr->cached = true;
bch2_keylist_push(&op->insert_keys); bch2_keylist_push(&op->insert_keys);
} }
......
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