Commit 321f4992 authored by David Sterba's avatar David Sterba

btrfs: reduce size of struct btrfs_ref

We can reduce two members' size that in turn reduce size of struct
btrfs_ref from 64 to 56 bytes. As the structure is often used as a local
variable several functions reduce their stack usage.

- make enum btrfs_ref_type packed, there are only 4 values

- switch action and its values to a packed enum

Final structure layout:

struct btrfs_ref {
        enum btrfs_ref_type        type;                 /*     0     1 */
        enum btrfs_delayed_ref_action action;            /*     1     1 */
        bool                       skip_qgroup;          /*     2     1 */

        /* XXX 5 bytes hole, try to pack */

        u64                        bytenr;               /*     8     8 */
        u64                        len;                  /*    16     8 */
        u64                        parent;               /*    24     8 */
        union {
                struct btrfs_data_ref data_ref;          /*    32    24 */
                struct btrfs_tree_ref tree_ref;          /*    32    16 */
        };                                               /*    32    24 */

        /* size: 56, cachelines: 1, members: 7 */
        /* sum members: 51, holes: 1, sum holes: 5 */
        /* last cacheline: 56 bytes */
};
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e41570d3
...@@ -9,10 +9,16 @@ ...@@ -9,10 +9,16 @@
#include <linux/refcount.h> #include <linux/refcount.h>
/* these are the possible values of struct btrfs_delayed_ref_node->action */ /* these are the possible values of struct btrfs_delayed_ref_node->action */
#define BTRFS_ADD_DELAYED_REF 1 /* add one backref to the tree */ enum btrfs_delayed_ref_action {
#define BTRFS_DROP_DELAYED_REF 2 /* delete one backref from the tree */ /* Add one backref to the tree */
#define BTRFS_ADD_DELAYED_EXTENT 3 /* record a full extent allocation */ BTRFS_ADD_DELAYED_REF = 1,
#define BTRFS_UPDATE_DELAYED_HEAD 4 /* not changing ref count on head ref */ /* Delete one backref from the tree */
BTRFS_DROP_DELAYED_REF,
/* Record a full extent allocation */
BTRFS_ADD_DELAYED_EXTENT,
/* Not changing ref count on head ref */
BTRFS_UPDATE_DELAYED_HEAD,
} __packed;
struct btrfs_delayed_ref_node { struct btrfs_delayed_ref_node {
struct rb_node ref_node; struct rb_node ref_node;
...@@ -183,7 +189,7 @@ enum btrfs_ref_type { ...@@ -183,7 +189,7 @@ enum btrfs_ref_type {
BTRFS_REF_DATA, BTRFS_REF_DATA,
BTRFS_REF_METADATA, BTRFS_REF_METADATA,
BTRFS_REF_LAST, BTRFS_REF_LAST,
}; } __packed;
struct btrfs_data_ref { struct btrfs_data_ref {
/* For EXTENT_DATA_REF */ /* For EXTENT_DATA_REF */
...@@ -223,7 +229,7 @@ struct btrfs_tree_ref { ...@@ -223,7 +229,7 @@ struct btrfs_tree_ref {
struct btrfs_ref { struct btrfs_ref {
enum btrfs_ref_type type; enum btrfs_ref_type type;
int action; enum btrfs_delayed_ref_action action;
/* /*
* Whether this extent should go through qgroup record. * Whether this extent should go through qgroup record.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment