Message ID | e20220675e8d2501f4b98bae12a105615abe634b.1695380646.git.dsterba@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Minor cleanups in relocation.c | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On 2023/9/22 20:37, David Sterba wrote: > Add an enum type for data relocation stages. > > Signed-off-by: David Sterba <dsterba@suse.com> > --- > fs/btrfs/relocation.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > index 9ff3572a8451..3afe499f00b1 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -125,6 +125,12 @@ struct file_extent_cluster { > u64 owning_root; > }; > > +/* Stages of data relocation. */ > +enum reloc_stage { > + MOVE_DATA_EXTENTS, > + UPDATE_DATA_PTRS > +}; > + > struct reloc_control { > /* block group to relocate */ > struct btrfs_block_group *block_group; > @@ -156,16 +162,12 @@ struct reloc_control { > u64 search_start; > u64 extents_found; > > - unsigned int stage:8; > + enum reloc_stage stage; Wouldn't this cause extra hole? Thanks, Qu > unsigned int create_reloc_tree:1; > unsigned int merge_reloc_tree:1; > unsigned int found_file_extent:1; > }; > > -/* stages of data relocation */ > -#define MOVE_DATA_EXTENTS 0 > -#define UPDATE_DATA_PTRS 1 > - > static void mark_block_processed(struct reloc_control *rc, > struct btrfs_backref_node *node) > { > @@ -4054,7 +4056,7 @@ static void describe_relocation(struct btrfs_fs_info *fs_info, > block_group->start, buf); > } > > -static const char *stage_to_string(int stage) > +static const char *stage_to_string(enum reloc_stage stage) > { > if (stage == MOVE_DATA_EXTENTS) > return "move data extents"; > @@ -4170,7 +4172,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start) > WARN_ON(ret && ret != -EAGAIN); > > while (1) { > - int finishes_stage; > + enum reloc_stage finishes_stage; > > mutex_lock(&fs_info->cleaner_mutex); > ret = relocate_block_group(rc);
On Sat, Sep 23, 2023 at 07:59:54AM +0930, Qu Wenruo wrote: > > > On 2023/9/22 20:37, David Sterba wrote: > > Add an enum type for data relocation stages. > > > > Signed-off-by: David Sterba <dsterba@suse.com> > > --- > > fs/btrfs/relocation.c | 16 +++++++++------- > > 1 file changed, 9 insertions(+), 7 deletions(-) > > > > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > > index 9ff3572a8451..3afe499f00b1 100644 > > --- a/fs/btrfs/relocation.c > > +++ b/fs/btrfs/relocation.c > > @@ -125,6 +125,12 @@ struct file_extent_cluster { > > u64 owning_root; > > }; > > > > +/* Stages of data relocation. */ > > +enum reloc_stage { > > + MOVE_DATA_EXTENTS, > > + UPDATE_DATA_PTRS > > +}; > > + > > struct reloc_control { > > /* block group to relocate */ > > struct btrfs_block_group *block_group; > > @@ -156,16 +162,12 @@ struct reloc_control { > > u64 search_start; > > u64 extents_found; > > > > - unsigned int stage:8; > > + enum reloc_stage stage; > > Wouldn't this cause extra hole? No, it's an int and after u64, the bitfields are in an int as well, so both are aligned. The diff after the change: @@ -7711,15 +7711,14 @@ struct reloc_control { u64 reserved_bytes; /* 1496 8 */ u64 search_start; /* 1504 8 */ u64 extents_found; /* 1512 8 */ - unsigned int stage:8; /* 1520: 0 4 */ - unsigned int create_reloc_tree:1; /* 1520: 8 4 */ - unsigned int merge_reloc_tree:1; /* 1520: 9 4 */ - unsigned int found_file_extent:1; /* 1520:10 4 */ + enum reloc_stage stage; /* 1520 4 */ + unsigned int create_reloc_tree:1; /* 1524: 0 4 */ + unsigned int merge_reloc_tree:1; /* 1524: 1 4 */ + unsigned int found_file_extent:1; /* 1524: 2 4 */ /* size: 1528, cachelines: 24, members: 19 */ - /* padding: 4 */ /* paddings: 2, sum paddings: 8 */ - /* bit_padding: 21 bits */ + /* bit_padding: 29 bits */ /* last cacheline: 56 bytes */ }; ---
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 9ff3572a8451..3afe499f00b1 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -125,6 +125,12 @@ struct file_extent_cluster { u64 owning_root; }; +/* Stages of data relocation. */ +enum reloc_stage { + MOVE_DATA_EXTENTS, + UPDATE_DATA_PTRS +}; + struct reloc_control { /* block group to relocate */ struct btrfs_block_group *block_group; @@ -156,16 +162,12 @@ struct reloc_control { u64 search_start; u64 extents_found; - unsigned int stage:8; + enum reloc_stage stage; unsigned int create_reloc_tree:1; unsigned int merge_reloc_tree:1; unsigned int found_file_extent:1; }; -/* stages of data relocation */ -#define MOVE_DATA_EXTENTS 0 -#define UPDATE_DATA_PTRS 1 - static void mark_block_processed(struct reloc_control *rc, struct btrfs_backref_node *node) { @@ -4054,7 +4056,7 @@ static void describe_relocation(struct btrfs_fs_info *fs_info, block_group->start, buf); } -static const char *stage_to_string(int stage) +static const char *stage_to_string(enum reloc_stage stage) { if (stage == MOVE_DATA_EXTENTS) return "move data extents"; @@ -4170,7 +4172,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start) WARN_ON(ret && ret != -EAGAIN); while (1) { - int finishes_stage; + enum reloc_stage finishes_stage; mutex_lock(&fs_info->cleaner_mutex); ret = relocate_block_group(rc);
Add an enum type for data relocation stages. Signed-off-by: David Sterba <dsterba@suse.com> --- fs/btrfs/relocation.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)