Skip to contentSkip to conversation

brd: remove max_hw_sectors limit and warn on un-aligned buffer

PATCH Applied Ming Lei 2 participants 4 messages Dec 4, 2019

Subsystems (2)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

cover brd: remove max_hw_sectors limit and warn on un-aligned buffer

Hi,

The 1st patch removes max_hw_sectors queue limit.

The 2nd one adds warning on un-aligned buffer.

Ming Lei (2):
brd: remove max_hw_sectors queue limit
brd: warn on un-aligned buffer

 drivers/block/brd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Cc Stephen Rust <[email protected]>
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/2 brd: remove max_hw_sectors queue limit

Now we depend on blk_queue_split() to respect most of queue limit (the only one exception could be dma alignment), however blk_queue_split() isn't used for brd, so this limit isn't respected since v4.3.

Also max_hw_sectors limit doesn't play a big role for brd, which is added since brd is added to tree for unknown reason.

So remove it.

---
 drivers/block/brd.c | 1 -
 1 file changed, 1 deletion(-)
drivers/block/brd.c +0 -1
index c548a5a6c1a0..c2e5b2ad88bc 100644
@@ -382,7 +382,6 @@ static struct brd_device *brd_alloc(int i)
 		goto out_free_dev;
 
 	blk_queue_make_request(brd->brd_queue, brd_make_request);
-	blk_queue_max_hw_sectors(brd->brd_queue, 1024);
 
 	/* This is so fdisk will align partitions on 4k, because of
 	 * direct_access API needing 4k alignment, returning a PFN
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH 2/2 brd: warn on un-aligned buffer

In reply to Ming Lei

Queue dma alignment limit requires users(fs, target, ...) of block layer to pass aligned buffer.

So far brd doesn't support un-aligned buffer, even though it is easy to support it.

However, given brd is often used for debug purpose, and there are other drivers which can't support un-aligned buffer too.

So add warning so that brd users know what to fix.

---
 drivers/block/brd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/block/brd.c +4 -0
index c2e5b2ad88bc..a8730cc4db10 100644
@@ -297,6 +297,10 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
 		unsigned int len = bvec.bv_len;
 		int err;
 
+		/* Don't support un-aligned buffer */
+		WARN_ON_ONCE((bvec.bv_offset & (SECTOR_SIZE - 1)) ||
+				(len & (SECTOR_SIZE - 1)));
+
 		err = brd_do_bvec(brd, bvec.bv_page, len, bvec.bv_offset,
 				  bio_op(bio), sector);
 		if (err)
Signature · 1 line
2.20.1
maintainer Applied
#3 lore raw
In reply to Ming Lei
Quoted 7 lines · Ming Lei

Hi,

The 1st patch removes max_hw_sectors queue limit.

The 2nd one adds warning on un-aligned buffer.

Quoted 8 lines

Ming Lei (2):
brd: remove max_hw_sectors queue limit
brd: warn on un-aligned buffer

  drivers/block/brd.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
Cc Stephen Rust <[email protected]>

Applied, thanks Ming.

Signature · 1 line
Jens Axboe