From: Keith Busch <kbusch@meta.com>
To: <linux-block@vger.kernel.org>
Cc: <axboe@kernel.org>, <ming.lei@redhat.com>, <nilay@linux.ibm.com>,
<chaitanyak@nvidia.com>, Keith Busch <kbusch@kernel.org>
Subject: [PATCHv3 2/4] block: __blkdev_issue_write_zeroes cleanup
Date: Thu, 22 Feb 2024 11:19:20 -0800 [thread overview]
Message-ID: <20240222191922.2130580-3-kbusch@meta.com> (raw)
In-Reply-To: <20240222191922.2130580-1-kbusch@meta.com>
From: Keith Busch <kbusch@kernel.org>
Use min to calculate the next number of sectors like everyone else.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
block/blk-lib.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 91770da2239f2..d4c476cf3784a 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -132,19 +132,16 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
return -EOPNOTSUPP;
while (nr_sects) {
+ unsigned int len = min_t(sector_t, nr_sects, max_write_zeroes_sectors);
+
bio = blk_next_bio(bio, bdev, 0, REQ_OP_WRITE_ZEROES, gfp_mask);
bio->bi_iter.bi_sector = sector;
if (flags & BLKDEV_ZERO_NOUNMAP)
bio->bi_opf |= REQ_NOUNMAP;
- if (nr_sects > max_write_zeroes_sectors) {
- bio->bi_iter.bi_size = max_write_zeroes_sectors << 9;
- nr_sects -= max_write_zeroes_sectors;
- sector += max_write_zeroes_sectors;
- } else {
- bio->bi_iter.bi_size = nr_sects << 9;
- nr_sects = 0;
- }
+ bio->bi_iter.bi_size = len << 9;
+ nr_sects -= len;
+ sector += len;
cond_resched();
}
--
2.34.1
next prev parent reply other threads:[~2024-02-22 19:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 19:19 [PATCHv3 0/4] block: make long runnint operations killable Keith Busch
2024-02-22 19:19 ` [PATCHv3 1/4] block: blkdev_issue_secure_erase loop style Keith Busch
2024-02-23 3:22 ` Ming Lei
2024-02-23 6:41 ` Christoph Hellwig
2024-02-22 19:19 ` Keith Busch [this message]
2024-02-23 3:29 ` [PATCHv3 2/4] block: __blkdev_issue_write_zeroes cleanup Ming Lei
2024-02-23 6:42 ` Christoph Hellwig
2024-02-22 19:19 ` [PATCHv3 3/4] block: introduce io wait hang check helper Keith Busch
2024-02-23 3:31 ` Ming Lei
2024-02-23 6:43 ` Christoph Hellwig
2024-02-22 19:19 ` [PATCHv3 4/4] blk-lib: check for kill signal Keith Busch
2024-02-23 3:38 ` Ming Lei
2024-02-23 6:46 ` Christoph Hellwig
2024-02-23 11:00 ` Nilay Shroff
2024-02-23 15:58 ` Keith Busch
2024-02-23 11:25 ` [PATCHv3 0/4] block: make long runnint operations killable Nilay Shroff
2024-02-23 15:57 ` Keith Busch
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=20240222191922.2130580-3-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=axboe@kernel.org \
--cc=chaitanyak@nvidia.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=nilay@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.