diff options
author | Li Zefan <lizefan@huawei.com> | 2012-07-09 22:22:35 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-07-23 16:28:06 -0400 |
commit | 18077bb413687f96bd168efcfb2b8778529e3b74 (patch) | |
tree | 44adcefcc2177267437826b800800021cc2f4faf /fs/btrfs/ctree.h | |
parent | 293f7e07405a63975cee4e95a2cfa0c17b34b3aa (diff) |
Btrfs: rewrite BTRFS_SETGET_FUNCS
BTRFS_SETGET_FUNCS macro is used to generate btrfs_set_foo() and
btrfs_foo() functions, which read and write specific fields in the
extent buffer.
The total number of set/get functions is ~200, but in fact we only
need 8 functions: 2 for u8 field, 2 for u16, 2 for u32 and 2 for u64.
It results in redunction of ~37K bytes.
text data bss dec hex filename
629661 12489 216 642366 9cd3e fs/btrfs/btrfs.o.orig
592637 12489 216 605342 93c9e fs/btrfs/btrfs.o
Signed-off-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 6761490b91cd..a0ee2f8e0566 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1623,13 +1623,54 @@ static inline void btrfs_init_map_token (struct btrfs_map_token *token) | |||
1623 | offsetof(type, member), \ | 1623 | offsetof(type, member), \ |
1624 | sizeof(((type *)0)->member))) | 1624 | sizeof(((type *)0)->member))) |
1625 | 1625 | ||
1626 | #ifndef BTRFS_SETGET_FUNCS | 1626 | #define DECLARE_BTRFS_SETGET_BITS(bits) \ |
1627 | u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \ | ||
1628 | unsigned long off, \ | ||
1629 | struct btrfs_map_token *token); \ | ||
1630 | void btrfs_set_token_##bits(struct extent_buffer *eb, void *ptr, \ | ||
1631 | unsigned long off, u##bits val, \ | ||
1632 | struct btrfs_map_token *token); \ | ||
1633 | static inline u##bits btrfs_get_##bits(struct extent_buffer *eb, void *ptr, \ | ||
1634 | unsigned long off) \ | ||
1635 | { \ | ||
1636 | return btrfs_get_token_##bits(eb, ptr, off, NULL); \ | ||
1637 | } \ | ||
1638 | static inline void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \ | ||
1639 | unsigned long off, u##bits val) \ | ||
1640 | { \ | ||
1641 | btrfs_set_token_##bits(eb, ptr, off, val, NULL); \ | ||
1642 | } | ||
1643 | |||
1644 | DECLARE_BTRFS_SETGET_BITS(8) | ||
1645 | DECLARE_BTRFS_SETGET_BITS(16) | ||
1646 | DECLARE_BTRFS_SETGET_BITS(32) | ||
1647 | DECLARE_BTRFS_SETGET_BITS(64) | ||
1648 | |||
1627 | #define BTRFS_SETGET_FUNCS(name, type, member, bits) \ | 1649 | #define BTRFS_SETGET_FUNCS(name, type, member, bits) \ |
1628 | u##bits btrfs_##name(struct extent_buffer *eb, type *s); \ | 1650 | static inline u##bits btrfs_##name(struct extent_buffer *eb, type *s) \ |
1629 | u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, struct btrfs_map_token *token); \ | 1651 | { \ |
1630 | void btrfs_set_token_##name(struct extent_buffer *eb, type *s, u##bits val, struct btrfs_map_token *token);\ | 1652 | BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ |
1631 | void btrfs_set_##name(struct extent_buffer *eb, type *s, u##bits val); | 1653 | return btrfs_get_##bits(eb, s, offsetof(type, member)); \ |
1632 | #endif | 1654 | } \ |
1655 | static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \ | ||
1656 | u##bits val) \ | ||
1657 | { \ | ||
1658 | BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ | ||
1659 | btrfs_set_##bits(eb, s, offsetof(type, member), val); \ | ||
1660 | } \ | ||
1661 | static inline u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, \ | ||
1662 | struct btrfs_map_token *token) \ | ||
1663 | { \ | ||
1664 | BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ | ||
1665 | return btrfs_get_token_##bits(eb, s, offsetof(type, member), token); \ | ||
1666 | } \ | ||
1667 | static inline void btrfs_set_token_##name(struct extent_buffer *eb, \ | ||
1668 | type *s, u##bits val, \ | ||
1669 | struct btrfs_map_token *token) \ | ||
1670 | { \ | ||
1671 | BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \ | ||
1672 | btrfs_set_token_##bits(eb, s, offsetof(type, member), val, token); \ | ||
1673 | } | ||
1633 | 1674 | ||
1634 | #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ | 1675 | #define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ |
1635 | static inline u##bits btrfs_##name(struct extent_buffer *eb) \ | 1676 | static inline u##bits btrfs_##name(struct extent_buffer *eb) \ |