Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0f9a751

Browse files
committed
Merge tag 'block-6.10-20240530' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe fixes via Keith: - Removing unused fields (Kanchan) - Large folio offsets support (Kundan) - Multipath NUMA node initialiazation fix (Nilay) - Multipath IO stats accounting fixes (Keith) - Circular lockdep fix (Keith) - Target race condition fix (Sagi) - Target memory leak fix (Sagi) - bcache fixes - null_blk fixes (Damien) - Fix regression in io.max due to throttle low removal (Waiman) - DM limit table fixes (Christoph) - SCSI and block limit fixes (Christoph) - zone fixes (Damien) - Misc fixes (Christoph, Hannes, hexue) * tag 'block-6.10-20240530' of git://git.kernel.dk/linux: (25 commits) blk-throttle: Fix incorrect display of io.max block: Fix zone write plugging handling of devices with a runt zone block: Fix validation of zoned device with a runt zone null_blk: Do not allow runt zone with zone capacity smaller then zone size nvmet: fix a possible leak when destroy a ctrl during qp establishment nvme: use srcu for iterating namespace list bcache: code cleanup in __bch_bucket_alloc_set() bcache: call force_wake_up_gc() if necessary in check_should_bypass() bcache: allow allocator to invalidate bucket in gc block: check for max_hw_sectors underflow block: stack max_user_sectors sd: also set max_user_sectors when setting max_sectors null_blk: Print correct max open zones limit in null_init_zoned_dev() block: delete redundant function declaration null_blk: Fix return value of nullb_device_power_store() dm: make dm_set_zones_restrictions work on the queue limits dm: remove dm_check_zoned dm: move setting zoned_enabled to dm_table_set_restrictions block: remove blk_queue_max_integrity_segments nvme: adjust multiples of NVME_CTRL_PAGE_SIZE in offset ...
2 parents 6d541d6 + 0a751df commit 0f9a751

File tree

24 files changed

+262
-176
lines changed

24 files changed

+262
-176
lines changed

block/blk-settings.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static int blk_validate_zoned_limits(struct queue_limits *lim)
104104
static int blk_validate_limits(struct queue_limits *lim)
105105
{
106106
unsigned int max_hw_sectors;
107+
unsigned int logical_block_sectors;
107108

108109
/*
109110
* Unless otherwise specified, default to 512 byte logical blocks and a
@@ -134,8 +135,11 @@ static int blk_validate_limits(struct queue_limits *lim)
134135
lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
135136
if (WARN_ON_ONCE(lim->max_hw_sectors < PAGE_SECTORS))
136137
return -EINVAL;
138+
logical_block_sectors = lim->logical_block_size >> SECTOR_SHIFT;
139+
if (WARN_ON_ONCE(logical_block_sectors > lim->max_hw_sectors))
140+
return -EINVAL;
137141
lim->max_hw_sectors = round_down(lim->max_hw_sectors,
138-
lim->logical_block_size >> SECTOR_SHIFT);
142+
logical_block_sectors);
139143

140144
/*
141145
* The actual max_sectors value is a complex beast and also takes the
@@ -153,7 +157,7 @@ static int blk_validate_limits(struct queue_limits *lim)
153157
lim->max_sectors = min(max_hw_sectors, BLK_DEF_MAX_SECTORS_CAP);
154158
}
155159
lim->max_sectors = round_down(lim->max_sectors,
156-
lim->logical_block_size >> SECTOR_SHIFT);
160+
logical_block_sectors);
157161

158162
/*
159163
* Random default for the maximum number of segments. Driver should not
@@ -611,6 +615,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
611615
unsigned int top, bottom, alignment, ret = 0;
612616

613617
t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
618+
t->max_user_sectors = min_not_zero(t->max_user_sectors,
619+
b->max_user_sectors);
614620
t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
615621
t->max_dev_sectors = min_not_zero(t->max_dev_sectors, b->max_dev_sectors);
616622
t->max_write_zeroes_sectors = min(t->max_write_zeroes_sectors,

block/blk-stat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ struct blk_stat_callback {
6464

6565
struct blk_queue_stats *blk_alloc_queue_stats(void);
6666
void blk_free_queue_stats(struct blk_queue_stats *);
67-
bool blk_stats_alloc_enable(struct request_queue *q);
6867

6968
void blk_stat_add(struct request *rq, u64 now);
7069

block/blk-throttle.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,32 +1399,32 @@ static u64 tg_prfill_limit(struct seq_file *sf, struct blkg_policy_data *pd,
13991399
bps_dft = U64_MAX;
14001400
iops_dft = UINT_MAX;
14011401

1402-
if (tg->bps_conf[READ] == bps_dft &&
1403-
tg->bps_conf[WRITE] == bps_dft &&
1404-
tg->iops_conf[READ] == iops_dft &&
1405-
tg->iops_conf[WRITE] == iops_dft)
1402+
if (tg->bps[READ] == bps_dft &&
1403+
tg->bps[WRITE] == bps_dft &&
1404+
tg->iops[READ] == iops_dft &&
1405+
tg->iops[WRITE] == iops_dft)
14061406
return 0;
14071407

14081408
seq_printf(sf, "%s", dname);
1409-
if (tg->bps_conf[READ] == U64_MAX)
1409+
if (tg->bps[READ] == U64_MAX)
14101410
seq_printf(sf, " rbps=max");
14111411
else
1412-
seq_printf(sf, " rbps=%llu", tg->bps_conf[READ]);
1412+
seq_printf(sf, " rbps=%llu", tg->bps[READ]);
14131413

1414-
if (tg->bps_conf[WRITE] == U64_MAX)
1414+
if (tg->bps[WRITE] == U64_MAX)
14151415
seq_printf(sf, " wbps=max");
14161416
else
1417-
seq_printf(sf, " wbps=%llu", tg->bps_conf[WRITE]);
1417+
seq_printf(sf, " wbps=%llu", tg->bps[WRITE]);
14181418

1419-
if (tg->iops_conf[READ] == UINT_MAX)
1419+
if (tg->iops[READ] == UINT_MAX)
14201420
seq_printf(sf, " riops=max");
14211421
else
1422-
seq_printf(sf, " riops=%u", tg->iops_conf[READ]);
1422+
seq_printf(sf, " riops=%u", tg->iops[READ]);
14231423

1424-
if (tg->iops_conf[WRITE] == UINT_MAX)
1424+
if (tg->iops[WRITE] == UINT_MAX)
14251425
seq_printf(sf, " wiops=max");
14261426
else
1427-
seq_printf(sf, " wiops=%u", tg->iops_conf[WRITE]);
1427+
seq_printf(sf, " wiops=%u", tg->iops[WRITE]);
14281428

14291429
seq_printf(sf, "\n");
14301430
return 0;

block/blk-throttle.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,11 @@ struct throtl_grp {
9595
bool has_rules_bps[2];
9696
bool has_rules_iops[2];
9797

98-
/* internally used bytes per second rate limits */
98+
/* bytes per second rate limits */
9999
uint64_t bps[2];
100-
/* user configured bps limits */
101-
uint64_t bps_conf[2];
102100

103-
/* internally used IOPS limits */
101+
/* IOPS limits */
104102
unsigned int iops[2];
105-
/* user configured IOPS limits */
106-
unsigned int iops_conf[2];
107103

108104
/* Number of bytes dispatched in current slice */
109105
uint64_t bytes_disp[2];

block/blk-zoned.c

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,25 @@ static inline bool disk_zone_is_conv(struct gendisk *disk, sector_t sector)
450450
return test_bit(disk_zone_no(disk, sector), disk->conv_zones_bitmap);
451451
}
452452

453+
static bool disk_zone_is_last(struct gendisk *disk, struct blk_zone *zone)
454+
{
455+
return zone->start + zone->len >= get_capacity(disk);
456+
}
457+
458+
static bool disk_zone_is_full(struct gendisk *disk,
459+
unsigned int zno, unsigned int offset_in_zone)
460+
{
461+
if (zno < disk->nr_zones - 1)
462+
return offset_in_zone >= disk->zone_capacity;
463+
return offset_in_zone >= disk->last_zone_capacity;
464+
}
465+
466+
static bool disk_zone_wplug_is_full(struct gendisk *disk,
467+
struct blk_zone_wplug *zwplug)
468+
{
469+
return disk_zone_is_full(disk, zwplug->zone_no, zwplug->wp_offset);
470+
}
471+
453472
static bool disk_insert_zone_wplug(struct gendisk *disk,
454473
struct blk_zone_wplug *zwplug)
455474
{
@@ -543,7 +562,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
543562
return false;
544563

545564
/* We can remove zone write plugs for zones that are empty or full. */
546-
return !zwplug->wp_offset || zwplug->wp_offset >= disk->zone_capacity;
565+
return !zwplug->wp_offset || disk_zone_wplug_is_full(disk, zwplug);
547566
}
548567

549568
static void disk_remove_zone_wplug(struct gendisk *disk,
@@ -664,13 +683,12 @@ static void disk_zone_wplug_abort(struct blk_zone_wplug *zwplug)
664683
static void disk_zone_wplug_abort_unaligned(struct gendisk *disk,
665684
struct blk_zone_wplug *zwplug)
666685
{
667-
unsigned int zone_capacity = disk->zone_capacity;
668686
unsigned int wp_offset = zwplug->wp_offset;
669687
struct bio_list bl = BIO_EMPTY_LIST;
670688
struct bio *bio;
671689

672690
while ((bio = bio_list_pop(&zwplug->bio_list))) {
673-
if (wp_offset >= zone_capacity ||
691+
if (disk_zone_is_full(disk, zwplug->zone_no, wp_offset) ||
674692
(bio_op(bio) != REQ_OP_ZONE_APPEND &&
675693
bio_offset_from_zone_start(bio) != wp_offset)) {
676694
blk_zone_wplug_bio_io_error(zwplug, bio);
@@ -909,7 +927,6 @@ void blk_zone_write_plug_init_request(struct request *req)
909927
sector_t req_back_sector = blk_rq_pos(req) + blk_rq_sectors(req);
910928
struct request_queue *q = req->q;
911929
struct gendisk *disk = q->disk;
912-
unsigned int zone_capacity = disk->zone_capacity;
913930
struct blk_zone_wplug *zwplug =
914931
disk_get_zone_wplug(disk, blk_rq_pos(req));
915932
unsigned long flags;
@@ -933,7 +950,7 @@ void blk_zone_write_plug_init_request(struct request *req)
933950
* into the back of the request.
934951
*/
935952
spin_lock_irqsave(&zwplug->lock, flags);
936-
while (zwplug->wp_offset < zone_capacity) {
953+
while (!disk_zone_wplug_is_full(disk, zwplug)) {
937954
bio = bio_list_peek(&zwplug->bio_list);
938955
if (!bio)
939956
break;
@@ -979,7 +996,7 @@ static bool blk_zone_wplug_prepare_bio(struct blk_zone_wplug *zwplug,
979996
* We know such BIO will fail, and that would potentially overflow our
980997
* write pointer offset beyond the end of the zone.
981998
*/
982-
if (zwplug->wp_offset >= disk->zone_capacity)
999+
if (disk_zone_wplug_is_full(disk, zwplug))
9831000
goto err;
9841001

9851002
if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
@@ -1556,6 +1573,7 @@ void disk_free_zone_resources(struct gendisk *disk)
15561573
kfree(disk->conv_zones_bitmap);
15571574
disk->conv_zones_bitmap = NULL;
15581575
disk->zone_capacity = 0;
1576+
disk->last_zone_capacity = 0;
15591577
disk->nr_zones = 0;
15601578
}
15611579

@@ -1600,6 +1618,7 @@ struct blk_revalidate_zone_args {
16001618
unsigned long *conv_zones_bitmap;
16011619
unsigned int nr_zones;
16021620
unsigned int zone_capacity;
1621+
unsigned int last_zone_capacity;
16031622
sector_t sector;
16041623
};
16051624

@@ -1617,6 +1636,7 @@ static int disk_update_zone_resources(struct gendisk *disk,
16171636

16181637
disk->nr_zones = args->nr_zones;
16191638
disk->zone_capacity = args->zone_capacity;
1639+
disk->last_zone_capacity = args->last_zone_capacity;
16201640
swap(disk->conv_zones_bitmap, args->conv_zones_bitmap);
16211641
if (disk->conv_zones_bitmap)
16221642
nr_conv_zones = bitmap_weight(disk->conv_zones_bitmap,
@@ -1668,6 +1688,9 @@ static int blk_revalidate_conv_zone(struct blk_zone *zone, unsigned int idx,
16681688
return -ENODEV;
16691689
}
16701690

1691+
if (disk_zone_is_last(disk, zone))
1692+
args->last_zone_capacity = zone->capacity;
1693+
16711694
if (!disk_need_zone_resources(disk))
16721695
return 0;
16731696

@@ -1693,11 +1716,14 @@ static int blk_revalidate_seq_zone(struct blk_zone *zone, unsigned int idx,
16931716

16941717
/*
16951718
* Remember the capacity of the first sequential zone and check
1696-
* if it is constant for all zones.
1719+
* if it is constant for all zones, ignoring the last zone as it can be
1720+
* smaller.
16971721
*/
16981722
if (!args->zone_capacity)
16991723
args->zone_capacity = zone->capacity;
1700-
if (zone->capacity != args->zone_capacity) {
1724+
if (disk_zone_is_last(disk, zone)) {
1725+
args->last_zone_capacity = zone->capacity;
1726+
} else if (zone->capacity != args->zone_capacity) {
17011727
pr_warn("%s: Invalid variable zone capacity\n",
17021728
disk->disk_name);
17031729
return -ENODEV;
@@ -1732,7 +1758,6 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
17321758
{
17331759
struct blk_revalidate_zone_args *args = data;
17341760
struct gendisk *disk = args->disk;
1735-
sector_t capacity = get_capacity(disk);
17361761
sector_t zone_sectors = disk->queue->limits.chunk_sectors;
17371762
int ret;
17381763

@@ -1743,7 +1768,7 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
17431768
return -ENODEV;
17441769
}
17451770

1746-
if (zone->start >= capacity || !zone->len) {
1771+
if (zone->start >= get_capacity(disk) || !zone->len) {
17471772
pr_warn("%s: Invalid zone start %llu, length %llu\n",
17481773
disk->disk_name, zone->start, zone->len);
17491774
return -ENODEV;
@@ -1753,7 +1778,7 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
17531778
* All zones must have the same size, with the exception on an eventual
17541779
* smaller last zone.
17551780
*/
1756-
if (zone->start + zone->len < capacity) {
1781+
if (!disk_zone_is_last(disk, zone)) {
17571782
if (zone->len != zone_sectors) {
17581783
pr_warn("%s: Invalid zoned device with non constant zone size\n",
17591784
disk->disk_name);

drivers/block/null_blk/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ static ssize_t nullb_device_power_store(struct config_item *item,
494494

495495
set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
496496
dev->power = newp;
497+
ret = count;
497498
} else if (dev->power && !newp) {
498499
if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) {
499500
dev->power = newp;

drivers/block/null_blk/zoned.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ int null_init_zoned_dev(struct nullb_device *dev,
7474
return -EINVAL;
7575
}
7676

77+
/*
78+
* If a smaller zone capacity was requested, do not allow a smaller last
79+
* zone at the same time as such zone configuration does not correspond
80+
* to any real zoned device.
81+
*/
82+
if (dev->zone_capacity != dev->zone_size &&
83+
dev->size & (dev->zone_size - 1)) {
84+
pr_err("A smaller last zone is not allowed with zone capacity smaller than zone size.\n");
85+
return -EINVAL;
86+
}
87+
7788
zone_capacity_sects = mb_to_sects(dev->zone_capacity);
7889
dev_capacity_sects = mb_to_sects(dev->size);
7990
dev->zone_size_sects = mb_to_sects(dev->zone_size);
@@ -108,7 +119,7 @@ int null_init_zoned_dev(struct nullb_device *dev,
108119
if (dev->zone_max_active && dev->zone_max_open > dev->zone_max_active) {
109120
dev->zone_max_open = dev->zone_max_active;
110121
pr_info("changed the maximum number of open zones to %u\n",
111-
dev->nr_zones);
122+
dev->zone_max_open);
112123
} else if (dev->zone_max_open >= dev->nr_zones - dev->zone_nr_conv) {
113124
dev->zone_max_open = 0;
114125
pr_info("zone_max_open limit disabled, limit >= zone count\n");

drivers/md/bcache/alloc.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,9 @@ static inline bool can_inc_bucket_gen(struct bucket *b)
129129

130130
bool bch_can_invalidate_bucket(struct cache *ca, struct bucket *b)
131131
{
132-
BUG_ON(!ca->set->gc_mark_valid);
133-
134-
return (!GC_MARK(b) ||
135-
GC_MARK(b) == GC_MARK_RECLAIMABLE) &&
136-
!atomic_read(&b->pin) &&
137-
can_inc_bucket_gen(b);
132+
return (ca->set->gc_mark_valid || b->reclaimable_in_gc) &&
133+
((!GC_MARK(b) || GC_MARK(b) == GC_MARK_RECLAIMABLE) &&
134+
!atomic_read(&b->pin) && can_inc_bucket_gen(b));
138135
}
139136

140137
void __bch_invalidate_one_bucket(struct cache *ca, struct bucket *b)
@@ -148,6 +145,7 @@ void __bch_invalidate_one_bucket(struct cache *ca, struct bucket *b)
148145
bch_inc_gen(ca, b);
149146
b->prio = INITIAL_PRIO;
150147
atomic_inc(&b->pin);
148+
b->reclaimable_in_gc = 0;
151149
}
152150

153151
static void bch_invalidate_one_bucket(struct cache *ca, struct bucket *b)
@@ -352,8 +350,7 @@ static int bch_allocator_thread(void *arg)
352350
*/
353351

354352
retry_invalidate:
355-
allocator_wait(ca, ca->set->gc_mark_valid &&
356-
!ca->invalidate_needs_gc);
353+
allocator_wait(ca, !ca->invalidate_needs_gc);
357354
invalidate_buckets(ca);
358355

359356
/*
@@ -501,8 +498,8 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,
501498

502499
ca = c->cache;
503500
b = bch_bucket_alloc(ca, reserve, wait);
504-
if (b == -1)
505-
goto err;
501+
if (b < 0)
502+
return -1;
506503

507504
k->ptr[0] = MAKE_PTR(ca->buckets[b].gen,
508505
bucket_to_sector(c, b),
@@ -511,10 +508,6 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,
511508
SET_KEY_PTRS(k, 1);
512509

513510
return 0;
514-
err:
515-
bch_bucket_free(c, k);
516-
bkey_put(c, k);
517-
return -1;
518511
}
519512

520513
int bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,

drivers/md/bcache/bcache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ struct bucket {
200200
uint8_t gen;
201201
uint8_t last_gc; /* Most out of date gen in the btree */
202202
uint16_t gc_mark; /* Bitfield used by GC. See below for field */
203+
uint16_t reclaimable_in_gc:1;
203204
};
204205

205206
/*

drivers/md/bcache/btree.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1741,18 +1741,20 @@ static void btree_gc_start(struct cache_set *c)
17411741

17421742
mutex_lock(&c->bucket_lock);
17431743

1744-
c->gc_mark_valid = 0;
17451744
c->gc_done = ZERO_KEY;
17461745

17471746
ca = c->cache;
17481747
for_each_bucket(b, ca) {
17491748
b->last_gc = b->gen;
1749+
if (bch_can_invalidate_bucket(ca, b))
1750+
b->reclaimable_in_gc = 1;
17501751
if (!atomic_read(&b->pin)) {
17511752
SET_GC_MARK(b, 0);
17521753
SET_GC_SECTORS_USED(b, 0);
17531754
}
17541755
}
17551756

1757+
c->gc_mark_valid = 0;
17561758
mutex_unlock(&c->bucket_lock);
17571759
}
17581760

@@ -1809,6 +1811,9 @@ static void bch_btree_gc_finish(struct cache_set *c)
18091811
for_each_bucket(b, ca) {
18101812
c->need_gc = max(c->need_gc, bucket_gc_gen(b));
18111813

1814+
if (b->reclaimable_in_gc)
1815+
b->reclaimable_in_gc = 0;
1816+
18121817
if (atomic_read(&b->pin))
18131818
continue;
18141819

0 commit comments

Comments
 (0)