Skip to content

Commit cdc8fcb

Browse files
committed
Merge tag 'for-5.9/io_uring-20200802' of git://git.kernel.dk/linux-block
Pull io_uring updates from Jens Axboe: "Lots of cleanups in here, hardening the code and/or making it easier to read and fixing bugs, but a core feature/change too adding support for real async buffered reads. With the latter in place, we just need buffered write async support and we're done relying on kthreads for the fast path. In detail: - Cleanup how memory accounting is done on ring setup/free (Bijan) - sq array offset calculation fixup (Dmitry) - Consistently handle blocking off O_DIRECT submission path (me) - Support proper async buffered reads, instead of relying on kthread offload for that. This uses the page waitqueue to drive retries from task_work, like we handle poll based retry. (me) - IO completion optimizations (me) - Fix race with accounting and ring fd install (me) - Support EPOLLEXCLUSIVE (Jiufei) - Get rid of the io_kiocb unionizing, made possible by shrinking other bits (Pavel) - Completion side cleanups (Pavel) - Cleanup REQ_F_ flags handling, and kill off many of them (Pavel) - Request environment grabbing cleanups (Pavel) - File and socket read/write cleanups (Pavel) - Improve kiocb_set_rw_flags() (Pavel) - Tons of fixes and cleanups (Pavel) - IORING_SQ_NEED_WAKEUP clear fix (Xiaoguang)" * tag 'for-5.9/io_uring-20200802' of git://git.kernel.dk/linux-block: (127 commits) io_uring: flip if handling after io_setup_async_rw fs: optimise kiocb_set_rw_flags() io_uring: don't touch 'ctx' after installing file descriptor io_uring: get rid of atomic FAA for cq_timeouts io_uring: consolidate *_check_overflow accounting io_uring: fix stalled deferred requests io_uring: fix racy overflow count reporting io_uring: deduplicate __io_complete_rw() io_uring: de-unionise io_kiocb io-wq: update hash bits io_uring: fix missing io_queue_linked_timeout() io_uring: mark ->work uninitialised after cleanup io_uring: deduplicate io_grab_files() calls io_uring: don't do opcode prep twice io_uring: clear IORING_SQ_NEED_WAKEUP after executing task works io_uring: batch put_task_struct() tasks: add put_task_struct_many() io_uring: return locked and pinned page accounting io_uring: don't miscount pinned memory io_uring: don't open-code recv kbuf managment ...
2 parents 382625d + fa15baf commit cdc8fcb

File tree

14 files changed

+1644
-1181
lines changed

14 files changed

+1644
-1181
lines changed

block/blk-core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,14 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
960960
{
961961
struct request_queue *q = bio->bi_disk->queue;
962962
blk_status_t status = BLK_STS_IOERR;
963+
struct blk_plug *plug;
963964

964965
might_sleep();
965966

967+
plug = blk_mq_plug(q, bio);
968+
if (plug && plug->nowait)
969+
bio->bi_opf |= REQ_NOWAIT;
970+
966971
/*
967972
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
968973
* if queue is not a request based queue.
@@ -1802,6 +1807,7 @@ void blk_start_plug(struct blk_plug *plug)
18021807
INIT_LIST_HEAD(&plug->cb_list);
18031808
plug->rq_count = 0;
18041809
plug->multiple_queues = false;
1810+
plug->nowait = false;
18051811

18061812
/*
18071813
* Store ordering should not be needed here, since a potential

fs/block_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ static int blkdev_open(struct inode * inode, struct file * filp)
17341734
*/
17351735
filp->f_flags |= O_LARGEFILE;
17361736

1737-
filp->f_mode |= FMODE_NOWAIT;
1737+
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
17381738

17391739
if (filp->f_flags & O_NDELAY)
17401740
filp->f_mode |= FMODE_NDELAY;

fs/btrfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3537,7 +3537,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
35373537

35383538
static int btrfs_file_open(struct inode *inode, struct file *filp)
35393539
{
3540-
filp->f_mode |= FMODE_NOWAIT;
3540+
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
35413541
return generic_file_open(inode, filp);
35423542
}
35433543

fs/io-wq.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ static void io_impersonate_work(struct io_worker *worker,
462462
io_wq_switch_mm(worker, work);
463463
if (worker->cur_creds != work->creds)
464464
io_wq_switch_creds(worker, work);
465+
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = work->fsize;
465466
}
466467

467468
static void io_assign_current_work(struct io_worker *worker,
@@ -489,7 +490,6 @@ static void io_worker_handle_work(struct io_worker *worker)
489490

490491
do {
491492
struct io_wq_work *work;
492-
unsigned int hash;
493493
get_next:
494494
/*
495495
* If we got some work, mark us as busy. If we didn't, but
@@ -512,6 +512,7 @@ static void io_worker_handle_work(struct io_worker *worker)
512512
/* handle a whole dependent link */
513513
do {
514514
struct io_wq_work *old_work, *next_hashed, *linked;
515+
unsigned int hash = io_get_work_hash(work);
515516

516517
next_hashed = wq_next_work(work);
517518
io_impersonate_work(worker, work);
@@ -522,10 +523,8 @@ static void io_worker_handle_work(struct io_worker *worker)
522523
if (test_bit(IO_WQ_BIT_CANCEL, &wq->state))
523524
work->flags |= IO_WQ_WORK_CANCEL;
524525

525-
hash = io_get_work_hash(work);
526-
linked = old_work = work;
527-
wq->do_work(&linked);
528-
linked = (old_work == linked) ? NULL : linked;
526+
old_work = work;
527+
linked = wq->do_work(work);
529528

530529
work = next_hashed;
531530
if (!work && linked && !io_wq_is_hashed(linked)) {
@@ -542,8 +541,6 @@ static void io_worker_handle_work(struct io_worker *worker)
542541
spin_lock_irq(&wqe->lock);
543542
wqe->hash_map &= ~BIT_ULL(hash);
544543
wqe->flags &= ~IO_WQE_FLAG_STALLED;
545-
/* dependent work is not hashed */
546-
hash = -1U;
547544
/* skip unnecessary unlock-lock wqe->lock */
548545
if (!work)
549546
goto get_next;
@@ -781,8 +778,7 @@ static void io_run_cancel(struct io_wq_work *work, struct io_wqe *wqe)
781778
struct io_wq_work *old_work = work;
782779

783780
work->flags |= IO_WQ_WORK_CANCEL;
784-
wq->do_work(&work);
785-
work = (work == old_work) ? NULL : work;
781+
work = wq->do_work(work);
786782
wq->free_work(old_work);
787783
} while (work);
788784
}

fs/io-wq.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ struct io_wq;
55

66
enum {
77
IO_WQ_WORK_CANCEL = 1,
8-
IO_WQ_WORK_HASHED = 4,
9-
IO_WQ_WORK_UNBOUND = 32,
10-
IO_WQ_WORK_NO_CANCEL = 256,
11-
IO_WQ_WORK_CONCURRENT = 512,
8+
IO_WQ_WORK_HASHED = 2,
9+
IO_WQ_WORK_UNBOUND = 4,
10+
IO_WQ_WORK_NO_CANCEL = 8,
11+
IO_WQ_WORK_CONCURRENT = 16,
1212

1313
IO_WQ_HASH_SHIFT = 24, /* upper 8 bits are used for hash key */
1414
};
@@ -89,6 +89,7 @@ struct io_wq_work {
8989
struct mm_struct *mm;
9090
const struct cred *creds;
9191
struct fs_struct *fs;
92+
unsigned long fsize;
9293
unsigned flags;
9394
};
9495

@@ -101,7 +102,7 @@ static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
101102
}
102103

103104
typedef void (free_work_fn)(struct io_wq_work *);
104-
typedef void (io_wq_work_fn)(struct io_wq_work **);
105+
typedef struct io_wq_work *(io_wq_work_fn)(struct io_wq_work *);
105106

106107
struct io_wq_data {
107108
struct user_struct *user;

0 commit comments

Comments
 (0)