All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jack Wang" <jinpu.wang@ionos.com>
Cc: yukuai@fygo.io, linux-raid@vger.kernel.org
Subject: Re: [PATCH v2 6/8] md: pass a queue_limits through ->run()
Date: Thu, 10 Sep 2026 08:49:46 +0000	[thread overview]
Message-ID: <20260910084947.08C151F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910081114.1605746-7-jinpu.wang@ionos.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Array starts successfully but fails to apply its queue limits if queue_limits_commit_update() returns an error, leaving a running array with inconsistent block limits.
--

commit a296ef119cee93cfa123eae52144130e9c5df88f
Author: Jack Wang <jinpu.wang@cloud.ionos.com>

md: pass a queue_limits through ->run()

This commit delegates the application of queue limits to the top-level callers
that start the array. This is done to prevent lock inversion between the
reconfig_mutex and q->limits_lock. Personalities now pass the limits up
to be committed by the caller.

> diff --git a/drivers/md/md.c b/drivers/md/md.c
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c

[ ... ]

> @@ -4826,6 +4880,9 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
>  			mddev->hold_active = 0;
>  		sysfs_notify_dirent_safe(mddev->sysfs_state);
>  	}
> +	/* apply the limits before the array takes I/O */
> +	if (limp)
> +		err = queue_limits_commit_update(q, limp) ?: err;
>  	mddev_unlock(mddev);

[Severity: High]
If queue_limits_commit_update() fails here, does it leave the array in an
inconsistent state?

The limits are committed after do_md_run() has already activated the array.
If the commit fails, an error is returned to userspace, but the running array
isn't stopped or rolled back. Can this lead to block layer warnings, driver
crashes, or data corruption if I/O requests exceed the capabilities of the
underlying devices?

[ ... ]

> @@ -8660,7 +8742,7 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>  		goto unlock;
>  
>  	case RUN_ARRAY:
> -		err = do_md_run(mddev);
> +		err = do_md_run(mddev, limp);
>  		goto unlock;

[Severity: High]
Similarly, when do_md_run() successfully starts the array here, the limits
are committed later in the function (under the unlock label). If that commit
fails, the array will remain active with unvalidated or default limits.

Should there be a rollback mechanism (e.g., calling do_md_stop()) if the
limits cannot be successfully applied after the array is started?

> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c

[ ... ]

> @@ -3185,10 +3186,19 @@ static int raid1_set_limits(struct mddev *mddev)
>  	err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
>  	if (err)
>  		return err;
> +	/*
> +	 * The caller owns an update and commits it itself; taking
> +	 * q->limits_lock here would take it a second time.
> +	 */
> +	if (caller_lim) {
> +		*caller_lim = lim;
> +		return 0;
> +	}
> +
>  	return queue_limits_set(mddev->gendisk->queue, &lim);
>  }

[Severity: High]
By unconditionally returning 0 when caller_lim is provided, are we deferring
all limit validation until after the array is fully activated?

Because the personality's ->run() method copies the limits but does not
validate them with the block layer, the first point of failure becomes
queue_limits_commit_update() in the caller. Since the caller currently
lacks rollback handling, this guarantees the array is left running with
invalid limits if the configuration is rejected by blk_validate_limits().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910081114.1605746-1-jinpu.wang@ionos.com?part=6

  reply	other threads:[~2026-09-10  8:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  8:11 [PATCH v2 0/8] md: don't wait for q->limits_lock while md holds back I/O Jack Wang
2026-09-10  8:11 ` [PATCH v2 1/8] md: pass a queue_limits down to ->hot_add_disk() Jack Wang
2026-09-10  8:31   ` sashiko-bot
2026-09-11 10:46   ` Nilay Shroff
2026-09-10  8:11 ` [PATCH v2 2/8] md: don't wait for q->limits_lock in check_sb_changes() Jack Wang
2026-09-10  8:36   ` sashiko-bot
2026-09-10  8:11 ` [PATCH v2 3/8] md: pass a queue_limits through the rdev sysfs stores Jack Wang
2026-09-10  8:11 ` [PATCH v2 4/8] md: defer the io_opt update out of the sync thread Jack Wang
2026-09-10  8:37   ` sashiko-bot
2026-09-10  8:11 ` [PATCH v2 5/8] md: take q->limits_lock before locking and suspending the array Jack Wang
2026-09-10  8:51   ` sashiko-bot
2026-09-10  8:11 ` [PATCH v2 6/8] md: pass a queue_limits through ->run() Jack Wang
2026-09-10  8:49   ` sashiko-bot [this message]
2026-09-11 10:54   ` Nilay Shroff
2026-09-10  8:11 ` [PATCH v2 7/8] md: open new legs before locking the array Jack Wang
2026-09-10  8:48   ` sashiko-bot
2026-09-10  8:11 ` [PATCH v2 8/8] md: link a new leg's holder " Jack Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260910084947.08C151F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jinpu.wang@ionos.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yukuai@fygo.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.