diff options
author | 2024-10-09 21:51:05 -0400 | |
---|---|---|
committer | 2024-12-21 01:36:15 -0500 | |
commit | 106480e9a869e8d2dd2db34819d04e15ccfd896c (patch) | |
tree | e61bcc3c771a863aedb56eccbb0c6dc61551e5d4 | |
parent | bcachefs: improved bkey_val_copy() (diff) | |
download | linux-rng-106480e9a869e8d2dd2db34819d04e15ccfd896c.tar.xz linux-rng-106480e9a869e8d2dd2db34819d04e15ccfd896c.zip |
bcachefs: Factor out jset_entry_log_msg_bytes()
Needed for improved userspace cmd_list_journal
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/bcachefs_format.h | 9 | ||||
-rw-r--r-- | fs/bcachefs/journal_io.c | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 79a80a78c2d8..c5e3824d5771 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1219,6 +1219,15 @@ struct jset_entry_log { u8 d[]; } __packed __aligned(8); +static inline unsigned jset_entry_log_msg_bytes(struct jset_entry_log *l) +{ + unsigned b = vstruct_bytes(&l->entry) - offsetof(struct jset_entry_log, d); + + while (b && !l->d[b - 1]) + --b; + return b; +} + struct jset_entry_datetime { struct jset_entry entry; __le64 seconds; diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index fb35dd336331..7c7595e5369b 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -738,9 +738,8 @@ static void journal_entry_log_to_text(struct printbuf *out, struct bch_fs *c, struct jset_entry *entry) { struct jset_entry_log *l = container_of(entry, struct jset_entry_log, entry); - unsigned bytes = vstruct_bytes(entry) - offsetof(struct jset_entry_log, d); - prt_printf(out, "%.*s", bytes, l->d); + prt_printf(out, "%.*s", jset_entry_log_msg_bytes(l), l->d); } static int journal_entry_overwrite_validate(struct bch_fs *c, |