Skip to content

Commit 64b4fc4

Browse files
committed
Merge tag 'block-5.14-2021-08-27' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - Revert the mq-deadline priority handling, it's causing serious performance regressions. While experimental patches exists to fix this up, it's too late to do so now. Revert it and re-do it properly for 5.15 instead. - Fix a NULL vs IS_ERR() regression in this release (Dan) - Fix a mq-deadline accounting regression in this release (Bart) - Mark cryptoloop as deprecated. It's broken and dm-crypt fully supports it, and it's actively intefering with loop. Plan on removal for 5.16 (Christoph) * tag 'block-5.14-2021-08-27' of git://git.kernel.dk/linux-block: cryptoloop: add a deprecation warning pd: fix a NULL vs IS_ERR() check Revert "block/mq-deadline: Prioritize high-priority requests" mq-deadline: Fix request accounting
2 parents 6f18b82 + 222013f commit 64b4fc4

File tree

4 files changed

+21
-45
lines changed

4 files changed

+21
-45
lines changed

block/mq-deadline.c

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
*/
3232
static const int read_expire = HZ / 2; /* max time before a read is submitted. */
3333
static const int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */
34-
/*
35-
* Time after which to dispatch lower priority requests even if higher
36-
* priority requests are pending.
37-
*/
38-
static const int aging_expire = 10 * HZ;
3934
static const int writes_starved = 2; /* max times reads can starve a write */
4035
static const int fifo_batch = 16; /* # of sequential requests treated as one
4136
by the above parameters. For throughput. */
@@ -103,7 +98,6 @@ struct deadline_data {
10398
int writes_starved;
10499
int front_merges;
105100
u32 async_depth;
106-
int aging_expire;
107101

108102
spinlock_t lock;
109103
spinlock_t zone_lock;
@@ -369,11 +363,10 @@ deadline_next_request(struct deadline_data *dd, struct dd_per_prio *per_prio,
369363

370364
/*
371365
* deadline_dispatch_requests selects the best request according to
372-
* read/write expire, fifo_batch, etc and with a start time <= @latest.
366+
* read/write expire, fifo_batch, etc
373367
*/
374368
static struct request *__dd_dispatch_request(struct deadline_data *dd,
375-
struct dd_per_prio *per_prio,
376-
u64 latest_start_ns)
369+
struct dd_per_prio *per_prio)
377370
{
378371
struct request *rq, *next_rq;
379372
enum dd_data_dir data_dir;
@@ -385,8 +378,6 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd,
385378
if (!list_empty(&per_prio->dispatch)) {
386379
rq = list_first_entry(&per_prio->dispatch, struct request,
387380
queuelist);
388-
if (rq->start_time_ns > latest_start_ns)
389-
return NULL;
390381
list_del_init(&rq->queuelist);
391382
goto done;
392383
}
@@ -464,8 +455,6 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd,
464455
dd->batching = 0;
465456

466457
dispatch_request:
467-
if (rq->start_time_ns > latest_start_ns)
468-
return NULL;
469458
/*
470459
* rq is the selected appropriate request.
471460
*/
@@ -494,32 +483,15 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd,
494483
static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
495484
{
496485
struct deadline_data *dd = hctx->queue->elevator->elevator_data;
497-
const u64 now_ns = ktime_get_ns();
498-
struct request *rq = NULL;
486+
struct request *rq;
499487
enum dd_prio prio;
500488

501489
spin_lock(&dd->lock);
502-
/*
503-
* Start with dispatching requests whose deadline expired more than
504-
* aging_expire jiffies ago.
505-
*/
506-
for (prio = DD_BE_PRIO; prio <= DD_PRIO_MAX; prio++) {
507-
rq = __dd_dispatch_request(dd, &dd->per_prio[prio], now_ns -
508-
jiffies_to_nsecs(dd->aging_expire));
509-
if (rq)
510-
goto unlock;
511-
}
512-
/*
513-
* Next, dispatch requests in priority order. Ignore lower priority
514-
* requests if any higher priority requests are pending.
515-
*/
516490
for (prio = 0; prio <= DD_PRIO_MAX; prio++) {
517-
rq = __dd_dispatch_request(dd, &dd->per_prio[prio], now_ns);
518-
if (rq || dd_queued(dd, prio))
491+
rq = __dd_dispatch_request(dd, &dd->per_prio[prio]);
492+
if (rq)
519493
break;
520494
}
521-
522-
unlock:
523495
spin_unlock(&dd->lock);
524496

525497
return rq;
@@ -620,7 +592,6 @@ static int dd_init_sched(struct request_queue *q, struct elevator_type *e)
620592
dd->front_merges = 1;
621593
dd->last_dir = DD_WRITE;
622594
dd->fifo_batch = fifo_batch;
623-
dd->aging_expire = aging_expire;
624595
spin_lock_init(&dd->lock);
625596
spin_lock_init(&dd->zone_lock);
626597

@@ -711,6 +682,7 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
711682

712683
prio = ioprio_class_to_prio[ioprio_class];
713684
dd_count(dd, inserted, prio);
685+
rq->elv.priv[0] = (void *)(uintptr_t)1;
714686

715687
if (blk_mq_sched_try_insert_merge(q, rq, &free)) {
716688
blk_mq_free_requests(&free);
@@ -759,12 +731,10 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx,
759731
spin_unlock(&dd->lock);
760732
}
761733

762-
/*
763-
* Nothing to do here. This is defined only to ensure that .finish_request
764-
* method is called upon request completion.
765-
*/
734+
/* Callback from inside blk_mq_rq_ctx_init(). */
766735
static void dd_prepare_request(struct request *rq)
767736
{
737+
rq->elv.priv[0] = NULL;
768738
}
769739

770740
/*
@@ -791,7 +761,14 @@ static void dd_finish_request(struct request *rq)
791761
const enum dd_prio prio = ioprio_class_to_prio[ioprio_class];
792762
struct dd_per_prio *per_prio = &dd->per_prio[prio];
793763

794-
dd_count(dd, completed, prio);
764+
/*
765+
* The block layer core may call dd_finish_request() without having
766+
* called dd_insert_requests(). Hence only update statistics for
767+
* requests for which dd_insert_requests() has been called. See also
768+
* blk_mq_request_bypass_insert().
769+
*/
770+
if (rq->elv.priv[0])
771+
dd_count(dd, completed, prio);
795772

796773
if (blk_queue_is_zoned(q)) {
797774
unsigned long flags;
@@ -836,7 +813,6 @@ static ssize_t __FUNC(struct elevator_queue *e, char *page) \
836813
#define SHOW_JIFFIES(__FUNC, __VAR) SHOW_INT(__FUNC, jiffies_to_msecs(__VAR))
837814
SHOW_JIFFIES(deadline_read_expire_show, dd->fifo_expire[DD_READ]);
838815
SHOW_JIFFIES(deadline_write_expire_show, dd->fifo_expire[DD_WRITE]);
839-
SHOW_JIFFIES(deadline_aging_expire_show, dd->aging_expire);
840816
SHOW_INT(deadline_writes_starved_show, dd->writes_starved);
841817
SHOW_INT(deadline_front_merges_show, dd->front_merges);
842818
SHOW_INT(deadline_async_depth_show, dd->front_merges);
@@ -866,7 +842,6 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
866842
STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, msecs_to_jiffies)
867843
STORE_JIFFIES(deadline_read_expire_store, &dd->fifo_expire[DD_READ], 0, INT_MAX);
868844
STORE_JIFFIES(deadline_write_expire_store, &dd->fifo_expire[DD_WRITE], 0, INT_MAX);
869-
STORE_JIFFIES(deadline_aging_expire_store, &dd->aging_expire, 0, INT_MAX);
870845
STORE_INT(deadline_writes_starved_store, &dd->writes_starved, INT_MIN, INT_MAX);
871846
STORE_INT(deadline_front_merges_store, &dd->front_merges, 0, 1);
872847
STORE_INT(deadline_async_depth_store, &dd->front_merges, 1, INT_MAX);
@@ -885,7 +860,6 @@ static struct elv_fs_entry deadline_attrs[] = {
885860
DD_ATTR(front_merges),
886861
DD_ATTR(async_depth),
887862
DD_ATTR(fifo_batch),
888-
DD_ATTR(aging_expire),
889863
__ATTR_NULL
890864
};
891865

drivers/block/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ config BLK_DEV_LOOP_MIN_COUNT
213213
dynamically allocated with the /dev/loop-control interface.
214214

215215
config BLK_DEV_CRYPTOLOOP
216-
tristate "Cryptoloop Support"
216+
tristate "Cryptoloop Support (DEPRECATED)"
217217
select CRYPTO
218218
select CRYPTO_CBC
219219
depends on BLK_DEV_LOOP
@@ -225,7 +225,7 @@ config BLK_DEV_CRYPTOLOOP
225225
WARNING: This device is not safe for journaled file systems like
226226
ext3 or Reiserfs. Please use the Device Mapper crypto module
227227
instead, which can be configured to be on-disk compatible with the
228-
cryptoloop device.
228+
cryptoloop device. cryptoloop support will be removed in Linux 5.16.
229229

230230
source "drivers/block/drbd/Kconfig"
231231

drivers/block/cryptoloop.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ init_cryptoloop(void)
189189

190190
if (rc)
191191
printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
192+
else
193+
pr_warn("the cryptoloop driver has been deprecated and will be removed in in Linux 5.16\n");
192194
return rc;
193195
}
194196

drivers/block/paride/pd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ static void pd_probe_drive(struct pd_unit *disk)
892892
return;
893893

894894
p = blk_mq_alloc_disk(&disk->tag_set, disk);
895-
if (!p) {
895+
if (IS_ERR(p)) {
896896
blk_mq_free_tag_set(&disk->tag_set);
897897
return;
898898
}

0 commit comments

Comments
 (0)