Re: [PATCH v3 11/11] md: fix abnormal io_opt from member disks

Li Nan <[email protected]>
Newsgroups gmane.linux.raid
Message-ID <[email protected]>

在 2026/1/12 2:26, Yu Kuai 写道:
> It's reported that mtp3sas can report abnormal io_opt, for consequence,
> md array will end up with abnormal io_opt as well, due to the
> lcm_not_zero() from blk_stack_limits().
> 
> Some personalities will configure optimal IO size, and it's indicate that
> users can get the best IO bandwidth if they issue IO with this size, and
> we don't want io_opt to be covered by member disks with abnormal io_opt.
> 
> Fix this problem by adding a new mddev flags MD_STACK_IO_OPT to indicate
> that io_opt configured by personalities is preferred over member disks
> or not.
> 
> Reported-by: Filippo Giunchedi <[email protected]>
> Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1121006
> Reported-by: Coly Li <[email protected]>
> Closes: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Yu Kuai <[email protected]>
> ---
>   drivers/md/md.c     | 35 ++++++++++++++++++++++++++++++++++-
>   drivers/md/md.h     |  5 ++++-
>   drivers/md/raid1.c  |  2 +-
>   drivers/md/raid10.c |  4 ++--
>   4 files changed, 41 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 731ec800f5cb..5a10c922107b 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6200,11 +6200,17 @@ static const struct kobj_type md_ktype = {
>   
>   int mdp_major = 0;
>   
> +static bool rdev_is_mddev(struct md_rdev *rdev)
> +{
> +	return rdev->bdev->bd_disk->fops == &md_fops;
> +}
> +
>   /* stack the limit for all rdevs into lim */
>   int mddev_stack_rdev_limits(struct mddev *mddev, struct queue_limits *lim,
>   		unsigned int flags)
>   {
>   	struct md_rdev *rdev;
> +	unsigned int io_opt = lim->io_opt;
>   
>   	rdev_for_each(rdev, mddev) {
>   		queue_limits_stack_bdev(lim, rdev->bdev, rdev->data_offset,
> @@ -6212,6 +6218,9 @@ int mddev_stack_rdev_limits(struct mddev *mddev, struct queue_limits *lim,
>   		if ((flags & MDDEV_STACK_INTEGRITY) &&
>   		    !queue_limits_stack_integrity_bdev(lim, rdev->bdev))
>   			return -EINVAL;
> +
> +		if (rdev_is_mddev(rdev))
> +			set_bit(MD_STACK_IO_OPT, &mddev->flags);
>   	}
>   

We only intend to do lcm_not_zero() with the mddev's opt, so would this
modification be more reasonable?


@@ -6204,6 +6210,11 @@ int mddev_stack_rdev_limits(struct mddev *mddev, 
struct queue_limits *lim,
                 if ((flags & MDDEV_STACK_INTEGRITY) &&
                     !queue_limits_stack_integrity_bdev(lim, rdev->bdev))
                         return -EINVAL;
+
+               if (rdev_is_mddev(rdev))
+                       io_opt = lim->io_opt;
+               else if (io_opt)
+                       lim->io_opt = io_opt;
         }

-- 
Thanks,
Nan
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.