Skip to content

Commit 5543217

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: move the misaligned flag into the features field
Move the misaligned flags into the features field to reclaim a little bit of space. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20240619154623.450048-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent bae1c74 commit 5543217

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

block/blk-settings.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static int blk_validate_limits(struct queue_limits *lim)
258258

259259
if (lim->alignment_offset) {
260260
lim->alignment_offset &= (lim->physical_block_size - 1);
261-
lim->misaligned = 0;
261+
lim->features &= ~BLK_FEAT_MISALIGNED;
262262
}
263263

264264
if (!(lim->features & BLK_FEAT_WRITE_CACHE))
@@ -470,6 +470,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
470470
if (!(b->features & BLK_FEAT_POLL))
471471
t->features &= ~BLK_FEAT_POLL;
472472

473+
t->flags |= (b->flags & BLK_FEAT_MISALIGNED);
474+
473475
t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
474476
t->max_user_sectors = min_not_zero(t->max_user_sectors,
475477
b->max_user_sectors);
@@ -494,8 +496,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
494496
t->max_segment_size = min_not_zero(t->max_segment_size,
495497
b->max_segment_size);
496498

497-
t->misaligned |= b->misaligned;
498-
499499
alignment = queue_limit_alignment_offset(b, start);
500500

501501
/* Bottom device has different alignment. Check that it is
@@ -509,7 +509,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
509509

510510
/* Verify that top and bottom intervals line up */
511511
if (max(top, bottom) % min(top, bottom)) {
512-
t->misaligned = 1;
512+
t->flags |= BLK_FEAT_MISALIGNED;
513513
ret = -1;
514514
}
515515
}
@@ -531,28 +531,28 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
531531
/* Physical block size a multiple of the logical block size? */
532532
if (t->physical_block_size & (t->logical_block_size - 1)) {
533533
t->physical_block_size = t->logical_block_size;
534-
t->misaligned = 1;
534+
t->flags |= BLK_FEAT_MISALIGNED;
535535
ret = -1;
536536
}
537537

538538
/* Minimum I/O a multiple of the physical block size? */
539539
if (t->io_min & (t->physical_block_size - 1)) {
540540
t->io_min = t->physical_block_size;
541-
t->misaligned = 1;
541+
t->flags |= BLK_FEAT_MISALIGNED;
542542
ret = -1;
543543
}
544544

545545
/* Optimal I/O a multiple of the physical block size? */
546546
if (t->io_opt & (t->physical_block_size - 1)) {
547547
t->io_opt = 0;
548-
t->misaligned = 1;
548+
t->flags |= BLK_FEAT_MISALIGNED;
549549
ret = -1;
550550
}
551551

552552
/* chunk_sectors a multiple of the physical block size? */
553553
if ((t->chunk_sectors << 9) & (t->physical_block_size - 1)) {
554554
t->chunk_sectors = 0;
555-
t->misaligned = 1;
555+
t->flags |= BLK_FEAT_MISALIGNED;
556556
ret = -1;
557557
}
558558

@@ -566,7 +566,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
566566

567567
/* Verify that new alignment_offset is on a logical block boundary */
568568
if (t->alignment_offset & (t->logical_block_size - 1)) {
569-
t->misaligned = 1;
569+
t->flags |= BLK_FEAT_MISALIGNED;
570570
ret = -1;
571571
}
572572

@@ -729,7 +729,7 @@ int bdev_alignment_offset(struct block_device *bdev)
729729
{
730730
struct request_queue *q = bdev_get_queue(bdev);
731731

732-
if (q->limits.misaligned)
732+
if (q->limits.flags & BLK_FEAT_MISALIGNED)
733733
return -1;
734734
if (bdev_is_partition(bdev))
735735
return queue_limit_alignment_offset(&q->limits,

include/linux/blkdev.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ enum {
341341
enum {
342342
/* do not send FLUSH/FUA commands despite advertising a write cache */
343343
BLK_FLAG_WRITE_CACHE_DISABLED = (1u << 0),
344+
345+
/* I/O topology is misaligned */
346+
BLK_FEAT_MISALIGNED = (1u << 1),
344347
};
345348

346349
struct queue_limits {
@@ -374,7 +377,6 @@ struct queue_limits {
374377
unsigned short max_integrity_segments;
375378
unsigned short max_discard_segments;
376379

377-
unsigned char misaligned;
378380
unsigned char discard_misaligned;
379381
unsigned char raid_partial_stripes_expensive;
380382
unsigned int max_open_zones;

0 commit comments

Comments
 (0)