[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2a6d5554-4f71-6476-6d14-031da52005f5@linux.dev>
Date: Wed, 27 Apr 2022 09:28:33 +0800
From: Guoqing Jiang <guoqing.jiang@...ux.dev>
To: Logan Gunthorpe <logang@...tatee.com>,
linux-kernel@...r.kernel.org, linux-raid@...r.kernel.org,
Song Liu <song@...nel.org>
Cc: Christoph Hellwig <hch@...radead.org>,
Stephen Bates <sbates@...thlin.com>,
Martin Oliveira <Martin.Oliveira@...eticom.com>,
David Sloan <David.Sloan@...eticom.com>,
Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v2 01/12] md/raid5: Factor out ahead_of_reshape() function
On 4/21/22 3:54 AM, Logan Gunthorpe wrote:
> There are a few uses of an ugly ternary operator in raid5_make_request()
> to check if a sector is a head of a reshape sector.
>
> Factor this out into a simple helper called ahead_of_reshape().
>
> This appears to fix the first bio_wouldblock_error() check which appears
> to have comparison operators that didn't match the check below which
> causes a schedule. Besides this, no functional changes intended.
>
> Suggested-by: Christoph Hellwig<hch@....de>
> Signed-off-by: Logan Gunthorpe<logang@...tatee.com>
> ---
> drivers/md/raid5.c | 29 +++++++++++++++++------------
> 1 file changed, 17 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 7f7d1546b9ba..97b23c18402b 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -5787,6 +5787,15 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
> bio_endio(bi);
> }
>
> +static bool ahead_of_reshape(struct mddev *mddev, sector_t sector,
> + sector_t reshape_sector)
> +{
> + if (mddev->reshape_backwards)
> + return sector < reshape_sector;
> + else
> + return sector >= reshape_sector;
> +}
I think it can be an inline function.
> +
> static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
> {
> struct r5conf *conf = mddev->private;
> @@ -5843,9 +5852,8 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
> /* Bail out if conflicts with reshape and REQ_NOWAIT is set */
> if ((bi->bi_opf & REQ_NOWAIT) &&
> (conf->reshape_progress != MaxSector) &&
> - (mddev->reshape_backwards
> - ? (logical_sector > conf->reshape_progress && logical_sector <= conf->reshape_safe)
> - : (logical_sector >= conf->reshape_safe && logical_sector < conf->reshape_progress))) {
> + !ahead_of_reshape(mddev, logical_sector, conf->reshape_progress) &&
> + ahead_of_reshape(mddev, logical_sector, conf->reshape_safe)) {
TBH, the previous code is more readable to me though I can live with the
change.
Thanks,
Guoqing
Powered by blists - more mailing lists