diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-14 21:48:42 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:29 -0400 |
commit | 31f63fd1244d9609265eb5cfc522c142b35cdacc (patch) | |
tree | ba7e780ac34fe7ce6f6647b0a47f4da301b26d83 /fs/bcachefs/journal_types.h | |
parent | d905f67ec89fda758bcfa70d0b5c3d3006bbdb3e (diff) | |
download | linux-stable-31f63fd1244d9609265eb5cfc522c142b35cdacc.tar.gz linux-stable-31f63fd1244d9609265eb5cfc522c142b35cdacc.tar.bz2 linux-stable-31f63fd1244d9609265eb5cfc522c142b35cdacc.zip |
bcachefs: Introduce a separate journal watermark for copygc
Since journal reclaim -> btree key cache flushing may require the
allocation of new btree nodes, it has an implicit dependency on copygc
in order to make forward progress - so we should avoid blocking copygc
unless the journal is really close to full.
This introduces watermarks to replace our single MAY_GET_UNRESERVED bit
in the journal, and adds a watermark for copygc and plumbs it through.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_types.h')
-rw-r--r-- | fs/bcachefs/journal_types.h | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/fs/bcachefs/journal_types.h b/fs/bcachefs/journal_types.h index 91f829adf862..a41b915b3ac6 100644 --- a/fs/bcachefs/journal_types.h +++ b/fs/bcachefs/journal_types.h @@ -144,16 +144,45 @@ enum journal_space_from { enum { JOURNAL_REPLAY_DONE, JOURNAL_STARTED, - JOURNAL_MAY_GET_UNRESERVED, JOURNAL_MAY_SKIP_FLUSH, }; +#define JOURNAL_WATERMARKS() \ + x(any) \ + x(copygc) \ + x(reserved) + +enum journal_watermark { +#define x(n) JOURNAL_WATERMARK_##n, + JOURNAL_WATERMARKS() +#undef x +}; + +#define JOURNAL_WATERMARK_MASK 3 + +/* Reasons we may fail to get a journal reservation: */ +#define JOURNAL_ERRORS() \ + x(ok) \ + x(blocked) \ + x(max_in_flight) \ + x(journal_full) \ + x(journal_pin_full) \ + x(journal_stuck) \ + x(insufficient_devices) + +enum journal_errors { +#define x(n) JOURNAL_ERR_##n, + JOURNAL_ERRORS() +#undef x +}; + /* Embedded in struct bch_fs */ struct journal { /* Fastpath stuff up front: */ struct { union journal_res_state reservations; + enum journal_watermark watermark; union journal_preres_state prereserved; @@ -173,15 +202,7 @@ struct journal { * 0, or -ENOSPC if waiting on journal reclaim, or -EROFS if * insufficient devices: */ - enum { - cur_entry_ok, - cur_entry_blocked, - cur_entry_max_in_flight, - cur_entry_journal_full, - cur_entry_journal_pin_full, - cur_entry_journal_stuck, - cur_entry_insufficient_devices, - } cur_entry_error; + enum journal_errors cur_entry_error; unsigned buf_size_want; /* |