Commit e7f63c67 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: plumb data_type into bch2_bucket_alloc_trans()

prep work for making the allocator try to keep btree nodes within the
existing member info btree allocated bitmap
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 018b32a6
...@@ -516,6 +516,7 @@ static struct open_bucket *bch2_bucket_alloc_freelist(struct btree_trans *trans, ...@@ -516,6 +516,7 @@ static struct open_bucket *bch2_bucket_alloc_freelist(struct btree_trans *trans,
* @trans: transaction object * @trans: transaction object
* @ca: device to allocate from * @ca: device to allocate from
* @watermark: how important is this allocation? * @watermark: how important is this allocation?
* @data_type: BCH_DATA_journal, btree, user...
* @cl: if not NULL, closure to be used to wait if buckets not available * @cl: if not NULL, closure to be used to wait if buckets not available
* @usage: for secondarily also returning the current device usage * @usage: for secondarily also returning the current device usage
* *
...@@ -524,6 +525,7 @@ static struct open_bucket *bch2_bucket_alloc_freelist(struct btree_trans *trans, ...@@ -524,6 +525,7 @@ static struct open_bucket *bch2_bucket_alloc_freelist(struct btree_trans *trans,
static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans, static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
struct bch_dev *ca, struct bch_dev *ca,
enum bch_watermark watermark, enum bch_watermark watermark,
enum bch_data_type data_type,
struct closure *cl, struct closure *cl,
struct bch_dev_usage *usage) struct bch_dev_usage *usage)
{ {
...@@ -577,6 +579,9 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans, ...@@ -577,6 +579,9 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
if (!ob) if (!ob)
ob = ERR_PTR(-BCH_ERR_no_buckets_found); ob = ERR_PTR(-BCH_ERR_no_buckets_found);
if (!IS_ERR(ob))
ob->data_type = data_type;
if (!IS_ERR(ob)) if (!IS_ERR(ob))
trace_and_count(c, bucket_alloc, ca, trace_and_count(c, bucket_alloc, ca,
bch2_watermarks[watermark], bch2_watermarks[watermark],
...@@ -605,6 +610,7 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans, ...@@ -605,6 +610,7 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca, struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca,
enum bch_watermark watermark, enum bch_watermark watermark,
enum bch_data_type data_type,
struct closure *cl) struct closure *cl)
{ {
struct bch_dev_usage usage; struct bch_dev_usage usage;
...@@ -612,7 +618,7 @@ struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca, ...@@ -612,7 +618,7 @@ struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca,
bch2_trans_do(c, NULL, NULL, 0, bch2_trans_do(c, NULL, NULL, 0,
PTR_ERR_OR_ZERO(ob = bch2_bucket_alloc_trans(trans, ca, watermark, PTR_ERR_OR_ZERO(ob = bch2_bucket_alloc_trans(trans, ca, watermark,
cl, &usage))); data_type, cl, &usage)));
return ob; return ob;
} }
...@@ -738,7 +744,7 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans, ...@@ -738,7 +744,7 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
continue; continue;
} }
ob = bch2_bucket_alloc_trans(trans, ca, watermark, cl, &usage); ob = bch2_bucket_alloc_trans(trans, ca, watermark, data_type, cl, &usage);
if (!IS_ERR(ob)) if (!IS_ERR(ob))
bch2_dev_stripe_increment_inlined(ca, stripe, &usage); bch2_dev_stripe_increment_inlined(ca, stripe, &usage);
percpu_ref_put(&ca->ref); percpu_ref_put(&ca->ref);
...@@ -750,8 +756,6 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans, ...@@ -750,8 +756,6 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
continue; continue;
} }
ob->data_type = data_type;
if (add_new_bucket(c, ptrs, devs_may_alloc, if (add_new_bucket(c, ptrs, devs_may_alloc,
nr_replicas, nr_effective, nr_replicas, nr_effective,
have_cache, flags, ob)) { have_cache, flags, ob)) {
......
...@@ -31,7 +31,8 @@ void bch2_dev_stripe_increment(struct bch_dev *, struct dev_stripe_state *); ...@@ -31,7 +31,8 @@ void bch2_dev_stripe_increment(struct bch_dev *, struct dev_stripe_state *);
long bch2_bucket_alloc_new_fs(struct bch_dev *); long bch2_bucket_alloc_new_fs(struct bch_dev *);
struct open_bucket *bch2_bucket_alloc(struct bch_fs *, struct bch_dev *, struct open_bucket *bch2_bucket_alloc(struct bch_fs *, struct bch_dev *,
enum bch_watermark, struct closure *); enum bch_watermark, enum bch_data_type,
struct closure *);
static inline void ob_push(struct bch_fs *c, struct open_buckets *obs, static inline void ob_push(struct bch_fs *c, struct open_buckets *obs,
struct open_bucket *ob) struct open_bucket *ob)
......
...@@ -938,7 +938,8 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr, ...@@ -938,7 +938,8 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
break; break;
} }
} else { } else {
ob[nr_got] = bch2_bucket_alloc(c, ca, BCH_WATERMARK_normal, cl); ob[nr_got] = bch2_bucket_alloc(c, ca, BCH_WATERMARK_normal,
BCH_DATA_journal, cl);
ret = PTR_ERR_OR_ZERO(ob[nr_got]); ret = PTR_ERR_OR_ZERO(ob[nr_got]);
if (ret) if (ret)
break; break;
......
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