summaryrefslogtreecommitdiff
path: root/libbcachefs/inode.h
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/inode.h')
-rw-r--r--libbcachefs/inode.h44
1 files changed, 24 insertions, 20 deletions
diff --git a/libbcachefs/inode.h b/libbcachefs/inode.h
index 44855e1a..0d609985 100644
--- a/libbcachefs/inode.h
+++ b/libbcachefs/inode.h
@@ -5,6 +5,8 @@
#include <linux/math64.h>
+extern const char * const bch2_inode_opts[];
+
const char *bch2_inode_invalid(const struct bch_fs *, struct bkey_s_c);
void bch2_inode_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
@@ -29,17 +31,17 @@ struct bch_inode_unpacked {
u32 bi_flags;
u16 bi_mode;
-#define BCH_INODE_FIELD(_name, _bits) u##_bits _name;
+#define x(_name, _bits) u##_bits _name;
BCH_INODE_FIELDS()
-#undef BCH_INODE_FIELD
+#undef x
};
struct bkey_inode_buf {
struct bkey_i_inode inode;
-#define BCH_INODE_FIELD(_name, _bits) + 8 + _bits / 8
+#define x(_name, _bits) + 8 + _bits / 8
u8 _pad[0 + BCH_INODE_FIELDS()];
-#undef BCH_INODE_FIELD
+#undef x
} __attribute__((packed, aligned(8)));
void bch2_inode_pack(struct bkey_inode_buf *, const struct bch_inode_unpacked *);
@@ -79,39 +81,41 @@ static inline struct bch_io_opts bch2_inode_opts_get(struct bch_inode_unpacked *
{
struct bch_io_opts ret = { 0 };
-#define BCH_INODE_OPT(_name, _bits) \
+#define x(_name, _bits) \
if (inode->bi_##_name) \
opt_set(ret, _name, inode->bi_##_name - 1);
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
return ret;
}
-static inline void __bch2_inode_opt_set(struct bch_inode_unpacked *inode,
- enum bch_opt_id id, u64 v)
+static inline void bch2_inode_opt_set(struct bch_inode_unpacked *inode,
+ enum inode_opt_id id, u64 v)
{
switch (id) {
-#define BCH_INODE_OPT(_name, ...) \
- case Opt_##_name: \
+#define x(_name, ...) \
+ case Inode_opt_##_name: \
inode->bi_##_name = v; \
break;
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
default:
BUG();
}
}
-static inline void bch2_inode_opt_set(struct bch_inode_unpacked *inode,
- enum bch_opt_id id, u64 v)
-{
- return __bch2_inode_opt_set(inode, id, v + 1);
-}
-
-static inline void bch2_inode_opt_clear(struct bch_inode_unpacked *inode,
- enum bch_opt_id id)
+static inline u64 bch2_inode_opt_get(struct bch_inode_unpacked *inode,
+ enum inode_opt_id id)
{
- return __bch2_inode_opt_set(inode, id, 0);
+ switch (id) {
+#define x(_name, ...) \
+ case Inode_opt_##_name: \
+ return inode->bi_##_name;
+ BCH_INODE_OPTS()
+#undef x
+ default:
+ BUG();
+ }
}
#ifdef CONFIG_BCACHEFS_DEBUG