diff mbox series

[v5,4/8] md: return directly before setting did_set_md_closing

Message ID 20240201063404.772797-5-linan666@huaweicloud.com (mailing list archive)
State Superseded, archived
Headers show
Series bugfix of MD_CLOSING and clean up md_ioctl() | expand

Commit Message

Li Nan Feb. 1, 2024, 6:34 a.m. UTC
From: Li Nan <linan122@huawei.com>

There is nothing to do at 'out' before setting 'did_set_md_closing'
in md_ioctl(). Return directly, and it will help us to remove
'did_set_md_closing' later.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

Comments

Yu Kuai Feb. 2, 2024, 1:24 a.m. UTC | #1
Hi,

在 2024/02/01 14:34, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> There is nothing to do at 'out' before setting 'did_set_md_closing'
> in md_ioctl(). Return directly, and it will help us to remove
> 'did_set_md_closing' later.
> 
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/md.c | 23 ++++++++---------------
>   1 file changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 656080086052..5442e8e3c161 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -7636,10 +7636,8 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>   	 * Commands dealing with the RAID driver but not any
>   	 * particular array:
>   	 */
> -	if (cmd == RAID_VERSION) {
> -		err = get_version(argp);
> -		goto out;
> -	}
> +	if (cmd == RAID_VERSION)
> +		return get_version(argp);
Please merge this into patch 2.

>   
>   	/*
>   	 * Commands creating/starting a new array:
> @@ -7654,23 +7652,20 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>   			err = -ENODEV;
>   		else
>   			err = get_array_info(mddev, argp);

You can also remove 'err' here:

if (...)
	return -ENODEV;
return get_array_info(mddev, argp);

> -		goto out;
> +		return err;
>   
>   	case GET_DISK_INFO:
>   		if (!mddev->raid_disks && !mddev->external)
>   			err = -ENODEV;
>   		else
>   			err = get_disk_info(mddev, argp);

Same here.

Thanks,
Kuai

> -		goto out;
> +		return err;
>   
>   	case SET_DISK_FAULTY:
> -		err = set_disk_faulty(mddev, new_decode_dev(arg));
> -		goto out;
> +		return set_disk_faulty(mddev, new_decode_dev(arg));
>   
>   	case GET_BITMAP_FILE:
> -		err = get_bitmap_file(mddev, argp);
> -		goto out;
> -
> +		return get_bitmap_file(mddev, argp);
>   	}
>   
>   	if (cmd == HOT_REMOVE_DISK)
> @@ -7686,13 +7681,11 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>   		mutex_lock(&mddev->open_mutex);
>   		if (mddev->pers && atomic_read(&mddev->openers) > 1) {
>   			mutex_unlock(&mddev->open_mutex);
> -			err = -EBUSY;
> -			goto out;
> +			return -EBUSY;
>   		}
>   		if (test_and_set_bit(MD_CLOSING, &mddev->flags)) {
>   			mutex_unlock(&mddev->open_mutex);
> -			err = -EBUSY;
> -			goto out;
> +			return -EBUSY;
>   		}
>   		did_set_md_closing = true;
>   		mutex_unlock(&mddev->open_mutex);
>
diff mbox series

Patch

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 656080086052..5442e8e3c161 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7636,10 +7636,8 @@  static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
 	 * Commands dealing with the RAID driver but not any
 	 * particular array:
 	 */
-	if (cmd == RAID_VERSION) {
-		err = get_version(argp);
-		goto out;
-	}
+	if (cmd == RAID_VERSION)
+		return get_version(argp);
 
 	/*
 	 * Commands creating/starting a new array:
@@ -7654,23 +7652,20 @@  static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
 			err = -ENODEV;
 		else
 			err = get_array_info(mddev, argp);
-		goto out;
+		return err;
 
 	case GET_DISK_INFO:
 		if (!mddev->raid_disks && !mddev->external)
 			err = -ENODEV;
 		else
 			err = get_disk_info(mddev, argp);
-		goto out;
+		return err;
 
 	case SET_DISK_FAULTY:
-		err = set_disk_faulty(mddev, new_decode_dev(arg));
-		goto out;
+		return set_disk_faulty(mddev, new_decode_dev(arg));
 
 	case GET_BITMAP_FILE:
-		err = get_bitmap_file(mddev, argp);
-		goto out;
-
+		return get_bitmap_file(mddev, argp);
 	}
 
 	if (cmd == HOT_REMOVE_DISK)
@@ -7686,13 +7681,11 @@  static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
 		mutex_lock(&mddev->open_mutex);
 		if (mddev->pers && atomic_read(&mddev->openers) > 1) {
 			mutex_unlock(&mddev->open_mutex);
-			err = -EBUSY;
-			goto out;
+			return -EBUSY;
 		}
 		if (test_and_set_bit(MD_CLOSING, &mddev->flags)) {
 			mutex_unlock(&mddev->open_mutex);
-			err = -EBUSY;
-			goto out;
+			return -EBUSY;
 		}
 		did_set_md_closing = true;
 		mutex_unlock(&mddev->open_mutex);