@@ -266,7 +266,7 @@ static int blk_validate_limits(struct queue_limits *lim)
266266
267267 if (lim -> alignment_offset ) {
268268 lim -> alignment_offset &= (lim -> physical_block_size - 1 );
269- lim -> misaligned = 0 ;
269+ lim -> features &= ~ BLK_FEAT_MISALIGNED ;
270270 }
271271
272272 if (!(lim -> features & BLK_FEAT_WRITE_CACHE ))
@@ -477,6 +477,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
477477 if (!(b -> features & BLK_FEAT_POLL ))
478478 t -> features &= ~BLK_FEAT_POLL ;
479479
480+ t -> flags |= (b -> flags & BLK_FEAT_MISALIGNED );
481+
480482 t -> max_sectors = min_not_zero (t -> max_sectors , b -> max_sectors );
481483 t -> max_user_sectors = min_not_zero (t -> max_user_sectors ,
482484 b -> max_user_sectors );
@@ -501,8 +503,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
501503 t -> max_segment_size = min_not_zero (t -> max_segment_size ,
502504 b -> max_segment_size );
503505
504- t -> misaligned |= b -> misaligned ;
505-
506506 alignment = queue_limit_alignment_offset (b , start );
507507
508508 /* Bottom device has different alignment. Check that it is
@@ -516,7 +516,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
516516
517517 /* Verify that top and bottom intervals line up */
518518 if (max (top , bottom ) % min (top , bottom )) {
519- t -> misaligned = 1 ;
519+ t -> flags |= BLK_FEAT_MISALIGNED ;
520520 ret = -1 ;
521521 }
522522 }
@@ -538,42 +538,38 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
538538 /* Physical block size a multiple of the logical block size? */
539539 if (t -> physical_block_size & (t -> logical_block_size - 1 )) {
540540 t -> physical_block_size = t -> logical_block_size ;
541- t -> misaligned = 1 ;
541+ t -> flags |= BLK_FEAT_MISALIGNED ;
542542 ret = -1 ;
543543 }
544544
545545 /* Minimum I/O a multiple of the physical block size? */
546546 if (t -> io_min & (t -> physical_block_size - 1 )) {
547547 t -> io_min = t -> physical_block_size ;
548- t -> misaligned = 1 ;
548+ t -> flags |= BLK_FEAT_MISALIGNED ;
549549 ret = -1 ;
550550 }
551551
552552 /* Optimal I/O a multiple of the physical block size? */
553553 if (t -> io_opt & (t -> physical_block_size - 1 )) {
554554 t -> io_opt = 0 ;
555- t -> misaligned = 1 ;
555+ t -> flags |= BLK_FEAT_MISALIGNED ;
556556 ret = -1 ;
557557 }
558558
559559 /* chunk_sectors a multiple of the physical block size? */
560560 if ((t -> chunk_sectors << 9 ) & (t -> physical_block_size - 1 )) {
561561 t -> chunk_sectors = 0 ;
562- t -> misaligned = 1 ;
562+ t -> flags |= BLK_FEAT_MISALIGNED ;
563563 ret = -1 ;
564564 }
565565
566- t -> raid_partial_stripes_expensive =
567- max (t -> raid_partial_stripes_expensive ,
568- b -> raid_partial_stripes_expensive );
569-
570566 /* Find lowest common alignment_offset */
571567 t -> alignment_offset = lcm_not_zero (t -> alignment_offset , alignment )
572568 % max (t -> physical_block_size , t -> io_min );
573569
574570 /* Verify that new alignment_offset is on a logical block boundary */
575571 if (t -> alignment_offset & (t -> logical_block_size - 1 )) {
576- t -> misaligned = 1 ;
572+ t -> flags |= BLK_FEAT_MISALIGNED ;
577573 ret = -1 ;
578574 }
579575
@@ -585,16 +581,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
585581 if (b -> discard_granularity ) {
586582 alignment = queue_limit_discard_alignment (b , start );
587583
588- if (t -> discard_granularity != 0 &&
589- t -> discard_alignment != alignment ) {
590- top = t -> discard_granularity + t -> discard_alignment ;
591- bottom = b -> discard_granularity + alignment ;
592-
593- /* Verify that top and bottom intervals line up */
594- if ((max (top , bottom ) % min (top , bottom )) != 0 )
595- t -> discard_misaligned = 1 ;
596- }
597-
598584 t -> max_discard_sectors = min_not_zero (t -> max_discard_sectors ,
599585 b -> max_discard_sectors );
600586 t -> max_hw_discard_sectors = min_not_zero (t -> max_hw_discard_sectors ,
@@ -736,7 +722,7 @@ int bdev_alignment_offset(struct block_device *bdev)
736722{
737723 struct request_queue * q = bdev_get_queue (bdev );
738724
739- if (q -> limits .misaligned )
725+ if (q -> limits .flags & BLK_FEAT_MISALIGNED )
740726 return -1 ;
741727 if (bdev_is_partition (bdev ))
742728 return queue_limit_alignment_offset (& q -> limits ,
0 commit comments