diff mbox

[2/2] Btrfs-progs: use bitfield instead of integer for some variants in fs_info

Message ID 1393328937-26171-2-git-send-email-wangsl.fnst@cn.fujitsu.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Wang Shilong Feb. 25, 2014, 11:48 a.m. UTC
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
 ctree.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

David Sterba Feb. 25, 2014, 4:28 p.m. UTC | #1
On Tue, Feb 25, 2014 at 07:48:57PM +0800, Wang Shilong wrote:
> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
> ---
>  ctree.h | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/ctree.h b/ctree.h
> index 3cc3477..9b461af 100644
> --- a/ctree.h
> +++ b/ctree.h
> @@ -984,9 +984,11 @@ struct btrfs_fs_info {
>  	struct btrfs_fs_devices *fs_devices;
>  	struct list_head space_info;
>  	int system_allocs;
> -	int readonly;
> -	int on_restoring;
> -	int is_chunk_recover;
> +
> +	unsigned int readonly:1;
> +	unsigned int on_restoring:1;
> +	unsigned int is_chunk_recover:1;

Well, the integers are wasteful, but there's only one instance of
fs_info per fsck run, so it saves like 8 bytes in total. I'm not sure
this patch is needed.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wang Shilong Feb. 26, 2014, 2:25 a.m. UTC | #2
On 02/26/2014 12:28 AM, David Sterba wrote:
> On Tue, Feb 25, 2014 at 07:48:57PM +0800, Wang Shilong wrote:
>> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
>> ---
>>   ctree.h | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/ctree.h b/ctree.h
>> index 3cc3477..9b461af 100644
>> --- a/ctree.h
>> +++ b/ctree.h
>> @@ -984,9 +984,11 @@ struct btrfs_fs_info {
>>   	struct btrfs_fs_devices *fs_devices;
>>   	struct list_head space_info;
>>   	int system_allocs;
>> -	int readonly;
>> -	int on_restoring;
>> -	int is_chunk_recover;
>> +
>> +	unsigned int readonly:1;
>> +	unsigned int on_restoring:1;
>> +	unsigned int is_chunk_recover:1;
> Well, the integers are wasteful, but there's only one instance of
> fs_info per fsck run, so it saves like 8 bytes in total. I'm not sure
> this patch is needed.
Originally, i wrote this patch, it is because i was going to add a new flag.
However, that approach has been replaced by a better idea.

Anyway, this patch will be a good start, however, i don't insist on it.
We can also change it  when we have to add another flag later.

David, just do what you like here.

Thanks,
Wang
>

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Feb. 26, 2014, 6:16 p.m. UTC | #3
On Wed, Feb 26, 2014 at 10:25:24AM +0800, Wang Shilong wrote:
> On 02/26/2014 12:28 AM, David Sterba wrote:
> >On Tue, Feb 25, 2014 at 07:48:57PM +0800, Wang Shilong wrote:
> >>Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
> >>---
> >>  ctree.h | 8 +++++---
> >>  1 file changed, 5 insertions(+), 3 deletions(-)
> >>
> >>diff --git a/ctree.h b/ctree.h
> >>index 3cc3477..9b461af 100644
> >>--- a/ctree.h
> >>+++ b/ctree.h
> >>@@ -984,9 +984,11 @@ struct btrfs_fs_info {
> >>  	struct btrfs_fs_devices *fs_devices;
> >>  	struct list_head space_info;
> >>  	int system_allocs;
> >>-	int readonly;
> >>-	int on_restoring;
> >>-	int is_chunk_recover;
> >>+
> >>+	unsigned int readonly:1;
> >>+	unsigned int on_restoring:1;
> >>+	unsigned int is_chunk_recover:1;
> >Well, the integers are wasteful, but there's only one instance of
> >fs_info per fsck run, so it saves like 8 bytes in total. I'm not sure
> >this patch is needed.
> Originally, i wrote this patch, it is because i was going to add a new flag.
> However, that approach has been replaced by a better idea.
> 
> Anyway, this patch will be a good start, however, i don't insist on it.
> We can also change it  when we have to add another flag later.

Ok, let's keep it, as an example of the pattern 'bitfields for flags'.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ctree.h b/ctree.h
index 3cc3477..9b461af 100644
--- a/ctree.h
+++ b/ctree.h
@@ -984,9 +984,11 @@  struct btrfs_fs_info {
 	struct btrfs_fs_devices *fs_devices;
 	struct list_head space_info;
 	int system_allocs;
-	int readonly;
-	int on_restoring;
-	int is_chunk_recover;
+
+	unsigned int readonly:1;
+	unsigned int on_restoring:1;
+	unsigned int is_chunk_recover:1;
+
 	int (*free_extent_hook)(struct btrfs_trans_handle *trans,
 				struct btrfs_root *root,
 				u64 bytenr, u64 num_bytes, u64 parent,