io_uring: only hash regular files for async work execution
authorJens Axboe <axboe@kernel.dk>
Tue, 10 Dec 2019 03:12:38 +0000 (20:12 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 10 Dec 2019 23:33:23 +0000 (16:33 -0700)
We hash regular files to avoid having multiple threads hammer on the
inode mutex, but it should not be needed on other types of files
(like sockets).

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 3dae005..e54bd46 100644 (file)
@@ -581,7 +581,9 @@ static inline bool io_prep_async_work(struct io_kiocb *req,
                switch (req->sqe->opcode) {
                case IORING_OP_WRITEV:
                case IORING_OP_WRITE_FIXED:
-                       do_hashed = true;
+                       /* only regular files should be hashed for writes */
+                       if (req->flags & REQ_F_ISREG)
+                               do_hashed = true;
                        /* fall-through */
                case IORING_OP_READV:
                case IORING_OP_READ_FIXED: