Linux RAID subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: linux-raid@vger.kernel.org, yukuai@fygo.io
Subject: Re: [PATCH AUTOSEL 6.18] md/raid5: complete discard bios while reshape is active
Date: Mon, 19 Oct 2026 15:25:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-177721@kernel.org> (raw)
In-Reply-To: <20261019135441.1420968-447-sashal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] md/raid5: make_discard_request() returns BLK_STS_AGAIN without REQ_NOWAIT
--

commit 2fc0a245a9d15532fa0b76f75c094edac4ec73ed
Author: Genjian Zhang <zhanggenjian@kylinos.cn>

md/raid5: complete discard bios while reshape is active

This commit completes discard bios in make_discard_request() with
BLK_STS_AGAIN when reshape is active instead of returning without
calling bio_endio().

Link: https://patch.msgid.link/20260711161326.962336-1-zhanggenjian@126.com

> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 2817cd7d197e9..b7da2b83e1938 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -5707,8 +5707,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
>  	int stripe_sectors;
>  
>  	if (mddev->reshape_position != MaxSector)
> -		/* Skip discard while reshape is happening */
> -		return;
> +		goto complete_again;
>  
>  	stripe_sectors = conf->chunk_sectors *
>  		(conf->raid_disks - conf->max_degraded);
> @@ -5786,6 +5785,11 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
>  	}
>  
>  	bio_endio(bi);
> +	return;
> +
> +complete_again:
> +	/* Skip discard while reshape is happening */
> +	bio_endio_status(bi, BLK_STS_AGAIN);
>  }

[Severity: Medium]
Is it valid to complete synchronous discard bios with BLK_STS_AGAIN when
REQ_NOWAIT is not set?

In include/linux/blk_types.h, BLK_STS_AGAIN is documented as only valid
when RQF_NOWAIT is set:

    /*
     * BLK_STS_AGAIN should only be returned if RQF_NOWAIT is set
     * and the bio would block (cf bio_wouldblock_error())
     */
    #define BLK_STS_AGAIN		((__force blk_status_t)12)

When a mounted filesystem or fstrim issues a synchronous discard via
sb_issue_discard() -> blkdev_issue_discard() -> submit_bio_wait() while
RAID5 reshape is active (mddev->reshape_position != MaxSector),
blkdev_issue_discard() only masks -EOPNOTSUPP and propagates -EAGAIN to
the caller:

    if (!ret && bio) {
        ret = submit_bio_wait(bio);
        if (ret == -EOPNOTSUPP)
            ret = 0;
        bio_put(bio);
    }

In fs/ext4/mballoc.c:ext4_mb_clear_bb(), when freeing blocks with the
discard mount option enabled (in no-journal or data=writeback mode),
only -EOPNOTSUPP is ignored:

    if (test_opt(sb, DISCARD)) {
        err = ext4_issue_discard(sb, block_group, bit,
                                 count_clusters);
        if (err == -EOPNOTSUPP)
            err = 0;
        if (err)
            ext4_msg(sb, KERN_WARNING, "discard request in"
                     " group:%u block:%d count:%lu failed"
                     " with %d", block_group, bit, count,
                     err);
    }

When err is -EAGAIN, ext4_mb_clear_bb() skips freeing cross-group
overflow blocks and passes -EAGAIN to ext4_std_error(sb, err), marking
the filesystem in error and triggering a read-only remount or panic.

Similarly, in fs/gfs2/rgrp.c:gfs2_rgrp_send_discards(), an -EAGAIN
return from sb_issue_discard() jumps to fail: and sets
sdp->sd_args.ar_discard = 0, permanently disabling discards on the
mounted filesystem even after reshape completes.

Since make_discard_request() already completes skipped sub-stripe
advisory discards with bio_endio(bi) (BLK_STS_OK):

    if (first_stripe >= last_stripe) {
        bio_endio(bi);
        return;
    }

should discard bios skipped during reshape also be completed with
bio_endio(bi) (or BLK_STS_NOTSUPP) when REQ_NOWAIT is not set?

>  
>  static bool ahead_of_reshape(struct mddev *mddev, sector_t sector,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261019135441.1420968-447-sashal@kernel.org?part=1

      reply	other threads:[~2026-10-19 15:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261019135441.1420968-1-sashal@kernel.org>
2026-10-19 13:46 ` [PATCH AUTOSEL 6.18-5.10] md: add cond_resched() to md_do_sync()'s skip path Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18] md: skip bitmap accounting for empty write ranges Sasha Levin
2026-10-19 15:34   ` sashiko-bot
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-5.10] md/raid5: reject zero-sector reshape chunks Sasha Levin
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18] md/raid5: complete discard bios while reshape is active Sasha Levin
2026-10-19 15:25   ` sashiko-bot [this message]

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=sashiko-outbox-177721@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=sashal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox