* simplify I/O size calculation helpers
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: Mike Snitzer, linux-block, dm-devel
Hi Jens,
this series calculates various I/O size calculations.
Diffstat:
block/blk-merge.c | 33 ++++++++++++++++++---------------
drivers/md/dm.c | 18 ++++++------------
include/linux/blkdev.h | 27 ++++++++-------------------
3 files changed, 32 insertions(+), 46 deletions(-)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dm-devel] simplify I/O size calculation helpers
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
Hi Jens,
this series calculates various I/O size calculations.
Diffstat:
block/blk-merge.c | 33 ++++++++++++++++++---------------
drivers/md/dm.c | 18 ++++++------------
include/linux/blkdev.h | 27 ++++++++-------------------
3 files changed, 32 insertions(+), 46 deletions(-)
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/5] block: factor out a chunk_size_left helper
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
@ 2021-10-12 16:36 ` Christoph Hellwig
-1 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: Mike Snitzer, linux-block, dm-devel
Factor out a helper from blk_max_size_offset so that it can be reused
independently.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/blkdev.h | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 17705c970d7e1..0b020bb45a3e7 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -622,6 +622,18 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
return q->limits.max_sectors;
}
+/*
+ * Return how much of the chunk sectors is left to be used for an I/O at the
+ * given offset.
+ */
+static inline unsigned int chunk_size_left(sector_t offset,
+ unsigned int chunk_sectors)
+{
+ if (unlikely(!is_power_of_2(chunk_sectors)))
+ return chunk_sectors - sector_div(offset, chunk_sectors);
+ return chunk_sectors - (offset & (chunk_sectors - 1));
+}
+
/*
* Return maximum size of a request at given offset. Only valid for
* file system requests.
@@ -637,12 +649,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
return q->limits.max_sectors;
}
- if (likely(is_power_of_2(chunk_sectors)))
- chunk_sectors -= offset & (chunk_sectors - 1);
- else
- chunk_sectors -= sector_div(offset, chunk_sectors);
-
- return min(q->limits.max_sectors, chunk_sectors);
+ return min(q->limits.max_sectors,
+ chunk_size_left(offset, chunk_sectors));
}
/*
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [dm-devel] [PATCH 1/5] block: factor out a chunk_size_left helper
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
Factor out a helper from blk_max_size_offset so that it can be reused
independently.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/blkdev.h | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 17705c970d7e1..0b020bb45a3e7 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -622,6 +622,18 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
return q->limits.max_sectors;
}
+/*
+ * Return how much of the chunk sectors is left to be used for an I/O at the
+ * given offset.
+ */
+static inline unsigned int chunk_size_left(sector_t offset,
+ unsigned int chunk_sectors)
+{
+ if (unlikely(!is_power_of_2(chunk_sectors)))
+ return chunk_sectors - sector_div(offset, chunk_sectors);
+ return chunk_sectors - (offset & (chunk_sectors - 1));
+}
+
/*
* Return maximum size of a request at given offset. Only valid for
* file system requests.
@@ -637,12 +649,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
return q->limits.max_sectors;
}
- if (likely(is_power_of_2(chunk_sectors)))
- chunk_sectors -= offset & (chunk_sectors - 1);
- else
- chunk_sectors -= sector_div(offset, chunk_sectors);
-
- return min(q->limits.max_sectors, chunk_sectors);
+ return min(q->limits.max_sectors,
+ chunk_size_left(offset, chunk_sectors));
}
/*
--
2.30.2
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/5] dm: open code blk_max_size_offset in max_io_len
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
@ 2021-10-12 16:36 ` Christoph Hellwig
-1 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: Mike Snitzer, linux-block, dm-devel
max_io_len always passed in an explicit, non-zero chunk_sectors into
blk_max_size_offset. That means much of blk_max_size_offset is not needed
and open coding it simplifies the code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a011d09cb0fac..0b6dfe8667438 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -944,24 +944,18 @@ static inline sector_t max_io_len_target_boundary(struct dm_target *ti,
static sector_t max_io_len(struct dm_target *ti, sector_t sector)
{
sector_t target_offset = dm_target_offset(ti, sector);
- sector_t len = max_io_len_target_boundary(ti, target_offset);
- sector_t max_len;
+ unsigned int len = max_io_len_target_boundary(ti, target_offset);
/*
* Does the target need to split IO even further?
* - varied (per target) IO splitting is a tenet of DM; this
* explains why stacked chunk_sectors based splitting via
- * blk_max_size_offset() isn't possible here. So pass in
- * ti->max_io_len to override stacked chunk_sectors.
+ * blk_queue_split() isn't possible here.
*/
- if (ti->max_io_len) {
- max_len = blk_max_size_offset(ti->table->md->queue,
- target_offset, ti->max_io_len);
- if (len > max_len)
- len = max_len;
- }
-
- return len;
+ if (!ti->max_io_len)
+ return len;
+ return min3(len, ti->table->md->queue->limits.max_sectors,
+ chunk_size_left(target_offset, ti->max_io_len));
}
int dm_set_target_max_io_len(struct dm_target *ti, sector_t len)
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [dm-devel] [PATCH 2/5] dm: open code blk_max_size_offset in max_io_len
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
max_io_len always passed in an explicit, non-zero chunk_sectors into
blk_max_size_offset. That means much of blk_max_size_offset is not needed
and open coding it simplifies the code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a011d09cb0fac..0b6dfe8667438 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -944,24 +944,18 @@ static inline sector_t max_io_len_target_boundary(struct dm_target *ti,
static sector_t max_io_len(struct dm_target *ti, sector_t sector)
{
sector_t target_offset = dm_target_offset(ti, sector);
- sector_t len = max_io_len_target_boundary(ti, target_offset);
- sector_t max_len;
+ unsigned int len = max_io_len_target_boundary(ti, target_offset);
/*
* Does the target need to split IO even further?
* - varied (per target) IO splitting is a tenet of DM; this
* explains why stacked chunk_sectors based splitting via
- * blk_max_size_offset() isn't possible here. So pass in
- * ti->max_io_len to override stacked chunk_sectors.
+ * blk_queue_split() isn't possible here.
*/
- if (ti->max_io_len) {
- max_len = blk_max_size_offset(ti->table->md->queue,
- target_offset, ti->max_io_len);
- if (len > max_len)
- len = max_len;
- }
-
- return len;
+ if (!ti->max_io_len)
+ return len;
+ return min3(len, ti->table->md->queue->limits.max_sectors,
+ chunk_size_left(target_offset, ti->max_io_len));
}
int dm_set_target_max_io_len(struct dm_target *ti, sector_t len)
--
2.30.2
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/5] block: open code blk_max_size_offset in blk_rq_get_max_sectors
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
@ 2021-10-12 16:36 ` Christoph Hellwig
-1 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: Mike Snitzer, linux-block, dm-devel
blk_rq_get_max_sectors always uses q->limits.chunk_sectors as the
chunk_sectors argument, and already checks for max_sectors through the
call to blk_queue_get_max_sectors. That means much of
blk_max_size_offset is not needed and open coding it simplifies the code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 14ce19607cd8a..b3da43160032f 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -595,17 +595,18 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
sector_t offset)
{
struct request_queue *q = rq->q;
+ unsigned int max_sectors;
if (blk_rq_is_passthrough(rq))
return q->limits.max_hw_sectors;
- if (!q->limits.chunk_sectors ||
- req_op(rq) == REQ_OP_DISCARD ||
- req_op(rq) == REQ_OP_SECURE_ERASE)
- return blk_queue_get_max_sectors(q, req_op(rq));
-
- return min(blk_max_size_offset(q, offset, 0),
- blk_queue_get_max_sectors(q, req_op(rq)));
+ max_sectors = blk_queue_get_max_sectors(q, req_op(rq));
+ if (q->limits.chunk_sectors &&
+ req_op(rq) != REQ_OP_DISCARD &&
+ req_op(rq) != REQ_OP_SECURE_ERASE)
+ max_sectors = min(max_sectors,
+ chunk_size_left(offset, q->limits.chunk_sectors));
+ return max_sectors;
}
static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [dm-devel] [PATCH 3/5] block: open code blk_max_size_offset in blk_rq_get_max_sectors
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
blk_rq_get_max_sectors always uses q->limits.chunk_sectors as the
chunk_sectors argument, and already checks for max_sectors through the
call to blk_queue_get_max_sectors. That means much of
blk_max_size_offset is not needed and open coding it simplifies the code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 14ce19607cd8a..b3da43160032f 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -595,17 +595,18 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
sector_t offset)
{
struct request_queue *q = rq->q;
+ unsigned int max_sectors;
if (blk_rq_is_passthrough(rq))
return q->limits.max_hw_sectors;
- if (!q->limits.chunk_sectors ||
- req_op(rq) == REQ_OP_DISCARD ||
- req_op(rq) == REQ_OP_SECURE_ERASE)
- return blk_queue_get_max_sectors(q, req_op(rq));
-
- return min(blk_max_size_offset(q, offset, 0),
- blk_queue_get_max_sectors(q, req_op(rq)));
+ max_sectors = blk_queue_get_max_sectors(q, req_op(rq));
+ if (q->limits.chunk_sectors &&
+ req_op(rq) != REQ_OP_DISCARD &&
+ req_op(rq) != REQ_OP_SECURE_ERASE)
+ max_sectors = min(max_sectors,
+ chunk_size_left(offset, q->limits.chunk_sectors));
+ return max_sectors;
}
static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
--
2.30.2
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/5] block: fold blk_max_size_offset into get_max_io_size
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
@ 2021-10-12 16:36 ` Christoph Hellwig
-1 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: Mike Snitzer, linux-block, dm-devel
Fold blk_max_size_offset into the only remaining user.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 14 +++++++++-----
include/linux/blkdev.h | 19 -------------------
2 files changed, 9 insertions(+), 24 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index b3da43160032f..15b2aef1507e5 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -177,14 +177,18 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
static inline unsigned get_max_io_size(struct request_queue *q,
struct bio *bio)
{
- unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
- unsigned max_sectors = sectors;
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
- unsigned start_offset = bio->bi_iter.bi_sector & (pbs - 1);
+ sector_t sector = bio->bi_iter.bi_sector;
+ unsigned start_offset = sector & (pbs - 1);
+ unsigned sectors = q->limits.max_sectors;
+ unsigned max_sectors;
- max_sectors += start_offset;
- max_sectors &= ~(pbs - 1);
+ if (q->limits.chunk_sectors)
+ sectors = min(chunk_size_left(sector, q->limits.chunk_sectors),
+ sectors);
+
+ max_sectors = (sectors + start_offset) & ~(pbs - 1);
if (max_sectors > start_offset)
return max_sectors - start_offset;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0b020bb45a3e7..c2fa4666f25e3 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -634,25 +634,6 @@ static inline unsigned int chunk_size_left(sector_t offset,
return chunk_sectors - (offset & (chunk_sectors - 1));
}
-/*
- * Return maximum size of a request at given offset. Only valid for
- * file system requests.
- */
-static inline unsigned int blk_max_size_offset(struct request_queue *q,
- sector_t offset,
- unsigned int chunk_sectors)
-{
- if (!chunk_sectors) {
- if (q->limits.chunk_sectors)
- chunk_sectors = q->limits.chunk_sectors;
- else
- return q->limits.max_sectors;
- }
-
- return min(q->limits.max_sectors,
- chunk_size_left(offset, chunk_sectors));
-}
-
/*
* Access functions for manipulating queue properties
*/
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [dm-devel] [PATCH 4/5] block: fold blk_max_size_offset into get_max_io_size
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
Fold blk_max_size_offset into the only remaining user.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 14 +++++++++-----
include/linux/blkdev.h | 19 -------------------
2 files changed, 9 insertions(+), 24 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index b3da43160032f..15b2aef1507e5 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -177,14 +177,18 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
static inline unsigned get_max_io_size(struct request_queue *q,
struct bio *bio)
{
- unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
- unsigned max_sectors = sectors;
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
- unsigned start_offset = bio->bi_iter.bi_sector & (pbs - 1);
+ sector_t sector = bio->bi_iter.bi_sector;
+ unsigned start_offset = sector & (pbs - 1);
+ unsigned sectors = q->limits.max_sectors;
+ unsigned max_sectors;
- max_sectors += start_offset;
- max_sectors &= ~(pbs - 1);
+ if (q->limits.chunk_sectors)
+ sectors = min(chunk_size_left(sector, q->limits.chunk_sectors),
+ sectors);
+
+ max_sectors = (sectors + start_offset) & ~(pbs - 1);
if (max_sectors > start_offset)
return max_sectors - start_offset;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0b020bb45a3e7..c2fa4666f25e3 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -634,25 +634,6 @@ static inline unsigned int chunk_size_left(sector_t offset,
return chunk_sectors - (offset & (chunk_sectors - 1));
}
-/*
- * Return maximum size of a request at given offset. Only valid for
- * file system requests.
- */
-static inline unsigned int blk_max_size_offset(struct request_queue *q,
- sector_t offset,
- unsigned int chunk_sectors)
-{
- if (!chunk_sectors) {
- if (q->limits.chunk_sectors)
- chunk_sectors = q->limits.chunk_sectors;
- else
- return q->limits.max_sectors;
- }
-
- return min(q->limits.max_sectors,
- chunk_size_left(offset, chunk_sectors));
-}
-
/*
* Access functions for manipulating queue properties
*/
--
2.30.2
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] block: pass the start sector to get_max_io_size
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
@ 2021-10-12 16:36 ` Christoph Hellwig
-1 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: Mike Snitzer, linux-block, dm-devel
Pass the start sector instead of the whole bio.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 15b2aef1507e5..b397972b526a0 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -174,12 +174,10 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
* requests that are submitted to a block device if the start of a bio is not
* aligned to a physical block boundary.
*/
-static inline unsigned get_max_io_size(struct request_queue *q,
- struct bio *bio)
+static inline unsigned get_max_io_size(struct request_queue *q, sector_t sector)
{
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
- sector_t sector = bio->bi_iter.bi_sector;
unsigned start_offset = sector & (pbs - 1);
unsigned sectors = q->limits.max_sectors;
unsigned max_sectors;
@@ -287,7 +285,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
struct bio_vec bv, bvprv, *bvprvp = NULL;
struct bvec_iter iter;
unsigned nsegs = 0, sectors = 0;
- const unsigned max_sectors = get_max_io_size(q, bio);
+ const unsigned max_sectors = get_max_io_size(q, bio->bi_iter.bi_sector);
const unsigned max_segs = queue_max_segments(q);
bio_for_each_bvec(bv, bio, iter) {
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [dm-devel] [PATCH 5/5] block: pass the start sector to get_max_io_size
@ 2021-10-12 16:36 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-12 16:36 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
Pass the start sector instead of the whole bio.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 15b2aef1507e5..b397972b526a0 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -174,12 +174,10 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
* requests that are submitted to a block device if the start of a bio is not
* aligned to a physical block boundary.
*/
-static inline unsigned get_max_io_size(struct request_queue *q,
- struct bio *bio)
+static inline unsigned get_max_io_size(struct request_queue *q, sector_t sector)
{
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
- sector_t sector = bio->bi_iter.bi_sector;
unsigned start_offset = sector & (pbs - 1);
unsigned sectors = q->limits.max_sectors;
unsigned max_sectors;
@@ -287,7 +285,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
struct bio_vec bv, bvprv, *bvprvp = NULL;
struct bvec_iter iter;
unsigned nsegs = 0, sectors = 0;
- const unsigned max_sectors = get_max_io_size(q, bio);
+ const unsigned max_sectors = get_max_io_size(q, bio->bi_iter.bi_sector);
const unsigned max_segs = queue_max_segments(q);
bio_for_each_bvec(bv, bio, iter) {
--
2.30.2
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [dm-devel] [PATCH 1/5] block: factor out a chunk_size_left helper
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
@ 2021-10-12 16:50 ` Bart Van Assche
-1 siblings, 0 replies; 14+ messages in thread
From: Bart Van Assche @ 2021-10-12 16:50 UTC (permalink / raw)
To: Christoph Hellwig, Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
On 10/12/21 9:36 AM, Christoph Hellwig wrote:
> +/*
> + * Return how much of the chunk sectors is left to be used for an I/O at the
> + * given offset.
> + */
> +static inline unsigned int chunk_size_left(sector_t offset,
> + unsigned int chunk_sectors)
> +{
> + if (unlikely(!is_power_of_2(chunk_sectors)))
> + return chunk_sectors - sector_div(offset, chunk_sectors);
> + return chunk_sectors - (offset & (chunk_sectors - 1));
> +}
No "blk_" prefix for the function name? I think most other functions
declared or defined in this header file have such a prefix.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dm-devel] [PATCH 1/5] block: factor out a chunk_size_left helper
@ 2021-10-12 16:50 ` Bart Van Assche
0 siblings, 0 replies; 14+ messages in thread
From: Bart Van Assche @ 2021-10-12 16:50 UTC (permalink / raw)
To: Christoph Hellwig, Jens Axboe; +Cc: linux-block, dm-devel, Mike Snitzer
On 10/12/21 9:36 AM, Christoph Hellwig wrote:
> +/*
> + * Return how much of the chunk sectors is left to be used for an I/O at the
> + * given offset.
> + */
> +static inline unsigned int chunk_size_left(sector_t offset,
> + unsigned int chunk_sectors)
> +{
> + if (unlikely(!is_power_of_2(chunk_sectors)))
> + return chunk_sectors - sector_div(offset, chunk_sectors);
> + return chunk_sectors - (offset & (chunk_sectors - 1));
> +}
No "blk_" prefix for the function name? I think most other functions
declared or defined in this header file have such a prefix.
Thanks,
Bart.
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-10-12 16:50 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 16:36 simplify I/O size calculation helpers Christoph Hellwig
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
2021-10-12 16:36 ` [PATCH 1/5] block: factor out a chunk_size_left helper Christoph Hellwig
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
2021-10-12 16:50 ` Bart Van Assche
2021-10-12 16:50 ` Bart Van Assche
2021-10-12 16:36 ` [PATCH 2/5] dm: open code blk_max_size_offset in max_io_len Christoph Hellwig
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
2021-10-12 16:36 ` [PATCH 3/5] block: open code blk_max_size_offset in blk_rq_get_max_sectors Christoph Hellwig
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
2021-10-12 16:36 ` [PATCH 4/5] block: fold blk_max_size_offset into get_max_io_size Christoph Hellwig
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
2021-10-12 16:36 ` [PATCH 5/5] block: pass the start sector to get_max_io_size Christoph Hellwig
2021-10-12 16:36 ` [dm-devel] " Christoph Hellwig
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.