From: sashiko-bot@kernel.org
To: "Shuai Liu" <847807867@qq.com>, linux-mtd@lists.infradead.org
Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
syzbot+c66e7044aa73c620d862@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] mtd: blktrans: keep reclaim out of the ->release paths
Date: Tue, 17 Nov 2026 06:53:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-218282@kernel.org> (raw)
In-Reply-To: <tencent_9B9358CCE5C39B1E7017C4B42600DC95A409@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mtd: blktrans: missing memalloc_noio_save() in mtd_queue_rq()
I/O path
--
commit 8a8ffa3e0c75306708e0a409beff68c7d20840ca
Author: Shuai Liu <847807867@qq.com>
mtd: blktrans: keep reclaim out of the ->release paths
This commit wraps the translator ->release() callbacks in
blktrans_release() and del_mtd_blktrans_dev() with memalloc_noio_save()
and memalloc_noio_restore() to prevent memory reclaim from recursing into
the block queue under dev->lock.
> The io path is already protected: mtd_queue_rq() disables reclaim
> across dispatch with memalloc_noio_save(), because translators may
> allocate while processing requests under dev->lock and the srcu read
> side. ->release() runs under the same locks, so give it the same
> treatment in blktrans_release() and del_mtd_blktrans_dev().
[ ... ]
> diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
> index 4d2e7b7774e90..86a8644881ce7 100644
> --- a/drivers/mtd/mtd_blkdevs.c
> +++ b/drivers/mtd/mtd_blkdevs.c
> @@ -228,6 +228,7 @@ static int blktrans_open(struct gendisk *disk, blk_mode_t mode)
> static void blktrans_release(struct gendisk *disk)
> {
> struct mtd_blktrans_dev *dev = disk->private_data;
> + unsigned int noio_flags;
>
> mutex_lock(&dev->lock);
>
> @@ -237,8 +238,12 @@ static void blktrans_release(struct gendisk *disk)
> module_put(dev->tr->owner);
>
> if (dev->mtd) {
> - if (dev->tr->release)
> + if (dev->tr->release) {
> + /* Reclaim must not recurse into I/O while releasing the device. */
> + noio_flags = memalloc_noio_save();
> dev->tr->release(dev);
> + memalloc_noio_restore(noio_flags);
> + }
> __put_mtd_device(dev->mtd);
> }
[Severity: High]
Does mtd_queue_rq() or mtd_blktrans_work() actually call
memalloc_noio_save()?
Contrary to the commit message, neither function sets PF_MEMALLOC_NOIO:
drivers/mtd/mtd_blkdevs.c:mtd_queue_rq() {
...
spin_lock_irq(&dev->queue_lock);
list_add_tail(&bd->rq->queuelist, &dev->rq_list);
mtd_blktrans_work(dev);
spin_unlock_irq(&dev->queue_lock);
return BLK_STS_OK;
}
During normal request dispatch under set->srcu and dev->lock,
mtd_blktrans_work() -> do_blktrans_request() invokes translator callbacks
that allocate with GFP_KERNEL. For example, a REQ_OP_FLUSH request calls
mtdblock_flush(), which takes mtdblk->cache_mutex and runs
write_cached_data() -> erase_write() -> mtd_erase() -> concat_erase(),
hitting the same fs_reclaim lockdep cycle and reclaim deadlock on the I/O
path as well.
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_9B9358CCE5C39B1E7017C4B42600DC95A409@qq.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-11-17 6:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:01 [syzbot] [mtd?] possible deadlock in blktrans_release syzbot
2026-11-17 5:28 ` [PATCH] mtd: blktrans: keep reclaim out of the ->release paths Shuai Liu
2026-11-17 5:40 ` sashiko-bot
2026-11-17 6:08 ` [PATCH v2] " Shuai Liu
2026-11-17 6:53 ` sashiko-bot [this message]
2026-11-17 8:40 ` Shuai Liu
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-218282@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=847807867@qq.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=syzbot+c66e7044aa73c620d862@syzkaller.appspotmail.com \
--cc=vigneshr@ti.com \
/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