diff options
| author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-01-19 13:55:33 -0500 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-03-14 21:02:11 -0400 |
| commit | 7e9ed60f5fe58dd4b4b6dcf63e57154c6262a2af (patch) | |
| tree | 623543adf499b31adf6d1c1f4960901defa79c1e /fs/bcachefs/alloc_foreground.h | |
| parent | bcachefs: Rework init order in bch2_data_update_init() (diff) | |
| download | linux-7e9ed60f5fe58dd4b4b6dcf63e57154c6262a2af.tar.gz linux-7e9ed60f5fe58dd4b4b6dcf63e57154c6262a2af.zip | |
bcachefs: Bail out early on alloc_nowait data updates
If a data update doesn't want to block on allocations (promotes, self
healing on read error) - check if the allocation would fail before
kicking off the data update and calling into the write path.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_foreground.h')
| -rw-r--r-- | fs/bcachefs/alloc_foreground.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/bcachefs/alloc_foreground.h b/fs/bcachefs/alloc_foreground.h index f25481a0d1a0..baf5dc163c8a 100644 --- a/fs/bcachefs/alloc_foreground.h +++ b/fs/bcachefs/alloc_foreground.h @@ -33,6 +33,23 @@ static inline struct bch_dev *ob_dev(struct bch_fs *c, struct open_bucket *ob) return bch2_dev_have_ref(c, ob->dev); } +static inline unsigned bch2_open_buckets_reserved(enum bch_watermark watermark) +{ + switch (watermark) { + case BCH_WATERMARK_interior_updates: + return 0; + case BCH_WATERMARK_reclaim: + return OPEN_BUCKETS_COUNT / 6; + case BCH_WATERMARK_btree: + case BCH_WATERMARK_btree_copygc: + return OPEN_BUCKETS_COUNT / 4; + case BCH_WATERMARK_copygc: + return OPEN_BUCKETS_COUNT / 3; + default: + return OPEN_BUCKETS_COUNT / 2; + } +} + struct open_bucket *bch2_bucket_alloc(struct bch_fs *, struct bch_dev *, enum bch_watermark, enum bch_data_type, struct closure *); |
