Skip to content

Commit e821bce

Browse files
committed
Merge branch 'for-6.11/block-limits' into for-6.11/block
Merge in queue limits cleanups. * for-6.11/block-limits: block: move the raid_partial_stripes_expensive flag into the features field block: remove the discard_alignment flag block: move the misaligned flag into the features field block: renumber and rename the cache disabled flag block: fix spelling and grammar for in writeback_cache_control.rst block: remove the unused blk_bounce enum
2 parents 5ddb88f + 7d4dec5 commit e821bce

9 files changed

Lines changed: 29 additions & 51 deletions

File tree

Documentation/block/writeback_cache_control.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ flag in the features field of the queue_limits structure.
7070
Implementation details for bio based block drivers
7171
--------------------------------------------------
7272

73-
For bio based drivers the REQ_PREFLUSH and REQ_FUA bit are simplify passed on
74-
to the driver if the drivers sets the BLK_FEAT_WRITE_CACHE flag and the drivers
73+
For bio based drivers the REQ_PREFLUSH and REQ_FUA bit are simply passed on to
74+
the driver if the driver sets the BLK_FEAT_WRITE_CACHE flag and the driver
7575
needs to handle them.
7676

7777
*NOTE*: The REQ_FUA bit also gets passed on when the BLK_FEAT_FUA flags is
@@ -89,7 +89,7 @@ When the BLK_FEAT_WRITE_CACHE flag is set, REQ_OP_WRITE | REQ_PREFLUSH requests
8989
with a payload are automatically turned into a sequence of a REQ_OP_FLUSH
9090
request followed by the actual write by the block layer.
9191

92-
When the BLK_FEAT_FUA flags is set, the REQ_FUA bit simplify passed on for the
92+
When the BLK_FEAT_FUA flags is set, the REQ_FUA bit is simply passed on for the
9393
REQ_OP_WRITE request, else a REQ_OP_FLUSH request is sent by the block layer
9494
after the completion of the write request for bio submissions with the REQ_FUA
9595
bit set.

block/blk-settings.c

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

block/blk-sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
429429

430430
static ssize_t queue_wc_show(struct request_queue *q, char *page)
431431
{
432-
if (q->limits.features & BLK_FLAGS_WRITE_CACHE_DISABLED)
432+
if (q->limits.features & BLK_FLAG_WRITE_CACHE_DISABLED)
433433
return sprintf(page, "write through\n");
434434
return sprintf(page, "write back\n");
435435
}
@@ -452,9 +452,9 @@ static ssize_t queue_wc_store(struct request_queue *q, const char *page,
452452

453453
lim = queue_limits_start_update(q);
454454
if (disable)
455-
lim.flags |= BLK_FLAGS_WRITE_CACHE_DISABLED;
455+
lim.flags |= BLK_FLAG_WRITE_CACHE_DISABLED;
456456
else
457-
lim.flags &= ~BLK_FLAGS_WRITE_CACHE_DISABLED;
457+
lim.flags &= ~BLK_FLAG_WRITE_CACHE_DISABLED;
458458
err = queue_limits_commit_update(q, &lim);
459459
if (err)
460460
return err;

drivers/md/bcache/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
14161416
}
14171417

14181418
if (bdev_io_opt(dc->bdev))
1419-
dc->partial_stripes_expensive =
1420-
q->limits.raid_partial_stripes_expensive;
1419+
dc->partial_stripes_expensive = q->limits.features &
1420+
BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;
14211421

14221422
ret = bcache_device_init(&dc->disk, block_size,
14231423
bdev_nr_sectors(dc->bdev) - dc->sb.data_offset,

drivers/md/dm-cache-target.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3403,7 +3403,6 @@ static void set_discard_limits(struct cache *cache, struct queue_limits *limits)
34033403
limits->max_hw_discard_sectors = origin_limits->max_hw_discard_sectors;
34043404
limits->discard_granularity = origin_limits->discard_granularity;
34053405
limits->discard_alignment = origin_limits->discard_alignment;
3406-
limits->discard_misaligned = origin_limits->discard_misaligned;
34073406
}
34083407

34093408
static void cache_io_hints(struct dm_target *ti, struct queue_limits *limits)

drivers/md/dm-clone-target.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,6 @@ static void set_discard_limits(struct clone *clone, struct queue_limits *limits)
20592059
limits->max_hw_discard_sectors = dest_limits->max_hw_discard_sectors;
20602060
limits->discard_granularity = dest_limits->discard_granularity;
20612061
limits->discard_alignment = dest_limits->discard_alignment;
2062-
limits->discard_misaligned = dest_limits->discard_misaligned;
20632062
limits->max_discard_segments = dest_limits->max_discard_segments;
20642063
}
20652064

drivers/md/dm-table.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18081808
limits->max_hw_discard_sectors = 0;
18091809
limits->discard_granularity = 0;
18101810
limits->discard_alignment = 0;
1811-
limits->discard_misaligned = 0;
18121811
}
18131812

18141813
if (!dm_table_supports_write_zeroes(t))

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7711,7 +7711,7 @@ static int raid5_set_limits(struct mddev *mddev)
77117711
blk_set_stacking_limits(&lim);
77127712
lim.io_min = mddev->chunk_sectors << 9;
77137713
lim.io_opt = lim.io_min * (conf->raid_disks - conf->max_degraded);
7714-
lim.raid_partial_stripes_expensive = 1;
7714+
lim.features |= BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;
77157715
lim.discard_granularity = stripe;
77167716
lim.max_write_zeroes_sectors = 0;
77177717
mddev_stack_rdev_limits(mddev, &lim, 0);

include/linux/blkdev.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -328,28 +328,26 @@ enum {
328328

329329
/* bounce all highmem pages */
330330
BLK_FEAT_BOUNCE_HIGH = (1u << 14),
331+
332+
/* undocumented magic for bcache */
333+
BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE = (1u << 15),
331334
};
332335

333336
/*
334337
* Flags automatically inherited when stacking limits.
335338
*/
336339
#define BLK_FEAT_INHERIT_MASK \
337340
(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA | BLK_FEAT_ROTATIONAL | \
338-
BLK_FEAT_STABLE_WRITES | BLK_FEAT_ZONED | BLK_FEAT_BOUNCE_HIGH)
341+
BLK_FEAT_STABLE_WRITES | BLK_FEAT_ZONED | BLK_FEAT_BOUNCE_HIGH | \
342+
BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE)
339343

340344
/* internal flags in queue_limits.flags */
341345
enum {
342-
/* do not send FLUSH or FUA command despite advertised write cache */
343-
BLK_FLAGS_WRITE_CACHE_DISABLED = (1u << 31),
344-
};
346+
/* do not send FLUSH/FUA commands despite advertising a write cache */
347+
BLK_FLAG_WRITE_CACHE_DISABLED = (1u << 0),
345348

346-
/*
347-
* BLK_BOUNCE_NONE: never bounce (default)
348-
* BLK_BOUNCE_HIGH: bounce all highmem pages
349-
*/
350-
enum blk_bounce {
351-
BLK_BOUNCE_NONE,
352-
BLK_BOUNCE_HIGH,
349+
/* I/O topology is misaligned */
350+
BLK_FEAT_MISALIGNED = (1u << 1),
353351
};
354352

355353
struct queue_limits {
@@ -383,9 +381,6 @@ struct queue_limits {
383381
unsigned short max_integrity_segments;
384382
unsigned short max_discard_segments;
385383

386-
unsigned char misaligned;
387-
unsigned char discard_misaligned;
388-
unsigned char raid_partial_stripes_expensive;
389384
unsigned int max_open_zones;
390385
unsigned int max_active_zones;
391386

@@ -1347,7 +1342,7 @@ static inline bool bdev_stable_writes(struct block_device *bdev)
13471342
static inline bool blk_queue_write_cache(struct request_queue *q)
13481343
{
13491344
return (q->limits.features & BLK_FEAT_WRITE_CACHE) &&
1350-
!(q->limits.flags & BLK_FLAGS_WRITE_CACHE_DISABLED);
1345+
!(q->limits.flags & BLK_FLAG_WRITE_CACHE_DISABLED);
13511346
}
13521347

13531348
static inline bool bdev_write_cache(struct block_device *bdev)

0 commit comments

Comments
 (0)