ploop: Discard bios of size not aligned at 512 bytes

Submitted by Kirill Tkhai on Feb. 21, 2018, 11:41 a.m.

Details

Message ID 151921329816.3172.8845565373047221196.stgit@localhost.localdomain
State New
Series "ploop: Discard bios of size not aligned at 512 bytes"
Headers show

Commit Message

Kirill Tkhai Feb. 21, 2018, 11:41 a.m.
Currently, we have BUG_ON() on this place. But it's
easy to generate 511 bytes request from userspace,
as it was found by Andrey Vagin via iscsi tests:

sg_raw -r511 /dev/sda 28 0 0 0 0 0 0 0 9 0

This patch replaces BUG_ON() with bio discarding
like other drivers do when they see a size above
their logical block size.

https://jira.sw.ru/browse/PSBM-81576

Reported-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 6c0b3c0252c0..7f079aea0e88 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -846,7 +846,11 @@  static void ploop_make_request(struct request_queue *q, struct bio *bio)
 	plo->st.bio_in++;
 
 	BUG_ON(bio->bi_idx);
-	BUG_ON(bio->bi_size & 511);
+	if (bio->bi_size & 511) {
+		pr_err_once("ploop: dropped bio: bi_size=%u\n", bio->bi_size);
+		BIO_ENDIO(q, bio, -EIO);
+		return;
+	}
 
 	cpu = part_stat_lock();
 	part = disk_map_sector_rcu(plo->disk, bio->bi_sector);

Comments

Andrey Vagin Feb. 21, 2018, 5:29 p.m.
On Wed, Feb 21, 2018 at 02:41:47PM +0300, Kirill Tkhai wrote:
> Currently, we have BUG_ON() on this place. But it's
> easy to generate 511 bytes request from userspace,
> as it was found by Andrey Vagin via iscsi tests:
> 
> sg_raw -r511 /dev/sda 28 0 0 0 0 0 0 0 9 0
> 
> This patch replaces BUG_ON() with bio discarding
> like other drivers do when they see a size above
> their logical block size.
> 
> https://jira.sw.ru/browse/PSBM-81576
> 
> Reported-by: Andrey Vagin <avagin@virtuozzo.com>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  drivers/block/ploop/dev.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
> index 6c0b3c0252c0..7f079aea0e88 100644
> --- a/drivers/block/ploop/dev.c
> +++ b/drivers/block/ploop/dev.c
> @@ -846,7 +846,11 @@ static void ploop_make_request(struct request_queue *q, struct bio *bio)
>  	plo->st.bio_in++;
>  
>  	BUG_ON(bio->bi_idx);
> -	BUG_ON(bio->bi_size & 511);
> +	if (bio->bi_size & 511) {
> +		pr_err_once("ploop: dropped bio: bi_size=%u\n", bio->bi_size);

I think it would be better if we will know which ploop produces this
message
		pr_err_once("ploop%d: dropped bio: bi_size=%u\n", dev->index, bio->bi_size);

> +		BIO_ENDIO(q, bio, -EIO);
> +		return;
> +	}
>  
>  	cpu = part_stat_lock();
>  	part = disk_map_sector_rcu(plo->disk, bio->bi_sector);
>