OSDN Git Service

block: Improve physical block alignment of split bios
authorBart Van Assche <bvanassche@acm.org>
Thu, 1 Aug 2019 22:50:44 +0000 (15:50 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 5 Aug 2019 03:41:29 +0000 (21:41 -0600)
commit9cc5169cd478bc596902a57580804f1da3dfd74e
tree98fedd293733a36dae88142eafd518688ada4fbd
parent708b25b344fd9bedd02ccc0f8eee71f7006d7d07
block: Improve physical block alignment of split bios

Consider the following example:
* The logical block size is 4 KB.
* The physical block size is 8 KB.
* max_sectors equals (16 KB >> 9) sectors.
* A non-aligned 4 KB and an aligned 64 KB bio are merged into a single
  non-aligned 68 KB bio.

The current behavior is to split such a bio into (16 KB + 16 KB + 16 KB
+ 16 KB + 4 KB). The start of none of these five bio's is aligned to a
physical block boundary.

This patch ensures that such a bio is split into four aligned and
one non-aligned bio instead of being split into five non-aligned bios.
This improves performance because most block devices can handle aligned
requests faster than non-aligned requests.

Since the physical block size is larger than or equal to the logical
block size, this patch preserves the guarantee that the returned
value is a multiple of the logical block size.

Cc: Christoph Hellwig <hch@infradead.org>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-merge.c