1 From 95b1369a9638cfa322ad1c0cde8efbe524059884 Mon Sep 17 00:00:00 2001
2 From: Mikulas Patocka <mpatocka@redhat.com>
3 Date: Tue, 7 Nov 2017 10:40:40 -0500
4 Subject: dm integrity: allow unaligned bv_offset
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Mikulas Patocka <mpatocka@redhat.com>
11 commit 95b1369a9638cfa322ad1c0cde8efbe524059884 upstream.
13 When slub_debug is enabled kmalloc returns unaligned memory. XFS uses
14 this unaligned memory for its buffers (if an unaligned buffer crosses a
15 page, XFS frees it and allocates a full page instead - see the function
16 xfs_buf_allocate_memory).
18 dm-integrity checks if bv_offset is aligned on page size and this check
19 fail with slub_debug and XFS.
21 Fix this bug by removing the bv_offset check, leaving only the check for
24 Fixes: 7eada909bfd7 ("dm: add integrity target")
25 Reported-by: Bruno Prémont <bonbons@sysophe.eu>
26 Reviewed-by: Milan Broz <gmazyland@gmail.com>
27 Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
28 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 drivers/md/dm-integrity.c | 2 +-
33 1 file changed, 1 insertion(+), 1 deletion(-)
35 --- a/drivers/md/dm-integrity.c
36 +++ b/drivers/md/dm-integrity.c
37 @@ -1376,7 +1376,7 @@ static int dm_integrity_map(struct dm_ta
38 struct bvec_iter iter;
40 bio_for_each_segment(bv, bio, iter) {
41 - if (unlikely((bv.bv_offset | bv.bv_len) & ((ic->sectors_per_block << SECTOR_SHIFT) - 1))) {
42 + if (unlikely(bv.bv_len & ((ic->sectors_per_block << SECTOR_SHIFT) - 1))) {
43 DMERR("Bio vector (%u,%u) is not aligned on %u-sector boundary",
44 bv.bv_offset, bv.bv_len, ic->sectors_per_block);