From: Yongpeng Yang <yangyongpeng.storage@gmail.com>
To: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>,
axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org,
mpatocka@redhat.com, song@kernel.org, yukuai@fnnas.com,
hch@lst.de, sagi@grimberg.me, kch@nvidia.com, jaegeuk@kernel.org,
chao@kernel.org, cem@kernel.org
Cc: dm-devel@lists.linux.dev, linux-raid@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-block@vger.kernel.org, bpf@vger.kernel.org,
linux-xfs@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH V3 4/6] nvmet: ignore discard return value
Date: Wed, 26 Nov 2025 18:14:32 +0800 [thread overview]
Message-ID: <e40cb47c-9f92-4982-bf3f-45ec9f2a1681@gmail.com> (raw)
In-Reply-To: <20251124234806.75216-5-ckulkarnilinux@gmail.com>
On 11/25/25 07:48, Chaitanya Kulkarni wrote:
> __blkdev_issue_discard() always returns 0, making the error checking
> in nvmet_bdev_discard_range() dead code.
>
> Kill the function nvmet_bdev_discard_range() and call
> __blkdev_issue_discard() directly from nvmet_bdev_execute_discard(),
> since no error handling is needed anymore for __blkdev_issue_discard()
> call.
>
> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
> ---
> drivers/nvme/target/io-cmd-bdev.c | 28 +++++++---------------------
> 1 file changed, 7 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
> index 8d246b8ca604..ca7731048940 100644
> --- a/drivers/nvme/target/io-cmd-bdev.c
> +++ b/drivers/nvme/target/io-cmd-bdev.c
> @@ -362,29 +362,14 @@ u16 nvmet_bdev_flush(struct nvmet_req *req)
> return 0;
> }
>
> -static u16 nvmet_bdev_discard_range(struct nvmet_req *req,
> - struct nvme_dsm_range *range, struct bio **bio)
> -{
> - struct nvmet_ns *ns = req->ns;
> - int ret;
> -
> - ret = __blkdev_issue_discard(ns->bdev,
> - nvmet_lba_to_sect(ns, range->slba),
> - le32_to_cpu(range->nlb) << (ns->blksize_shift - 9),
> - GFP_KERNEL, bio);
> - if (ret && ret != -EOPNOTSUPP) {
> - req->error_slba = le64_to_cpu(range->slba);
> - return errno_to_nvme_status(req, ret);
> - }
> - return NVME_SC_SUCCESS;
> -}
> -
> static void nvmet_bdev_execute_discard(struct nvmet_req *req)
> {
> + struct nvmet_ns *ns = req->ns;
> struct nvme_dsm_range range;
> struct bio *bio = NULL;
> + sector_t nr_sects;
> int i;
> - u16 status;
> + u16 status = NVME_SC_SUCCESS;
>
> for (i = 0; i <= le32_to_cpu(req->cmd->dsm.nr); i++) {
> status = nvmet_copy_from_sgl(req, i * sizeof(range), &range,
> @@ -392,9 +377,10 @@ static void nvmet_bdev_execute_discard(struct nvmet_req *req)
> if (status)
> break;
>
> - status = nvmet_bdev_discard_range(req, &range, &bio);
> - if (status)
> - break;
> + nr_sects = le32_to_cpu(range.nlb) << (ns->blksize_shift - 9);
> + __blkdev_issue_discard(ns->bdev,
> + nvmet_lba_to_sect(ns, range.slba), nr_sects,
> + GFP_KERNEL, &bio);
We also need to check for memory allocation errors in
__blkdev_issue_discard(). However, this cannot be done by simply
checking if bio is NULL. Similar to the issue with xfs_discard_extents,
once __blkdev_issue_discard()->blk_alloc_discard_bio() succeeds once,
any subsequent memory allocation failures cannot be detected by checking
if bio is NULL.
Yongpeng,
> }
>
> if (bio) {
next prev parent reply other threads:[~2025-11-26 10:14 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 23:48 [PATCH V3 0/6] block: ignore __blkdev_issue_discard() ret value Chaitanya Kulkarni
2025-11-24 23:48 ` [PATCH V3 1/6] block: ignore discard return value Chaitanya Kulkarni
2025-11-25 17:38 ` Jens Axboe
2025-11-25 19:09 ` Chaitanya Kulkarni
2025-11-25 19:19 ` Jens Axboe
2025-11-24 23:48 ` [PATCH V3 2/6] md: " Chaitanya Kulkarni
2025-12-01 6:22 ` Chaitanya Kulkarni
2026-01-24 21:29 ` Chaitanya Kulkarni
2025-11-24 23:48 ` [PATCH V3 3/6] dm: " Chaitanya Kulkarni
2025-11-24 23:48 ` [PATCH V3 4/6] nvmet: " Chaitanya Kulkarni
2025-11-26 10:14 ` Yongpeng Yang [this message]
2025-11-26 10:37 ` [f2fs-dev] " Christoph Hellwig
2026-01-24 21:35 ` Chaitanya Kulkarni
2026-01-26 4:57 ` hch
2026-01-27 22:40 ` Chaitanya Kulkarni
2025-11-24 23:48 ` [PATCH V3 5/6] f2fs: " Chaitanya Kulkarni
2025-11-25 1:10 ` Chao Yu
2025-11-25 6:33 ` Christoph Hellwig
2025-11-25 7:11 ` Chao Yu
2025-11-26 2:47 ` Chao Yu
2025-11-26 3:37 ` Chaitanya Kulkarni
2025-11-26 3:58 ` Chao Yu
2025-11-24 23:48 ` [PATCH V3 6/6] xfs: " Chaitanya Kulkarni
2025-11-26 2:37 ` [f2fs-dev] " Yongpeng Yang
2025-11-26 8:07 ` Chaitanya Kulkarni
2025-11-26 9:14 ` Yongpeng Yang
2025-11-26 9:48 ` Yongpeng Yang
2025-11-26 10:34 ` hch
2025-11-26 10:33 ` Christoph Hellwig
2025-11-25 13:20 ` [PATCH V3 0/6] block: ignore __blkdev_issue_discard() ret value Anuj gupta
2025-11-25 19:20 ` (subset) " Jens Axboe
2025-12-03 21:50 ` [f2fs-dev] " patchwork-bot+f2fs
2025-12-09 17:18 ` patchwork-bot+f2fs
2025-12-16 0:50 ` patchwork-bot+f2fs
2026-02-17 21:14 ` patchwork-bot+f2fs
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=e40cb47c-9f92-4982-bf3f-45ec9f2a1681@gmail.com \
--to=yangyongpeng.storage@gmail.com \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=cem@kernel.org \
--cc=chao@kernel.org \
--cc=ckulkarnilinux@gmail.com \
--cc=dm-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=johannes.thumshirn@wdc.com \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mpatocka@redhat.com \
--cc=sagi@grimberg.me \
--cc=snitzer@kernel.org \
--cc=song@kernel.org \
--cc=yukuai@fnnas.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