f2fs: remove submit label in __submit_discard_cmd()

Message ID 20221111161349.60689-1-frank.li@vivo.com
State New
Headers
Series f2fs: remove submit label in __submit_discard_cmd() |

Commit Message

李扬韬 Nov. 11, 2022, 4:13 p.m. UTC
  Complaint from Matthew Wilcox in another similar place:

	"submit?  You don't submit anything at the 'submit' label.
	it should be called 'skip' or something.  But I think this
	is just badly written and you don't need a goto at all."

Let's remove submit label for readability.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/segment.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Jaegeuk Kim Nov. 14, 2022, 10:49 p.m. UTC | #1
On 11/12, Yangtao Li wrote:
> Complaint from Matthew Wilcox in another similar place:
> 
> 	"submit?  You don't submit anything at the 'submit' label.
> 	it should be called 'skip' or something.  But I think this
> 	is just badly written and you don't need a goto at all."
> 
> Let's remove submit label for readability.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  fs/f2fs/segment.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 3654c30e0517..0a72e787c585 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1144,13 +1144,11 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
>  		if (time_to_inject(sbi, FAULT_DISCARD)) {
>  			f2fs_show_injection_info(sbi, FAULT_DISCARD);
>  			err = -EIO;
> -			goto submit;
> -		}
> -		err = __blkdev_issue_discard(bdev,
> +		} else
> +			err = __blkdev_issue_discard(bdev,
>  					SECTOR_FROM_BLOCK(start),
>  					SECTOR_FROM_BLOCK(len),
>  					GFP_NOFS, &bio);

Thanks. I added {} to meet the coding style.

> -submit:
>  		if (err) {
>  			spin_lock_irqsave(&dc->lock, flags);
>  			if (dc->state == D_PARTIAL)
> -- 
> 2.25.1
  
Chao Yu Nov. 15, 2022, 1:36 a.m. UTC | #2
On 2022/11/15 6:49, Jaegeuk Kim wrote:
> On 11/12, Yangtao Li wrote:
>> Complaint from Matthew Wilcox in another similar place:
>>
>> 	"submit?  You don't submit anything at the 'submit' label.
>> 	it should be called 'skip' or something.  But I think this
>> 	is just badly written and you don't need a goto at all."
>>
>> Let's remove submit label for readability.
>>
>> Signed-off-by: Yangtao Li <frank.li@vivo.com>
>> ---
>>   fs/f2fs/segment.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index 3654c30e0517..0a72e787c585 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -1144,13 +1144,11 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
>>   		if (time_to_inject(sbi, FAULT_DISCARD)) {
>>   			f2fs_show_injection_info(sbi, FAULT_DISCARD);
>>   			err = -EIO;
>> -			goto submit;
>> -		}
>> -		err = __blkdev_issue_discard(bdev,
>> +		} else
>> +			err = __blkdev_issue_discard(bdev,
>>   					SECTOR_FROM_BLOCK(start),
>>   					SECTOR_FROM_BLOCK(len),
>>   					GFP_NOFS, &bio);
> 
> Thanks. I added {} to meet the coding style.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> 
>> -submit:
>>   		if (err) {
>>   			spin_lock_irqsave(&dc->lock, flags);
>>   			if (dc->state == D_PARTIAL)
>> -- 
>> 2.25.1
  

Patch

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 3654c30e0517..0a72e787c585 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1144,13 +1144,11 @@  static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
 		if (time_to_inject(sbi, FAULT_DISCARD)) {
 			f2fs_show_injection_info(sbi, FAULT_DISCARD);
 			err = -EIO;
-			goto submit;
-		}
-		err = __blkdev_issue_discard(bdev,
+		} else
+			err = __blkdev_issue_discard(bdev,
 					SECTOR_FROM_BLOCK(start),
 					SECTOR_FROM_BLOCK(len),
 					GFP_NOFS, &bio);
-submit:
 		if (err) {
 			spin_lock_irqsave(&dc->lock, flags);
 			if (dc->state == D_PARTIAL)