From patchwork Sat May 23 01:50:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566521 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 8993390 for ; Sat, 23 May 2020 01:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71F722072C for ; Sat, 23 May 2020 01:51:59 +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="zbiGe0xN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387499AbgEWBvz (ORCPT ); Fri, 22 May 2020 21:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387453AbgEWBu7 (ORCPT ); Fri, 22 May 2020 21:50:59 -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 6FD21C061A0E for ; Fri, 22 May 2020 18:50:59 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id 5so5812722pjd.0 for ; Fri, 22 May 2020 18:50:59 -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=zbiGe0xN/5Eo+H2CF5xCbc37d8G9FUD+KwT1btc4sCr0MmxKKhWlYkpMFKsBDe+auM 9Lo6glgxT0TpCX3WRGG2vn4VE4AX+1pfCRCyrummCo1lCgDdqbkeBEk6ijx9JZHEJeU6 jRmvQq6kJzvuOmFc9w5apNTgM3Y6aWuEs/rQtJ0OKa8yDTfg0sKs6pnYpShqn12A0A9y J6Wc16rnzBpz+0lD/w43ca6v1fqIWEl8Vw2+W7mJDgRZMzxLokmiLxhG9yZLWNMkjrKX Hj5+zMmQhwgf39Gi5fHYe6g3ZGmPsA6EMMkh/9rZ+BCgVtl95AzUU9gmqRnnCNoVHzwK 88yQ== 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=J6gdSjOyFPfLaxTrw2ZmAzs5zPlpLssoXL1Y0Oc1qJ9R8JHJ4F/fSh+UymsL0jHBBZ 8wbEiIdCzdqkJwMqTL4Q2o+WgKalVMy9OO0iMGDK0p9KZjcSLSr8fNGy55Pc9FyNYArG 3CEeKwqDReeaApSCVxK8UrdPEV53/syXazAZ+pFfq3G8HwaoOvuRmg8whyJGgpVoy0+7 snF/t2g/ggRjB0l6OCbZlKvoelx1YicTl5HnESRDfToNEHmz9QhwC6jc6k9nGUChPbVN 8ATpITxn26TReb51FpjPaQ0pwlfT/PXRyKE6SjBv54IfgkEBYCNsSBUpN3rSYJWdILCL diTg== X-Gm-Message-State: AOAM531OYIhG7mq4O5lMNjm7CW80YsKPPGawK65Iv0JNsNwqRoyJ2I7/ V5x29/ZaGRmt8NMW5ATf9VmSvg== X-Google-Smtp-Source: ABdhPJwBmDXlE+x5QTHM8T9DaQOh7Fl5EgB2+dvXN52teuRxNlg4WmYuq4kTmwFYa3fjjpSWpHNLKQ== X-Received: by 2002:a17:90a:344c:: with SMTP id o70mr8104020pjb.23.1590198658974; Fri, 22 May 2020 18:50:58 -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.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:50:58 -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 19:50:39 -0600 Message-Id: <20200523015049.14808-2-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 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 Sat May 23 01:50:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566517 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 AF745913 for ; Sat, 23 May 2020 01:51:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96F1120756 for ; Sat, 23 May 2020 01:51:53 +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="kBqllv8u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387647AbgEWBvu (ORCPT ); Fri, 22 May 2020 21:51:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387538AbgEWBvB (ORCPT ); Fri, 22 May 2020 21:51:01 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC4B8C061A0E for ; Fri, 22 May 2020 18:51:00 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id w20so802744pga.6 for ; Fri, 22 May 2020 18:51:00 -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=kBqllv8uys4gT00yGgiunqjeponh5Nq8C8hpBlk3I4cc90Q/f4dSIrnyLUyS/Afz+r 0RJjV5F56+x6vupgwbgihJ4FmQ+NkFT9yuigJ6Nrmv3UBWv/0wNOHnYiCzYr1tDtGjo4 9QNHGjZJ73Y4XECmG7jLNdlmlEi4tPrvSdreIls5bnHJThbD/p6olZ03f+MUeQeVDE0I fOxDlTpgsFLX4TUxiHF9FjuRx6OsKHlg1Buy7Ts/XS6Ufe5If00TpoJC+Nr3HjuUQ2OT CVD6/VP0MSTt+JfzQ458ZhXnJAR2xxZGCO3gBrUjQrNTGpi1xfAoufFvveKQSv3Db8J8 hfag== 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=HtsjClzWwCUA7A+RKem62f7erbILsGJRneMEg+0QqWgBsgyU+hW/r+xB4OyoeWSyYX laDNBZAkCxm7JpNCABbCAEw85T3jSFzQlinRCEwHwUDlPhprpreMhH43PJPJyCsaIa2t EalfiO6RCK/Kk3HSHrbViUk2GQUsa21bh6eZUnWpVc9KfhJq378vzGbi+HSN1ecrzP6C ZFqwrSEiYFclEwMJKzYHvhQ7fXqP+Txk60sbAuTSGpPg3BhlzHGufTq/XO/BYbmfVfHu 6nGaAmGbHAC516iLaIX5avD73w81VPDi4fo6kZKw00lnELR3TVAoAioFRXKu8aIVJw6J JM/g== X-Gm-Message-State: AOAM5318wPM8ngwUdC5XRXzbIS7cNYLb4wmJIZUHKDRA1HEqB1pxXtZJ 7h12rXC/9hbin+Dgj34Ozozb5rsw/4Q= X-Google-Smtp-Source: ABdhPJwELIq6E78ugR6AHpeggJ/RDId6psVvcflU5HJfCYBxWSeXZtdKisZBE0iaGFRnuziLQ5YBKA== X-Received: by 2002:a62:754f:: with SMTP id q76mr6783393pfc.14.1590198660209; Fri, 22 May 2020 18:51:00 -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.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:50:59 -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 19:50:40 -0600 Message-Id: <20200523015049.14808-3-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 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 Sat May 23 01:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566519 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 E9F12913 for ; Sat, 23 May 2020 01:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D17982072C for ; Sat, 23 May 2020 01:51:54 +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="1BEPA92f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387644AbgEWBvu (ORCPT ); Fri, 22 May 2020 21:51:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387537AbgEWBvB (ORCPT ); Fri, 22 May 2020 21:51:01 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3AFBC08C5C0 for ; Fri, 22 May 2020 18:51:01 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id p30so5806131pgl.11 for ; Fri, 22 May 2020 18:51:01 -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=NV7E3PVOJV+DrSVqvM0fq14D8mCjxQwXXmJVa/Gbb/M=; b=1BEPA92fmudyakxYMuwGsAvSGUef6CrxjH6Bj+rHr3hQcssDmsjZAxSXEVeNVW9Fty PWUD3QdpmKM5iq0HszoeTfCMA01j05FWDCTJT+ql9n1VlCQnHzNc7Q6nQ/xQMa5CgxA8 mLv9i7KCHFCMyHnP8zgt66OnVYNBM1bbbWcJE1a6sciQhVGnb+1bBlJVuo3ShpMWDDhg z4zjxYZHveqzePLvtpxYt1Dj5N86tvWAwk+TazmMENq06Oglw+kgGhErg95vm+UQlG6I GYRk0xuLoOgcAaXEaWbnkZXRAwHsMDP/0Qe86Y2fHE4GApP4c/yBIfM/NLTY5rx+tiCz 9tvw== 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=NV7E3PVOJV+DrSVqvM0fq14D8mCjxQwXXmJVa/Gbb/M=; b=FZnqHdP0/fN4yqV5eC600Qkr+CxJk5ckXP/asbOHtVc2q/mNK8ncZmX8o3rh7DH0Ln xizzrtqSZLmd6oflaM28Tulz2qKCEomVVxezPLY+MVZcsvYFciBhJAF+3yhaAsR/tGAc RrOyICyAerntbeUuUeZqkXDOkJWrprNxK/Sb+sxRn1nz4ON9IarzZ9yfKFT+8ZRRcH0h 5ZCF3Mf3ldLiPHMZhX2U6L6ppRb9/efoPNr5VkSRK/GDzzyEoX5CFk2f/WopR88W9B2t Df4yE8Mv139hY7h8Zktn71BmWhMud7pMN9Ki6M7goEdjIQ7tI1rkA2gOhxJx4mqOier6 7xIA== X-Gm-Message-State: AOAM531P3QqXVmiuIVKN/pBLa/qiJeQHCblHewQR2P8Yry4/kAerxpGz ctnmUqx0BPodEObsNcHBA05txw== X-Google-Smtp-Source: ABdhPJy3zSBLoF6AYULdnKhsv41lX8Bgq50w4QoyGby7dLFXVxT8537akfk9NdlKdcMZ176gJtXwvQ== X-Received: by 2002:a63:7d4e:: with SMTP id m14mr16808897pgn.391.1590198661379; Fri, 22 May 2020 18:51:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:00 -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 19:50:41 -0600 Message-Id: <20200523015049.14808-4-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 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 | 21 ++++++++++++++++ mm/filemap.c | 56 +++++++++++++++++++++++++++++++++++------ 3 files changed, 72 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..e260bcd071e4 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,14 @@ 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) +{ + if (!trylock_page(page)) + return __lock_page_async(page, wait); + return 0; +} + /* * 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..a01daafd49fd 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,50 @@ 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, bool set) +{ + 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 (set) + ret = !trylock_page(page); + else + ret = PageLocked(page); + if (ret) { + __add_wait_queue_entry_tail(q, &wait->wait); + SetPageWaiters(page); + if (set) + ret = !trylock_page(page); + else + ret = PageLocked(page); + /* + * If we were succesful now, we know we're still on the + * waitqueue as we're still under the lock. This means it's + * safe to remove and return success, we know the callback + * isn't going to trigger. + */ + if (!ret) + __remove_wait_queue(q, &wait->wait); + else + ret = -EIOCBQUEUED; + } + spin_unlock_irq(&q->lock); + return ret; +} + +static int wait_on_page_locked_async(struct page *page, + struct wait_page_async *wait) +{ + if (!PageLocked(page)) + return 0; + return __wait_on_page_locked_async(compound_head(page), wait, false); +} + /** * put_and_wait_on_page_locked - Drop a reference and wait for it to be unlocked * @page: The page to wait for. @@ -1372,6 +1409,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, true); +} + /* * Return values: * 1 - page is locked; mmap_sem is still held. 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: 11566511 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 74F5D913 for ; Sat, 23 May 2020 01:51:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DAAD2074B for ; Sat, 23 May 2020 01:51:31 +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="z7HrSHy4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387561AbgEWBvH (ORCPT ); Fri, 22 May 2020 21:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387547AbgEWBvD (ORCPT ); Fri, 22 May 2020 21:51:03 -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 03834C08C5C3 for ; Fri, 22 May 2020 18:51:03 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id u22so5100722plq.12 for ; Fri, 22 May 2020 18:51:02 -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=sB2DTKuhYjvKpP86PLgGLFvrb6TM0MkIIAWlFPN/Mh+YRKqYYYyZ7M+dZPae7yUac4 wadxXuCoAtHSd58jHpOYJIka0faphbfegdjMqc+qMBCJRlIsT4pySd66hOebxP05F/8O KXBRHXv1y64XMx8jxjQtXTySqhjNO2HGLgltATqOnAqi/d23FLH5kqXzxn51edsheAFc PZUgSj/Kwa0gq+kY2OCUJxv0W2fRDRm2Tnza4LxNzgsieWV2GJL1PScQAfp+LrdNk6z5 CEhe5XqFj5BMkeMCfTbNeeovvkG91DyfOXCYkPVNTelLxPoah+/Hpr5qafoCS7yuPjLB MUuQ== X-Gm-Message-State: AOAM533+DuPv9vQYscT8iiZ5lr0DjE+lMsNlb9XywPtZQLQFJFlPTguy KtnF9GbZ/2mU8VaYv0tCK+kPpQ== 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 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 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; From patchwork Sat May 23 01:50:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566515 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 1BB0990 for ; Sat, 23 May 2020 01:51:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0207E20756 for ; Sat, 23 May 2020 01:51: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="HnYcrZsd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387551AbgEWBvr (ORCPT ); Fri, 22 May 2020 21:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387485AbgEWBvF (ORCPT ); Fri, 22 May 2020 21:51:05 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F23AC08C5C0 for ; Fri, 22 May 2020 18:51:04 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id n11so5811645pgl.9 for ; Fri, 22 May 2020 18:51:04 -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=HnYcrZsdOxNRPX01BAnp52Y7QAzXP3CsE9SKw6fM2ImM1eIgaLTppeiQWVnE4+11m3 OejnkqB4kn5KbmRxULadm7opO6Kb+xsQiehV88PQ/0Zt5ygcKMubjp3qUbnsmu8xw1dO tUNho/mPqi5E13I6F+oLG00gGtZLIc3imnV22yFOYC9TXgLmfk5T2dygoCfZ7JOJGVAv KlhOHI1SnxOsFUv768fRTyN/geFG4DgbMjHnx9M9CqPJYXXVONngEu0cBOr13pfQx7vS rJQvZvesC+TDpqUL8Xn8iJylJnj4S66DggYzHPxNJvyUc4XmLS+1qrQd1F9klkosbR5/ JpMQ== 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=Nh2zXJCQuOymglf37pjvnKmlVYJqgsfKQqlEl5U9W6wYl4uBtdasEEY31r28q8qeL5 i9sRYYg9Ou31E9Cjp7xiQkwKyLrQEJTxgvMq93omFpnD24Cvn66VxE+JATxiZeSMlm2c +E20yKJDSU4J8isFr0N43S393ZiGCyEbSV9Du7haRnv8pye/T9A1uP7DT9Dnnlgy1vqr fdky2umoMkOBy8ASqz0ADKM4wozdvLFSbZ35aEXUfj5vLhe5CMIcjwwi4pZkG/f/mOBn 9Ug0xwpqRgQm/SlKs2leUmT7rwVooPVNceVv2Xn75sKOVxMupL4jHwtjKB5DtbgOtbsC lCOg== X-Gm-Message-State: AOAM531Ro9+mMgend9eyUgeUDEGNp0WzIAkStc6RL0RMDxPmYFYB1iqm fRvAxbIE+FqkLS8OQfjxPnjh4g== X-Google-Smtp-Source: ABdhPJwDt7vAik+XV1ClU0sHBzKsLdX3gET9tONikOf+AYZa2mXQmQJNwaXlM2gsfrr+iZBKtp8bmw== X-Received: by 2002:aa7:855a:: with SMTP id y26mr6530839pfn.281.1590198663998; Fri, 22 May 2020 18:51:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:03 -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 19:50:43 -0600 Message-Id: <20200523015049.14808-6-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 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 Sat May 23 01:50:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566513 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 74688913 for ; Sat, 23 May 2020 01:51:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C2302072C for ; Sat, 23 May 2020 01:51:44 +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="viOUEJ1f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387633AbgEWBvn (ORCPT ); Fri, 22 May 2020 21:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387555AbgEWBvF (ORCPT ); Fri, 22 May 2020 21:51:05 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E2FC08C5C3 for ; Fri, 22 May 2020 18:51:05 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id q8so6009451pfu.5 for ; Fri, 22 May 2020 18:51:05 -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=viOUEJ1fR6EBYLV+aGk4n4pPCzVmSS3wNBos+myVsG9d41L0VNwWkGpSJmOhx3K9++ f9KJqmYPc52aQNDh7YBCfGeiMDtYKLgYg3KJ8Tinr03i/xE1uwVTqvhDcqDMbeFtl0ry /Fbrftn8RXZ8jfaKQjlRMnDxcx7ZUeBqLwxIInOHFnGah2gnFiWL+aSKx/Vus5jvhAvb OUE0VGbgSSqfdsPWnexlxMY+WF6b/eVXTi5o6mZVwVvwHDPL5zY9JJY/lOfTSooU5zq/ 3vaOAuGthCRFAY6UAqlOO3/p3MtxKBubwxgq6lOmlbcoZuFWfQBxZer5UAP630v53ff+ KF4w== 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=PGVReAu81ZfHWJZeML+HgW/K1Vp+rjGBbw4tui4iURvFX8pJ6z1yNv+63NTQjvXOBV Lvi2ktSJlZBs3vK+gfikh+RKhvt5MbkLr4HWDHbwf3TbG5dVL/7HadSY7O6053oosDqz pMzGZgAMNEjxshlN1MCyaADIKKNmSzYLNUtvqYR7uF2qG8jClYz01OcrujwKTfVRd/bw s9czw12U2xMUJ88ZkpB3ViT70lXqGC/HkOA+GRXuoco+SuBhioB5ak71UNqx5aQ7Bxyu nSsudYLlq2fIyEvFPV1efYa81Z1QqoQQ4BJwPYCEa6MJeSjX3m2baix8tEwRM63S1e// o1eA== X-Gm-Message-State: AOAM531ZwsTD8Cjvpg1onsqN1dZYa6kV1VCvWrRYtGWwQb1IKw6+OjUh UzBOenK6jXFJsQFrBslhiIWDHA== X-Google-Smtp-Source: ABdhPJxMDUN9GWGHzw/t3Lk7jZslvDAozX8xG9m2W1wpHYgfAm8cjUlGT/CMaOFe5dKd6Q6mLPzZ2A== X-Received: by 2002:a65:6094:: with SMTP id t20mr16806792pgu.220.1590198665111; Fri, 22 May 2020 18:51:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:04 -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 19:50:44 -0600 Message-Id: <20200523015049.14808-7-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 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 Sat May 23 01:50:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566487 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 4F8D5913 for ; Sat, 23 May 2020 01:51:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 375E820735 for ; Sat, 23 May 2020 01:51:10 +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="HWiIpVJ0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387572AbgEWBvJ (ORCPT ); Fri, 22 May 2020 21:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387566AbgEWBvI (ORCPT ); Fri, 22 May 2020 21:51:08 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC879C061A0E for ; Fri, 22 May 2020 18:51:06 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id z26so5992442pfk.12 for ; Fri, 22 May 2020 18:51:06 -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=HWiIpVJ0rbiIpbanC9FRw7TVz9oZwP0rp5HJBm3PBdMNA69cgUdOvPeGShjJ95mpwz eM3w0I76JQXY6eewhOI6WGMug0mdjEcjo1159u1LrEDJkGVG2c94kRuWmswELgKMf5X2 HSf3k1SDRGGiSfTt+N/7tUoMThp1Dh0szve7+DHCYl9OdA79R2zMf9RSfB2anFohfIAA uuIRNXjlGgGyAwDzXd0CBBDB3o6dSCZ5jSPkxxeardFObAFgRY35MpQHQmQem7PeBQ+A KAeQ3zurCwciU4RzhLE152QNK/Smu2h0cJ2hGTx2DLdnbM2FdWkGXcxhK+r1MLs96NR7 jFMQ== 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=InGzXgArqgqPOAND7XvK29Ltpn45Y0elLQd/FqAZHMLQUi211KhlYTGTBhQF+98c0m cEA1eybw8qlDhrSVREs4wUJ8tlLijLaEKHMX0G34SJc6DEKNqbViHbCz52pCY78S7FP+ w1lYJHX7beCHTA4UzGZbUWl5IQ33JwBWXjnVXon20LK9BjzJdW4M7nAqbBRST2UDCzWP VtW5fiVWKU8YNAYB9+urPHyeGQNIU0tHdnkmDl02802UoUSq4iw0qMDfB4zW1NJfgnJN mWFqog5O2iQLzaztHMqzbGjWG0HapCIjNHXi6uSPgyYJRoB0hvRaynFBQwbpwq3K0THO mqPQ== X-Gm-Message-State: AOAM530IjeE6hKn02p/1R6BjgyBMG/7NQFTRt++y3HBTdJqo0idnSibw of/dZ8IjvVSWfP8xksO9izSd0A== X-Google-Smtp-Source: ABdhPJxGTsRVBy9xHpjhWrY0KMo+JW0XIbljpozkhKZ4qE+E/pFMPYZvl4ItatMrGzf9Se9U7xUQFw== X-Received: by 2002:a62:1c93:: with SMTP id c141mr6669567pfc.289.1590198666267; Fri, 22 May 2020 18:51:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:05 -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 19:50:45 -0600 Message-Id: <20200523015049.14808-8-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 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 Sat May 23 01:50:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566491 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 9D8D4159A for ; Sat, 23 May 2020 01:51:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75D5E20735 for ; Sat, 23 May 2020 01:51:11 +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="Kc3axrOr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387578AbgEWBvK (ORCPT ); Fri, 22 May 2020 21:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387568AbgEWBvI (ORCPT ); Fri, 22 May 2020 21:51:08 -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 D3071C05BD43 for ; Fri, 22 May 2020 18:51:07 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id f15so5124706plr.3 for ; Fri, 22 May 2020 18:51:07 -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=Kc3axrOr8g6RyUGzN4WwNP4r3OGAumLf5kpA+8EMTGVWnYe4InoSbthNtLq1X9D5rL y/70lT4NweSq/L9I+SQszizll3X1bhdvfgWCfGCUgfqEiYqwq4KOs5PPlO2zrn7ySz3n p6/slYwB2tCt8M5c0gMvijxmOFPa8UOS6s3JIFa6bts5pYqoZE0PkZWFtnfOpUSaNiw0 lZz0Z88hp5u2jk5VRbbMuYl4y2jMfKWR9ssIP6RwMcYOtYgcvFgP6xNUwen9hzMo+Rg8 MYZ9w5zMVgDRFYxQWw7WKYyDNB5XrSk4xd2d7bzTVnY7wfZsZxBdWjhHGlXlSbQh4kFd 2F5w== 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=KBzXE7xvGpn4yfgLMisZQC4k64mg01Hs4HU6VhaCwa48z57mEbY9E64Wf4DJoh0f24 JNQldhvuIdvjwrW7pEnWZ7VcDxkVYCcErWjp/iiqMScqL9gSEkq306iHBcCslNhk2/sE OLYT/StdKPSu1ewcADJSfoKAE0CPlzBbSvueaV+zHoYiLqp3iOt63vofTqLCHYIRl0Lw JXNpwArVr4BenyQVANWE5qKchIfSZhZhT86zpXNA696MT/Az/Bx7IjhYEJaaAL+HCzzg lYOcGbyrmTWeVjBvRg/ZRDHXoGgZfZPAwAl3YdThDrvPfrpqfTf58jTIu2NUP9WCJtD/ L+2A== X-Gm-Message-State: AOAM531yp3b7OwJ47Q1nnMqLcZ/ttFT6W80YHtq11qFxWS4DnfGhIbbp ObE1XgfTh1Nfclj8LMNvI9cV7w== X-Google-Smtp-Source: ABdhPJxcS/HRQUwxMhKYNzvxtXy9z9SbHgXgGovyXvDbUCjxMMj2BnFCWsV8TcdQI7La9/Hb3uSngg== X-Received: by 2002:a17:90a:aa8f:: with SMTP id l15mr2047286pjq.156.1590198667421; Fri, 22 May 2020 18:51:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:06 -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 19:50:46 -0600 Message-Id: <20200523015049.14808-9-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 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 Sat May 23 01:50:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566509 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 2B2A6913 for ; Sat, 23 May 2020 01:51:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A86E2074B for ; Sat, 23 May 2020 01:51:25 +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="xN8NwRmS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387576AbgEWBvX (ORCPT ); Fri, 22 May 2020 21:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387438AbgEWBvK (ORCPT ); Fri, 22 May 2020 21:51:10 -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 1B326C08C5C1 for ; Fri, 22 May 2020 18:51:09 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id u22so5100774plq.12 for ; Fri, 22 May 2020 18:51:09 -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=xN8NwRmSZj3KWZhRv/KRaMZungdyWud1fPfvxX91TBDAas0f3RGQJhtwUc9bsOpYD+ qehVzky+nxxds1s08uTpi6wNc8TSmWi+wAH1qS+2cwAlKmSLByajIDk3fKTDP07EBCv1 ByzrBhkqH7Fi15hf+Xcef1drhJrC86fxHQy4O1XwSsOy6g6ZItp3jK4wbh6fQqdEYK1E +2XGqQXuLkliIC+pIUdmCRrWM3FS8yGjyJyGlVxU6myazzPESWv3XhG9efZtbIdTM8DE 5Ve0zocw4u7wy39QwnyOZCoAfBY3yGuJ3lJHjSGqujeS9/y7N0Ws1hVjzPIG1hmM41Gb 3hgg== 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=XwhA+x+JoT4inGJkCVFPfaChWxYm2GwAX58XrwIaNkTaXJM0Fnsfagoc/H/XTt7xqY BSPx5a06RWBKO7cjDB37MIZgp7L1dBvf7+yD01AoTrrB7h6sYF2INBIMMY6HHsygmvkI V+ArpvhVj8C5UPWZXcCU7bZWeOKPVa3mYPrdyL1KmNcp5b8/vpftVzemREKJ0ArVjyXb 127Ux36tR/KAB8r6tFSJQAkElkcdAs5/M3svCvBuvNC2JvhGdEiPQbSlHfu23YF/NljT iAh5KSkNyUdRpc6RP5QRpIiwuRO1ed9/N7DUPvdRaYwNwwTbsLwkrhwX1HUjPGAPw9GU irjg== X-Gm-Message-State: AOAM531zf74a8w+55Nk9N6vkWhKy5f6gYgCjMRIHkhK6z88p31MFBtB3 kl55iA0xqLO/JJuFauRHB9aVPg== X-Google-Smtp-Source: ABdhPJztwQahKJhtCBJUZvWAeijHNskrzA5ff8ZARDi37j/dWUEIIWlaDM7fyqURSemcqutfVlZDKg== X-Received: by 2002:a17:90a:db0f:: with SMTP id g15mr8098085pjv.8.1590198668620; Fri, 22 May 2020 18:51:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:08 -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 19:50:47 -0600 Message-Id: <20200523015049.14808-10-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 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 Sat May 23 01:50:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566505 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 7A559913 for ; Sat, 23 May 2020 01:51:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6392620814 for ; Sat, 23 May 2020 01:51:23 +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="ETmKby8p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387568AbgEWBvW (ORCPT ); Fri, 22 May 2020 21:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387576AbgEWBvK (ORCPT ); Fri, 22 May 2020 21:51:10 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54F7FC05BD43 for ; Fri, 22 May 2020 18:51:10 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id v63so5999249pfb.10 for ; Fri, 22 May 2020 18:51:10 -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=JH4qffDw1bR16LSZOmXHQ8vTjhgFWUTnPL/hN0raEaw=; b=ETmKby8pAAIxY9U6WKn9CNosQ44mYgxTdTEtopdfdIDXO+NjGX+ifvqGeQRY+HJLIA zY/uuUSY7ifcyny8cCud0KJJtWED2SwscDrPgSbt9iDpo6l5rWhZ/iWY3YeImMCN8iMw L/7j62wezVNEzhqDM3bI8PBpBnkH7SjhNbw41sQr28LB9x44BGLyFn6rdBNi9M1yaRJJ XZU/iC4PhJhfemfcMMM8/912GLbEFK+hudvmr0EFF29TKybjESBwie4GPrS5paBlNGpI +3XhOzxy9MSMPaP2RNYzlt8xEZiiLsPjce+rDPBpL7L7WQNe5ic1esa1XcBzqGkfkR/u tRNA== 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=JH4qffDw1bR16LSZOmXHQ8vTjhgFWUTnPL/hN0raEaw=; b=aLWRaiRaaEv6BTAnLAEElPMskgZwKvnU9fYPHaj8BBAc4T6G2s0NEEbxG0TttCg4N0 tSpJUiwXIhzD41zazwLOb0AeLIejWXJVeFx3pbO8n7n91l2n3+LRN215tkBnOox9s+5F oUjt+S+Ku1JHYalEee5oTrhRabKmMYVfTp3S4S6dVOIOGgt4DV/oM9S6VUv0DqTlHZJ1 Yh6y41tmAo7YV6waf0CB65EXsWQIUa7frlytd66e7VXrTO2Sew0RG9N4G+4vKocMnxlC Q1sSLQrfeMm8YugvuLTsYrbwB+wl4Qr9aa3FaEQEiDWiQ3rY+sBQW+A4V7zycAV2l+Rv KIFg== X-Gm-Message-State: AOAM530LDEZjXUxeDN6AgrCWiHQCNowWsmCd/coyLW8/nKSbbL9qy/VD IFCrqDaNK4COc9C5DB0FihhMUQxZ+og= X-Google-Smtp-Source: ABdhPJz0nFKgn1N3JiIfLboWuIb5grjg380HgPkl+kUx5EXcYlCR6fXRG759tLrdb0IJ28scGhXSoQ== X-Received: by 2002:a62:641:: with SMTP id 62mr6411983pfg.283.1590198669882; Fri, 22 May 2020 18:51:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:09 -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 19:50:48 -0600 Message-Id: <20200523015049.14808-11-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 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 e260bcd071e4..21ced353310a 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 Sat May 23 01:50:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566503 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 0239290 for ; Sat, 23 May 2020 01:51:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D85852072C for ; Sat, 23 May 2020 01:51:21 +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="cuiALyzq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387589AbgEWBvO (ORCPT ); Fri, 22 May 2020 21:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387505AbgEWBvL (ORCPT ); Fri, 22 May 2020 21:51:11 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B863C08C5C3 for ; Fri, 22 May 2020 18:51:11 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id n18so6011498pfa.2 for ; Fri, 22 May 2020 18:51:11 -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=Wd+Rnx5Y+ukW2PvArxihC3mXgVqc6YPFp4BCl1P9bmM=; b=cuiALyzqy5LdaGkggEMKMw8ZCbPYkVsgaGoYkowUv2YSqau1sCJea1+tn9y+FD2jE0 hqs9giU8Mi3LAGZ7Yy4V2tu22HzwH3W81J8+fBe9bvb1GODyDanjB735pb1vgFfx19+c vSLpeyOjo6AaiBKXXUUUCBj5yRXMrOhX4sjADgLdrD6qQfN2X3QnC6PsVLemka9yqxy2 LDVcNP7vH1c4WJIP5GG2T5p+I+bqIcwJAREQ8SkTyyjweJ4KWTvpGe1TR5xjJXMA3Ww4 5K73NgWM8zvy5ZCFXxxXE4JdmpfIlctPbay9J6SCA/1iaFUvCpYuDLZeLP+qDI2bVj7S 4CWg== 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=Wd+Rnx5Y+ukW2PvArxihC3mXgVqc6YPFp4BCl1P9bmM=; b=ntINuODPc6Z3EpqiPWnTLj27sU8rvwMTGk713YOy3GhEnFdWCRJUNfL3adUaLzp9Gj Qy7+8QZOLZw/oQnQuiU6uAfNynumcAYqMDtpjyiLP3dO9Gwxz28MAMbzEH7O4ggDulSO ejAQ7GsdJ1yZj1A7EdOBp6DeCphp+iMGHEIl3wwN0Wvim2YZL5qXmQFW7cC8+ebjBS+N w+RgI9QDDyB5o/c/nNX79kyoFWCDOnxfQ/GdjYvNNZkl9DU+OMwjgcaPJTDe51oO2dw+ OM5pEnTcHxMDwVTYOoNkrG1C+4zr6QY2j4lNVg/zX2Lud43OVRsHUW47V22JhFwHhtLi XIkg== X-Gm-Message-State: AOAM531H+AAU7Bjv7T4xkOOBcI6xUPLFkE0SLK7JnzdoYKfhuxS+kj/D pbGgH4+x5yvcFBq/y7ADcDz37g== X-Google-Smtp-Source: ABdhPJyd+1pCYzGsi2Ok0s0JF7kIgQclUmTGxfhARdgyfgJsfSNYz06K7py8/X/MIRJH7+fbjmCzaw== X-Received: by 2002:aa7:9096:: with SMTP id i22mr6644986pfa.250.1590198671034; Fri, 22 May 2020 18:51:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 18:51:10 -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 19:50:49 -0600 Message-Id: <20200523015049.14808-12-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 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 | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index e95481c552ff..9eeae10db648 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,102 @@ 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; + key->page_match = 1; + 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 +2699,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 +2718,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; } }