All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Simplify conditional in assert
@ 2021-10-15 10:36 Wan Jiabing
  2021-10-15 10:51 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Wan Jiabing @ 2021-10-15 10:36 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-kernel
  Cc: kael_w, Wan Jiabing

Fix following coccicheck warning:
./fs/btrfs/inode.c:2015:16-18: WARNING !A || A && B is equivalent to !A || B

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 fs/btrfs/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e9154b436c47..da4aeef73b0d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2011,8 +2011,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
 		 * to use run_delalloc_nocow() here, like for  regular
 		 * preallocated inodes.
 		 */
-		ASSERT(!zoned ||
-		       (zoned && btrfs_is_data_reloc_root(inode->root)));
+		ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root));
 		ret = run_delalloc_nocow(inode, locked_page, start, end,
 					 page_started, nr_written);
 	} else if (!inode_can_compress(inode) ||
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Simplify conditional in assert
  2021-10-15 10:36 [PATCH] btrfs: Simplify conditional in assert Wan Jiabing
@ 2021-10-15 10:51 ` David Sterba
  2021-10-15 11:41   ` Johannes Thumshirn
  2021-10-15 14:18   ` Nikolay Borisov
  0 siblings, 2 replies; 4+ messages in thread
From: David Sterba @ 2021-10-15 10:51 UTC (permalink / raw)
  To: Wan Jiabing
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel, kael_w, johannes.thumshirn

Adding Johannes to CC,

On Fri, Oct 15, 2021 at 06:36:39AM -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./fs/btrfs/inode.c:2015:16-18: WARNING !A || A && B is equivalent to !A || B
> 
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
>  fs/btrfs/inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e9154b436c47..da4aeef73b0d 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -2011,8 +2011,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
>  		 * to use run_delalloc_nocow() here, like for  regular
>  		 * preallocated inodes.
>  		 */
> -		ASSERT(!zoned ||
> -		       (zoned && btrfs_is_data_reloc_root(inode->root)));
> +		ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root));

The short form is equivalent, but I'm not sure it's also on the same
level of readability. Repeating the 'zoned' condition check makes it
obvious on first sight, which is what I'd prefer.

Johannes if you'd like the new version I'll change it but otherwise I'm
fine with what we have now.

>  		ret = run_delalloc_nocow(inode, locked_page, start, end,
>  					 page_started, nr_written);
>  	} else if (!inode_can_compress(inode) ||
> -- 
> 2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Simplify conditional in assert
  2021-10-15 10:51 ` David Sterba
@ 2021-10-15 11:41   ` Johannes Thumshirn
  2021-10-15 14:18   ` Nikolay Borisov
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2021-10-15 11:41 UTC (permalink / raw)
  To: dsterba, Wan Jiabing
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel, kael_w

On 15/10/2021 12:52, David Sterba wrote:
> Adding Johannes to CC,
> 
> On Fri, Oct 15, 2021 at 06:36:39AM -0400, Wan Jiabing wrote:
>> Fix following coccicheck warning:
>> ./fs/btrfs/inode.c:2015:16-18: WARNING !A || A && B is equivalent to !A || B
>>
>> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
>> ---
>>  fs/btrfs/inode.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
>> index e9154b436c47..da4aeef73b0d 100644
>> --- a/fs/btrfs/inode.c
>> +++ b/fs/btrfs/inode.c
>> @@ -2011,8 +2011,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
>>  		 * to use run_delalloc_nocow() here, like for  regular
>>  		 * preallocated inodes.
>>  		 */
>> -		ASSERT(!zoned ||
>> -		       (zoned && btrfs_is_data_reloc_root(inode->root)));
>> +		ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root));
> 
> The short form is equivalent, but I'm not sure it's also on the same
> level of readability. Repeating the 'zoned' condition check makes it
> obvious on first sight, which is what I'd prefer.
> 
> Johannes if you'd like the new version I'll change it but otherwise I'm
> fine with what we have now.

I'm fine either way, no strong preferences from my side.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Simplify conditional in assert
  2021-10-15 10:51 ` David Sterba
  2021-10-15 11:41   ` Johannes Thumshirn
@ 2021-10-15 14:18   ` Nikolay Borisov
  1 sibling, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2021-10-15 14:18 UTC (permalink / raw)
  To: dsterba, Wan Jiabing, Chris Mason, Josef Bacik, David Sterba,
	linux-btrfs, linux-kernel, kael_w, johannes.thumshirn



On 15.10.21 г. 13:51, David Sterba wrote:
> Adding Johannes to CC,
> 
> On Fri, Oct 15, 2021 at 06:36:39AM -0400, Wan Jiabing wrote:
>> Fix following coccicheck warning:
>> ./fs/btrfs/inode.c:2015:16-18: WARNING !A || A && B is equivalent to !A || B
>>
>> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
>> ---
>>  fs/btrfs/inode.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
>> index e9154b436c47..da4aeef73b0d 100644
>> --- a/fs/btrfs/inode.c
>> +++ b/fs/btrfs/inode.c
>> @@ -2011,8 +2011,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
>>  		 * to use run_delalloc_nocow() here, like for  regular
>>  		 * preallocated inodes.
>>  		 */
>> -		ASSERT(!zoned ||
>> -		       (zoned && btrfs_is_data_reloc_root(inode->root)));
>> +		ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root));
> 
> The short form is equivalent, but I'm not sure it's also on the same
> level of readability. Repeating the 'zoned' condition check makes it
> obvious on first sight, which is what I'd prefer.
> 
> Johannes if you'd like the new version I'll change it but otherwise I'm
> fine with what we have now.

Just my 2 cents:

The less code we have the better, i.e !zoned is obvious when it's true
i.e when zoned is false. So the way I read teh assert with the short
form is "we are not zoned OR we are (this is implicit) and this is the
data reloc root". Obviously this is personal preference as you deem it's
better  better to have the !zoned || zoned.


> 
>>  		ret = run_delalloc_nocow(inode, locked_page, start, end,
>>  					 page_started, nr_written);
>>  	} else if (!inode_can_compress(inode) ||
>> -- 
>> 2.20.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-15 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 10:36 [PATCH] btrfs: Simplify conditional in assert Wan Jiabing
2021-10-15 10:51 ` David Sterba
2021-10-15 11:41   ` Johannes Thumshirn
2021-10-15 14:18   ` Nikolay Borisov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.