Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
a3e70fb2
Commit
a3e70fb2
authored
Dec 13, 2018
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: use x-macros more consistently
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
7121643e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
71 deletions
+71
-71
fs/bcachefs/bcachefs_format.h
fs/bcachefs/bcachefs_format.h
+32
-32
fs/bcachefs/inode.c
fs/bcachefs/inode.c
+10
-10
fs/bcachefs/inode.h
fs/bcachefs/inode.h
+8
-8
fs/bcachefs/opts.c
fs/bcachefs/opts.c
+8
-8
fs/bcachefs/opts.h
fs/bcachefs/opts.h
+13
-13
No files found.
fs/bcachefs/bcachefs_format.h
View file @
a3e70fb2
...
...
@@ -695,37 +695,37 @@ struct bch_inode_generation {
}
__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)
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() \
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)
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
{
/*
...
...
fs/bcachefs/inode.c
View file @
a3e70fb2
...
...
@@ -98,7 +98,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++; \
\
...
...
@@ -108,7 +108,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
;
...
...
@@ -130,9 +130,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
}
}
...
...
@@ -150,7 +150,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)) { \
unsigned offset = offsetof(struct bch_inode_unpacked, _name);\
memset((void *) unpacked + offset, 0, \
...
...
@@ -169,7 +169,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? */
...
...
@@ -220,10 +220,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
,
...
...
@@ -265,9 +265,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
}
}
...
...
fs/bcachefs/inode.h
View file @
a3e70fb2
...
...
@@ -30,17 +30,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
*
);
...
...
@@ -65,11 +65,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
;
}
...
...
@@ -77,12 +77,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
();
}
...
...
fs/bcachefs/opts.c
View file @
a3e70fb2
...
...
@@ -377,40 +377,40 @@ int bch2_parse_mount_opts(struct bch_opts *opts, char *options)
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
;
...
...
fs/bcachefs/opts.h
View file @
a3e70fb2
...
...
@@ -282,23 +282,23 @@ 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)
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment