Re: [PATCH v2 07/11] md: add a helper md_config_align_limits()
Li Nan <[email protected]>
| Newsgroups | gmane.linux.raid |
|---|---|
| Message-ID | <[email protected]> |
在 2026/1/3 23:45, Yu Kuai 写道: > This helper will be used by personalities that want to align bio to > io_opt to get best IO bandwidth. > > Also add the new flag to UNSUPPORTED_MDDEV_FLAGS for now, following > patches will enable this for personalities. > > Signed-off-by: Yu Kuai <[email protected]> > --- > drivers/md/md.h | 11 +++++++++++ > drivers/md/raid0.c | 3 ++- > drivers/md/raid1.c | 3 ++- > drivers/md/raid5.c | 3 ++- > 4 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/drivers/md/md.h b/drivers/md/md.h > index e7aba83b708b..ddf989f2a139 100644 > --- a/drivers/md/md.h > +++ b/drivers/md/md.h > @@ -1091,6 +1091,17 @@ static inline bool rdev_blocked(struct md_rdev *rdev) > return false; > } > > +static inline void md_config_align_limits(struct mddev *mddev, > + struct queue_limits *lim) > +{ > + if ((lim->max_hw_sectors << 9) < lim->io_opt) > + lim->max_hw_sectors = lim->io_opt >> 9; > + else > + lim->max_hw_sectors = rounddown(lim->max_hw_sectors, > + lim->io_opt >> 9); > + set_bit(MD_BIO_ALIGN, &mddev->flags); > +} > + > #define mddev_add_trace_msg(mddev, fmt, args...) \ > do { \ > if (!mddev_is_dm(mddev)) \ > diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c > index d83b2b1c0049..f3814a69cd13 100644 > --- a/drivers/md/raid0.c > +++ b/drivers/md/raid0.c > @@ -29,7 +29,8 @@ module_param(default_layout, int, 0644); > (1L << MD_HAS_PPL) | \ > (1L << MD_HAS_MULTIPLE_PPLS) | \ > (1L << MD_FAILLAST_DEV) | \ > - (1L << MD_SERIALIZE_POLICY)) > + (1L << MD_SERIALIZE_POLICY) | \ > + (1L << MD_BIO_ALIGN)) > > /* > * inform the user of the raid configuration > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > index f4c7004888af..1a957dba2640 100644 > --- a/drivers/md/raid1.c > +++ b/drivers/md/raid1.c > @@ -42,7 +42,8 @@ > ((1L << MD_HAS_JOURNAL) | \ > (1L << MD_JOURNAL_CLEAN) | \ > (1L << MD_HAS_PPL) | \ > - (1L << MD_HAS_MULTIPLE_PPLS)) > + (1L << MD_HAS_MULTIPLE_PPLS) | \ > + (1L << MD_BIO_ALIGN)) > > static void allow_barrier(struct r1conf *conf, sector_t sector_nr); > static void lower_barrier(struct r1conf *conf, sector_t sector_nr); > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > index db0afb0b70e8..005a2404de27 100644 > --- a/drivers/md/raid5.c > +++ b/drivers/md/raid5.c > @@ -59,7 +59,8 @@ > #define UNSUPPORTED_MDDEV_FLAGS \ > ((1L << MD_FAILFAST_SUPPORTED) | \ > (1L << MD_FAILLAST_DEV) | \ > - (1L << MD_SERIALIZE_POLICY)) > + (1L << MD_SERIALIZE_POLICY) | \ > + (1L << MD_BIO_ALIGN)) > > > #define cpu_to_group(cpu) cpu_to_node(cpu) LGTM Reviewed-by: Li Nan <[email protected]> -- Thanks, Nan