Re: [PATCH 2/2] dm era: fix error code propagation in era_ctr()

Ming Hung Tsai <[email protected]>
Newsgroups dev.linux.lists.dm-devel,org.kernel.vger.linux-kernel
Message-ID <CALjSBEtBfn8M+uZd24qYdjq-094xTcV11q1bPkKxEvASoy=djQ@mail.gmail.com>
On Wed, Jun 17, 2026 at 2:12 PM <[email protected]> wrote:
>
> From: Cao Guanghui <[email protected]>
>
> era_ctr() replaces the actual error codes returned by dm_get_device()
> and dm_set_target_max_io_len() with hardcoded -EINVAL, discarding
> the real reason for the failure (e.g. -ENODEV, -ENOMEM).  This makes
> it harder for users to diagnose problems and is inconsistent with
> other dm targets (dm-thin, dm-verity, dm-flakey, dm-ebs) which
> propagate the original error.
>
> Fix all three sites to return 'r' instead of -EINVAL.
>
> Signed-off-by: Cao Guanghui <[email protected]>

Thanks!

Reviewed-by: Ming-Hung Tsai <[email protected]>

> ---
>  drivers/md/dm-era-target.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
> index 08ce96e8cf4f..4eb1c4f90e1b 100644
> --- a/drivers/md/dm-era-target.c
> +++ b/drivers/md/dm-era-target.c
> @@ -1488,7 +1488,7 @@ static int era_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>         if (r) {
>                 ti->error = "Error opening metadata device";
>                 era_destroy(era);
> -               return -EINVAL;
> +               return r;
>         }
>
>         r = dm_get_device(ti, argv[1], BLK_OPEN_READ | BLK_OPEN_WRITE,
> @@ -1496,7 +1496,7 @@ static int era_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>         if (r) {
>                 ti->error = "Error opening data device";
>                 era_destroy(era);
> -               return -EINVAL;
> +               return r;
>         }
>
>         r = sscanf(argv[2], "%u%c", &era->sectors_per_block, &dummy);
> @@ -1510,7 +1510,7 @@ static int era_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>         if (r) {
>                 ti->error = "could not set max io len";
>                 era_destroy(era);
> -               return -EINVAL;
> +               return r;
>         }
>
>         if (!valid_block_size(era->sectors_per_block)) {
> --
> 2.25.1
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.