From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f194.google.com ([209.85.166.194]:36363 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbeLAE1v (ORCPT ); Fri, 30 Nov 2018 23:27:51 -0500 Received: by mail-it1-f194.google.com with SMTP id c9so10360804itj.1 for ; Fri, 30 Nov 2018 09:17:52 -0800 (PST) Subject: Re: [PATCH 05/27] block: ensure that async polled IO is marked REQ_NOWAIT To: Bart Van Assche , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org Cc: hch@lst.de References: <20181130165646.27341-1-axboe@kernel.dk> <20181130165646.27341-6-axboe@kernel.dk> <1543597960.4347.3.camel@acm.org> From: Jens Axboe Message-ID: <6044f9e1-0175-823b-b923-998094bdca72@kernel.dk> Date: Fri, 30 Nov 2018 10:17:49 -0700 MIME-Version: 1.0 In-Reply-To: <1543597960.4347.3.camel@acm.org> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 11/30/18 10:12 AM, Bart Van Assche wrote: > On Fri, 2018-11-30 at 09:56 -0700, Jens Axboe wrote: >> We can't wait for polled events to complete, as they may require active >> polling from whoever submitted it. If that is the same task that is >> submitting new IO, we could deadlock waiting for IO to complete that >> this task is supposed to be completing itself. >> >> Signed-off-by: Jens Axboe >> --- >> fs/block_dev.c | 10 +++++++++- >> 1 file changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/fs/block_dev.c b/fs/block_dev.c >> index 6de8d35f6e41..ebc3d5a0f424 100644 >> --- a/fs/block_dev.c >> +++ b/fs/block_dev.c >> @@ -402,8 +402,16 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) >> >> nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES); >> if (!nr_pages) { >> - if (iocb->ki_flags & IOCB_HIPRI) >> + if (iocb->ki_flags & IOCB_HIPRI) { >> bio->bi_opf |= REQ_HIPRI; >> + /* >> + * For async polled IO, we can't wait for >> + * requests to complete, as they may also be >> + * polled and require active reaping. >> + */ >> + if (!is_sync) >> + bio->bi_opf |= REQ_NOWAIT; >> + } >> >> qc = submit_bio(bio); >> WRITE_ONCE(iocb->ki_cookie, qc); > > Setting REQ_NOWAIT from inside the block layer will make the code that > submits requests harder to review. Have you considered to make this code > fail I/O if REQ_NOWAIT has not been set and to require that the context > that submits I/O sets REQ_NOWAIT? It's technically still feasible to do for sync polled IO, it's only the async case that makes it a potential deadlock. -- Jens Axboe