Skip to content

Commit d0ac06a

Browse files
author
Mikulas Patocka
committed
dm-bufio: align write boundary on physical block size
There may be devices with physical block size larger than 4k. If dm-bufio sends I/O that is not aligned on physical block size, performance is degraded. The 4k minimum alignment limit is there because some SSDs report logical and physical block size 512 despite having 4k internally - so dm-bufio shouldn't send I/Os not aligned on 4k boundary, because they perform badly (the SSD does read-modify-write for them). Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Reported-by: Uladzislau Rezki (Sony) <urezki@gmail.com> Cc: stable@vger.kernel.org
1 parent ce51c69 commit d0ac06a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/md/dm-bufio.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ static void submit_io(struct dm_buffer *b, enum req_op op, unsigned short ioprio
13741374
{
13751375
unsigned int n_sectors;
13761376
sector_t sector;
1377-
unsigned int offset, end;
1377+
unsigned int offset, end, align;
13781378

13791379
b->end_io = end_io;
13801380

@@ -1388,9 +1388,11 @@ static void submit_io(struct dm_buffer *b, enum req_op op, unsigned short ioprio
13881388
b->c->write_callback(b);
13891389
offset = b->write_start;
13901390
end = b->write_end;
1391-
offset &= -DM_BUFIO_WRITE_ALIGN;
1392-
end += DM_BUFIO_WRITE_ALIGN - 1;
1393-
end &= -DM_BUFIO_WRITE_ALIGN;
1391+
align = max(DM_BUFIO_WRITE_ALIGN,
1392+
bdev_physical_block_size(b->c->bdev));
1393+
offset &= -align;
1394+
end += align - 1;
1395+
end &= -align;
13941396
if (unlikely(end > b->c->block_size))
13951397
end = b->c->block_size;
13961398

0 commit comments

Comments
 (0)