Skip to content

Commit f036d67

Browse files
committed
Merge tag 'block-6.5-2023-07-21' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - Fix for loop regressions (Mauricio) - Fix a potential stall with batched wakeups in sbitmap (David) - Fix for stall with recursive plug flushes (Ross) - Skip accounting of empty requests for blk-iocost (Chengming) - Remove a dead field in struct blk_mq_hw_ctx (Chengming) * tag 'block-6.5-2023-07-21' of git://git.kernel.dk/linux: loop: do not enforce max_loop hard limit by (new) default loop: deprecate autoloading callback loop_probe() sbitmap: fix batching wakeup blk-iocost: skip empty flush bio in iocost blk-mq: delete dead struct blk_mq_hw_ctx->queued field blk-mq: Fix stall due to recursive flush plug
2 parents bdd1d82 + bb5faa9 commit f036d67

File tree

6 files changed

+58
-15
lines changed

6 files changed

+58
-15
lines changed

block/blk-core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,7 @@ void __blk_flush_plug(struct blk_plug *plug, bool from_schedule)
11441144
{
11451145
if (!list_empty(&plug->cb_list))
11461146
flush_plug_callbacks(plug, from_schedule);
1147-
if (!rq_list_empty(plug->mq_list))
1148-
blk_mq_flush_plug_list(plug, from_schedule);
1147+
blk_mq_flush_plug_list(plug, from_schedule);
11491148
/*
11501149
* Unconditionally flush out cached requests, even if the unplug
11511150
* event came from schedule. Since we know hold references to the

block/blk-iocost.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,10 @@ static void calc_vtime_cost_builtin(struct bio *bio, struct ioc_gq *iocg,
25162516
u64 seek_pages = 0;
25172517
u64 cost = 0;
25182518

2519+
/* Can't calculate cost for empty bio */
2520+
if (!bio->bi_iter.bi_size)
2521+
goto out;
2522+
25192523
switch (bio_op(bio)) {
25202524
case REQ_OP_READ:
25212525
coef_seqio = ioc->params.lcoefs[LCOEF_RSEQIO];

block/blk-mq.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,14 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
27542754
{
27552755
struct request *rq;
27562756

2757-
if (rq_list_empty(plug->mq_list))
2757+
/*
2758+
* We may have been called recursively midway through handling
2759+
* plug->mq_list via a schedule() in the driver's queue_rq() callback.
2760+
* To avoid mq_list changing under our feet, clear rq_count early and
2761+
* bail out specifically if rq_count is 0 rather than checking
2762+
* whether the mq_list is empty.
2763+
*/
2764+
if (plug->rq_count == 0)
27582765
return;
27592766
plug->rq_count = 0;
27602767

drivers/block/loop.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,14 +1775,43 @@ static const struct block_device_operations lo_fops = {
17751775
/*
17761776
* If max_loop is specified, create that many devices upfront.
17771777
* This also becomes a hard limit. If max_loop is not specified,
1778+
* the default isn't a hard limit (as before commit 85c50197716c
1779+
* changed the default value from 0 for max_loop=0 reasons), just
17781780
* create CONFIG_BLK_DEV_LOOP_MIN_COUNT loop devices at module
17791781
* init time. Loop devices can be requested on-demand with the
17801782
* /dev/loop-control interface, or be instantiated by accessing
17811783
* a 'dead' device node.
17821784
*/
17831785
static int max_loop = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
1784-
module_param(max_loop, int, 0444);
1786+
1787+
#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
1788+
static bool max_loop_specified;
1789+
1790+
static int max_loop_param_set_int(const char *val,
1791+
const struct kernel_param *kp)
1792+
{
1793+
int ret;
1794+
1795+
ret = param_set_int(val, kp);
1796+
if (ret < 0)
1797+
return ret;
1798+
1799+
max_loop_specified = true;
1800+
return 0;
1801+
}
1802+
1803+
static const struct kernel_param_ops max_loop_param_ops = {
1804+
.set = max_loop_param_set_int,
1805+
.get = param_get_int,
1806+
};
1807+
1808+
module_param_cb(max_loop, &max_loop_param_ops, &max_loop, 0444);
17851809
MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
1810+
#else
1811+
module_param(max_loop, int, 0444);
1812+
MODULE_PARM_DESC(max_loop, "Initial number of loop devices");
1813+
#endif
1814+
17861815
module_param(max_part, int, 0444);
17871816
MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
17881817

@@ -2093,14 +2122,18 @@ static void loop_remove(struct loop_device *lo)
20932122
put_disk(lo->lo_disk);
20942123
}
20952124

2125+
#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
20962126
static void loop_probe(dev_t dev)
20972127
{
20982128
int idx = MINOR(dev) >> part_shift;
20992129

2100-
if (max_loop && idx >= max_loop)
2130+
if (max_loop_specified && max_loop && idx >= max_loop)
21012131
return;
21022132
loop_add(idx);
21032133
}
2134+
#else
2135+
#define loop_probe NULL
2136+
#endif /* !CONFIG_BLOCK_LEGACY_AUTOLOAD */
21042137

21052138
static int loop_control_remove(int idx)
21062139
{
@@ -2281,6 +2314,9 @@ module_exit(loop_exit);
22812314
static int __init max_loop_setup(char *str)
22822315
{
22832316
max_loop = simple_strtol(str, NULL, 0);
2317+
#ifdef CONFIG_BLOCK_LEGACY_AUTOLOAD
2318+
max_loop_specified = true;
2319+
#endif
22842320
return 1;
22852321
}
22862322

include/linux/blk-mq.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,6 @@ struct blk_mq_hw_ctx {
397397
*/
398398
struct blk_mq_tags *sched_tags;
399399

400-
/** @queued: Number of queued requests. */
401-
unsigned long queued;
402400
/** @run: Number of dispatched requests. */
403401
unsigned long run;
404402

lib/sbitmap.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ EXPORT_SYMBOL_GPL(sbitmap_queue_min_shallow_depth);
550550

551551
static void __sbitmap_queue_wake_up(struct sbitmap_queue *sbq, int nr)
552552
{
553-
int i, wake_index;
553+
int i, wake_index, woken;
554554

555555
if (!atomic_read(&sbq->ws_active))
556556
return;
@@ -567,13 +567,12 @@ static void __sbitmap_queue_wake_up(struct sbitmap_queue *sbq, int nr)
567567
*/
568568
wake_index = sbq_index_inc(wake_index);
569569

570-
/*
571-
* It is sufficient to wake up at least one waiter to
572-
* guarantee forward progress.
573-
*/
574-
if (waitqueue_active(&ws->wait) &&
575-
wake_up_nr(&ws->wait, nr))
576-
break;
570+
if (waitqueue_active(&ws->wait)) {
571+
woken = wake_up_nr(&ws->wait, nr);
572+
if (woken == nr)
573+
break;
574+
nr -= woken;
575+
}
577576
}
578577

579578
if (wake_index != atomic_read(&sbq->wake_index))

0 commit comments

Comments
 (0)