public inbox for linux-raid@vger.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Christoph Hellwig <hch@lst.de>,
	Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"dm-devel@lists.linux.dev" <dm-devel@lists.linux.dev>,
	"linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>,
	"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"agk@redhat.com" <agk@redhat.com>,
	"snitzer@kernel.org" <snitzer@kernel.org>,
	"mpatocka@redhat.com" <mpatocka@redhat.com>,
	"song@kernel.org" <song@kernel.org>,
	"yukuai3@huawei.com" <yukuai3@huawei.com>,
	"sagi@grimberg.me" <sagi@grimberg.me>,
	Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	"jaegeuk@kernel.org" <jaegeuk@kernel.org>,
	"chao@kernel.org" <chao@kernel.org>,
	"cem@kernel.org" <cem@kernel.org>
Subject: Re: [RFC PATCH] block: change __blkdev_issue_discard() return type to void
Date: Wed, 19 Nov 2025 01:48:16 +0000	[thread overview]
Message-ID: <ac3443b4-9b68-4613-b6df-c94970d1fc68@nvidia.com> (raw)
In-Reply-To: <20251118080427.GA26299@lst.de>

On 11/18/25 00:04, Christoph Hellwig wrote:
> On Mon, Nov 17, 2025 at 11:42:43PM -0800, Chaitanya Kulkarni wrote:
>> Due to involvement of all the subsystem making it as an RFC, ideally
>> it shuoldn't be an RFC.
> I think best would be a series that drops error checking first,
> and then changes the return type.  That way we can maybe get all
> the callers fixed up in this merge window and then drop the return
> value after -rc1.

thanks for the suggestion

>>   			gfp_mask)))
>>   		*biop = bio_chain_and_submit(*biop, bio);
>> -	return 0;
>>   }
>>   EXPORT_SYMBOL(__blkdev_issue_discard);
>>   
>> @@ -90,8 +89,8 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
>>   	int ret;
>>   
>>   	blk_start_plug(&plug);
>> -	ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, &bio);
>> -	if (!ret && bio) {
>> +	__blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, &bio);
> ret now needs to be initialized to 0 above.

done.

>
>> index 8d246b8ca604..f26010c46c33 100644
>> --- a/drivers/nvme/target/io-cmd-bdev.c
>> +++ b/drivers/nvme/target/io-cmd-bdev.c
>> @@ -366,16 +366,11 @@ 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,
>> +	__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;
> nvmet_bdev_discard_range can return void now.

done.

>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index b45eace879d7..e6078176f733 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -1346,7 +1346,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
>>   		if (time_to_inject(sbi, FAULT_DISCARD)) {
>>   			err = -EIO;
>>   		} else {
>> -			err = __blkdev_issue_discard(bdev,
>> +			__blkdev_issue_discard(bdev,
>>   					SECTOR_FROM_BLOCK(start),
>>   					SECTOR_FROM_BLOCK(len),
>>   					GFP_NOFS, &bio);
> Please fold the following 'if (err)' block directly into the injection
> one, and either initialize err to 0, or use a direct return from that
> block to skip the last branch in the function checking err.

done :-

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b45eace879d7..3dbcfb9067e9 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1343,15 +1343,9 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
  
                 dc->di.len += len;
  
+               err = 0;
                 if (time_to_inject(sbi, FAULT_DISCARD)) {
                         err = -EIO;
-               } else {
-                       err = __blkdev_issue_discard(bdev,
-                                       SECTOR_FROM_BLOCK(start),
-                                       SECTOR_FROM_BLOCK(len),
-                                       GFP_NOFS, &bio);
-               }
-               if (err) {
                         spin_lock_irqsave(&dc->lock, flags);
                         if (dc->state == D_PARTIAL)
                                 dc->state = D_SUBMIT;
@@ -1360,6 +1354,10 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
                         break;
                 }
  
+               __blkdev_issue_discard(bdev,
+                               SECTOR_FROM_BLOCK(start),
+                               SECTOR_FROM_BLOCK(len),
+                               GFP_NOFS, &bio);
                 f2fs_bug_on(sbi, !bio);
  
                 /*
-- 
2.40.0


>
>>   	blk_finish_plug(&plug);
>>   
>> -	return error;
>> +	return 0;
> Please drop the error return for xfs_discard_extents entirely.
>

done :-

diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index ee49f20875af..1f35c1d80cea 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -108,7 +108,7 @@ xfs_discard_endio(
   * list. We plug and chain the bios so that we only need a single completion
   * call to clear all the busy extents once the discards are complete.
   */
-int
+void
  xfs_discard_extents(
  	struct xfs_mount	*mp,
  	struct xfs_busy_extents	*extents)
@@ -116,7 +116,6 @@ xfs_discard_extents(
  	struct xfs_extent_busy	*busyp;
  	struct bio		*bio = NULL;
  	struct blk_plug		plug;
-	int			error = 0;
  
  	blk_start_plug(&plug);
  	list_for_each_entry(busyp, &extents->extent_list, list) {
@@ -126,18 +125,10 @@ xfs_discard_extents(
  
  		trace_xfs_discard_extent(xg, busyp->bno, busyp->length);
  
-		error = __blkdev_issue_discard(btp->bt_bdev,
+		__blkdev_issue_discard(btp->bt_bdev,
  				xfs_gbno_to_daddr(xg, busyp->bno),
  				XFS_FSB_TO_BB(mp, busyp->length),
  				GFP_KERNEL, &bio);
-		if (error && error != -EOPNOTSUPP) {
-			xfs_info(mp,
-	 "discard failed for extent [0x%llx,%u], error %d",
-				 (unsigned long long)busyp->bno,
-				 busyp->length,
-				 error);
-			break;
-		}
  	}
  
  	if (bio) {
@@ -148,8 +139,6 @@ xfs_discard_extents(
  		xfs_discard_endio_work(&extents->endio_work);
  	}
  	blk_finish_plug(&plug);
-
-	return error;
  }
  
  /*
@@ -385,9 +374,7 @@ xfs_trim_perag_extents(
  		 * list  after this function call, as it may have been freed by
  		 * the time control returns to us.
  		 */
-		error = xfs_discard_extents(pag_mount(pag), extents);
-		if (error)
-			break;
+		xfs_discard_extents(pag_mount(pag), extents);
  
  		if (xfs_trim_should_stop())
  			break;
@@ -496,12 +483,10 @@ xfs_discard_rtdev_extents(
  
  		trace_xfs_discard_rtextent(mp, busyp->bno, busyp->length);
  
-		error = __blkdev_issue_discard(bdev,
+		__blkdev_issue_discard(bdev,
  				xfs_rtb_to_daddr(mp, busyp->bno),
  				XFS_FSB_TO_BB(mp, busyp->length),
  				GFP_NOFS, &bio);
-		if (error)
-			break;
  	}
  	xfs_discard_free_rtdev_extents(tr);
  
@@ -739,9 +724,7 @@ xfs_trim_rtgroup_extents(
  		 * list  after this function call, as it may have been freed by
  		 * the time control returns to us.
  		 */
-		error = xfs_discard_extents(rtg_mount(rtg), tr.extents);
-		if (error)
-			break;
+		xfs_discard_extents(rtg_mount(rtg), tr.extents);
  
  		low = tr.restart_rtx;
  	} while (!xfs_trim_should_stop() && low <= high);
diff --git a/fs/xfs/xfs_discard.h b/fs/xfs/xfs_discard.h
index 2b1a85223a56..8c5cc4af6a07 100644
--- a/fs/xfs/xfs_discard.h
+++ b/fs/xfs/xfs_discard.h
@@ -6,7 +6,7 @@ struct fstrim_range;
  struct xfs_mount;
  struct xfs_busy_extents;
  
-int xfs_discard_extents(struct xfs_mount *mp, struct xfs_busy_extents *busy);
+void xfs_discard_extents(struct xfs_mount *mp, struct xfs_busy_extents *busy);
  int xfs_ioc_trim(struct xfs_mount *mp, struct fstrim_range __user *fstrim);
  
  #endif /* XFS_DISCARD_H */
-- 
2.40.0


will run the basic xfstest and send out a series to just remove the dead-code.

Thanks for the review comments.

-ck



      reply	other threads:[~2025-11-19  1:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18  7:42 [RFC PATCH] block: change __blkdev_issue_discard() return type to void Chaitanya Kulkarni
2025-11-18  8:04 ` Christoph Hellwig
2025-11-19  1:48   ` Chaitanya Kulkarni [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=ac3443b4-9b68-4613-b6df-c94970d1fc68@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --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=linux-block@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.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