diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-02-19 13:41:36 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:17 -0400 |
commit | 68ef94a63caf214ee238434bf0d4c7a6a32c33a2 (patch) | |
tree | 903e1c65cc599f98f6417e0ca845247b850b9148 /fs/bcachefs/journal_types.h | |
parent | 9ace606e93e9c6dff919ca8f35d461e8462590b7 (diff) | |
download | linux-stable-68ef94a63caf214ee238434bf0d4c7a6a32c33a2.tar.gz linux-stable-68ef94a63caf214ee238434bf0d4c7a6a32c33a2.tar.bz2 linux-stable-68ef94a63caf214ee238434bf0d4c7a6a32c33a2.zip |
bcachefs: Add a pre-reserve mechanism for the journal
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 | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_types.h b/fs/bcachefs/journal_types.h index c91a21e07809..85bf5e2706f7 100644 --- a/fs/bcachefs/journal_types.h +++ b/fs/bcachefs/journal_types.h @@ -80,6 +80,14 @@ struct journal_res { u64 seq; }; +/* + * For reserving space in the journal prior to getting a reservation on a + * particular journal entry: + */ +struct journal_preres { + unsigned u64s; +}; + union journal_res_state { struct { atomic64_t counter; @@ -98,6 +106,21 @@ union journal_res_state { }; }; +union journal_preres_state { + struct { + atomic64_t counter; + }; + + struct { + u64 v; + }; + + struct { + u32 reserved; + u32 remaining; + }; +}; + /* bytes: */ #define JOURNAL_ENTRY_SIZE_MIN (64U << 10) /* 64k */ #define JOURNAL_ENTRY_SIZE_MAX (4U << 20) /* 4M */ @@ -122,6 +145,7 @@ enum { JOURNAL_STARTED, JOURNAL_NEED_WRITE, JOURNAL_NOT_EMPTY, + JOURNAL_MAY_GET_UNRESERVED, }; /* Embedded in struct bch_fs */ @@ -142,6 +166,8 @@ struct journal { */ int cur_entry_error; + union journal_preres_state prereserved; + /* Reserved space in journal entry to be used just prior to write */ unsigned entry_u64s_reserved; @@ -161,6 +187,7 @@ struct journal { /* Used when waiting because the journal was full */ wait_queue_head_t wait; struct closure_waitlist async_wait; + struct closure_waitlist preres_wait; struct closure io; struct delayed_work write_work; |