misc cleanup patches
cover misc cleanup patches
These patches are independent, not related.
They are miscellaneous cleanup patches.
Anand Jain (2):
btrfs: cleanup fs_devices pointer usage in btrfs_trim_fs
btrfs: change btrfs_io_bio_init inline function to macro
fs/btrfs/extent-tree.c | 10 +++++----- fs/btrfs/extent_io.c | 5 +---- 2 files changed, 6 insertions(+), 9 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 btrfs: cleanup fs_devices pointer usage in btrfs_trim_fs
Drop variable
struct list_head *devices
and add new variable
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
so that fs_devices is used at two locations within btrfs_trim_fs() function and also helps to access fs_devices->devices.
--- fs/btrfs/extent-tree.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/extent-tree.c +5 -5
@@ -5950,9 +5950,9 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed)*/ int btrfs_trim_fs (struct btrfs_fs_info *fs_info,struct fstrim_range *range) { +struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;struct btrfs_block_group *cache =NULL ;struct btrfs_device *device; -struct list_head *devices;u64 group_trimmed;u64 range_end =U64_MAX ;u64 start;
@@ -6016,9 +6016,9 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)btrfs_warn (fs_info,"failed to trim %llu block group(s), last error %d" , bg_failed, bg_ret); -mutex_lock (&fs_info->fs_devices->device_list_mutex); - devices = &fs_info->fs_devices->devices; -list_for_each_entry (device, devices, dev_list) { + +mutex_lock (&fs_devices->device_list_mutex); +list_for_each_entry (device, &fs_devices->devices, dev_list) {if (test_bit (BTRFS_DEV_STATE_MISSING , &device->dev_state))continue ;
@@ -6031,7 +6031,7 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range) trimmed += group_trimmed; } -mutex_unlock (&fs_info->fs_devices->device_list_mutex); +mutex_unlock (&fs_devices->device_list_mutex);if (dev_failed) btrfs_warn(fs_info,
Signature · 1 line
2.31.1
PATCH 2/2 btrfs: change btrfs_io_bio_init inline function to macro
In reply to Anand Jainbtrfs_io_bio_init() is a single line static inline function and initializes part of allocated struct btrfs_io_bio. Make it macro so that preprocessor handles it and preserve the original comments of the function.
--- fs/btrfs/extent_io.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/btrfs/extent_io.c +1 -4
@@ -3110,10 +3110,7 @@ static void end_bio_extent_readpage(struct bio *bio)* new bio by bio_alloc_bioset as it does not initialize the bytes outside of * 'bio' because use of __GFP_ZERO is not supported. */ -static inline void btrfs_io_bio_init (struct btrfs_io_bio *btrfs_bio) -{ -memset (btrfs_bio,0 , offsetof(struct btrfs_io_bio , bio)); -} +#define btrfs_io_bio_init (bbio) memset(bbio, 0, offsetof(struct btrfs_io_bio, bio))/* * The following helpers allocate a bio. As it's backed by a bioset, it'll
Signature · 1 line
2.31.1
Re: [PATCH 2/2] btrfs: change btrfs_io_bio_init inline function to macro
Quoted 16 lines · Anand Jain
btrfs_io_bio_init()is a single line static inline function and initializes part of allocated structbtrfs_io_bio. Make it macro so that preprocessor handles it and preserve the original comments of the function.Signed-off-by Anand Jain <[email protected]>--- fs/btrfs/extent_io.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)fs/btrfs/extent_io.c +0
-0@@ -3110,10 +3110,7 @@ static void end_bio_extent_readpage(struct bio *bio)* new bio by bio_alloc_bioset as it does not initialize the bytes outside of
fs/btrfs/extent_io.c static void end_bio_extent_readpage(struct bio *bio) · line 3116
Quoted 10 lines
fs/btrfs/extent_io.c +1
-4* 'bio' because use of __GFP_ZERO is not supported. */ -static inline void btrfs_io_bio_init (struct btrfs_io_bio *btrfs_bio) -{ -memset (btrfs_bio,0 , offsetof(struct btrfs_io_bio , bio)); -} +#define btrfs_io_bio_init (bbio) memset(bbio, 0, offsetof(struct btrfs_io_bio, bio))/* * The following helpers allocate a bio. As it's backed by a bioset, it'll
What do we gain by this change? The compiler is perfectly able to inline btrfs_io_bio_init.
Re: [PATCH 2/2] btrfs: change btrfs_io_bio_init inline function to macro
Quoted 26 lines · Nikolay Borisov
Quoted 23 lines · Anand Jain
btrfs_io_bio_init()is a single line static inline function and initializes part of allocated structbtrfs_io_bio. Make it macro so that preprocessor handles it and preserve the original comments of the function.Signed-off-by Anand Jain <[email protected]>--- fs/btrfs/extent_io.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)fs/btrfs/extent_io.c +1
-4@@ -3110,10 +3110,7 @@ static void end_bio_extent_readpage(struct bio *bio)* new bio by bio_alloc_bioset as it does not initialize the bytes outside of * 'bio' because use of __GFP_ZERO is not supported. */ -static inline void btrfs_io_bio_init (struct btrfs_io_bio *btrfs_bio) -{ -memset (btrfs_bio,0 , offsetof(struct btrfs_io_bio , bio)); -} +#define btrfs_io_bio_init (bbio) memset(bbio, 0, offsetof(struct btrfs_io_bio, bio))
Quoted 8 lines
fs/btrfs/extent_io.c static void end_bio_extent_readpage(struct bio *bio) · line 3116
Quoted 3 lines
fs/btrfs/extent_io.c +0
-0/* * The following helpers allocate a bio. As it's backed by a bioset, it'll What do we gain by this change? The compiler is perfectly able to inline
btrfs_io_bio_init.
The gain is macro is guaranteed to be inline-ed. A function with the inline prefix isn't.
Re: [PATCH 2/2] btrfs: change btrfs_io_bio_init inline function to macro
Quoted 43 lines · Anand Jain
Quoted 30 lines · Nikolay Borisov
Quoted 27 lines · Anand Jain
btrfs_io_bio_init()is a single line static inline function and initializes
part of allocated structbtrfs_io_bio. Make it macro so that preprocessor
handles it and preserve the original comments of the function.Signed-off-by Anand Jain <[email protected]>---
fs/btrfs/extent_io.c| 5 +----1 file changed, 1 insertion(+), 4 deletions(-)fs/btrfs/extent_io.c +0
-0@@ -3110,10 +3110,7 @@ static void end_bio_extent_readpage(struct bio *bio) * new bio by bio_alloc_bioset as it does not initialize the bytesoutside of
* 'bio' because use of__GFP_ZEROis not supported. */fs/btrfs/extent_io.c +1
-4-static inline void btrfs_io_bio_init (struct btrfs_io_bio *btrfs_bio) -{ - memset(btrfs_bio, 0, offsetof(struct btrfs_io_bio, bio)); -} +#define btrfs_io_bio_init (bbio) memset(bbio, 0, offsetof(struct
btrfs_io_bio, bio))Quoted 9 lines
Quoted 4 lines
/*
* The following helpers allocate a bio. As it's backed by a bioset, it'llWhat do we gain by this change? The compiler is perfectly able to inline
btrfs_io_bio_init.
Quoted 3 lines
The gain is macro is guaranteed to be inline-ed. A function with the inline prefix isn't.
In this particular case it's guaranteed that the function will be inlined.
Re: [PATCH 2/2] btrfs: change btrfs_io_bio_init inline function to macro
Quoted 5 lines · Nikolay Borisov
Quoted 3 lines
The gain is macro is guaranteed to be inline-ed. A function with the inline prefix isn't.
In this particular case it's guaranteed that the function will be inlined.
And we also get additional type safety from the function, which the macro doesn't provide.
Re: [PATCH 2/2] btrfs: change btrfs_io_bio_init inline function to macro
Quoted 9 lines · Johannes Thumshirn
Quoted 5 lines · Nikolay Borisov
Quoted 3 lines
The gain is macro is guaranteed to be inline-ed. A function with the inline prefix isn't.
In this particular case it's guaranteed that the function will be inlined.
And we also get additional type safety from the function, which the macro doesn't provide.
Yeah, using static inlines instead of macros is preferred when they're reasonably simple, like in this case.
Re: [PATCH 1/2] btrfs: cleanup fs_devices pointer usage in btrfs_trim_fs
In reply to Anand JainQuoted 9 lines · Anand Jain
Drop variable
structlist_head*devices
and add new variable
structbtrfs_fs_devices*fs_devices=fs_info->fs_devices;so that
fs_devicesis used at two locations withinbtrfs_trim_fs()function and also helps to accessfs_devices->devices.Signed-off-by Anand Jain <[email protected]>
Added to misc-next, thanks.