summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-12-13 06:01:30 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2018-12-27 11:38:37 -0500
commit24ac71e96b8995e8413324a6d00225572ccba875 (patch)
tree41c472a4805f1789841a10ad7bc7f67f701d3e85
parent3c2308d4582591375df91a7daf8142254674d91c (diff)
bcachefs: use x-macros more consistently
-rw-r--r--fs/bcachefs/bcachefs_format.h64
-rw-r--r--fs/bcachefs/inode.c20
-rw-r--r--fs/bcachefs/inode.h16
-rw-r--r--fs/bcachefs/opts.c16
-rw-r--r--fs/bcachefs/opts.h26
5 files changed, 71 insertions, 71 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index efda901efae1..4ce8943c263b 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -689,38 +689,38 @@ struct bch_inode_generation {
__le32 pad;
} __attribute__((packed, aligned(8)));
-#define BCH_INODE_FIELDS() \
- BCH_INODE_FIELD(bi_atime, 64) \
- BCH_INODE_FIELD(bi_ctime, 64) \
- BCH_INODE_FIELD(bi_mtime, 64) \
- BCH_INODE_FIELD(bi_otime, 64) \
- BCH_INODE_FIELD(bi_size, 64) \
- BCH_INODE_FIELD(bi_sectors, 64) \
- BCH_INODE_FIELD(bi_uid, 32) \
- BCH_INODE_FIELD(bi_gid, 32) \
- BCH_INODE_FIELD(bi_nlink, 32) \
- BCH_INODE_FIELD(bi_generation, 32) \
- BCH_INODE_FIELD(bi_dev, 32) \
- BCH_INODE_FIELD(bi_data_checksum, 8) \
- BCH_INODE_FIELD(bi_compression, 8) \
- BCH_INODE_FIELD(bi_project, 32) \
- BCH_INODE_FIELD(bi_background_compression, 8) \
- BCH_INODE_FIELD(bi_data_replicas, 8) \
- BCH_INODE_FIELD(bi_promote_target, 16) \
- BCH_INODE_FIELD(bi_foreground_target, 16) \
- BCH_INODE_FIELD(bi_background_target, 16) \
- BCH_INODE_FIELD(bi_erasure_code, 16)
-
-#define BCH_INODE_FIELDS_INHERIT() \
- BCH_INODE_FIELD(bi_data_checksum) \
- BCH_INODE_FIELD(bi_compression) \
- BCH_INODE_FIELD(bi_project) \
- BCH_INODE_FIELD(bi_background_compression) \
- BCH_INODE_FIELD(bi_data_replicas) \
- BCH_INODE_FIELD(bi_promote_target) \
- BCH_INODE_FIELD(bi_foreground_target) \
- BCH_INODE_FIELD(bi_background_target) \
- BCH_INODE_FIELD(bi_erasure_code)
+#define BCH_INODE_FIELDS() \
+ x(bi_atime, 64) \
+ x(bi_ctime, 64) \
+ x(bi_mtime, 64) \
+ x(bi_otime, 64) \
+ x(bi_size, 64) \
+ x(bi_sectors, 64) \
+ x(bi_uid, 32) \
+ x(bi_gid, 32) \
+ x(bi_nlink, 32) \
+ x(bi_generation, 32) \
+ x(bi_dev, 32) \
+ x(bi_data_checksum, 8) \
+ x(bi_compression, 8) \
+ x(bi_project, 32) \
+ x(bi_background_compression, 8) \
+ x(bi_data_replicas, 8) \
+ x(bi_promote_target, 16) \
+ x(bi_foreground_target, 16) \
+ x(bi_background_target, 16) \
+ x(bi_erasure_code, 16)
+
+#define BCH_INODE_FIELDS_INHERIT() \
+ x(bi_data_checksum) \
+ x(bi_compression) \
+ x(bi_project) \
+ x(bi_background_compression) \
+ x(bi_data_replicas) \
+ x(bi_promote_target) \
+ x(bi_foreground_target) \
+ x(bi_background_target) \
+ x(bi_erasure_code)
enum {
/*
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index 8c3d4431de10..f46af03cad5e 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -97,7 +97,7 @@ void bch2_inode_pack(struct bkey_inode_buf *packed,
packed->inode.v.bi_flags = cpu_to_le32(inode->bi_flags);
packed->inode.v.bi_mode = cpu_to_le16(inode->bi_mode);
-#define BCH_INODE_FIELD(_name, _bits) \
+#define x(_name, _bits) \
out += inode_encode_field(out, end, 0, inode->_name); \
nr_fields++; \
\
@@ -107,7 +107,7 @@ void bch2_inode_pack(struct bkey_inode_buf *packed,
}
BCH_INODE_FIELDS()
-#undef BCH_INODE_FIELD
+#undef x
out = last_nonzero_field;
nr_fields = last_nonzero_fieldnr;
@@ -129,9 +129,9 @@ void bch2_inode_pack(struct bkey_inode_buf *packed,
BUG_ON(unpacked.bi_hash_seed != inode->bi_hash_seed);
BUG_ON(unpacked.bi_mode != inode->bi_mode);
-#define BCH_INODE_FIELD(_name, _bits) BUG_ON(unpacked._name != inode->_name);
+#define x(_name, _bits) BUG_ON(unpacked._name != inode->_name);
BCH_INODE_FIELDS()
-#undef BCH_INODE_FIELD
+#undef x
}
}
@@ -149,7 +149,7 @@ int bch2_inode_unpack(struct bkey_s_c_inode inode,
unpacked->bi_flags = le32_to_cpu(inode.v->bi_flags);
unpacked->bi_mode = le16_to_cpu(inode.v->bi_mode);
-#define BCH_INODE_FIELD(_name, _bits) \
+#define x(_name, _bits) \
if (fieldnr++ == INODE_NR_FIELDS(inode.v)) { \
memset(&unpacked->_name, 0, \
sizeof(*unpacked) - \
@@ -168,7 +168,7 @@ int bch2_inode_unpack(struct bkey_s_c_inode inode,
in += ret;
BCH_INODE_FIELDS()
-#undef BCH_INODE_FIELD
+#undef x
/* XXX: signal if there were more fields than expected? */
@@ -219,10 +219,10 @@ void bch2_inode_to_text(struct printbuf *out, struct bch_fs *c,
return;
}
-#define BCH_INODE_FIELD(_name, _bits) \
+#define x(_name, _bits) \
pr_buf(out, #_name ": %llu ", (u64) unpacked._name);
BCH_INODE_FIELDS()
-#undef BCH_INODE_FIELD
+#undef x
}
const char *bch2_inode_generation_invalid(const struct bch_fs *c,
@@ -266,9 +266,9 @@ void bch2_inode_init(struct bch_fs *c, struct bch_inode_unpacked *inode_u,
inode_u->bi_otime = now;
if (parent) {
-#define BCH_INODE_FIELD(_name) inode_u->_name = parent->_name;
+#define x(_name) inode_u->_name = parent->_name;
BCH_INODE_FIELDS_INHERIT()
-#undef BCH_INODE_FIELD
+#undef x
}
}
diff --git a/fs/bcachefs/inode.h b/fs/bcachefs/inode.h
index 44855e1a163e..e4ac4b67223a 100644
--- a/fs/bcachefs/inode.h
+++ b/fs/bcachefs/inode.h
@@ -29,17 +29,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,11 +79,11 @@ 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;
}
@@ -91,12 +91,12 @@ static inline void __bch2_inode_opt_set(struct bch_inode_unpacked *inode,
enum bch_opt_id id, u64 v)
{
switch (id) {
-#define BCH_INODE_OPT(_name, ...) \
+#define x(_name, ...) \
case Opt_##_name: \
inode->bi_##_name = v; \
break;
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
default:
BUG();
}
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index 449cd5bfcfc7..4739f78262da 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -376,40 +376,40 @@ no_val:
struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts src)
{
struct bch_io_opts ret = { 0 };
-#define BCH_INODE_OPT(_name, _bits) \
+#define x(_name, _bits) \
if (opt_defined(src, _name)) \
opt_set(ret, _name, src._name);
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
return ret;
}
struct bch_opts bch2_inode_opts_to_opts(struct bch_io_opts src)
{
struct bch_opts ret = { 0 };
-#define BCH_INODE_OPT(_name, _bits) \
+#define x(_name, _bits) \
if (opt_defined(src, _name)) \
opt_set(ret, _name, src._name);
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
return ret;
}
void bch2_io_opts_apply(struct bch_io_opts *dst, struct bch_io_opts src)
{
-#define BCH_INODE_OPT(_name, _bits) \
+#define x(_name, _bits) \
if (opt_defined(src, _name)) \
opt_set(*dst, _name, src._name);
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
}
bool bch2_opt_is_inode_opt(enum bch_opt_id id)
{
static const enum bch_opt_id inode_opt_list[] = {
-#define BCH_INODE_OPT(_name, _bits) Opt_##_name,
+#define x(_name, _bits) Opt_##_name,
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
};
unsigned i;
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index 5c74401848a0..af76fe021c77 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -277,24 +277,24 @@ int bch2_parse_mount_opts(struct bch_opts *, char *);
/* inode opts: */
-#define BCH_INODE_OPTS() \
- BCH_INODE_OPT(data_checksum, 8) \
- BCH_INODE_OPT(compression, 8) \
- BCH_INODE_OPT(background_compression, 8) \
- BCH_INODE_OPT(data_replicas, 8) \
- BCH_INODE_OPT(promote_target, 16) \
- BCH_INODE_OPT(foreground_target, 16) \
- BCH_INODE_OPT(background_target, 16) \
- BCH_INODE_OPT(erasure_code, 16)
+#define BCH_INODE_OPTS() \
+ x(data_checksum, 8) \
+ x(compression, 8) \
+ x(background_compression, 8) \
+ x(data_replicas, 8) \
+ x(promote_target, 16) \
+ x(foreground_target, 16) \
+ x(background_target, 16) \
+ x(erasure_code, 16)
struct bch_io_opts {
-#define BCH_INODE_OPT(_name, _bits) unsigned _name##_defined:1;
+#define x(_name, _bits) unsigned _name##_defined:1;
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
-#define BCH_INODE_OPT(_name, _bits) u##_bits _name;
+#define x(_name, _bits) u##_bits _name;
BCH_INODE_OPTS()
-#undef BCH_INODE_OPT
+#undef x
};
struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts);