Skip to content

Commit b226c9e

Browse files
committed
Merge tag 'for-linus-20191115' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "A few fixes that should make it into this release. This contains: - io_uring: - The timeout command assumes sequence == 0 means that we want one completion, but this kind of overloading is unfortunate as it prevents users from doing a pure time based wait. Since this operation was introduced in this cycle, let's correct it now, while we can. (me) - One-liner to fix an issue with dependent links and fixed buffer reads. The actual IO completed fine, but the link got severed since we stored the wrong expected value. (me) - Add TIMEOUT to list of opcodes that don't need a file. (Pavel) - rsxx missing workqueue destry calls. Old bug. (Chuhong) - Fix blk-iocost active list check (Jiufei) - Fix impossible-to-hit overflow merge condition, that still hit some folks very rarely (Junichi) - Fix bfq hang issue from 5.3. This didn't get marked for stable, but will go into stable post this merge (Paolo)" * tag 'for-linus-20191115' of git://git.kernel.dk/linux-block: rsxx: add missed destroy_workqueue calls in remove iocost: check active_list of all the ancestors in iocg_activate() block, bfq: deschedule empty bfq_queues not referred by any process io_uring: ensure registered buffer import returns the IO length io_uring: Fix getting file for timeout block: check bi_size overflow before merge io_uring: make timeout sequence == 0 mean no sequence
2 parents 875fef4 + dcb77e4 commit b226c9e

File tree

5 files changed

+59
-17
lines changed

5 files changed

+59
-17
lines changed

block/bfq-iosched.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,6 +2713,28 @@ static void bfq_bfqq_save_state(struct bfq_queue *bfqq)
27132713
}
27142714
}
27152715

2716+
2717+
static
2718+
void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq)
2719+
{
2720+
/*
2721+
* To prevent bfqq's service guarantees from being violated,
2722+
* bfqq may be left busy, i.e., queued for service, even if
2723+
* empty (see comments in __bfq_bfqq_expire() for
2724+
* details). But, if no process will send requests to bfqq any
2725+
* longer, then there is no point in keeping bfqq queued for
2726+
* service. In addition, keeping bfqq queued for service, but
2727+
* with no process ref any longer, may have caused bfqq to be
2728+
* freed when dequeued from service. But this is assumed to
2729+
* never happen.
2730+
*/
2731+
if (bfq_bfqq_busy(bfqq) && RB_EMPTY_ROOT(&bfqq->sort_list) &&
2732+
bfqq != bfqd->in_service_queue)
2733+
bfq_del_bfqq_busy(bfqd, bfqq, false);
2734+
2735+
bfq_put_queue(bfqq);
2736+
}
2737+
27162738
static void
27172739
bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic,
27182740
struct bfq_queue *bfqq, struct bfq_queue *new_bfqq)
@@ -2783,8 +2805,7 @@ bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic,
27832805
*/
27842806
new_bfqq->pid = -1;
27852807
bfqq->bic = NULL;
2786-
/* release process reference to bfqq */
2787-
bfq_put_queue(bfqq);
2808+
bfq_release_process_ref(bfqd, bfqq);
27882809
}
27892810

27902811
static bool bfq_allow_bio_merge(struct request_queue *q, struct request *rq,
@@ -4899,7 +4920,7 @@ static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq)
48994920

49004921
bfq_put_cooperator(bfqq);
49014922

4902-
bfq_put_queue(bfqq); /* release process reference */
4923+
bfq_release_process_ref(bfqd, bfqq);
49034924
}
49044925

49054926
static void bfq_exit_icq_bfqq(struct bfq_io_cq *bic, bool is_sync)
@@ -5001,8 +5022,7 @@ static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio)
50015022

50025023
bfqq = bic_to_bfqq(bic, false);
50035024
if (bfqq) {
5004-
/* release process reference on this queue */
5005-
bfq_put_queue(bfqq);
5025+
bfq_release_process_ref(bfqd, bfqq);
50065026
bfqq = bfq_get_queue(bfqd, bio, BLK_RW_ASYNC, bic);
50075027
bic_set_bfqq(bic, bfqq, false);
50085028
}
@@ -5963,7 +5983,7 @@ bfq_split_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq)
59635983

59645984
bfq_put_cooperator(bfqq);
59655985

5966-
bfq_put_queue(bfqq);
5986+
bfq_release_process_ref(bfqq->bfqd, bfqq);
59675987
return NULL;
59685988
}
59695989

block/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
751751
if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
752752
return false;
753753

754-
if (bio->bi_vcnt > 0) {
754+
if (bio->bi_vcnt > 0 && !bio_full(bio, len)) {
755755
struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
756756

757757
if (page_is_mergeable(bv, page, len, off, same_page)) {

block/blk-iocost.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,12 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
10571057
atomic64_set(&iocg->active_period, cur_period);
10581058

10591059
/* already activated or breaking leaf-only constraint? */
1060-
for (i = iocg->level; i > 0; i--)
1061-
if (!list_empty(&iocg->active_list))
1060+
if (!list_empty(&iocg->active_list))
1061+
goto succeed_unlock;
1062+
for (i = iocg->level - 1; i > 0; i--)
1063+
if (!list_empty(&iocg->ancestors[i]->active_list))
10621064
goto fail_unlock;
1065+
10631066
if (iocg->child_active_sum)
10641067
goto fail_unlock;
10651068

@@ -1101,6 +1104,7 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
11011104
ioc_start_period(ioc, now);
11021105
}
11031106

1107+
succeed_unlock:
11041108
spin_unlock_irq(&ioc->lock);
11051109
return true;
11061110

drivers/block/rsxx/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,10 @@ static void rsxx_pci_remove(struct pci_dev *dev)
10001000

10011001
cancel_work_sync(&card->event_work);
10021002

1003+
destroy_workqueue(card->event_wq);
10031004
rsxx_destroy_dev(card);
10041005
rsxx_dma_destroy(card);
1006+
destroy_workqueue(card->creg_ctrl.creg_wq);
10051007

10061008
spin_lock_irqsave(&card->irq_lock, flags);
10071009
rsxx_disable_ier_and_isr(card, CR_INTR_ALL);

fs/io_uring.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ struct io_kiocb {
326326
#define REQ_F_TIMEOUT 1024 /* timeout request */
327327
#define REQ_F_ISREG 2048 /* regular file */
328328
#define REQ_F_MUST_PUNT 4096 /* must be punted even for NONBLOCK */
329+
#define REQ_F_TIMEOUT_NOSEQ 8192 /* no timeout sequence */
329330
u64 user_data;
330331
u32 result;
331332
u32 sequence;
@@ -453,9 +454,13 @@ static struct io_kiocb *io_get_timeout_req(struct io_ring_ctx *ctx)
453454
struct io_kiocb *req;
454455

455456
req = list_first_entry_or_null(&ctx->timeout_list, struct io_kiocb, list);
456-
if (req && !__io_sequence_defer(ctx, req)) {
457-
list_del_init(&req->list);
458-
return req;
457+
if (req) {
458+
if (req->flags & REQ_F_TIMEOUT_NOSEQ)
459+
return NULL;
460+
if (!__io_sequence_defer(ctx, req)) {
461+
list_del_init(&req->list);
462+
return req;
463+
}
459464
}
460465

461466
return NULL;
@@ -1225,7 +1230,7 @@ static int io_import_fixed(struct io_ring_ctx *ctx, int rw,
12251230
}
12261231
}
12271232

1228-
return 0;
1233+
return len;
12291234
}
12301235

12311236
static ssize_t io_import_iovec(struct io_ring_ctx *ctx, int rw,
@@ -1941,18 +1946,24 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe)
19411946
if (get_timespec64(&ts, u64_to_user_ptr(sqe->addr)))
19421947
return -EFAULT;
19431948

1949+
req->flags |= REQ_F_TIMEOUT;
1950+
19441951
/*
19451952
* sqe->off holds how many events that need to occur for this
1946-
* timeout event to be satisfied.
1953+
* timeout event to be satisfied. If it isn't set, then this is
1954+
* a pure timeout request, sequence isn't used.
19471955
*/
19481956
count = READ_ONCE(sqe->off);
1949-
if (!count)
1950-
count = 1;
1957+
if (!count) {
1958+
req->flags |= REQ_F_TIMEOUT_NOSEQ;
1959+
spin_lock_irq(&ctx->completion_lock);
1960+
entry = ctx->timeout_list.prev;
1961+
goto add;
1962+
}
19511963

19521964
req->sequence = ctx->cached_sq_head + count - 1;
19531965
/* reuse it to store the count */
19541966
req->submit.sequence = count;
1955-
req->flags |= REQ_F_TIMEOUT;
19561967

19571968
/*
19581969
* Insertion sort, ensuring the first entry in the list is always
@@ -1964,6 +1975,9 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe)
19641975
unsigned nxt_sq_head;
19651976
long long tmp, tmp_nxt;
19661977

1978+
if (nxt->flags & REQ_F_TIMEOUT_NOSEQ)
1979+
continue;
1980+
19671981
/*
19681982
* Since cached_sq_head + count - 1 can overflow, use type long
19691983
* long to store it.
@@ -1990,6 +2004,7 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe)
19902004
nxt->sequence++;
19912005
}
19922006
req->sequence -= span;
2007+
add:
19932008
list_add(&req->list, entry);
19942009
spin_unlock_irq(&ctx->completion_lock);
19952010

@@ -2283,6 +2298,7 @@ static bool io_op_needs_file(const struct io_uring_sqe *sqe)
22832298
switch (op) {
22842299
case IORING_OP_NOP:
22852300
case IORING_OP_POLL_REMOVE:
2301+
case IORING_OP_TIMEOUT:
22862302
return false;
22872303
default:
22882304
return true;

0 commit comments

Comments
 (0)