From: Mikulas Patocka <mpatocka@redhat.com>
To: David Teigland <teigland@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: heinzm@redhat.com, Zdenek Kabelac <zkabelac@redhat.com>,
Marian Csontos <mcsontos@redhat.com>,
linux-block@vger.kernel.org, dm-devel@redhat.com
Subject: [PATCH] blk-settings: make sure that max_sectors is aligned on "logical_block_size" boundary.
Date: Thu, 19 Nov 2020 15:36:51 -0500 (EST) [thread overview]
Message-ID: <alpine.LRH.2.02.2011191517360.10231@file01.intranet.prod.int.rdu2.redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.02.2011191337180.588@file01.intranet.prod.int.rdu2.redhat.com>
We get these I/O errors when we run md-raid1 on the top of dm-integrity on
the top of ramdisk:
device-mapper: integrity: Bio not aligned on 8 sectors: 0xff00, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0xff00, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0xffff, 0x1
device-mapper: integrity: Bio not aligned on 8 sectors: 0xffff, 0x1
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8048, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8147, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8246, 0xff
device-mapper: integrity: Bio not aligned on 8 sectors: 0x8345, 0xbb
The ramdisk device has logical_block_size 512 and max_sectors 255. The
dm-integrity device uses logical_block_size 4096 and it doesn't affect the
"max_sectors" value - thus, it inherits 255 from the ramdisk. So, we have
a device with max_sectors not aligned on logical_block_size.
The md-raid device sees that the underlying leg has max_sectors 255 and it
will split the bios on 255-sector boundary, making the bios unaligned on
logical_block_size.
In order to fix the bug, we round down max_sectors to logical_block_size.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
---
block/blk-settings.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Index: linux-2.6/block/blk-settings.c
===================================================================
--- linux-2.6.orig/block/blk-settings.c 2020-10-29 12:20:46.000000000 +0100
+++ linux-2.6/block/blk-settings.c 2020-11-19 21:20:18.000000000 +0100
@@ -591,6 +591,16 @@ int blk_stack_limits(struct queue_limits
ret = -1;
}
+ t->max_sectors = round_down(t->max_sectors, t->logical_block_size / 512);
+ if (t->max_sectors < PAGE_SIZE / 512)
+ t->max_sectors = PAGE_SIZE / 512;
+ t->max_hw_sectors = round_down(t->max_hw_sectors, t->logical_block_size / 512);
+ if (t->max_sectors < PAGE_SIZE / 512)
+ t->max_hw_sectors = PAGE_SIZE / 512;
+ t->max_dev_sectors = round_down(t->max_dev_sectors, t->logical_block_size / 512);
+ if (t->max_sectors < PAGE_SIZE / 512)
+ t->max_dev_sectors = PAGE_SIZE / 512;
+
/* Discard alignment and granularity */
if (b->discard_granularity) {
alignment = queue_limit_discard_alignment(b, start);
next parent reply other threads:[~2020-11-19 20:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201118203127.GA30066@redhat.com>
[not found] ` <20201118203408.GB30066@redhat.com>
[not found] ` <fc7c4efd-0bb3-f023-19c6-54359d279ca8@redhat.com>
[not found] ` <alpine.LRH.2.02.2011190810001.32672@file01.intranet.prod.int.rdu2.redhat.com>
[not found] ` <20201119172807.GC1879@redhat.com>
[not found] ` <alpine.LRH.2.02.2011191337180.588@file01.intranet.prod.int.rdu2.redhat.com>
2020-11-19 20:36 ` Mikulas Patocka [this message]
2020-11-20 1:27 ` [dm-devel] [PATCH] blk-settings: make sure that max_sectors is aligned on "logical_block_size" boundary John Dorminy
2020-11-20 9:47 ` Mikulas Patocka
2020-11-20 14:19 ` [PATCH v2] " Mikulas Patocka
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=alpine.LRH.2.02.2011191517360.10231@file01.intranet.prod.int.rdu2.redhat.com \
--to=mpatocka@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=heinzm@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=mcsontos@redhat.com \
--cc=teigland@redhat.com \
--cc=zkabelac@redhat.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;
as well as URLs for NNTP newsgroup(s).