Skip to content

Commit 6317ab9

Browse files
johnpgarrykawasaki
authored andcommitted
block: use chunk_sectors when evaluating stacked atomic write limits
The atomic write unit max is limited by any stack device stripe size. It is required that the atomic write unit is a power-of-2 factor of the stripe size. Currently we use io_min limit to hold the stripe size, and check for a io_min <= SECTOR_SIZE when deciding if we have a striped stacked device. Nilay reports that this causes a problem when the physical block size is greater than SECTOR_SIZE [0]. Furthermore, io_min may be mutated when stacking devices, and this makes it a poor candidate to hold the stripe size. Such an example would be when the io_min is less than the physical block size. Use chunk_sectors to hold the stripe size, which is more appropriate. [0] https://lore.kernel.org/linux-block/[email protected]/T/#mecca17129f72811137d3c2f1e477634e77f06781 Signed-off-by: John Garry <[email protected]>
1 parent 5f756ca commit 6317ab9

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

block/blk-settings.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,13 @@ static bool blk_stack_atomic_writes_boundary_head(struct queue_limits *t,
594594
static bool blk_stack_atomic_writes_head(struct queue_limits *t,
595595
struct queue_limits *b)
596596
{
597+
unsigned int chunk_size = t->chunk_sectors << SECTOR_SHIFT;
598+
597599
if (b->atomic_write_hw_boundary &&
598600
!blk_stack_atomic_writes_boundary_head(t, b))
599601
return false;
600602

601-
if (t->io_min <= SECTOR_SIZE) {
603+
if (!t->chunk_sectors) {
602604
/* No chunk sectors, so use bottom device values directly */
603605
t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max;
604606
t->atomic_write_hw_unit_min = b->atomic_write_hw_unit_min;
@@ -617,12 +619,12 @@ static bool blk_stack_atomic_writes_head(struct queue_limits *t,
617619
* aligned with both limits, i.e. 8K in this example.
618620
*/
619621
t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max;
620-
while (t->io_min % t->atomic_write_hw_unit_max)
622+
while (chunk_size % t->atomic_write_hw_unit_max)
621623
t->atomic_write_hw_unit_max /= 2;
622624

623625
t->atomic_write_hw_unit_min = min(b->atomic_write_hw_unit_min,
624626
t->atomic_write_hw_unit_max);
625-
t->atomic_write_hw_max = min(b->atomic_write_hw_max, t->io_min);
627+
t->atomic_write_hw_max = min(b->atomic_write_hw_max, chunk_size);
626628

627629
return true;
628630
}

0 commit comments

Comments
 (0)