From patchwork Fri May 22 20:23:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566167 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 4E36314B7 for ; Fri, 22 May 2020 20:24:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36842207D8 for ; Fri, 22 May 2020 20:24:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="oluJiB9k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731029AbgEVUXV (ORCPT ); Fri, 22 May 2020 16:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731012AbgEVUXT (ORCPT ); Fri, 22 May 2020 16:23:19 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92C0C05BD43 for ; Fri, 22 May 2020 13:23:19 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id m7so4827751plt.5 for ; Fri, 22 May 2020 13:23:19 -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=DT9kV8IQxC/D+uhFJsefv+iJT3TxYB4ReZ7s4ZFOil0=; b=oluJiB9kWUp1jQn6GyLmG8WAT4m3lKYyoaZWl/EYudmvX4dpan5EUM8v9K2zM1/sA7 O3g1BfDhqlwNJGIPOYmdgugrSlOXilKAkvTeGRZUAyg+ubdWg9R3UvtbrB8ako657CER OJig952C9v1iZGI2ZOQhlCVH6ErL4Ubx1gxOzYooasGRhDU0/Dt65urTRTAMtn67pdgQ gEFv59qa47MpUvtQ+b2fWdA5BKzUAJwUSiYvK2yAGfBa9QmyVAXuxxZeZrInMJdae2Zk mY5mg1VVp8HXmhTWFTyUwV1HXJ8c3ncMAaK9kqA0E1p1Xbei/hD9gc3x5raO9d4lvh4l JTXw== 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=DT9kV8IQxC/D+uhFJsefv+iJT3TxYB4ReZ7s4ZFOil0=; b=ZbwLtSTa9+11u17ZZx7kAB8YpELzKUza3kzSbpv4I1nO/XB5zJZhZ2F8gMq9oHE1yq pBGC0Jb6gRy7PLcxxoSCNlg6uEe2jaVnrnOHjndbixN2Q4eMEO23Or0ZxkGdldq2nlQH KjfBkvszRzaQDWx3RZrCaZkS8eyZBOexRRe7RN2P/zLqlf56snPVHNP6Rnp4KR6Oocf8 0WoBhxqoL8QTB85CNopqkZ2/xbrNQ53y/s/eDPSoUwlyehVuQsJEPVoV3Fwv5pa5B//Q SgrHiobQj6LKso+zixPovG5ex0MkqhcdYmtDTG3XflY/PHYfcd1Bp046TktmCbqToixH 173Q== X-Gm-Message-State: AOAM531wT9Vql1/ESaDFFQWwut31fYXNE1znQdzInsAVUQlSApp0sh9Y CKpPrTzOBrVnl07n4GXiHD0K0A== X-Google-Smtp-Source: ABdhPJwRmiBEyWg7pdyhPoLxCIRWXwfGbwz6AlixTjtFq9I6DrZDtT63kPMRKd8YJFJc1xW8WultIQ== X-Received: by 2002:a17:90a:d3ce:: with SMTP id d14mr6342767pjw.46.1590178999200; Fri, 22 May 2020 13:23:19 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:18 -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 01/11] block: read-ahead submission should imply no-wait as well Date: Fri, 22 May 2020 14:23:01 -0600 Message-Id: <20200522202311.10959-2-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org As read-ahead is opportunistic, don't block for request allocation. Signed-off-by: Jens Axboe --- include/linux/blk_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index ccb895f911b1..c296463c15eb 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -374,7 +374,8 @@ enum req_flag_bits { #define REQ_INTEGRITY (1ULL << __REQ_INTEGRITY) #define REQ_FUA (1ULL << __REQ_FUA) #define REQ_PREFLUSH (1ULL << __REQ_PREFLUSH) -#define REQ_RAHEAD (1ULL << __REQ_RAHEAD) +#define REQ_RAHEAD \ + ((1ULL << __REQ_RAHEAD) | (1ULL << __REQ_NOWAIT)) #define REQ_BACKGROUND (1ULL << __REQ_BACKGROUND) #define REQ_NOWAIT (1ULL << __REQ_NOWAIT) #define REQ_CGROUP_PUNT (1ULL << __REQ_CGROUP_PUNT) From patchwork Fri May 22 20:23:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566165 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 2AE5A14B7 for ; Fri, 22 May 2020 20:24:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09B64207CB for ; Fri, 22 May 2020 20:24:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="BXbHdLw2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731044AbgEVUXW (ORCPT ); Fri, 22 May 2020 16:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731035AbgEVUXV (ORCPT ); Fri, 22 May 2020 16:23:21 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BB35C061A0E for ; Fri, 22 May 2020 13:23:21 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id a13so4827205pls.8 for ; Fri, 22 May 2020 13:23:21 -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=TvoN8a3WZmoogVlnFEo2G3/jPQNtfJ5pQXb6VgaLeNI=; b=BXbHdLw2u7+4v2OrPmYOPKCximguO5jiRJZaHaFHSVsvSvWUEzYysWoLSxdtoQAhVk HQyzWIFFRo/mFUpenrzA6F5+44ecTT/9T8gl76XCfW+c2eXcPrv0LOIa2RbwWHAjv/HG LlwUH90hb2MejF0kbDvRktH/1MKI00SlTe1zoChJciTQecxjsyBVAaG5NbzlfHNdSLJo YxLoC+8l2OyrR2oOB0j03phI7j7zHKNXpqoNl19DH0baMd93TstNiHmfuTzQF3eeeuAS 2STt80Zor0RzeZK9zZbUp4rN1b+ryCJn37SAdistDxGmOl4mfgIIJQWGyWWE7PTGyUWw nDKA== 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=TvoN8a3WZmoogVlnFEo2G3/jPQNtfJ5pQXb6VgaLeNI=; b=FRP8aOkhDXCEwNOtheAhAjm94mYo8sFpr7HhRd+4t6o2XFonWFQBQtfyfE+7rLZ2cL wzwXzJ7aqt1obwCmyVGh4CL04xDMnuM8Rc7obsYhUCi66yqJVLdSTrZeuE/7tecOe0dt RnbDbOJIcqJt74bII5bc5kw3vwPvHCJH2NOCj5B9SevwsJMu5AAw/0rqN2VYJ4qp1X91 EYHatpcuOL4AJV+IQUU1iXXM7avNd1ioW8TrQBRA9Fp0YbEWoNsWJwLeywOJEkMMkHqy lo3TuTtNCE25+3bdIiJWD/zNNFsMesTiIxfOCL6HNsUWPdoMgf6DhDjnAraCIEjqf8Sa 53tw== X-Gm-Message-State: AOAM530sKUaEN3SBu6VrWwnMwQ6ITurnvoKbTVbMRPify1jWEbS+8FNN yzU5qrQpRkgp/bEfAYrHeX/E7O0J/XA= X-Google-Smtp-Source: ABdhPJyVyvEl6dSL6IOBsJmpnycz4H0kN8LpN+dJacQOGflvQ6nocjSVsWNNdSmRA8eHxZtEk7xEXQ== X-Received: by 2002:a17:90a:6881:: with SMTP id a1mr6499268pjd.153.1590179000778; Fri, 22 May 2020 13:23:20 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:20 -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 02/11] mm: allow read-ahead with IOCB_NOWAIT set Date: Fri, 22 May 2020 14:23:02 -0600 Message-Id: <20200522202311.10959-3-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The read-ahead shouldn't block, so allow it to be done even if IOCB_NOWAIT is set in the kiocb. Signed-off-by: Jens Axboe --- mm/filemap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 23a051a7ef0f..80747f1377d5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2031,8 +2031,6 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb, page = find_get_page(mapping, index); if (!page) { - if (iocb->ki_flags & IOCB_NOWAIT) - goto would_block; page_cache_sync_readahead(mapping, ra, filp, index, last_index - index); From patchwork Fri May 22 20:23:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566161 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 55FBA912 for ; Fri, 22 May 2020 20:24:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3846D20814 for ; Fri, 22 May 2020 20:24:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="M62vZgt7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731053AbgEVUXY (ORCPT ); Fri, 22 May 2020 16:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731050AbgEVUXX (ORCPT ); Fri, 22 May 2020 16:23:23 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8994CC08C5C1 for ; Fri, 22 May 2020 13:23:22 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id t8so3347666pju.3 for ; Fri, 22 May 2020 13:23:22 -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=E5DEkxIJkQWsUJs0qbxunHfP/DfTSgAGYfxGVJ+umf8=; b=M62vZgt7Z81D/uiR+GCOQQB3NqfNockOsJ/6frjYkhnWPNPJJZTcIPvOcq1e+OIlDL A7Uaby6+5+yzzVPToxB0CyZzT5Jw1ob2YGIEZqHXjXgKhQGh5U1q8a2A9pPN0Cj5rGty y3qU1pliP06kZl8w8cUT7dvfF3ahpHIQJ7dNrjzqotZO6ri1R9SVfzOckoAebjqf/Twx j91VjdHpplZRnRM3EsEkFM0HXA1ovT2U9jd3h2He485CnEKSF5f+kF6cuKM/q9U1z8MV UmuaS9qHJ8zAaJnmJl/2IfxSZvQnvGic/q3WR7JBZtt23tccTdCAAtq96+R89GOMjP2k aoYQ== 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=E5DEkxIJkQWsUJs0qbxunHfP/DfTSgAGYfxGVJ+umf8=; b=DB4R8viqygNE2CLsi9a9qffAF3Ds7Ya27CRnhPHJcwZtYy5DFy83DHdLe4kdjedQ1K KUIRtp/H0pfW2xjvwNoHQLsdFONOmO1j/pyThfBZYDZrkTysKeuQkD5aYcuG7hI+Ux5q YoWogq1X6Cp5E4f2AahVIzdULrdQV9ovYlWipebW8TntzobP1URiKaWOSxqoxCyttoWH /BmJ3hFrEQa+XRnGXJaFrpZlPBVYtqMOshgFheSGjl0Mk6lHQ2NqUF56W53PAk6Ta4In LOZikQwjtdfa/SnMQhyo0tzVfrojrkXlo9+zcE51GB0PYMOIlDesfUp2yJ76cswo8l/R XyMw== X-Gm-Message-State: AOAM531f/ADvcqcJW0zZ35rn10cy9iV0Ctz2pT1PuwKn+UNtS1bbjfir XTT9rRiFRT4sP2dq3wp7vQcNig== X-Google-Smtp-Source: ABdhPJxj+N3pVChoXFbbBEseusfqTToenJpOK897u7XCplyacE6niX5gkU9YVqdofi7hj7Jnx22hMA== X-Received: by 2002:a17:90a:4809:: with SMTP id a9mr6555363pjh.196.1590179002017; Fri, 22 May 2020 13:23:22 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:21 -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 03/11] mm: add support for async page locking Date: Fri, 22 May 2020 14:23:03 -0600 Message-Id: <20200522202311.10959-4-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Normally waiting for a page to become unlocked, or locking the page, requires waiting for IO to complete. Add support for lock_page_async() and wait_on_page_locked_async(), which are callback based instead. This allows a caller to get notified when a page becomes unlocked, rather than wait for it. We use the iocb->private field to pass in this necessary data for this to happen. struct wait_page_key is made public, and we define struct wait_page_async as the interface between the caller and the core. Signed-off-by: Jens Axboe --- include/linux/fs.h | 2 ++ include/linux/pagemap.h | 22 +++++++++++++++++++++ mm/filemap.c | 44 ++++++++++++++++++++++++++++++++++------- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 7e84d823c6a8..82b989695ab9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -314,6 +314,8 @@ enum rw_hint { #define IOCB_SYNC (1 << 5) #define IOCB_WRITE (1 << 6) #define IOCB_NOWAIT (1 << 7) +/* iocb->private holds wait_page_async struct */ +#define IOCB_WAITQ (1 << 8) struct kiocb { struct file *ki_filp; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index a8f7bd8ea1c6..39af9f890866 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -456,8 +456,21 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma, return pgoff; } +/* This has the same layout as wait_bit_key - see fs/cachefiles/rdwr.c */ +struct wait_page_key { + struct page *page; + int bit_nr; + int page_match; +}; + +struct wait_page_async { + struct wait_queue_entry wait; + struct wait_page_key key; +}; + extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); +extern int __lock_page_async(struct page *page, struct wait_page_async *wait); extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, unsigned int flags); extern void unlock_page(struct page *page); @@ -494,6 +507,15 @@ static inline int lock_page_killable(struct page *page) return 0; } +static inline int lock_page_async(struct page *page, + struct wait_page_async *wait) +{ + int ret; + if (!trylock_page(page)) + ret = __lock_page_async(page, wait); + return ret; +} + /* * lock_page_or_retry - Lock the page, unless this would block and the * caller indicated that it can handle a retry. diff --git a/mm/filemap.c b/mm/filemap.c index 80747f1377d5..0bc77f431bea 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -990,13 +990,6 @@ void __init pagecache_init(void) page_writeback_init(); } -/* This has the same layout as wait_bit_key - see fs/cachefiles/rdwr.c */ -struct wait_page_key { - struct page *page; - int bit_nr; - int page_match; -}; - struct wait_page_queue { struct page *page; int bit_nr; @@ -1210,6 +1203,38 @@ int wait_on_page_bit_killable(struct page *page, int bit_nr) } EXPORT_SYMBOL(wait_on_page_bit_killable); +static int __wait_on_page_locked_async(struct page *page, + struct wait_page_async *wait) +{ + struct wait_queue_head *q = page_waitqueue(page); + int ret = 0; + + wait->key.page = page; + wait->key.bit_nr = PG_locked; + + spin_lock_irq(&q->lock); + if (PageLocked(page)) { + __add_wait_queue_entry_tail(q, &wait->wait); + SetPageWaiters(page); + ret = -EIOCBQUEUED; + } + spin_unlock_irq(&q->lock); + return ret; +} + +static int wait_on_page_locked_async(struct page *page, + struct wait_page_async *wait) +{ + int ret; + if (!PageLocked(page)) + return 0; + ret = __wait_on_page_locked_async(compound_head(page), wait); + if (ret == -EIOCBQUEUED && !PageLocked(page)) + ret = 0; + return ret; +} + + /** * put_and_wait_on_page_locked - Drop a reference and wait for it to be unlocked * @page: The page to wait for. @@ -1372,6 +1397,11 @@ int __lock_page_killable(struct page *__page) } EXPORT_SYMBOL_GPL(__lock_page_killable); +int __lock_page_async(struct page *page, struct wait_page_async *wait) +{ + return wait_on_page_locked_async(page, wait); +} + /* * Return values: * 1 - page is locked; mmap_sem is still held. From patchwork Fri May 22 20:23:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566163 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 72BAA14B7 for ; Fri, 22 May 2020 20:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AC7C207CB for ; Fri, 22 May 2020 20:24:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="XR1Hfpng" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731052AbgEVUYA (ORCPT ); Fri, 22 May 2020 16:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731057AbgEVUXY (ORCPT ); Fri, 22 May 2020 16:23:24 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2AC3C05BD43 for ; Fri, 22 May 2020 13:23:23 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id q24so5460414pjd.1 for ; Fri, 22 May 2020 13:23:23 -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=pk0mOQuIM8W3goGTEUJ7lPQkF+2EvbiQPRxtP96y/VQ=; b=XR1Hfpngk92X60W6mtjRxmwWQjUpXxr57sMRlRMp6WKXl0EGRM1SyAOYAgYY/8k15p InaZ+j7vcNDYMPyNeT3pDlSC7+7MpYvudX2nOoV8UHce1YTszpzP9mKmUYM9+1SSZXq5 luaLISz3wcOf7+VgrtBaX5me2bW3GJ2GmAjc5UYbYKCQVBBAfA0DmjLo7fD31fEdUXGr jHzVrF/TM6JPGmvwNE0mpRc+1IJz9vT6u7Y4z3e0+t6sID85Socj7145P1lc8My6fsi2 kejNXdw85Mje1pDKxQKcH2qKiA+KYZmlq8rNRp4E3T8t8Bj9P56S+c++YndQX8+ING/I WFPg== 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=pk0mOQuIM8W3goGTEUJ7lPQkF+2EvbiQPRxtP96y/VQ=; b=ZGHn1lYwDbhTDAZKLOynWrDQsYi9/V2IhXG/VsIV8di0yAiiu4rQPqbUQNffK/0jAH s3QMdU5r+4yA6CYJvGlVymIE9WE2bAz1o8lQcTK9tgbFNlsCFfM4cCsfhbENtRB7c1TG EJUhgB5kMwqQu46W1+/CDc59DJI4k+bA7BaOdMEVYphHSZ+Z30BOwBWCmLxmr+Wcs+Gy sKfbuG2/wiqZOPVunWqGE4K80Lnw70Jq5bWmUpFH+ijPoEDdqnbmuA71uJHSxpp/lx/3 R8WIXbtj1+Qr/b92pqGB8CNIaTkSYfnALt2eh3Gk+Az2SmF6aknoeI/nTVlrdoznWROa 7GKg== X-Gm-Message-State: AOAM533m491OeBRZYzTQKerMFaC4nyOpZYkyFrEI5AAKAZC4iQl6CDaI MfqCKnpyQy5VZ2bUt8XYEt3OIFFay5M= X-Google-Smtp-Source: ABdhPJwS7xFlgv35cRDBhVL35NxCpOL//x8P0nJbD9YCPQRRanDgUxHWeCBsTZZ0WIpa+r85qBpFhw== X-Received: by 2002:a17:90a:c594:: with SMTP id l20mr6422753pjt.123.1590179003224; Fri, 22 May 2020 13:23:23 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:22 -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 14:23:04 -0600 Message-Id: <20200522202311.10959-5-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 0bc77f431bea..d9d65c74b2f0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2074,17 +2074,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)) @@ -2172,7 +2180,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; From patchwork Fri May 22 20:23:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566133 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 D293514B7 for ; Fri, 22 May 2020 20:23:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA2C520723 for ; Fri, 22 May 2020 20:23:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="jrTkj5mN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731077AbgEVUX2 (ORCPT ); Fri, 22 May 2020 16:23:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731061AbgEVUXZ (ORCPT ); Fri, 22 May 2020 16:23:25 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07AC7C08C5C0 for ; Fri, 22 May 2020 13:23:25 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id u22so4807741plq.12 for ; Fri, 22 May 2020 13:23:25 -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=+VWs0Nj9WGghWnCOq/fSx5SIRlxQxiE9MXDVdkqYQzM=; b=jrTkj5mNE8rkwflBEeAmIyb8Qnj27z1yhUum3fkVIs00PTWv5KrHY1A5uxtAVi65oK sOFOAmMe4Gijz004PQKYcIsCxcGM8MEtjGr0pk5W7S5Os5B7IeWfCmo12ZhXpV02UTQ8 NMWc32YYKiWXGBAXH68HZNtHCu+Opp2BtHSGYWjZOKcBXiW9cHxFRzCOMyky4/0vjdMn 5y35f5bHYq9Jg1W8nnVsoOeuzdArBHrHCpynV8TZM5GAjCe8erOkISRTfBQRsoiIsbpk A9dSOn4joSJzn6Jw8G+n53yZzeJQBQPsAlw9IQ8Jvjm9ct8cpyOb8gJwVVUsi/r/HQXI cDig== 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=+VWs0Nj9WGghWnCOq/fSx5SIRlxQxiE9MXDVdkqYQzM=; b=CINg02OK2iB8WdOSbgIo/Kd6TZ6ql3w4w0Q7bTQKIEbxxpiQ47Dq8Sw38c9GOHtPc+ 1jbTE1Gbeoyu1n6Svd5U/mokWiCh1WEiav/mV6zy4ka4B/bkT8KKSmEwVEU129YvdSKB zknhdx31wQsnw7OOfofeJXX3ZtRE1obNsemmfy/SgE86FWnD+5HHaXFj1zzXTMl73aAa z7ZcXcbzY3x7euMk3OV2yoVOZDz6Ag14cYWQgD1lRkq5F+zveTg84LlFVWzfitV0JNs3 EqiKqN25910mO3SnJ/aVgwymxaEke9qLXu4O+ReQ8mmuFqumdN5b5tPjYHHoSdxht6ri azjA== X-Gm-Message-State: AOAM533DJDYjiHEoDeAjlHFE4WftJq7lP7Rnvl86XIX1pOjCSBmFf3Sl MumKHTFKYmfK9VthhveFXvzWag== X-Google-Smtp-Source: ABdhPJyfk1Fi4CeJavhhm5jD+udLfDiANFaIVbhg/UeDmfEmwZxENiHETpIQtctD6WObNUCaWgH+4A== X-Received: by 2002:a17:90b:1082:: with SMTP id gj2mr6812346pjb.225.1590179004516; Fri, 22 May 2020 13:23:24 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:24 -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 05/11] fs: add FMODE_BUF_RASYNC Date: Fri, 22 May 2020 14:23:05 -0600 Message-Id: <20200522202311.10959-6-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If set, this indicates that the file system supports IOCB_WAITQ for buffered reads. Signed-off-by: Jens Axboe --- include/linux/fs.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 82b989695ab9..0ef5f5973b1c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -175,6 +175,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, /* File does not contribute to nr_files count */ #define FMODE_NOACCOUNT ((__force fmode_t)0x20000000) +/* File supports async buffered reads */ +#define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000) + /* * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector * that indicates that they should check the contents of the iovec are From patchwork Fri May 22 20:23:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566159 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 DB2A414B7 for ; Fri, 22 May 2020 20:23:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8352207FB for ; Fri, 22 May 2020 20:23:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="dDUvxjbs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731087AbgEVUX3 (ORCPT ); Fri, 22 May 2020 16:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731068AbgEVUX0 (ORCPT ); Fri, 22 May 2020 16:23:26 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4794BC05BD43 for ; Fri, 22 May 2020 13:23:26 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id s69so5411051pjb.4 for ; Fri, 22 May 2020 13:23:26 -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=7SUIxRwptQ6YWj2W/l7Dp7FzKmS+sjQ+qLVh2r/v7CQ=; b=dDUvxjbstbHn7Sjiy+FPAA2PEvxIM7GifOiRJeDAMSbY7yuZnnZssNPrW/E901JJmZ OiWeE8x8Dullp8KQX0tfScd3zLgJ5dqFDExo65YjCoSluEuUiua3jP++fR5YzUqru8zI NXVTSEKuAtwrG/ZRrJptiR6rdkUh3s0gV2rnNOuBXEHCRFP2f7G+O6Kd7xTEzLo5d7O6 1kKmpbdn46318RaR3RoKDqSBHERhxohD2GZV8Ws+IOrzVKyuazrQVmIYmUbQkjczdFs6 4tMUI5bcGqqrmfzKTUnEqt1xwSLASC838o8d/OH5NWXSrzKDy3ZhjDyXw5k2B4zWiXIr qkJA== 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=7SUIxRwptQ6YWj2W/l7Dp7FzKmS+sjQ+qLVh2r/v7CQ=; b=DqKlJlGXquwa1ZQGhgCSegrBY5qUce2Y2H8WkyuVltZG64L6tsHqCR6MAwyF8/f8O8 djpK3UoU84zs5qbZESsHfbCJkGvwU3j/7z/NbgqkkwBn3BsuTl1KDcA2yL8lRKtT9wMV 3JtT8MUKYrYat5YKab/2jNzJDhZ9SGEjBwPjKg6Eud9/VcXclMKTYLBAlAq9muRpeDks b2/QBbm2ficlgpCjWA2nFU6jLceYf+YOvkahj9DMApsEPcrvot+7/0BmSXWJEhbG+QtH aCwq2lTG5rtIU2RnKM/vU3PA2iHinq1U4D9oTpQNbVz3hfXIaj3rZcDqxfTBERkd+coF e1Kw== X-Gm-Message-State: AOAM533y1MHU6y70JSFyAagOfhepThr7gNWJ2U7GdNuE1MCzMBC03Gc0 wVm2xSCVtZgaHUGwojPrXkJfyA== X-Google-Smtp-Source: ABdhPJxHHV8hqa7uaJgKGvaQpHrwfQ3OD8pDgEG5RnHU/xBhEFUUXMnZAbPdGq2y0/Mjy8qPwsjM7w== X-Received: by 2002:a17:902:b907:: with SMTP id bf7mr16387892plb.136.1590179005767; Fri, 22 May 2020 13:23:25 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:25 -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 06/11] ext4: flag as supporting buffered async reads Date: Fri, 22 May 2020 14:23:06 -0600 Message-Id: <20200522202311.10959-7-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Signed-off-by: Jens Axboe --- fs/ext4/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 0d624250a62b..9f7d9bf427b4 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -826,7 +826,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) return ret; } - filp->f_mode |= FMODE_NOWAIT; + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; return dquot_file_open(inode, filp); } From patchwork Fri May 22 20:23:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566157 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 1273E912 for ; Fri, 22 May 2020 20:23:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4E3D20723 for ; Fri, 22 May 2020 20:23:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="vqlZYMPw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731090AbgEVUXa (ORCPT ); Fri, 22 May 2020 16:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731074AbgEVUX1 (ORCPT ); Fri, 22 May 2020 16:23:27 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A80E4C05BD43 for ; Fri, 22 May 2020 13:23:27 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id k7so5409476pjs.5 for ; Fri, 22 May 2020 13:23:27 -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=4QX6izj81MoWvGB/E4/khaJEguGwrdsEfxjduXmAWvc=; b=vqlZYMPww7j3TOIyzxvdW3/q03eVxx/Kt286FLeusp48yDbLJjq0ln6B43V8FbVo3u gcdL0IJhfUQanWN/Su6LcPlVskFIZoDE79RbCWvLDvXaYW8oYUjtUGwaSS93SvGaudU0 Dmja6SkC2nkNK/NZLi3mUHjaKvMiJ/q8BaDYHmBkAv6kq+6dvO1gdhPm3I6e7U2GPx7Z Sku/pU0sVdVBRuZriAmdEmXAdP3CLXjBAnqwV47vMFExFJB+158uymcq0+DXz/+vg0wR VHJyh2+6hv06m8Qe7Kg6r3uwm07yOeKHHjJ3925Ov3RZPMIzvNUdU2EAIEb5ptM7pC09 w09g== 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=4QX6izj81MoWvGB/E4/khaJEguGwrdsEfxjduXmAWvc=; b=l/QGnraHIbUXoQZIZmZ+Umdc1xQsZcL/hDFTQpxIUC8cOyNCBUU22+F3u19kn5GBOn DM9l5WaxRZYFFpHl42v2zgvesc5Dcwyj964XcHAgH9/OhwRjWSlolCKDJ5FafCRIEdGy /GoUDj4QJRMpNVndmuVzQBpW2lzgLPg9ICS61LnmWfpqLYWyERtz/cNnB7+ZqfDshJbp S6dwP1nNdOqdeCysuuBnpFSyByGBzzewRKwzRLvjkLPuIG+ye+c9X7eEWo9lrCIsVzA7 j8yXZ0v2JL6rwGifSaPFDKPuKMMHSHDrQG8fImTlzTM030N2gdJ7tlvUQbNhdadpYtnD akDg== X-Gm-Message-State: AOAM530yczo3QDiRX/bx9RSF+9UC8tSxWtXvEf5nM/BUf5IDRU2Dalw8 U6+lv1gfu5wOQLqk7tK+Ct9s2A== X-Google-Smtp-Source: ABdhPJwXSAs80allPBjJsy+8cK/RjOwPK4cXYA3LyZ3dlUNMHIjbWunnLsScPWqcRL/3fjvWEVHJEw== X-Received: by 2002:a17:902:aa4a:: with SMTP id c10mr8642851plr.0.1590179007178; Fri, 22 May 2020 13:23:27 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:26 -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 07/11] block: flag block devices as supporting IOCB_WAITQ Date: Fri, 22 May 2020 14:23:07 -0600 Message-Id: <20200522202311.10959-8-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Signed-off-by: Jens Axboe --- fs/block_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 86e2a7134513..ec8dccc81b65 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1851,7 +1851,7 @@ static int blkdev_open(struct inode * inode, struct file * filp) */ filp->f_flags |= O_LARGEFILE; - filp->f_mode |= FMODE_NOWAIT; + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; if (filp->f_flags & O_NDELAY) filp->f_mode |= FMODE_NDELAY; From patchwork Fri May 22 20:23:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566155 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 0CFA114B7 for ; Fri, 22 May 2020 20:23:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E90DA207FB for ; Fri, 22 May 2020 20:23:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="uBr7svy9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731132AbgEVUXm (ORCPT ); Fri, 22 May 2020 16:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731088AbgEVUXa (ORCPT ); Fri, 22 May 2020 16:23:30 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91C0C061A0E for ; Fri, 22 May 2020 13:23:28 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id z15so2502093pjb.0 for ; Fri, 22 May 2020 13:23:28 -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=39qQrTBLEctUrGanLy/C45/WjdVfQkC7faPzmr+qhpI=; b=uBr7svy9tGM1kfB0BhVdX6NmzQX7rjQdOtGeI9ETv3djnnaJou6LDEVAoqvNhiiMVT /Y5aMZKUeucWj4+6prged/kK2w3O11+J7ITuX3qF2rDWVpxOGNqwSl0Hy8USWsr9ntfH wTY67840FUisgxyeUli0TTVeTuG/PHpzi31HVq2pkUzGI7PT1MsmMlwDsnc/BVD/45NU bV0QmFFlKDq2DiZ6DxAELytGXg4aFefVWKQ5tYTu+5vUtoGLWwL0eIHhz4hZAfNx4D3p /hFGWFMxUuY/F/k91LWw7i7MJyeaK8gEpjfwnHCZfozr1yisHgoRMD5fqyyZGLgF68/T lIWw== 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=39qQrTBLEctUrGanLy/C45/WjdVfQkC7faPzmr+qhpI=; b=dicadCW53YtjOv1/WEIS6tgAHPmIEU1OaM1DAHZjvN+ydmqscWhAFBEua2S39FAtk/ CgH1op2ltcsryR84IHbmez8wjKkQNK9uuUaKi9nL6umLvKXVJQDEp1CWjjXbz/BPlxtP GruBvGmEap+dELkOmPhKbUvF1L33wZ4S/vBrkotiCchqIIRkofQRQo6og3hQOcoOABi7 BSeSUPP/nosuMtuGDXNrXhUQMXyQGTkijkv9OzFvq2ju2fD0BpWTp/hj0POXvFqxZfxE aKnfT7hFfSmudj02MER5q5/aMG90112R9SCfsfwkr1ZyHsYLpocJ86bbMdpggjfhFlIr Rxzw== X-Gm-Message-State: AOAM530DUxZrdGitG9JiPqpPdPJPDd7KCJ39c0C3J3RagQFv+FoCI0zi V4bkuaY0CKmVB++UDak1EvHp/w== X-Google-Smtp-Source: ABdhPJxx2gppjGUSOrpOA5NJuWG9g1kSxTIapFlBHOL94NWzUmJF8nmeuziyDIoMZKnC+btQ+HzhUQ== X-Received: by 2002:a17:902:d894:: with SMTP id b20mr16375293plz.156.1590179008383; Fri, 22 May 2020 13:23:28 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:27 -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 08/11] xfs: flag files as supporting buffered async reads Date: Fri, 22 May 2020 14:23:08 -0600 Message-Id: <20200522202311.10959-9-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org XFS uses generic_file_read_iter(), which already supports this. Signed-off-by: Jens Axboe --- fs/xfs/xfs_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4b8bdecc3863..97f44fbf17f2 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1080,7 +1080,7 @@ xfs_file_open( return -EFBIG; if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb))) return -EIO; - file->f_mode |= FMODE_NOWAIT; + file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; return 0; } From patchwork Fri May 22 20:23:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566139 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 50EDD14C0 for ; Fri, 22 May 2020 20:23:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38453207F9 for ; Fri, 22 May 2020 20:23:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="j03IEEOg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731107AbgEVUXc (ORCPT ); Fri, 22 May 2020 16:23:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731098AbgEVUXb (ORCPT ); Fri, 22 May 2020 16:23:31 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CCA2C05BD43 for ; Fri, 22 May 2020 13:23:30 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id q24so5460702pjd.1 for ; Fri, 22 May 2020 13:23:30 -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=mDbeWlveWyEr17EututM6ewZlLrenoq+wrG4TB+c+O8=; b=j03IEEOgnJZi5ko1SE4Yy8wNORC5fg5JXAn8lnUJFKJf5u/9dtYUczkr1QQ/dY+CIw YbVVb3BBuMMxABnx0zlKNSYyZAx2G/vflHNqNmswq2TJutNL0kOMepkLngLrig7h+7oS ujgpYoMXH+ou8n5IPuIyRW2ix5asnqvPP46P0HqNUYH7oKiQNM6Gy67i1W5isZEwKih8 OTvGPMeLn3efqm5Q2B5hhdq3U99RA2/4x0ebaA+WMXodP8rzwBFVxmSU86YJMleSfBMh TSp7hC+jwel4pfOL+8cOo7SxKq67U1+bTqluD9pbOs9RqNDYvqh/DBv78Wf6IsfF5oC2 lSbA== 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=mDbeWlveWyEr17EututM6ewZlLrenoq+wrG4TB+c+O8=; b=t+ExmdEIrX6uMEpF1z3omfHnUQ5y665LfjHLXlTSypibcOYAy52B8EHlxXE0B7F7NQ XZaXlql8n6yQZw3N3Cxja5X+HFZ9SEvtXZ9UbcC1zdY5IB9y6lcwDzgQu990nMeDvMn0 AXf7SJxvUN6PeKNu6GrsL9ROoggLYRmcfhsNqKkVzivjQuCRtnxkVYpFcZPGgcwJ6x7t cjTHW0xbeEOHXso7NcEoZ/O/UAO32pI+S+VY441mnk1Eqb7HU19nPKFAQgFKl98RWFlE PqFO/xZqRhJLlEjibhGgSrpk+U4zD8xei2Jxy6+mWqvDDtMpvp+to7gOU9g6e6btXU6g 9dVQ== X-Gm-Message-State: AOAM530gIS0PNr1G1x9+RsRZBp8Rp2dG6edlkhqmURy2RF8XHqzYlhb9 HuwIIsJ1qBZukqmOVEMnForXZg== X-Google-Smtp-Source: ABdhPJwGQW7A98JrKpyFk925FUprxECV23C7TpnQ/+SA3VA1Ed5K0vN07mxApztvyVgBXrkD+DwUvQ== X-Received: by 2002:a17:902:ab8b:: with SMTP id f11mr17078210plr.145.1590179009960; Fri, 22 May 2020 13:23:29 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:29 -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 09/11] btrfs: flag files as supporting buffered async reads Date: Fri, 22 May 2020 14:23:09 -0600 Message-Id: <20200522202311.10959-10-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org btrfs uses generic_file_read_iter(), which already supports this. Signed-off-by: Jens Axboe --- fs/btrfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 719e68ab552c..c933b6a1b4a8 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3480,7 +3480,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence) static int btrfs_file_open(struct inode *inode, struct file *filp) { - filp->f_mode |= FMODE_NOWAIT; + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; return generic_file_open(inode, filp); } From patchwork Fri May 22 20:23:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566147 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 1559F14B7 for ; Fri, 22 May 2020 20:23:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1F40207DA for ; Fri, 22 May 2020 20:23:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="e17fBBsJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731122AbgEVUXg (ORCPT ); Fri, 22 May 2020 16:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731111AbgEVUXc (ORCPT ); Fri, 22 May 2020 16:23:32 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8496C08C5C1 for ; Fri, 22 May 2020 13:23:31 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t7so4832573plr.0 for ; Fri, 22 May 2020 13:23:31 -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=97ziPRJaRp61bFALKKVlWwbLPU9AOxDDg9/9arO/CTQ=; b=e17fBBsJfZzejhyxzZWQq/0IdfUf4Mo7YkSITiDn2GwpMJENeHLROZ7xtML6c2G5aX HuBV1pCq/A8reKOFu/GCRwEdHlbBHMk0eD3XLv44Mw8gTWQh57rFxc1D/CyoZ+dHcP7A pd2LqaWGznMbFTRGhHaN0Z7tJizqem0z7kyisPSXDWuoLdV9PeMV9c0Xeb7U+w8UsFC3 TLKe5LDzzt4+WeD+Gut9wXCq3YC3SBiPiKoYRVu5mWW2dKca2CG6wEu1UBMuCHyqtlOG X7/3dWCwp6/uuPicBJJNLWqjdeacU7PZV+7zzos9IrX0bKKBof26X40REjM3sxDBfnuK CHcw== 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=97ziPRJaRp61bFALKKVlWwbLPU9AOxDDg9/9arO/CTQ=; b=ZBQM3U59vwinlHXZ6en+qTz9y83ksHX+4YbJkp/LEJn+cQM2w/9f6IDaXQ5Lki+8hq btYnjZy6cw7BrSNarYCOxZfuSWHxCzIU8sSXiK/aW0UAWPzd2/tfC8i9C6UGXIWkbMbW AUMfYJ2iq2qOj51ozSN1mj9/u86rLfXiOIuVTIZ6noll84In439sFUd8cnMH8UvAyBN8 rWZZFnppLVpVM5ED7cXcfNFHu0lmBSi+ZZDEACFzposmlSQwFCGs65Z4x1adSrT7Rso7 zQXfGunmzwpcsWdd60DSUdZgze7n0RbcA9YX3uo5kjVQIkcsmHnr1GnzLG1GI4x2AoiL nJdw== X-Gm-Message-State: AOAM532tiZac5nqQUtddYqzTgLdcNWPmmItpKLag6ls3KPOnA7cJei+w Adn+GBFjrTtOzB6rbxxJl203sw== X-Google-Smtp-Source: ABdhPJz01IRscjgYK73+OikJorEQXyPy9buBD3WYGODAQhQOCBJuBqKGCIESXg0wwn7P+hv3J9t1mg== X-Received: by 2002:a17:902:6f0f:: with SMTP id w15mr16026547plk.191.1590179011200; Fri, 22 May 2020 13:23:31 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:30 -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 10/11] mm: add kiocb_wait_page_async_init() helper Date: Fri, 22 May 2020 14:23:10 -0600 Message-Id: <20200522202311.10959-11-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Checks if the file supports it, and initializes the values that we need. Caller passes in 'data' pointer, if any, and the callback function to be used. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 39af9f890866..dec61e9e5710 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -468,6 +468,24 @@ struct wait_page_async { struct wait_page_key key; }; +static inline int kiocb_wait_page_async_init(struct kiocb *kiocb, + struct wait_page_async *wait, + wait_queue_func_t func, + void *data) +{ + if (kiocb->ki_filp->f_mode & FMODE_BUF_RASYNC) { + wait->wait.func = func; + wait->wait.private = data; + wait->wait.flags = 0; + INIT_LIST_HEAD(&wait->wait.entry); + kiocb->ki_flags |= IOCB_WAITQ; + kiocb->private = wait; + return 0; + } + + return -EOPNOTSUPP; +} + extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_async(struct page *page, struct wait_page_async *wait); From patchwork Fri May 22 20:23:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566151 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 B9D66912 for ; Fri, 22 May 2020 20:23:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D09120759 for ; Fri, 22 May 2020 20:23:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="Qy+W6tsC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731125AbgEVUXh (ORCPT ); Fri, 22 May 2020 16:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731113AbgEVUXd (ORCPT ); Fri, 22 May 2020 16:23:33 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE211C05BD43 for ; Fri, 22 May 2020 13:23:32 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id n15so5457425pjt.4 for ; Fri, 22 May 2020 13:23:32 -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=1VFf/UOKNgDVHZUKx45LznEg0u8N2FCy/awErcAtR0g=; b=Qy+W6tsCL3NH8Bq3rG6/UjcK93NBssdcv0jZGDBJKxqpc8Af5iRRlidXvE4LvcTbjQ VswLrbHzrKsuwOrz8VLGnv4GIz9ELw0+Ck61xKY0Cn/sicxCkPfwlPILus5BsdR4XbHd FivBuJiFW4rFu1pVMTyYm5FNYETtOu+OOK1rt/4nQryYpkvnhwXM0A8XWOflc3woQ/sR 5DVb+1ZIdrXK55MofhVLQcNwXyEsdQ/96R6uxVzL1zl1RP6pM7dRbw7qO6+uESrtdbTm TkK2TDXxpzbuWMaamdVVkjq2ku206Y+RpE6CKRjgQcmzRKlbx4iykHwOt3uPGN411ew9 Vgxw== 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=1VFf/UOKNgDVHZUKx45LznEg0u8N2FCy/awErcAtR0g=; b=gUwzLscT+7WwW2awNQD5+9MzwSWC8YoakLg+Fsm8RxrSpxDbmFJFm2lY2SH/SUiR8+ rEnTehMPlRcfGD0QDU+tJN000j+fsOaSZ/LrsWdcUdVJWod4sTNYWCZRQKHbfrBzlhsS ck+3B/D9Y33z/h/efgvUhOLHpoTx67Lm/PcxulciDDIwBLAXcefph9nKiYUqk2CG4wlb p6+Su2RSWoSR+aFa10q31jNcp8mr51tuFkA0a1raHucv81rB05TZltqpVNC4F8t7JRx4 XTFTgJrD8aIGs6NXr7mnFLntwqVwwMjZrMpkhi7rtHdH0ZgJLD7EeSsseCmQhn7tG2PY VN9w== X-Gm-Message-State: AOAM533etMmchW34NCs/SXlHBosgLKXn/+D7UzkUhV+OgGq+E2Hv8b6E Bv5dl/y+5w7za1T9xUS5NS5HYA== X-Google-Smtp-Source: ABdhPJyT3Ms2U6ScNVRxn8m3K+qYSXq6NTkzTCRzpeAAa7saFGGrDfVA2J0tFqYg01QCmFSbHYGH+w== X-Received: by 2002:a17:902:228:: with SMTP id 37mr16857591plc.105.1590179012288; Fri, 22 May 2020 13:23:32 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:e0db:da55:b0a4:601]) by smtp.gmail.com with ESMTPSA id e19sm7295561pfn.17.2020.05.22.13.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 13:23:31 -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 11/11] io_uring: support true async buffered reads, if file provides it Date: Fri, 22 May 2020 14:23:11 -0600 Message-Id: <20200522202311.10959-12-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200522202311.10959-1-axboe@kernel.dk> References: <20200522202311.10959-1-axboe@kernel.dk> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If the file is flagged with FMODE_BUF_RASYNC, then we don't have to punt the buffered read to an io-wq worker. Instead we can rely on page unlocking callbacks to support retry based async IO. This is a lot more efficient than doing async thread offload. The retry is done similarly to how we handle poll based retry. From the unlock callback, we simply queue the retry to a task_work based handler. Signed-off-by: Jens Axboe --- fs/io_uring.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index e95481c552ff..f0ca98bb688f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -498,6 +498,8 @@ struct io_async_rw { struct iovec *iov; ssize_t nr_segs; ssize_t size; + struct wait_page_async wait; + struct callback_head task_work; }; struct io_async_ctx { @@ -2568,6 +2570,101 @@ static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, return 0; } +static void io_async_buf_cancel(struct callback_head *cb) +{ + struct io_async_rw *rw; + struct io_ring_ctx *ctx; + struct io_kiocb *req; + + rw = container_of(cb, struct io_async_rw, task_work); + req = rw->wait.wait.private; + ctx = req->ctx; + + spin_lock_irq(&ctx->completion_lock); + io_cqring_fill_event(req, -ECANCELED); + io_commit_cqring(ctx); + spin_unlock_irq(&ctx->completion_lock); + + io_cqring_ev_posted(ctx); + req_set_fail_links(req); + io_double_put_req(req); +} + +static void io_async_buf_retry(struct callback_head *cb) +{ + struct io_async_rw *rw; + struct io_ring_ctx *ctx; + struct io_kiocb *req; + + rw = container_of(cb, struct io_async_rw, task_work); + req = rw->wait.wait.private; + ctx = req->ctx; + + __set_current_state(TASK_RUNNING); + mutex_lock(&ctx->uring_lock); + __io_queue_sqe(req, NULL); + mutex_unlock(&ctx->uring_lock); +} + +static int io_async_buf_func(struct wait_queue_entry *wait, unsigned mode, + int sync, void *arg) +{ + struct wait_page_async *wp; + struct io_kiocb *req = wait->private; + struct io_async_rw *rw = &req->io->rw; + struct wait_page_key *key = arg; + struct task_struct *tsk; + int ret; + + wp = container_of(wait, struct wait_page_async, wait); + if (wp->key.page != key->page) + return 0; + if (wp->key.bit_nr != key->bit_nr) + return 0; + if (test_bit(PG_locked, &key->page->flags)) + return -1; + + list_del_init(&wait->entry); + + init_task_work(&rw->task_work, io_async_buf_retry); + /* submit ref gets dropped, acquire a new one */ + refcount_inc(&req->refs); + tsk = req->task; + ret = task_work_add(tsk, &rw->task_work, true); + if (unlikely(ret)) { + /* queue just for cancelation */ + init_task_work(&rw->task_work, io_async_buf_cancel); + tsk = io_wq_get_task(req->ctx->io_wq); + task_work_add(tsk, &rw->task_work, true); + } + wake_up_process(tsk); + return 1; +} + +static bool io_rw_should_retry(struct io_kiocb *req) +{ + struct kiocb *kiocb = &req->rw.kiocb; + int ret; + + /* already tried, or we're doing O_DIRECT */ + if (kiocb->ki_flags & (IOCB_DIRECT | IOCB_WAITQ)) + return false; + /* + * just use poll if we can, and don't attempt if the fs doesn't + * support callback based unlocks + */ + if (file_can_poll(req->file) || !(req->file->f_mode & FMODE_BUF_RASYNC)) + return false; + + ret = kiocb_wait_page_async_init(kiocb, &req->io->rw.wait, + io_async_buf_func, req); + if (ret) + return false; + get_task_struct(current); + req->task = current; + return true; +} + static int io_read(struct io_kiocb *req, bool force_nonblock) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; @@ -2601,6 +2698,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock) if (!ret) { ssize_t ret2; +retry: if (req->file->f_op->read_iter) ret2 = call_read_iter(req->file, kiocb, &iter); else @@ -2619,6 +2717,9 @@ static int io_read(struct io_kiocb *req, bool force_nonblock) if (!(req->flags & REQ_F_NOWAIT) && !file_can_poll(req->file)) req->flags |= REQ_F_MUST_PUNT; + if (io_rw_should_retry(req)) + goto retry; + kiocb->ki_flags &= ~IOCB_WAITQ; return -EAGAIN; } }