From patchwork Sat May 23 01:50:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01B91913 for ; Sat, 23 May 2020 01:51:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C3CC72072C for ; Sat, 23 May 2020 01:51:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="z7HrSHy4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3CC72072C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 800308000C; Fri, 22 May 2020 21:51:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 69AC580007; Fri, 22 May 2020 21:51:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 427108000C; Fri, 22 May 2020 21:51:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id 2887980007 for ; Fri, 22 May 2020 21:51:04 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CE0805DDB for ; Sat, 23 May 2020 01:51:03 +0000 (UTC) X-FDA: 76846305606.03.aunt81_608e59d0c3646 X-Spam-Summary: 2,0,0,ad7dcd622bfcc6a5,d41d8cd98f00b204,axboe@kernel.dk,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:2689:2901:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4250:5007:6119:6261:6653:7875:7903:8957:9592:10004:11026:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12895:13069:13161:13229:13311:13357:13894:14096:14181:14384:14394:14721:21080:21324:21444:21627:21990:30054,0,RBL:209.85.214.194:@kernel.dk:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: aunt81_608e59d0c3646 X-Filterd-Recvd-Size: 4893 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Sat, 23 May 2020 01:51:03 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id b12so5107685plz.13 for ; Fri, 22 May 2020 18:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L1+j2GDKy7H0PZDITKGHQ/OK2MPTBbiVlQTxtSNa/Ns=; b=z7HrSHy4DQ2KZLhor2+yKvhwKT3M5/avWRT8S5R2AJrrVQ/VvR19prxLmKkLZNkWzq pHUgk9D6XUmUkOewAT1qi3cXjH9XC3tQueuJoJCrrykyAZZ+GOo3XUCGFcpuqJUu77Cz qk5yHlSqkNewDc77Jj62TymY5U/UdV7bywroR1YBrukWND7+OAWlQLM4T/pruKlF8ECE ovOPYa9TZGG1f8t1lGBZ7YpIwfOtGCnVq9R2LgjgwzOVpCW9Vx8hYR07sVJrBcwLrhzj MPtjnH9yMF6hgSftEGBDEHfwTDDM2yWJWVxvIHOfr8e5Wc+D/P6S2Jyk9whuX1JG/BB8 N9QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L1+j2GDKy7H0PZDITKGHQ/OK2MPTBbiVlQTxtSNa/Ns=; b=PcQYeEuothFl9gohnmpQ2kPW0q8kOHie3BLV5Vpdk14KEC+2GxHJE/ch/0lod4LLYE o+1A23jtB02IsNZAA8h9B6YEGsjsuTPJpye37vLWf2MHkWuTF9AbBNFCy59/yYYgXtqo qJLCWwyn5bVN77VMzfGuyUvS+KO51clM67dqYmPGNTL/THejTtGQInzSVMh92KrKDhSh zX2yVFgswZIND3Z8LuEyzu/FoUIsRF4t7MbX1AeZ0MjplbHUK0zhBoUxWM0mdptw0xMe /bLEPLTXUymrS6GcZQbyqH5LDhvHuugPfdKyQdsfuYupDukQ1MZsiIB0eoAli4z8udiI PAgg== X-Gm-Message-State: AOAM533ZrAW985xE8U9WdB07zVXWmct3IzPHD9i3AJqruIijH1003kbs sSPVtWR5fM3PDfPAFQTE3DIf95+PQF8= X-Google-Smtp-Source: ABdhPJw9gKQXC8DtehX4lEQgYciMv55f8G+1qS4JkrtGXjBLDVm3iWFTcJNG1joBJBOAhIVEQbPUvQ== X-Received: by 2002:a17:90a:268f:: with SMTP id m15mr8317135pje.190.1590198662520; Fri, 22 May 2020 18:51:02 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id a71sm8255477pje.0.2020.05.22.18.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:02 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 04/11] mm: support async buffered reads in generic_file_buffered_read() Date: Fri, 22 May 2020 19:50:42 -0600 Message-Id: <20200523015049.14808-5-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523015049.14808-1-axboe@kernel.dk> References: <20200523015049.14808-1-axboe@kernel.dk> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the async page locking infrastructure, if IOCB_WAITQ is set in the passed in iocb. The caller must expect an -EIOCBQUEUED return value, which means that IO is started but not done yet. This is similar to how O_DIRECT signals the same operation. Once the callback is received by the caller for IO completion, the caller must retry the operation. Signed-off-by: Jens Axboe --- mm/filemap.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index a01daafd49fd..b49836ff0fdc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2086,17 +2086,25 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb, index, last_index - index); } if (!PageUptodate(page)) { - if (iocb->ki_flags & IOCB_NOWAIT) { - put_page(page); - goto would_block; - } - /* * See comment in do_read_cache_page on why * wait_on_page_locked is used to avoid unnecessarily * serialisations and why it's safe. */ - error = wait_on_page_locked_killable(page); + if (iocb->ki_flags & IOCB_WAITQ) { + if (written) { + put_page(page); + goto out; + } + error = wait_on_page_locked_async(page, + iocb->private); + } else { + if (iocb->ki_flags & IOCB_NOWAIT) { + put_page(page); + goto would_block; + } + error = wait_on_page_locked_killable(page); + } if (unlikely(error)) goto readpage_error; if (PageUptodate(page)) @@ -2184,7 +2192,10 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb, page_not_up_to_date: /* Get exclusive access to the page ... */ - error = lock_page_killable(page); + if (iocb->ki_flags & IOCB_WAITQ) + error = lock_page_async(page, iocb->private); + else + error = lock_page_killable(page); if (unlikely(error)) goto readpage_error;