From patchwork Tue May 26 19:51:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571187 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 4367F913 for ; Tue, 26 May 2020 19:52:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BB22208C3 for ; Tue, 26 May 2020 19:52:36 +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="OuGZsDad" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390187AbgEZTwf (ORCPT ); Tue, 26 May 2020 15:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390092AbgEZTv3 (ORCPT ); Tue, 26 May 2020 15:51:29 -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 086A5C03E979 for ; Tue, 26 May 2020 12:51:28 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a5so262158pjh.2 for ; Tue, 26 May 2020 12:51: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=DT9kV8IQxC/D+uhFJsefv+iJT3TxYB4ReZ7s4ZFOil0=; b=OuGZsDadMk0ouSxBbagElzrDsOFsdbddmk5eH65ga2Wxc3HZgfLVLJcFyhEw8usAcZ HTB+HylhbVE98IfGgUAnUH7V2yMwJESFU4207FlXryYh0fm8menLFq7jByDucoN4/oPf rJyxXSFaoAe7D9VKjzoCoCQGXgjxaau5MP+A01WQYIW/16fxIm7sCIPAjYEsvtXGsM60 0/ikp/pt7voJ76qWQsjOrJT4Xr0rTeQIodW8eo5MyOLN0+AY4TmYJZDl/Sm0O9y1vtWI bc7fhd+puE49SaeiR2JWPdxtuJM7gyKt8uZOc2YIZRlech7S/BIEWD8kxVapjAUHpLtp dpXw== 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=qinK5XpgYU5cf5nDRWsq95VP7pyxGG4LRsg1o48yzM4U0Pf+1TRw8knZuWoloP3n6e oP8GR9ClSVaHWkHdl04eVQPhAZ9JBzZdlvPnNWVALhveRs/nRGRtBLQtZj9uBQZMEERG CVUSxbQWflrpV/1BKunwJ+iVagAZ+gUabNlIH2Yz0qs40iq0MeBykHm1Jmr5JDJjtMtO iUnucgMOLH3Ra4zAvhkRciYWQeCAhWImwUiAJY3n2G1zu6a8dXuNUU9J8tbQEz1wIYus KpyiiJ3u6ZKxxySqKDVoujH7HYqBogI+++bb6dsYX0/+7N1QtBRS1I2iyLY1sWD4RYUW lwOA== X-Gm-Message-State: AOAM532dA0f3YdlexsOJJIRDMM6qLhDvsY07EjSvceUlnvuK9emXOxDV 3wjNACeGydwLzDOx2DDLogTZvQ== X-Google-Smtp-Source: ABdhPJz8Ax0r8XMmPGcDuG+vpoiMfRCzG//xGTpSe/ZiXq6nh5Ywfeb0pH34jS4EKxW64rcgwO66Uw== X-Received: by 2002:a17:90a:2a8e:: with SMTP id j14mr894757pjd.136.1590522687551; Tue, 26 May 2020 12:51:27 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51: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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 01/12] block: read-ahead submission should imply no-wait as well Date: Tue, 26 May 2020 13:51:12 -0600 Message-Id: <20200526195123.29053-2-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Tue May 26 19:51:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571141 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 67056913 for ; Tue, 26 May 2020 19:51:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E782208E4 for ; Tue, 26 May 2020 19: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="EEzkohF3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390169AbgEZTva (ORCPT ); Tue, 26 May 2020 15:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389952AbgEZTv3 (ORCPT ); Tue, 26 May 2020 15:51:29 -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 3FEFDC03E96D for ; Tue, 26 May 2020 12:51:29 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m7so9121302plt.5 for ; Tue, 26 May 2020 12:51:29 -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=EEzkohF3SUyIeVc607D1E79iz7OYkD/uy0I4GSnchfP+t2/8/jBtqFox0ipMXW7gmS ofFyzP3GFe0yYbASDLZaxrNNYrAZioS6+qyZzi3BNWoxV7sx7HqmGaPk0jbEdJvgnKeB LS9UwziDdS5h+5MFwXcOepQDNcjfOPRuuNqKL+56cp6TcQw3V1rzfELuJiMDiQxFYBUv vodgm8HTVNcfKt1cQ9mCuLi6iS5R/Q8g3QwtsGY6bO7P1eejUGE4Bg2SUpBDQd14zfM1 K3pATJ3oH3ooIkQY7kB2SG6VI0b8+IfGy1HVnsFn7Li+LHrtGMCLBa+H3phkx45yiFvC NeTQ== 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=UqAp7DuxLWdpMIKKI6nR4maS3bQRtBVEOQUB/XAWjLt637/TNhmBjMeG1izBl5Lr7s 5B44p1VqxaKj6iGkSfT9tKZ7U1imF232dm87k2XlfoNm/gZoVaykWeD4g+ZeManIa/jd 7F7IVa0EgPSyBVtDGoEApuMXVnPAbdM6u7TUwCWBtcvvp1pWqBkV6FmUmJLRFVm2X6Yr uFQ7w8I6j1w3YyYt0/B5X81QajVEVAcAlk3sZEvNmfjTb0Gr8ewWOkB0m/iSXzOmSPKe 54h2isvX+oqnk3Lkv+pgGODAtWZO/RkkNmsQ/in5bJ6DFXktbpVp5TXpSVwPf9bxdVjS 6a9g== X-Gm-Message-State: AOAM530b0x1X1XqI2vHrKyvVGEbU1X31PiMHlYKL/OLtxqDGZ3Jdx6CV aI0yxZUI1kBecVkBV3mDdwLzNg== X-Google-Smtp-Source: ABdhPJzlKhcLATAMmx3CWvH61LMiVxHHoRlGG4C3q4JS7w38d9LDkh0jn/mRK3Wz+nSKoQ/Hn6XBsQ== X-Received: by 2002:a17:90a:1b25:: with SMTP id q34mr920742pjq.12.1590522688801; Tue, 26 May 2020 12:51:28 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:28 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 02/12] mm: allow read-ahead with IOCB_NOWAIT set Date: Tue, 26 May 2020 13:51:13 -0600 Message-Id: <20200526195123.29053-3-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Acked-by: Johannes Weiner --- 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 Tue May 26 19:51:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571185 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 979F9913 for ; Tue, 26 May 2020 19:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80AEF208DB for ; Tue, 26 May 2020 19:52:30 +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="YKbLOw6L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390491AbgEZTw2 (ORCPT ); Tue, 26 May 2020 15:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390240AbgEZTvb (ORCPT ); Tue, 26 May 2020 15:51:31 -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 AFD76C03E96D for ; Tue, 26 May 2020 12:51:30 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id k22so9111866pls.10 for ; Tue, 26 May 2020 12:51: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=fQihCl0dLbHaElgiRrlXkibi9/E8OKsaJ7lF0uUyO/s=; b=YKbLOw6LpYloCfEz6cSjXDp7lo/SEH14850NuBSfnHJZqbSNda9ft1KrD9kDTlgX29 i5p9OTzKmGtxOrMHS+JBQto/yzM9zXGeRvk09gakJOY0/1BHuWAqj05obqvWTcQqZXjM tSs3FQLGux7Ieod96lB3tb6zv/Ei+e+rH+jvFEsgFfzk6f2Q6xviMQedqciMUxeS5bww YudmGt61FcA28hKFe3zbgPJZzUu27iwTT39ESm3iUzvAQWSmULv85wglM46pdLh9xw2G 2vQ4GSnPWkUwbN9Hsml5BFWibSXp84PL/jR8cl2CQ0mI7mUEGk1xtvkYObM/1b+lAY5j 3Wiw== 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=fQihCl0dLbHaElgiRrlXkibi9/E8OKsaJ7lF0uUyO/s=; b=BmIhMFSRt9k3gQ6D+8neLcWVqxe78pFEyv/9M/yGmpTXFpwwEIQUoHxN7ZtvVW4Jkm LBez7nMQpPDcsGZzuTMr6L2g9DErZdos6RizHgi4V/Bnjh1Lg3H2VH4KLbYPZoIMC9Br efkTjYV7w69Dumxrd+0IBy1gfGbAqVsDabhdrOCu+KTQvgJ6B1R68/iqUfWiIBE/XFLX uVmdw4UJ4I34V+Av3xhI2Z8XvNXm3ahZ5KoeD0GOx8d0rUgj55tezlkzteqgHek5EvXa w/XDAjP3pI1Fn/3Kx2WkhSt0D4cOy2U+E5C+Zy+b7WmVXeGc81PHv2boNIiXdOYZeVui jgFg== X-Gm-Message-State: AOAM533i6blyr4T+PE3Syg0+/U2+azjHAAtrbGeZRiLiYpdXAIHHdrZx tc7/i2HgQ+WKUe8qyXoMupk/Tg== X-Google-Smtp-Source: ABdhPJyeEiZx5SIpedWyfYllR0duff8tGiFVV6KjQ7XygtXqKPG6eKYMQBb6I07aOaSUrZejp48HpQ== X-Received: by 2002:a17:90a:f283:: with SMTP id fs3mr874913pjb.1.1590522690209; Tue, 26 May 2020 12:51:30 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51: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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 03/12] mm: abstract out wake_page_match() from wake_page_function() Date: Tue, 26 May 2020 13:51:14 -0600 Message-Id: <20200526195123.29053-4-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 No functional changes in this patch, just in preparation for allowing more callers. Signed-off-by: Jens Axboe Acked-by: Johannes Weiner --- include/linux/pagemap.h | 37 +++++++++++++++++++++++++++++++++++++ mm/filemap.c | 35 ++++------------------------------- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index a8f7bd8ea1c6..53d980f2208d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -456,6 +456,43 @@ 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_queue { + struct page *page; + int bit_nr; + wait_queue_entry_t wait; +}; + +static inline int wake_page_match(struct wait_page_queue *wait_page, + struct wait_page_key *key) +{ + if (wait_page->page != key->page) + return 0; + key->page_match = 1; + + if (wait_page->bit_nr != key->bit_nr) + return 0; + + /* + * Stop walking if it's locked. + * Is this safe if put_and_wait_on_page_locked() is in use? + * Yes: the waker must hold a reference to this page, and if PG_locked + * has now already been set by another task, that task must also hold + * a reference to the *same usage* of this page; so there is no need + * to walk on to wake even the put_and_wait_on_page_locked() callers. + */ + if (test_bit(key->bit_nr, &key->page->flags)) + return -1; + + return 1; +} + extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, diff --git a/mm/filemap.c b/mm/filemap.c index 80747f1377d5..e891b5bee8fd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -990,43 +990,16 @@ 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; - wait_queue_entry_t wait; -}; - static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync, void *arg) { struct wait_page_key *key = arg; struct wait_page_queue *wait_page = container_of(wait, struct wait_page_queue, wait); + int ret; - if (wait_page->page != key->page) - return 0; - key->page_match = 1; - - if (wait_page->bit_nr != key->bit_nr) - return 0; - - /* - * Stop walking if it's locked. - * Is this safe if put_and_wait_on_page_locked() is in use? - * Yes: the waker must hold a reference to this page, and if PG_locked - * has now already been set by another task, that task must also hold - * a reference to the *same usage* of this page; so there is no need - * to walk on to wake even the put_and_wait_on_page_locked() callers. - */ - if (test_bit(key->bit_nr, &key->page->flags)) - return -1; - + ret = wake_page_match(wait_page, key); + if (ret != 1) + return ret; return autoremove_wake_function(wait, mode, sync, key); } From patchwork Tue May 26 19:51:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571183 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 DF804913 for ; Tue, 26 May 2020 19:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3084208DB for ; Tue, 26 May 2020 19:52:27 +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="iE3qXf/O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390482AbgEZTw0 (ORCPT ); Tue, 26 May 2020 15:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390284AbgEZTvd (ORCPT ); Tue, 26 May 2020 15:51:33 -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 250FBC03E96D for ; Tue, 26 May 2020 12:51:32 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id t16so9105493plo.7 for ; Tue, 26 May 2020 12:51: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=91LPx4VFG9btmYMQhwNjB8l3CSYHzquXTBOwjvdo+tY=; b=iE3qXf/OK07yvdsW8Vb51ZnFfsRrhY/I8AyPsPZBuYDCG+TC8jz9R0D0M+GRoONqmI gim5npZm8cxTM+QSweOQXfZsODg5VS6+7bN+CKZ4dMY7gY+QpgkMzMrv59Fphw7RYayS JBGmAVIX3BEE46Smv2GYnsm+ImSrUvQiaACUJ58syDnlB+HNG5sK2LsdT4XG1F3dqp/4 oVhakRyiZ0nYbu4FXaNA5/FJOFFKKsGpp/Hce7YkE5gJePG3prwbUWapZwHq23NDXkHD /0mpwLPbH1DZDuHuFhnGHadUwVq75hkc8cYWz+Lkln7BqwK/1OvfBTdLVjGY87S3aO6Z QMtg== 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=91LPx4VFG9btmYMQhwNjB8l3CSYHzquXTBOwjvdo+tY=; b=SPcTI+SPeLThMWfqyB1SkAtSrWQDdRahNQsa4/Y67eNDNNerRpCbxa25U5jEzzMsoQ D6hW0/K11G/6Iiug7xnPtqzN8hkTZdhaHmS5UfofTJVrIvSXZZa19AVBs2ersgtDtTua H3tGsS8/IyOl0lVzFOau7bj+FQTsYpMbn1MD0+k1/IVPD6k1i4Y1gtrDZgsJnkXwjRL9 wJ3oGb2KzlwgukkCbPX5cgeNECY65ovITI8uImlvPjjNuHTApJQx1BAfYKyjY/FNEvwL Ie/DdIQUbLptJH8r2DhAjQcQ5XtwF5V13D7hnVfztKDhwC8gda/LrAW3KjApKQz/2YI6 uK1w== X-Gm-Message-State: AOAM530gX5a4Ma6Lc5T1YM+cr97lRJQ02GmBUCByRtRnsu8awb5PAkNI sQV1HjPrxZx4wcoOCegsq/DbGQ== X-Google-Smtp-Source: ABdhPJzk5ZeLZ9PiNns9o7WtuSDeeuU8oJZ8JIZZ0HjXadMCEeQTkM4QJqeJe1UnHKeyrNQoGn1fyg== X-Received: by 2002:a17:90a:2a0d:: with SMTP id i13mr909880pjd.94.1590522691575; Tue, 26 May 2020 12:51:31 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51: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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 04/12] mm: add support for async page locking Date: Tue, 26 May 2020 13:51:15 -0600 Message-Id: <20200526195123.29053-5-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 add a new iocb field, ki_waitq, to pass in the necessary data for this to happen. We can unionize this with ki_cookie, since that is only used for polled IO. Polled IO can never co-exist with async callbacks, as it is (by definition) polled completions. 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 Acked-by: Johannes Weiner --- include/linux/fs.h | 7 ++++++- include/linux/pagemap.h | 9 +++++++++ mm/filemap.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index d3ebb49189df..ba1fff0e7bca 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->ki_waitq is valid */ +#define IOCB_WAITQ (1 << 8) struct kiocb { struct file *ki_filp; @@ -327,7 +329,10 @@ struct kiocb { int ki_flags; u16 ki_hint; u16 ki_ioprio; /* See linux/ioprio.h */ - unsigned int ki_cookie; /* for ->iopoll */ + union { + unsigned int ki_cookie; /* for ->iopoll */ + struct wait_page_queue *ki_waitq; /* for async buffered IO */ + }; randomized_struct_fields_end }; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 53d980f2208d..d3e63c9c61ae 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -495,6 +495,7 @@ static inline int wake_page_match(struct wait_page_queue *wait_page, 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_queue *wait); extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, unsigned int flags); extern void unlock_page(struct page *page); @@ -531,6 +532,14 @@ static inline int lock_page_killable(struct page *page) return 0; } +static inline int lock_page_async(struct page *page, + struct wait_page_queue *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 e891b5bee8fd..c746541b1d49 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1183,6 +1183,42 @@ 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_queue *wait, bool set) +{ + struct wait_queue_head *q = page_waitqueue(page); + int ret = 0; + + wait->page = page; + wait->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; +} + /** * put_and_wait_on_page_locked - Drop a reference and wait for it to be unlocked * @page: The page to wait for. @@ -1345,6 +1381,11 @@ int __lock_page_killable(struct page *__page) } EXPORT_SYMBOL_GPL(__lock_page_killable); +int __lock_page_async(struct page *page, struct wait_page_queue *wait) +{ + return __wait_on_page_locked_async(page, wait, true); +} + /* * Return values: * 1 - page is locked; mmap_sem is still held. From patchwork Tue May 26 19:51:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571179 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 D79C3159A for ; Tue, 26 May 2020 19:52:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE4A4207D8 for ; Tue, 26 May 2020 19:52: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="bmGfUVJW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389257AbgEZTvi (ORCPT ); Tue, 26 May 2020 15:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389290AbgEZTvf (ORCPT ); Tue, 26 May 2020 15:51:35 -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 1AFCBC03E979 for ; Tue, 26 May 2020 12:51:34 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id z15so279298pjb.0 for ; Tue, 26 May 2020 12:51:34 -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=ooHBrOZD/3Y3JOqiI+j5WGnGx9rNLKp4UPlTrA3k0fA=; b=bmGfUVJWYu6f/+lClc0yvwBvsEefc8SiuJxE38gUHmvCG67ZCMQ1ZoFC93WjnhwWQ4 yZg7fQlvm/Sucx7ncKy3qvV98rMGm86zWQnvA8hq14lOsPQmzOry1k+ft5gveL4FUJQL gaUBcnu8T8B55uU9BUZgRqOrmN0p82G3CTFOtVxJUrhxYK5Gn/8JEk4HKkHRhEAIvpxF 8iJj/6xBx4Ipgxa4B/+4ClHWKS0rVZdsYpFYzgcgIZxh9GvRIk8QENgpCADWhtcWb7U6 btJvYpMYxIv2afcSGCvbCXlq8oQ8SvKxQmlD9hcdrFZzniK3vSqmkl4k4ZoCvIJr0Avu Vabw== 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=ooHBrOZD/3Y3JOqiI+j5WGnGx9rNLKp4UPlTrA3k0fA=; b=fz6lrTVMVndy8uidKhFa94BqCsX+8V1ic7DzgOKjNswMn0MDIIzlL2YBBvG3AqmgMc ZuZRqLPehqye3kOv68UnabhaayD+g/XV0M5vfBXfhv7H0+wE9RvC7OqQIQodJX9ZiF5a iukIvNjp6w42i1fgxXmTtM01XMEUoA28bSYgtcHNN254a35MuiczZ3SHpjs2Zwco+K2e rlpA3TlID2XkbFMmKlM+93ZLob1r2coPYGjNM90f1GEdzAcFvd5Bny/vBm2n3TPJkoMz DPYgYRyUm3ly8E00DmsCGQ1/Sx93JOfgDoTYh5rVnA4pvodr7WcXn9WkoadJz5UNLIKI mNZg== X-Gm-Message-State: AOAM532LiklAT1KrU/amX0QdTJgx3MNfyWKW/ht199NJassiNLGII6p4 t3vGqQWJkG3iVZ9+jfZBsDBERw== X-Google-Smtp-Source: ABdhPJwGQ4LouRwKTJPsAC18WrHUCMfjZtLRZJD5qeryOylS8TBNaNMGloP6eX183Bgo+/GUML+3Rg== X-Received: by 2002:a17:902:b110:: with SMTP id q16mr1318137plr.221.1590522693552; Tue, 26 May 2020 12:51:33 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:33 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 05/12] mm: support async buffered reads in generic_file_buffered_read() Date: Tue, 26 May 2020 13:51:16 -0600 Message-Id: <20200526195123.29053-6-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Acked-by: Johannes Weiner --- mm/filemap.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index c746541b1d49..18022de7dc33 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1219,6 +1219,14 @@ static int __wait_on_page_locked_async(struct page *page, return ret; } +static int wait_on_page_locked_async(struct page *page, + struct wait_page_queue *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. @@ -2058,17 +2066,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->ki_waitq); + } 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)) @@ -2156,7 +2172,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->ki_waitq); + else + error = lock_page_killable(page); if (unlikely(error)) goto readpage_error; From patchwork Tue May 26 19:51:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571181 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 5E7C4159A for ; Tue, 26 May 2020 19:52:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 458C8207D8 for ; Tue, 26 May 2020 19:52:16 +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="QGGh7eDv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389586AbgEZTvh (ORCPT ); Tue, 26 May 2020 15:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389362AbgEZTvg (ORCPT ); Tue, 26 May 2020 15:51:36 -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 52416C03E96E for ; Tue, 26 May 2020 12:51:35 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u5so10575898pgn.5 for ; Tue, 26 May 2020 12:51:35 -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=pJi+qFrBerZp7lBzD9z2X8A704PrrK58u6ckL/rX8b0=; b=QGGh7eDvuMEBseMP4f9z7p3YtnoMdEdl9ZhyIAyPiRAlOPWyjOt58ZYAEOyE5NGpZ+ VbiVeaEvFBaRPyUFJs+jXjd5VlpU+FnFUdGnRwd4iM9vS4L8882zLFU0dJLNP83bH/7X Hr9aSoECE600nn2BUNPRRieqpYPuc2kJasfGr0Oad4cVuC7JJqYajXm+cBZv+VfHISga vLPJeD20yZMDEi0ileA+x1DrR5XEs54TlbjSVb6dXpEJAnHRCLPDGSG+Q65Af5so6wyt UoNhrMBuw8SKSezT9NYfONZtHHhz+/qyOtkgNQTZkmJfGXNjvokqDQxWupSNHXy0H+/a mcwA== 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=pJi+qFrBerZp7lBzD9z2X8A704PrrK58u6ckL/rX8b0=; b=HTQvD0mYF9b27C+s3QiMbol1+hnIVDIPMvDmrjzHblQSnB4TYBjSRT6SPTaEgOOs5A lJeaE1Wt6plEfUFR/e4R2OvFHNDmVPbPHHLif8EHcuBrO4hgSPZo3Dy8rWVZXg10s2pE jlt9xoG6aYiySR4fRiN+vKCDsbf2Pn0goVqfZ/Qq+cL/X0bQDMnPhYNjt5kN2iqBboIc nnsOZnAMm0vTUSJWpOlZhPhiQ1VU0SqU284EgV1P40n+CK1rBlsl9AORegKRNukNfSzP 9EWDJiKv6889zLHOTD8/L2cABfEr9gl/9/RejF0jnujuiDwiFulDDJP73fIOVk4zj+X8 qKqw== X-Gm-Message-State: AOAM533gwQ8LT7yUkESKnQPEYEV1kAbXTJeJCe9KkXdNIP7H2EuzWAiJ Y0gKrMMBhNjKgcAWMA3W/TgH5fHQqqfR5g== X-Google-Smtp-Source: ABdhPJzJqSQxVJW7x8nTJ31d7qT/FMci6We/odd5NaY49/EasjZOkFDNFy9QZL38JZHs/iDqJ2x1gQ== X-Received: by 2002:a63:5245:: with SMTP id s5mr481181pgl.394.1590522694841; Tue, 26 May 2020 12:51:34 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:34 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 06/12] fs: add FMODE_BUF_RASYNC Date: Tue, 26 May 2020 13:51:17 -0600 Message-Id: <20200526195123.29053-7-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 ba1fff0e7bca..5ffc6d236b01 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 Tue May 26 19:51:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571177 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 A8CE9913 for ; Tue, 26 May 2020 19:52:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FAE5208C3 for ; Tue, 26 May 2020 19:52:09 +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="V4vZlEEo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388915AbgEZTvj (ORCPT ); Tue, 26 May 2020 15:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389420AbgEZTvg (ORCPT ); Tue, 26 May 2020 15:51:36 -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 A518BC03E97B for ; Tue, 26 May 2020 12:51:36 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id s69so257812pjb.4 for ; Tue, 26 May 2020 12:51:36 -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=V4vZlEEoKDqieT7hflzw5LCDI+LKcZUvo3Ldv1B6nIJyQFjQVObJEjYJvLZcOXvigJ XFaZZNKcVEjx92yoP/mrgXgpnR0CotgPlUTXVNVfzoKp9JzK30dNsQEmJb3wosGrLUxB U8RsYVcKqFttW2FE5KGyEAXW3lYLtI/Up6eRarLnAsqMbQv1c3x5NKGKDbBaB/ydFz6t 7nJ6/vrORT3XMoHvYvJSZPS6MwjnIf9/choDZ58RJSYg3LkxqDzYmJhgdB5KpzqaEp1D jz+Rq1oQarSSrrXlfv6K57XzM5S6Jo9ouSoj57WYGLAnQKn8EBEWyWXJUyXm1pphBhbm UMOg== 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=bndzx/ktLUm29eH9gQ+dEL0P4F11fbDMSa450BMpyDlzn46H9CORFWXIQGnnlt+kvz r7QXX/3ZIPW5Sm+wLbjCwYUVg2q85qmUHASYQd7e7RiGYdh7zZznU7yw8vzUmykEV79L Eiwwjh3j40ZDp9gXJz4rc2U4LNNTTeJa6mzxP67JLUqN9+XVGo2IeNFETMnwV/VLoz3Y vL7iC05oJfZibZ0kyDpyOE91Eju0QkNKHIAV8KrSiUWkPR+qZaZLo6Qm809Q9BTX1MdK RtZk4hHrdoa1lerhXaZEtVgkoc9FNM/duzkOR5FGpc7kQ++PYq4mqD6wMCTfkZXKsbaM ypvg== X-Gm-Message-State: AOAM532quLbgfemWg3myd8XR4q6pyWmr6btlKwyDDti7Qusc5gEZ5lR2 xgntsWi3ao4upqEWGHuoROqcvg== X-Google-Smtp-Source: ABdhPJzyYUJtjkoA0PGX2KjnNxmXZglyIl+UX6NMsOMleygDwAvXOfiUub9ZxxKR/u6SZWeIJxQwQA== X-Received: by 2002:a17:902:bc42:: with SMTP id t2mr2580008plz.233.1590522696165; Tue, 26 May 2020 12:51:36 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:35 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 07/12] ext4: flag as supporting buffered async reads Date: Tue, 26 May 2020 13:51:18 -0600 Message-Id: <20200526195123.29053-8-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Tue May 26 19:51:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571155 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 C7B51159A for ; Tue, 26 May 2020 19:51:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF717208B8 for ; Tue, 26 May 2020 19:51:41 +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="rFyVjlx1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389420AbgEZTvk (ORCPT ); Tue, 26 May 2020 15:51:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389362AbgEZTvi (ORCPT ); Tue, 26 May 2020 15:51:38 -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 DB698C03E96E for ; Tue, 26 May 2020 12:51:37 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id c75so10571738pga.3 for ; Tue, 26 May 2020 12:51:37 -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=LpuXvU/PwSGQGjarIP5I58hv7Zj24N1R3UNEgL0jNDI=; b=rFyVjlx1z2FAJn581hW2m8bZ9qQeVyi56a/pWp00XB5VUt4lek5ugSoCmtZrlde+kL tqa+1PfUl7M2/e9l+7pKHpZQtgFYG4+bog1h7E0GzkngfisOv6OenkOwIP49E+Nby6+f n3A60kLcYP3f42QbUwlhziWKSrx9XE0R68EGvyIxzXWOUrQT6B0FfWHTWWDCwdxgu/93 ZQMy6v5XLA5PHMfQ8913VJLQtb5tlNTD/giDskk7TgQrwjFvlPGLsUSQCT2W4wbP22Be mdo47Iq7BMkJzVco7I1VX/a7oWaZcUGsobhAzz8Kq1gdvewllJ0BMVepmGsBwrX++cOp OxHw== 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=LpuXvU/PwSGQGjarIP5I58hv7Zj24N1R3UNEgL0jNDI=; b=H5ofZqr4pmMQ/aESuXoYKpeSwORv3vI8cLTFIWG8d0/AxXc05SgsPjOp3kuO+Ns6Vr M9dc0MJv7AFkbeI/gauyaEJenfEVOtf2xo2XVLERkXgyicKKOkYQWQOBqHnjgaqSEDRJ PlADymaplCd6+SgLJl5jDSAgHgzBJN4KhA/ndeSKdVRYQz/leMZi6DpwWaKXGp8hzwHj TTaoEImIFw7g8b+9Q+wZ7vgHv1LU9G6lSi8pyzYXbTJNkGex8xnt05P7j5+9DOifN/S+ PLdZvJqEK1em8blqSAXeEe2F/dfsrHDZinYqrlvAbWF374PT6jadzfnQlOLLmPI5ikDP nSpw== X-Gm-Message-State: AOAM532QMlVDXUJPFO+CtsU5LagEk59kXki51v5H5x+et+OQGfXRpjwG KUz2HgIUoa+zcVu+tsr2jpjpyA== X-Google-Smtp-Source: ABdhPJxpwoTNNsMNmh/v14vfI6qih++e4eczlzPNldN5B/zhIcZmJK8bBxIbqtxwi5eARBPbplx1tw== X-Received: by 2002:a62:e408:: with SMTP id r8mr392923pfh.213.1590522697426; Tue, 26 May 2020 12:51:37 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:36 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 08/12] block: flag block devices as supporting IOCB_WAITQ Date: Tue, 26 May 2020 13:51:19 -0600 Message-Id: <20200526195123.29053-9-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 d1e08bba925a..980cfce01c9a 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 Tue May 26 19:51:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571163 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 4361B913 for ; Tue, 26 May 2020 19:51:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C67720899 for ; Tue, 26 May 2020 19:51:47 +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="yFrvO5Xl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390028AbgEZTvp (ORCPT ); Tue, 26 May 2020 15:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389362AbgEZTvk (ORCPT ); Tue, 26 May 2020 15:51:40 -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 9FB8DC03E96E for ; Tue, 26 May 2020 12:51:39 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id z26so10629619pfk.12 for ; Tue, 26 May 2020 12:51:39 -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=yFrvO5Xl3qNEXOkExAlKW5HCKxIsDSMlTDL6yu/qdDNmAN9gaTkhr8Ji+yI9XJMB6r Yyj0QZ3VaFi/iX801MVu58AB5V7toUQ/3YSKHrzjYv7i2pgw3diwzJ9VU9sKkiQ+CqO5 +3TnFQnSzV+5hEs5v5Y4SsfGIfcKj9q7W3SSj/g2m24bxPjK6B7OSCJCgOwvDr/T+fH0 FXKEQYV/edda3rOI2u6He8F3YutgqUpDtRr1cjsP0bBekPjb/tjeT+Zdyk9nrP1RvMHF IL3sBKXh1sO3XzmReF4iBAlL3BzPeFNzf+QnoSzUJnqeO7X206hePi35FPbwAjeQ87ro IySQ== 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=M2Oo/Puy7CN8jJ/dbhCcC4jSWNXFriAfnY8hSyYy5dQzdK6c6mfI7TaYHVxSv1V+qT ERoQob63NQZDbuISPxe8d6rkDTOP3PpMzzoKVpiZLZASo8xCDbX7Z7kJjwuiYeuKL1n0 MmN2I0moqfv1Gc/mkd+IwMJhAfYlwtPreRbrGHO69YyNkwXdtr4MQuWgc468AniJM4KY 8Co2464assbbq3S13DTNf4zdrPTv4FYFzrjTQWkXObV9mLPEvrtucubdxmdNxn9fkgIO 9ROO+bgow0nFQy5Cv4KRrzSvgeSJn3CfBoho5zhKbFAjH8pWCk7qL351tsvLc43ciy/C bhgw== X-Gm-Message-State: AOAM53214M1dTgmbtLDRb6BwN3h/67xHbKX/DTGmaNwZaNBW4NdYWli/ qvSlY473wT/H0p5RsVfB3w2pXw== X-Google-Smtp-Source: ABdhPJywnc6qZ+WtihMTbkb+pFwn9JjcTK1HqNCVBDIVrphWDInm6gN1LVPRjjrnGs3CvW4hueDaXA== X-Received: by 2002:a62:14d6:: with SMTP id 205mr417227pfu.75.1590522699174; Tue, 26 May 2020 12:51:39 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:38 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 09/12] xfs: flag files as supporting buffered async reads Date: Tue, 26 May 2020 13:51:20 -0600 Message-Id: <20200526195123.29053-10-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Acked-by: Darrick J. Wong --- 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 Tue May 26 19:51:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571173 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 D2F49159A for ; Tue, 26 May 2020 19:52:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BACB7207CB for ; Tue, 26 May 2020 19:52: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="UT8tDTtj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389772AbgEZTvx (ORCPT ); Tue, 26 May 2020 15:51:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389809AbgEZTvm (ORCPT ); Tue, 26 May 2020 15:51:42 -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 E154BC03E979 for ; Tue, 26 May 2020 12:51:40 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t16so9105652plo.7 for ; Tue, 26 May 2020 12:51:40 -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=UT8tDTtjIxNNLckeUW39C1DftMV8tadKSzZHS24JY/ZgL6QUhytEvq2lkIf1qolpKk U19xBYg0KGV33rpnvi79D2PmiTq7vV4GnQy/vbDB5t3xuGIzSzGqlvQmaVY0B+9G+GIX llYo8cOvcrKG7jjvG4eBsx1q+LF9dT2crnAC1DmoY/wdrKeOH+NZ2+jAdxVlTNFeGy4a bQz1a2+aBWm5/WLAaDmlh/4XzvXPR5G3jeezjLE44Z3L1BaD260oHfxmj3fx6/puUmDQ a+gZr/lzYlcH0GBmCG9QZp0U8aQKyRwejv/NOtaCLlRLWl4GrEw481VCXscus2avzuQ2 95Ew== 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=dYgfRkQzfOXtlZBFh/I0BkuYS6dKzJh50gFGkcK5ILzWF4CM66QC5V9mYopP5LXc3/ qofWiIeF9vqGF9fVrzcyWImLt3kV5XrthC9cDjIDsoZRMKvvCf3EtEKVZ8yNNeNbW5ni Lx6o66NBLg2q38MppYz+a5s16ONIJW5PBIY/sN8Ymz+ZWsWXZRpPr2EEY2LoPOFPAaRc RbXZqpKCs0vA0e1xFm2ly/njdepbhfrswDmIBUWrBVtiTpeDXD8ni/n1Y8QEhzeyrJ// xSw5MxDHT/o/WRB9H2r3Zt5FPBZlULtFoc/yVZAW5Qq8bIphjtQWrvZp8b3k5N+Qo8KT fBvQ== X-Gm-Message-State: AOAM531UvyZfSCmEF1JhoP/x0aos/ted/c0FgbLkb5bFWMJoysIyXTtH 9BEbI0r2FvHN7fHQsXJ/+FogpQ== X-Google-Smtp-Source: ABdhPJyosEhz0s+kAgLEF75WSYNIzH1LsNfIRNs9Hso+92gcwzjdxDZZ5u7k8VwB526quKNtSk2K0Q== X-Received: by 2002:a17:90a:a78f:: with SMTP id f15mr930733pjq.226.1590522700418; Tue, 26 May 2020 12:51:40 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:39 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 10/12] btrfs: flag files as supporting buffered async reads Date: Tue, 26 May 2020 13:51:21 -0600 Message-Id: <20200526195123.29053-11-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Acked-by: Chris Mason --- 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 Tue May 26 19:51:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571165 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 00414913 for ; Tue, 26 May 2020 19:51:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9CF9207D8 for ; Tue, 26 May 2020 19:51:47 +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="MLDFg6dO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390069AbgEZTvr (ORCPT ); Tue, 26 May 2020 15:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389848AbgEZTvm (ORCPT ); Tue, 26 May 2020 15:51:42 -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 72DD9C03E96F for ; Tue, 26 May 2020 12:51:42 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id q9so264293pjm.2 for ; Tue, 26 May 2020 12:51:42 -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=egusxH2Kf4IsegITvpm+Q3F8VxKliDk7k1e8lkissGM=; b=MLDFg6dOL3wi94Sm49zoJiHajT2Z6Uem1NGpbbefsORGLMzmbgt6H7oJbyNaRmzLhC 8Gf5ZNcnIwrFrsP15fHb8Hmk8a2hfjKN86KGFvtSh4PMPlyXApwguNjE2pUXQI5wzJ0a rImtmWOl8q0Gt2VD5UOeqH755bpc04N3G1iq2vwGTCann04vKvGxeoLEFP4xQ4fRN5L5 Wg9gBx9FYIQvKM0euflOkFd88eUTLbrv+ERHN3wTJKYKJYMp38rMrtrLJwTNL4ghE1HN EtuRhPWgN+n1jwAN6pgdhE4EdIt7SHFVS5ROARRrp8WYRbT1BdjRgRCf0aEwWTyQqK88 EjdQ== 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=egusxH2Kf4IsegITvpm+Q3F8VxKliDk7k1e8lkissGM=; b=ad0mR4VFnxMvhRTmEpSpOGSVCfLlo4pnDVJSIzLjNV4BYsN21CsHZ2/3pKT5o2SQxn OmKLHp5X2Up+83wYyP10T/bjXs3vya453e+iGSZltTp7VmgNtoxz8isi3Owle9LLlDwq M9FQKaX29c7I2YUmI/SUaLzPQ4y/ZAiEMSPFklZueTVcsnmNvUcSGJwNSZnLAkHURqPx a2NFUWCf1ccxvuR8fudEfVbYMXnp2zzS0GbY3xxmn7bC/JB39qV9BthM5T9du0MAyrVX JCt6bpRNO47M2unNEbTxiCGvbfzvnkWAFkO9xyTNtRrv262u0Ta9M8wrmfDBupXYArXr 34Zw== X-Gm-Message-State: AOAM5300/lK/m8BO9VPHoU1T0ojj4oYrx0z8Gh4tKvd2tODLEGs7MikV qyggaaIFuRYOxibiv+2DXxxX3w== X-Google-Smtp-Source: ABdhPJxAwu286c9tdXeF8Jkxcn+Zoh3JziTFwAwrgLKM/2XtZ0wj0VRphyzFquzNho/fJP8ygPEQiw== X-Received: by 2002:a17:902:b289:: with SMTP id u9mr2621523plr.138.1590522701930; Tue, 26 May 2020 12:51:41 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:41 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 11/12] mm: add kiocb_wait_page_queue_init() helper Date: Tue, 26 May 2020 13:51:22 -0600 Message-Id: <20200526195123.29053-12-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 Acked-by: Johannes Weiner --- include/linux/pagemap.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d3e63c9c61ae..8b65420410ee 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -493,6 +493,27 @@ static inline int wake_page_match(struct wait_page_queue *wait_page, return 1; } +static inline int kiocb_wait_page_queue_init(struct kiocb *kiocb, + struct wait_page_queue *wait, + wait_queue_func_t func, + void *data) +{ + /* Can't support async wakeup with polled IO */ + if (kiocb->ki_flags & IOCB_HIPRI) + return -EINVAL; + 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->ki_waitq = 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_queue *wait); From patchwork Tue May 26 19:51:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11571175 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 68FD5159A for ; Tue, 26 May 2020 19:52:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F0E3207D8 for ; Tue, 26 May 2020 19:52:09 +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="BAnRbAHj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390179AbgEZTvw (ORCPT ); Tue, 26 May 2020 15:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389933AbgEZTvo (ORCPT ); Tue, 26 May 2020 15:51:44 -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 C8945C03E97D for ; Tue, 26 May 2020 12:51:43 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id 5so266689pjd.0 for ; Tue, 26 May 2020 12:51:43 -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=Yu5b4WPlNLJ4FShHKrav5N/oC/rLKGyUa0V1npLkROk=; b=BAnRbAHjptEKaSP7aORnMOMvcRRwJYbUJCnBMqSaZ5LExh/WyjZAx0kpm9bGHRNipQ c9xKOXLv3vjiGsiBY1sSp47ys77lF0zegk2Z/RxBhYkJ+oizHWibDzDtaVyKsqqZtscm FwEZma7bB2podeT+bwe2UFoh0El2zE5bb2ykyavUywEuTB1tSqo2t2I71EDQL0x1hfyY EpM1AheRzrX3I6SAVuYiX/AKHnQYJkQtPWkZ9rw2ptTOJVNcB9NTHSHihcMpSOsbvfIi +n+bRE/L+0dLet27JP+fhpHeclePFF8u5DEjtYpBV85c3CaIk2/0DZUoZRk4tv9rWv1y zZ+w== 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=Yu5b4WPlNLJ4FShHKrav5N/oC/rLKGyUa0V1npLkROk=; b=NervzmxgobYBvv7Qd9gaOedTjnk1smaNoPMiZstN15jDjNR2l7ZNc1jshLpyjjQ8fC Mw+LhK/Ql6vdLmKYMcq96EoKLwEl+IV4FqqEAOw40RFCS28tjJUU8QxDv6chmg9hppuG +B0bvWsDlySHPXj1KT2siWki/9ktjiS4erHPe+nKL3nFXs52zil31Kv7ZY7+MgA22hgZ 4IXVntD+beyBcaTJyUVEPcJjqtMy7ZPtGotJX3lXyUmKWMfCjJLqsypYrL9Cn4AZcAki 9JLmv0FEXHkcqWbN/2Is5IfpU5/1AYWbrn9UwLw6FCry6+7N3Ccv7uukMYneiinnk4Lb ERPA== X-Gm-Message-State: AOAM530H7/xF5JjdmGJKhCpM/twNTqjT9l5Z2zMB3keAX1TQycpYkikg OwVM4+j4wZaBMf8+AYSg8NNSoQ== X-Google-Smtp-Source: ABdhPJyp1ndQMqu6aI+tmLSQqXTreoaTLldbZ84COMrIiZ1LVkC/ujNtpmTAZp5Rn4xnmw8iMWAw9Q== X-Received: by 2002:a17:902:228:: with SMTP id 37mr2636599plc.105.1590522703244; Tue, 26 May 2020 12:51:43 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:42 -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, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 12/12] io_uring: support true async buffered reads, if file provides it Date: Tue, 26 May 2020 13:51:23 -0600 Message-Id: <20200526195123.29053-13-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-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 | 130 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 4 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index e6865afa8467..95df63b0b2ce 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -79,6 +79,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -498,6 +499,8 @@ struct io_async_rw { struct iovec *iov; ssize_t nr_segs; ssize_t size; + struct wait_page_queue wpq; + struct callback_head task_work; }; struct io_async_ctx { @@ -2568,6 +2571,119 @@ 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->wpq.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->wpq.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_queue *wpq; + 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; + + wpq = container_of(wait, struct wait_page_queue, wait); + + ret = wake_page_match(wpq, key); + if (ret != 1) + return ret; + + 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; + + /* never retry for NOWAIT, we just complete with -EAGAIN */ + if (req->flags & REQ_F_NOWAIT) + return false; + + /* 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; + + /* + * If request type doesn't require req->io to defer in general, + * we need to allocate it here + */ + if (!req->io && __io_alloc_async_ctx(req)) + return false; + + ret = kiocb_wait_page_queue_init(kiocb, &req->io->rw.wpq, + io_async_buf_func, req); + if (!ret) { + get_task_struct(current); + req->task = current; + return true; + } + + return false; +} + +static int io_iter_do_read(struct io_kiocb *req, struct iov_iter *iter) +{ + if (req->file->f_op->read_iter) + return call_read_iter(req->file, &req->rw.kiocb, iter); + return loop_rw_iter(READ, req->file, &req->rw.kiocb, iter); +} + static int io_read(struct io_kiocb *req, bool force_nonblock) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; @@ -2601,10 +2717,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock) if (!ret) { ssize_t ret2; - if (req->file->f_op->read_iter) - ret2 = call_read_iter(req->file, kiocb, &iter); - else - ret2 = loop_rw_iter(READ, req->file, kiocb, &iter); + ret2 = io_iter_do_read(req, &iter); /* Catch -EAGAIN return for forced non-blocking submission */ if (!force_nonblock || ret2 != -EAGAIN) { @@ -2619,6 +2732,15 @@ 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 we can retry, do so with the callbacks armed */ + if (io_rw_should_retry(req)) { + ret2 = io_iter_do_read(req, &iter); + if (ret2 != -EAGAIN) { + kiocb_done(kiocb, ret2); + goto out_free; + } + } + kiocb->ki_flags &= ~IOCB_WAITQ; return -EAGAIN; } }