diff mbox series

[03/10] mdadm/Grow: Can't open raid when running --grow --continue

Message ID 20240828021150.63240-4-xni@redhat.com (mailing list archive)
State Superseded
Headers show
Series mdadm tests fix | expand

Checks

Context Check Description
mdraidci/vmtest-md-6_11-PR fail merge-conflict
mdraidci/vmtest-md-6_12-PR fail merge-conflict

Commit Message

Xiao Ni Aug. 28, 2024, 2:11 a.m. UTC
It passes 'array' as devname in Grow_continue. So it fails to
open raid device. Use mdinfo to open raid device.

Signed-off-by: Xiao Ni <xni@redhat.com>
---
 Grow.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Mariusz Tkaczyk Sept. 2, 2024, 10 a.m. UTC | #1
On Wed, 28 Aug 2024 10:11:43 +0800
Xiao Ni <xni@redhat.com> wrote:

> It passes 'array' as devname in Grow_continue. So it fails to
> open raid device. Use mdinfo to open raid device.
> 
> Signed-off-by: Xiao Ni <xni@redhat.com>
> ---
>  Grow.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/Grow.c b/Grow.c
> index 6b621aea4ecc..2a7587315817 100644
> --- a/Grow.c
> +++ b/Grow.c
> @@ -3688,9 +3688,12 @@ started:
>  		set_array_size(st, info, info->text_version);
>  
>  	if (info->new_level != reshape.level) {
> -		if (fd < 0)
> -			fd = open(devname, O_RDONLY);
> -		impose_level(fd, info->new_level, devname, verbose);
> +		fd = open_dev(sra->sys_name);
> +		if (fd < 0) {
> +			pr_err("Can't open %s\n", sra->sys_name);
> +			goto out;
> +		}
> +		impose_level(fd, info->new_level, sra->sys_name, verbose);
>  		close(fd);
>  		if (info->new_level == 0)
>  			st->update_tail = NULL;

You can consider declaring fd locally (inside if) but it is fine anyway.
You can also switch close(fd) to close_fd(&fd); because this resource is
probably reused later in the function body.

Anyway, LGTM but I will run my internal IMSM test suite to confirm that there is
no regression for IMSM before I will merge patchset.

Thanks,
Mariusz
diff mbox series

Patch

diff --git a/Grow.c b/Grow.c
index 6b621aea4ecc..2a7587315817 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3688,9 +3688,12 @@  started:
 		set_array_size(st, info, info->text_version);
 
 	if (info->new_level != reshape.level) {
-		if (fd < 0)
-			fd = open(devname, O_RDONLY);
-		impose_level(fd, info->new_level, devname, verbose);
+		fd = open_dev(sra->sys_name);
+		if (fd < 0) {
+			pr_err("Can't open %s\n", sra->sys_name);
+			goto out;
+		}
+		impose_level(fd, info->new_level, sra->sys_name, verbose);
 		close(fd);
 		if (info->new_level == 0)
 			st->update_tail = NULL;