summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bcachefs_format.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-31 17:06:29 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:21 -0400
commit528b18e6d1c67ccf4ab01cdee94299f3ac61e1ec (patch)
treed049e73bbff26298b6d4d159e8f65c80308c0031 /fs/bcachefs/bcachefs_format.h
parentfb64f3fdac7171d1b2c62239d512b749dec9582a (diff)
bcachefs: bch2_journal_entry_to_text()
This adds a _to_text() pretty printer for journal entries - including every subtype - which will shortly be used by the 'bcachefs list_journal' subcommand. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/bcachefs_format.h')
-rw-r--r--fs/bcachefs/bcachefs_format.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index 7eeab46d21b5..ace3df19950d 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -76,6 +76,7 @@
#include <asm/byteorder.h>
#include <linux/kernel.h>
#include <linux/uuid.h>
+#include "vstructs.h"
#ifdef __KERNEL__
typedef uuid_t __uuid_t;
@@ -1699,11 +1700,16 @@ struct jset_entry_blacklist_v2 {
__le64 end;
};
+#define BCH_FS_USAGE_TYPES() \
+ x(reserved, 0) \
+ x(inodes, 1) \
+ x(key_version, 2)
+
enum {
- FS_USAGE_RESERVED = 0,
- FS_USAGE_INODES = 1,
- FS_USAGE_KEY_VERSION = 2,
- FS_USAGE_NR = 3
+#define x(f, nr) BCH_FS_USAGE_##f = nr,
+ BCH_FS_USAGE_TYPES()
+#undef x
+ BCH_FS_USAGE_NR
};
struct jset_entry_usage {
@@ -1741,6 +1747,12 @@ struct jset_entry_dev_usage {
struct jset_entry_dev_usage_type d[];
} __attribute__((packed));
+static inline unsigned jset_entry_dev_usage_nr_types(struct jset_entry_dev_usage *u)
+{
+ return (vstruct_bytes(&u->entry) - sizeof(struct jset_entry_dev_usage)) /
+ sizeof(struct jset_entry_dev_usage_type);
+}
+
struct jset_entry_log {
struct jset_entry entry;
u8 d[];