From patchwork Sat May 23 18:57: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: 11566971 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 BF1C31391 for ; Sat, 23 May 2020 18:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A719220812 for ; Sat, 23 May 2020 18:58:56 +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="a87Bs6xG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728468AbgEWS6C (ORCPT ); Sat, 23 May 2020 14:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728246AbgEWS6B (ORCPT ); Sat, 23 May 2020 14:58:01 -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 3CEAEC08C5C1 for ; Sat, 23 May 2020 11:58:01 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id z26so6746714pfk.12 for ; Sat, 23 May 2020 11:58: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=DT9kV8IQxC/D+uhFJsefv+iJT3TxYB4ReZ7s4ZFOil0=; b=a87Bs6xGjaGsCBlocxfqOxy2zUrVZ1peF9M9El8QQmFnxZ4ofnyrA5X/03ZjgM5oMk zf0D9gsPh6iz68c+lczEGQM3V/GADtGDtxRQ31jmSVBKL1jK04nvWfXWvIUImNfnH3kf iDDUDGAnkjQgjcXuQ6a4VuWuEC8bTOR7qieLkAE391AGwrp2msXuEG5eXaF9F0sTB4El xJRLA5INBmlDwvcdz5MRIV2c+bmSNsIetglQf8jjepx0Kkn5lCf+xSkGUABJGpgf9L5C 7oa9Su9IFvIN+49vDAK5NqyrW+NLNVYtYBXw4n/n1hQuT6+hy/YomwcPhAuxTRqu1mZp QD6g== 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=bAiB54czHfVOUvEce2Hm+9XhDxM8aPi1oR0UDzSfR554qIg8GFTrPONWb3wl/9xApY wPEs/DcO6d7dsOwm0/et4I6Acwaubk56pry5HOMuUSDp/lxcv6CpCcnSDsXa1sHuKY75 5arFQOY9MKF61AzETyarxItuDV9a+ydQyS2Bx0gsKGw3kK5DrnSPqivQFXM2dXIoiyzS 1+35Xq2UVarQjs190vY2o/lAYET9bLScxYLZMwIMR3FOigq0kvNwkcEgiqrskv3ClVDH Jyqt7jDkeeB3XFv1yRbBhNSaJ+I+PAFmo0ry2uAoVXiSnqbtfl4s0PRrV85ntRygVxOt oQPw== X-Gm-Message-State: AOAM530MGXs1Dg/veopdbGAXf8SGpgAgTvK/axRJe6biyPpzKv8uKpky FwzBlJTmIVuyJ+26+2J6Crev+TsULI+VGg== X-Google-Smtp-Source: ABdhPJxn7lC8B7nFRg/yRVy5DZn0o0nXIqRSMuIOyfCbYvam4NLOj1/fhahVe0+8oMsT4fckX4/7FQ== X-Received: by 2002:a63:145f:: with SMTP id 31mr19792396pgu.383.1590260280791; Sat, 23 May 2020 11:58:00 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 01/12] block: read-ahead submission should imply no-wait as well Date: Sat, 23 May 2020 12:57:44 -0600 Message-Id: <20200523185755.8494-2-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57: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: 11566931 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 3AE011392 for ; Sat, 23 May 2020 18:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 197F020735 for ; Sat, 23 May 2020 18:58: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="dlRhMk44" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728639AbgEWS6D (ORCPT ); Sat, 23 May 2020 14:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728595AbgEWS6C (ORCPT ); Sat, 23 May 2020 14:58:02 -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 BB272C061A0E for ; Sat, 23 May 2020 11:58:02 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x18so4646278pll.6 for ; Sat, 23 May 2020 11:58: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=TvoN8a3WZmoogVlnFEo2G3/jPQNtfJ5pQXb6VgaLeNI=; b=dlRhMk444r2/QEHuAZ++S1wyLJ84KnLxTEI64EuE4dN1pFxVgN8A9K0quOu7H4b4Kq sjwJUAUsTLCVCGcV3VQIysTW9HiVCJ7sH5euxBGtqJm15I6wEKH3mue/IQD6jbfOMSi7 Ee6mlXKJeIhli6gCf6YjVyTShL+/w3Hnk2eTqSuVF+zoDvF1MfrGYqyMRFeDjw07L0cs Mpg8k135t1sCC7y9Xv6B4U4O7cl9wdgoiTFK8GtgUeb7Kc22w5q0VzvT/2c8RzsYEwH1 Cn02kuIXs3ldFHF8OFsS7U3UbM4AjfKkDhyZ7OjtrO7ogq6UpJoIBqUQAGUK22qWlIRj o4Mw== 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=s1WHfzT597VBL7sL65caq6eymhMBz048sp0GheM+cjQLZ6L4j1whvrjQMWEFyCApvF pi1GRmJV1UTXJ4UB4XgV14oy8TB+4WW1q+82QjjIzJ59ltZ0uGcQmGJojpYuVgmq6yjf QIHcwH1fg0GliQ0+9hzIk3j07Cf58KrNC5TaMn8H/3yrOgmiM7gEEI2xmlgntB1jyJu4 pX9nbHvuN/dEXToI1Glaj+uhkoPBahvm+nwXZruHU0PJrQuKudBJ0VDpSaXyiK6faoHA aE35nk5njwWrLUVLtPAttBDjY6EjRwuoDi2+rfIoIGJu2jPLHGTrpS8lx3iDodTQC0Oz M5jQ== X-Gm-Message-State: AOAM531ftL96rgYqDKcsvFtAR9C9NXtchv3n97ZWjMS5BgtuCMz//2UX z6oS5toV9oUHU69xM+m4GK8fbQ== X-Google-Smtp-Source: ABdhPJx4dsrrORWefyOaJaBwml4HUm2oobE0QtXJHHyZSr21A+y8BNmhuTv3ioELhwbbDTv2OiGRNA== X-Received: by 2002:a17:902:db82:: with SMTP id m2mr21720441pld.14.1590260282249; Sat, 23 May 2020 11:58:02 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58:01 -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/12] mm: allow read-ahead with IOCB_NOWAIT set Date: Sat, 23 May 2020 12:57:45 -0600 Message-Id: <20200523185755.8494-3-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57: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: 11566969 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 8D9411391 for ; Sat, 23 May 2020 18:58:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 757FE2085B for ; Sat, 23 May 2020 18:58:55 +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="eaWQu5rI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388092AbgEWS6y (ORCPT ); Sat, 23 May 2020 14:58:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387543AbgEWS6E (ORCPT ); Sat, 23 May 2020 14:58:04 -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 0D301C08C5C0 for ; Sat, 23 May 2020 11:58:04 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id v63so6752862pfb.10 for ; Sat, 23 May 2020 11:58: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=fQihCl0dLbHaElgiRrlXkibi9/E8OKsaJ7lF0uUyO/s=; b=eaWQu5rIF65IIe8LNBzP1VhRXuhf/K8YuXmyjWuD3csLufjFBKBEZDaJbIB6RwswAQ rDBP5Ms4v5GriXypOxasHghq7UnINAs0gaI86yQ/hNhK85oUXxh9tCLqJ+1ReVF5l/ix tPRMxxn5OJgrvK94v8gqoHCYdCO3fgQMAXr+vr1QgQvnYsZJ/wdm4/qp2eaVtNDY2sgH LDz+wH7VwwOwdN2+SX1xQCFbPnBR8BZ8SA2j96fkibGQYbL5STDJ4sUUYmLUjN6asTWW kgkWS4yZfdrzVsXNsu8c22UnUv/buUDX4ks7m/nlfPqKjekl11LSVTWWEwpgJg0OiRni cSww== 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=hiI76gTuJnOrbazhUVDn/JDsXR/4cP91izlGD7IiEulBHH32f/8oVAdfDTwQv7hGeR i+EwAnaG1WZKQeyVtdNF3iu3cVlQoc5xs1ERl6YEh8Z/28gPyZN0jJhjZo2TA4a2Cqwn Wh5cXTBC9RbAXpnZ3JCbU2GF937+dmOu87xBA0JfAMWn5EQDoDLD+yAxCKZ4f7MKjmRO KWpyBYFeqSNFpDEgX5pj2yAwccHcNX7EKC9Nct0d1ye5dWoioE1K74ajpHn64Ggl3VGU B6oCWDDE50n1hRfi1Z8SN53yxyCA6D7SuxNNv/Ger98+rq9DnoxVfJjUM+h4+qsrB1at 0x3g== X-Gm-Message-State: AOAM530hGNXHtfuviuSkGtIdY9Enb0V5020h71wE3GGlvUzU93L+Um// 1xwvDGgccVVt/zxktrgaw3aPY063NziwQQ== X-Google-Smtp-Source: ABdhPJz9vqnGrCG9qj0wEnBzhySeVMrYNwRHjDaahSZXAg0rEuCiNKORSORIP7O+cxiJTr2yWj4euQ== X-Received: by 2002:a63:3114:: with SMTP id x20mr20316638pgx.52.1590260283492; Sat, 23 May 2020 11:58:03 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 03/12] mm: abstract out wake_page_match() from wake_page_function() Date: Sat, 23 May 2020 12:57:46 -0600 Message-Id: <20200523185755.8494-4-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 --- 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 Sat May 23 18:57: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: 11566965 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 99AE260D for ; Sat, 23 May 2020 18:58:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8156F20812 for ; Sat, 23 May 2020 18:58:48 +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="IoUb1h2v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387593AbgEWS6p (ORCPT ); Sat, 23 May 2020 14:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387843AbgEWS6F (ORCPT ); Sat, 23 May 2020 14:58:05 -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 3AAB1C05BD43 for ; Sat, 23 May 2020 11:58:05 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id b12so5743943plz.13 for ; Sat, 23 May 2020 11:58: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=hENt+q3Sn8CtA9tFAzdLO364i6JHcfhAdPtfDTKZjEw=; b=IoUb1h2vKy+f0dtwmFTBDbGpNkk2wMhwXrlubxdrni8AO8E3DlT5YodBAgH9Bo0lAb lW1WJtaBGZfKwnRBxn+qBzZenE2peUkQgkHh9d5nebmKYs9YNDiCd8dvOvjDpj5rbO/n s0s7FihoaBqMkq0rzhjJcs2EnEd0abWfbDYSs2ekcPcCYLeB3N4zFnamKz+cGsxj8eNn F1ChMVdkAafH9S53RqNorXpYaYMzFBN1kPsG+QlVPUMBDg9DTew082jQfzOc2ih2Qb/r 3M+n7gPxJSlSImnvwlieeQzY2ObPa3uuVP6JcfMVBkARc9hJaWxZEAFois6e3Jy0h+Ct G8EQ== 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=hENt+q3Sn8CtA9tFAzdLO364i6JHcfhAdPtfDTKZjEw=; b=buC0OUoOJKM7BAtFZocRcSy9BbZgtt9pnYzeUasPrBFMNrk0DGMF67Pru5dUbN3h2Z 3GPd96A7mbFA7lced57h1/czNz1EK1kjummCz8DnQ7ydc6Sen25M0QVr15jq4hQ7FB1d vkgqM5TPasr/NwTW6VaPZveFhb2mR9/yBOT5T1gYE/0AOryS5jV6DH/w8fb36wc4PM4n 3J7ykZ9Tpuub5RZcI2OlWeJfE2BNfyI/plAsm/kzZcaiZg8WgwIZV4tV+vRv01ic+J92 KTj2a10ceByeIW6buPr1WcxkGwuoP25XasZz/lhPHZhiFLKHJzgIoeP1hrhpKFYGzMwb 9aZg== X-Gm-Message-State: AOAM5318AvhfPIoof4/12F9qEluMsDisUze/8CGP6lVlkX4xi3pmg0fy 9f90qYGKEkF90r+wA5rn4NCMGg== X-Google-Smtp-Source: ABdhPJz0eo745gK+bLfHgAeIdJu+l6vnctKVtOYWF0tbpRSPS4ji6QlFp3fk/3FEBowyABl4PmcaOg== X-Received: by 2002:a17:90b:1897:: with SMTP id mn23mr11837825pjb.84.1590260284702; Sat, 23 May 2020 11:58:04 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 04/12] mm: add support for async page locking Date: Sat, 23 May 2020 12:57:47 -0600 Message-Id: <20200523185755.8494-5-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 | 9 +++++++++ mm/filemap.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) 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 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 Sat May 23 18:57: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: 11566967 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 A62F960D for ; Sat, 23 May 2020 18:58:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E1AE20787 for ; Sat, 23 May 2020 18:58: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="MWKaekWv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388053AbgEWS6p (ORCPT ); Sat, 23 May 2020 14:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbgEWS6H (ORCPT ); Sat, 23 May 2020 14:58:07 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529A7C05BD43 for ; Sat, 23 May 2020 11:58:06 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id 23so6754522pfy.8 for ; Sat, 23 May 2020 11:58: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=QLIKOC51UDi6y8ydZtCT2FsP1dt+ucWxar6wAIDn3TQ=; b=MWKaekWvtx+WTMH7SA8TxEwVGEMQRZ6Y3Djw7RNC7oEYUCXetIPXBjtiJgnyF71Y0b UMa3s3nv9VNBNz/E5zE58K6odN5gP1YpWtoRtR26Jtt0hxzlYhRsfCdDXvyf1atMh5bs o3zeYxTrMI80Xwj9+WtyiI7NO1qDg3KQpO4qdC3SwkxvfVqMOsKdB1CW997onc1jjj0s glvIv02sptmvS0nrlsCIZFZqjJuVPnwA32f5p/IDDJg82jymdpaM0DYrJhhfbQg3g/lN 7krBmUvtb5GR2kiVrgRdtyjFenuM4+KBhSnVAZc+Y4QeRkSFLNE8OUmPmx2atAUI+eH/ IZtQ== 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=QLIKOC51UDi6y8ydZtCT2FsP1dt+ucWxar6wAIDn3TQ=; b=XYahvAQ6KIHWC5eJ6B2IHsi/FI3Gr4uwbgw3FBhf+8gRQFOkSpAhIwEQQKFY26AVUl lk13QDmtd9ev0tclzSxw34+UqPiSbTKsaVOZgPHJzBtIUNkDGn8LsE2owocppAv+i0Jp AKFrAXyAC10trONufK9AZXfWQgNIROL4eWY9BPHcYv23XLLvJmvJH3Ytxz3SxDXL5ry5 gbHSHarZoxSMs+/EUtBTVg7GL4mfHn2F6deBfEd2Ex/aqkTTOqc/PovSJziQCRL9dSP6 kiWjhuHpwvdA3FbckjZk/zzgsOkctaxoDtmBC3pITGuETyBW/kYZUSbzo9c9qa8g346r FiBg== X-Gm-Message-State: AOAM532Q28VMt09Lc1L5UDUsIg+2KHwC9ltIOzoW1EsVHyavdUGm2WF+ qLqa6uT5qX9r5srAr67jri/aqA== X-Google-Smtp-Source: ABdhPJxlGEJfDdI/CHMnwiSfxbLnvzCi9W829t09wDrbokAThLoEnwexsOcrvdVDPXc3WyV+F2HO2Q== X-Received: by 2002:a65:66d5:: with SMTP id c21mr18973961pgw.155.1590260285870; Sat, 23 May 2020 11:58:05 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 05/12] mm: support async buffered reads in generic_file_buffered_read() Date: Sat, 23 May 2020 12:57:48 -0600 Message-Id: <20200523185755.8494-6-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index c746541b1d49..a3b86c9acdc8 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->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)) @@ -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->private); + else + error = lock_page_killable(page); if (unlikely(error)) goto readpage_error; From patchwork Sat May 23 18:57: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: 11566963 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 95ABE60D for ; Sat, 23 May 2020 18:58:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C8A220787 for ; Sat, 23 May 2020 18:58: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="VQGxFJ1M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388037AbgEWS6l (ORCPT ); Sat, 23 May 2020 14:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728739AbgEWS6H (ORCPT ); Sat, 23 May 2020 14:58:07 -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 9F851C08C5C2 for ; Sat, 23 May 2020 11:58:07 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id q16so5761039plr.2 for ; Sat, 23 May 2020 11:58: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=+VWs0Nj9WGghWnCOq/fSx5SIRlxQxiE9MXDVdkqYQzM=; b=VQGxFJ1MxYS+Vw8KoeGE9Yp64TT9Leh+gvBEq3nSUIcV4q11TwCvNdgUOE64d9oXuR QwCYzp1XbRjhrfrIYCgDRiI3wNxKaPuOK9MAPnMWA0KnXYiuSAIVl2yI09EhrIdrcrFM yXlJUMX6/7/dnLIlxxx71WhbHGAAvf+qPT2dYyKUTUDXmSXge8//q718AUli9iaFfbEC dxVqtShxZExPi16L5fD/q3PnmzPb30ALVsAN2nzVeCsEO4ixAEqCTbiC/L3aSva3OchT 7fmGcoI1vJS88d1J9R3bXQ/OGQQpUX13sIuMZdX3/8Sy5tpafxaH30aJAQrsfvYlh05M iYyA== 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=E8Ycb00nVug6dhsyVwuPSgxUZVlTAFO1WgCItzPmUqxJWvZhgEAywuqoZMX4xqxiOa 0gtlxV6lrBWej0QQXhR6q2VAC9tTIF9Pxd6ZzVIKTH++0kDeXEgMGRF8ZKvnbge2em81 oG5px1xJitM6l+5qr5WwrdMkFWwBVdk2pkvHE4FtZutc1Gfys95nXtWVXfwTXHhegG0n Z1I3ra5PttmdC+mt15xon2M8k3cawUAw88i9EasqH1Tvw2UvFupv6+bTiPBcJiWtgyrE FMf1WBGrKyDI6XROaidKllb3oqYD6wdL2Jbc/SwvcIhvXw6fGHGrPOWQUmoABiHXkAix j6TA== X-Gm-Message-State: AOAM533OV/T5XGzQsqGsQNjs1i4HV+2w3Nf2Ph3uJQ6U79zMVVK+rF06 lv9UtWwPRsi4am5RgVtGD0eQTg== X-Google-Smtp-Source: ABdhPJww2IAmo9uAID5Z5Uv4A7c5klKM1alJ3HFIhYmGs43fpfvpJn60oDW0FK4OztR7UWpiSCL/KQ== X-Received: by 2002:a17:902:7:: with SMTP id 7mr21153561pla.45.1590260287140; Sat, 23 May 2020 11:58:07 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 06/12] fs: add FMODE_BUF_RASYNC Date: Sat, 23 May 2020 12:57:49 -0600 Message-Id: <20200523185755.8494-7-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566961 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 4B42460D for ; Sat, 23 May 2020 18:58:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29CEC20787 for ; Sat, 23 May 2020 18:58:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="asMd1oaZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728899AbgEWS6L (ORCPT ); Sat, 23 May 2020 14:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728869AbgEWS6K (ORCPT ); Sat, 23 May 2020 14:58:10 -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 D7AD8C05BD43 for ; Sat, 23 May 2020 11:58:08 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id u22so5737520plq.12 for ; Sat, 23 May 2020 11:58:08 -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=asMd1oaZIyB4OBJhuDDS6Qm6IETRfR3fCCxP9jAEJSZo3FYau0gIpI9b/WsuE4N1KX RhGUBNuuUrL+ZAlmaNkDbor8+W1ob/cE5h/o3evKIKCN9RWGAgjkY9nVj4AsDXFEOxvN jC7XVMjV1it0HHmhL0OxZuSDp/Abrk9rCOqaJil6/D6M7OiW2AtqylxkNCV9an6DjayG vOHDb15eEsnEy1dDiJMsIiXcTlcRPgEl8h11Wp/ZpqB/5F1uv0rEg/I9CQ+o05PMPjC4 Y320pJtBGjmXFef+eP+mcAHwtpvSBcWWOC2sJdIvszbOHJlfXMWF9y09acccBUgWfqzA 3Y1g== 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=TJLRGpmvAeVrtSbvFNt+YlTsIr7iseMeBu/4yxV2hUCLYGEI/E+fjw7oavmc3hLNNg vceSNOTlln6eO5erMRm7RjHqXAPb3RNCxnWwh89vz72yv14lGCF/7VVOAj45UZ+Rc5HJ eyteQBYcOWNxMiQwL+GonJMngh9ynBZSF1QDlwCR0+enw1iP2U/ASDqYi8x2RHDcpyuW TVkv9bXyso0KsYKY0Yo/kb49B1WSuZuw0KPXFhmHWH3G5Urvjb088jDSfLIw4IH4D5IE j7gLk/JQa3OVX5Zoc4Mdc3WQsQogLhVI1soWJMy72iqddJUJv5UYyYf9PF0ip+XYSIyV CWPA== X-Gm-Message-State: AOAM532gJDTaOi77wmvnAkDw8XeQ+AOI/jKkws55c7/CcBdaPcd2RBYv /SAZ4dRQ1CoDVYbgj2i/GTAg0g== X-Google-Smtp-Source: ABdhPJxN9tF6/2bYMLjdUOX4WlnRkytgiqQRjaUtCQS8ug7GAw+E2pO4OMfyhBqrcqoO8mwzIxyTZw== X-Received: by 2002:a17:902:b718:: with SMTP id d24mr6737530pls.185.1590260288366; Sat, 23 May 2020 11:58:08 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58:07 -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/12] ext4: flag as supporting buffered async reads Date: Sat, 23 May 2020 12:57:50 -0600 Message-Id: <20200523185755.8494-8-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566959 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 0669B60D for ; Sat, 23 May 2020 18:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8EFC20870 for ; Sat, 23 May 2020 18:58:38 +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="bB83Tj0B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728971AbgEWS6L (ORCPT ); Sat, 23 May 2020 14:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbgEWS6K (ORCPT ); Sat, 23 May 2020 14:58: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 4009EC08C5C0 for ; Sat, 23 May 2020 11:58:10 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id a13so5755252pls.8 for ; Sat, 23 May 2020 11:58: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=4QX6izj81MoWvGB/E4/khaJEguGwrdsEfxjduXmAWvc=; b=bB83Tj0BajwuSjWkcK8ehgNRsKT4dlqQdsgUPSjJiJ2iXaFPJSy+fQuN42JRHiuPAF Ds+TSO9sTx+8fbiOAVgtOWX6Sz5lYix1bG9WAh/F71WpAmuz6k6RoGgcULfHqhCzSSGy czJK+XJrC+LZTYdNLs5WA1tyopGAN51nNSKpEc4rmPTh+HjK5AUz5guhgngWLdElEoFp Y/U216s5zcrGi7OrgxVS0H1boXsUkpjkDmicuLJP4gJCppIK3k1wT0URrgfknJrl22Hn CRM8C/QHbp+xO5nT35RB17ABqdwxlpAFz/I5f7IJcf47ml75nwLzUmNlUz5/4oEh0drP Oicg== 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=aumFTPyhn+960JKvX+OTS/XQamou3kDqNcwkwOzBbaUQfWaWmCZOLg/ZmpOl6Te0m9 K/loT2nbUiKgRVKFec/i9wn6LxPRkZTyTTKuCT8C8bM1HNDw5d0jRMnQhyMjgaIi/DUK kBFyQn1nEFOsQyACvXmO8oAlOh31002cC+X3EsSWzqDz1ERNd/3HG5lTgl1MKsG4X/sS 60XPr8Q5FwwGmPYbYMkZdqvZv3IsKwexueJKRsGv4cObCCoEEnX3DVM1JVPfQmOQhiT6 KrV7O4G/Oa1ebKgIztLrsG43gFTE4vuizb6h9+3y+EalSUp4rd6DWn4V2NLEOXPEGchv HW2Q== X-Gm-Message-State: AOAM533ih69RLft+NFHhPDcVB/6O1JtHk/YFv7zR66ivixVVCK3wiQ1U DumSd55tmdriFlNjMNQOP3/KQg== X-Google-Smtp-Source: ABdhPJxtwoGUVtGeMjBKBqTDc5pH659x6OQMxIcezhl06qMF9UwN+jLw7DQKIdSMErnJ/wvDE2IMpw== X-Received: by 2002:a17:902:422:: with SMTP id 31mr21310761ple.310.1590260289753; Sat, 23 May 2020 11:58:09 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 08/12] block: flag block devices as supporting IOCB_WAITQ Date: Sat, 23 May 2020 12:57:51 -0600 Message-Id: <20200523185755.8494-9-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566957 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 BF2401391 for ; Sat, 23 May 2020 18:58:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CCB920849 for ; Sat, 23 May 2020 18:58:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="aKd+2/L3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388003AbgEWS6e (ORCPT ); Sat, 23 May 2020 14:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728984AbgEWS6M (ORCPT ); Sat, 23 May 2020 14:58:12 -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 515FDC05BD43 for ; Sat, 23 May 2020 11:58:11 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d3so5765659pln.1 for ; Sat, 23 May 2020 11:58: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=39qQrTBLEctUrGanLy/C45/WjdVfQkC7faPzmr+qhpI=; b=aKd+2/L3zhcWktix7GTJLEddQj7iHGpD8+Gbc5lZhZOPOtmfTJSybdWwo7P0uIA+5v nw2OIz8yCOB1kQ+IBoWa2qYrd11KuhOSiTCgjz8Jjm4+Tbl8Cf41Vg52NSUaa9pR0Tks pkC3Lt4M+d5mqE795NFN0OzGrct0KwdthHdOM6Z+6CVlf/5eQQtIf3ehLbgkfuqZc8TW LGTqI4HsD0RR6mx2SM2tRYFi+hbvTahsWpdHb5Bev/u13hAyTFgVlHtEXxkQ5BzcNmAl BuEeOlr0w8tDobCzI8GcOwgNnklK24cTNiXcD+JIsmWtWOcPcpqxO21EEftbMqyXTPz1 WWEg== 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=f2yaho1MPu8DxjHTSh8tZlOfFeJMX/ewZr/HG7aXcZW7DulWm/k9L1cAHxrlWh/LYM X9+RduuE7PGetPGnCtUbgP2pz80QQKxA/gjuX3sq/Z31OVIpi6SFdiXZkLu5OQ4cK2MB z1yH1wTTB1DqA54qGKhX8HnhXHEA0D9vvJaBQPo4SaH+IuVJdGnVjw+Z+qHWIBRaQ6Xf COjq6lF5zW9AWOzaUN0HsS09BrydjIartc36iTgBaHpWWUKK1H28xD/2XwHayf5lKwbV I3ZEOxtIvIxKMqd3MLtWLUIiVpLr8yvTCB6AQFJA0WO43aQILnPhr79xX/X8TM7QvOXZ FkgQ== X-Gm-Message-State: AOAM533ItKzTE4Qpi3TI8M0KAwekfVnFSkLcGNh0k+zzsgPFOlI3QY6E DxlhgbtY4fahjKnbAGo7nZZF/Q== X-Google-Smtp-Source: ABdhPJzz+UanoYeeFHEpf7tdaIQvpR4HprzsHsuIgK/sPHYRYz8bhbR5K4GsEWQ0YkbTx9slFOzW/g== X-Received: by 2002:a17:90a:930c:: with SMTP id p12mr12921445pjo.64.1590260290884; Sat, 23 May 2020 11:58:10 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58: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 09/12] xfs: flag files as supporting buffered async reads Date: Sat, 23 May 2020 12:57:52 -0600 Message-Id: <20200523185755.8494-10-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566953 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 95E3D60D for ; Sat, 23 May 2020 18:58:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7248520849 for ; Sat, 23 May 2020 18:58:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="SDURcEf2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729183AbgEWS6P (ORCPT ); Sat, 23 May 2020 14:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729005AbgEWS6M (ORCPT ); Sat, 23 May 2020 14:58:12 -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 95615C08C5C2 for ; Sat, 23 May 2020 11:58:12 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 124so374881pgi.9 for ; Sat, 23 May 2020 11:58:12 -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=SDURcEf2V5NO/4iU1aE24OeWSLHMCXpJdAgFrdnJEd7bIgxaZY8OsCWvWhzpOJOtb7 RA+oFu3X71L4OYZdo4lWYTXGqp8MWSeWkbW1ZPXTUNI/+Qc/A6l9IJVklr6G4fHvvyM2 eSkYQ36gSdm3LbIvrCiTfPKjmIT0uHzq657/N5EqmkFU1X3ShnSc8TgsHYOsTlmDtjbs fhQgttgwQveWyVOwYI4QoW4GE276osyEbPco1QcSxndNWxRvqeb591UYbiXTc10MOx29 fpGpdY3/b413xwsNy5DGpoifG0/dhZFZd2GrucUQb1vlwz2jFn1Z/Q8UTQqIGSSktfdg vdtQ== 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=UM35d60z7gJH3tApFvXxtF8rC50Tgn23AlgKO+wz6nAvE2Z2di8lAnJ/TBox7H8uzN nfdwnU5rgSZK3i1mAwcPMAaPzE0A+8h/n4bdRc/e7xjndD/5nEMA6Oo4pcdrGNuyzafv K2RpofpBWA3v0GvdjskobsGvShrjWAwG0Iixbl/Ex7ykGG4rPVddK6omHypEIbE7TlTT 0ggQ8rGjmMNhFRSoAZlRovjhHfSE+tKWkds9uGZiGVRHraMSuXBfwoJV7G5hIS8tnqAx b0CwdJJx7iw69j65JL60KyrRb1hjQQo+lZH28nXWVmQg1dLbB+G4R7rY/Zxwj5Ag4Uou W4aA== X-Gm-Message-State: AOAM532wPth0AEAfH6ZgaiRV3muKqrcnrNQBIEew7mCzrUL/mkIJCCsw RKsx78+MdLaGg10pJO71VFRUmw== X-Google-Smtp-Source: ABdhPJyltVIJNk8C4W/9AMto9tWC1IL7mnDA5eVGXtM6JkHvLgYtWln7h/t01grs2y91cUsPUSnHHA== X-Received: by 2002:a63:a36e:: with SMTP id v46mr19101914pgn.378.1590260292180; Sat, 23 May 2020 11:58:12 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58:11 -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/12] btrfs: flag files as supporting buffered async reads Date: Sat, 23 May 2020 12:57:53 -0600 Message-Id: <20200523185755.8494-11-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 18:57:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566955 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 95CF560D for ; Sat, 23 May 2020 18:58:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E04F20849 for ; Sat, 23 May 2020 18:58:32 +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="YC2Vfzsn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387965AbgEWS62 (ORCPT ); Sat, 23 May 2020 14:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729202AbgEWS6P (ORCPT ); Sat, 23 May 2020 14:58:15 -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 E4D2FC05BD43 for ; Sat, 23 May 2020 11:58:13 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id j21so6573771pgb.7 for ; Sat, 23 May 2020 11:58:13 -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=dAoC2D0g8n2nB3lVHnvM8l1E4Q5NdmCRN9F9KiRIdEU=; b=YC2VfzsnPeRpcE5DvmH1q7hRFR3ktyWmEBg1dhSrxX6BFoyD3fKdg4R2GLI95N/SE0 13pLuYLICLL5TpTf7k8tOQCbfcWAg+LSSWYlWJ1suwm0ov6o2L9xiYsqhC/dE4f5VSym icycAN5rixlSrfpPHHd9LLwl47FKj5W+W548LOgLrXWRYNWFtPZlt+gcRvbc5/F/zgL6 1FxFTEntDu/QcaUTMefGTsOHV6kxxyLa9N7whilVJyvdprYWKH11tzgAocRoJwCMs5sJ ORD5W6XVt276+iM8eGWGAHYZvutwMyV1kO9mZPyzKTsoS0Iqcx9DKWbS0Jhs1iPon9fh nHHw== 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=dAoC2D0g8n2nB3lVHnvM8l1E4Q5NdmCRN9F9KiRIdEU=; b=eQ7aodgfvzR6jLODJwXn0P/9E0Fyndiz5skIEe3Jcwy/lukXqz6ONGG2oo6PXxG1li pjzC73AqtlSX2v1mTDjEgZvjzi2EWtgO9c+9RZ5YDfM6cYBoZl0ky5/M/ozSRR+JDvaE nqhsRNd8qBaN5mxVuC9JNKD3Pq6iSsjYYVtf+d6QQ4/vpLGi6myd9HUgd6DpmhEEtmpm rV2xRU1TeIjKzGSJ5HEH7YxFcqWIYl6cMwJRnOxF7CsEFMHA3I2pfuiqixcy5YaSV2fs 3czA+4nh+T/pK2/eDTmltgOAmsJdJZYAhn4PLlzHtSptvgdhTIhag6mF9gTMExkY9PQc 5RLg== X-Gm-Message-State: AOAM531SFwzo26BwpalqZzcQ+tKQ0eMjz9xdftzqGe7OVHIotxJsseCC /Ud00Dpswmjf4Nk6N11d9vunnA== X-Google-Smtp-Source: ABdhPJzl0A8QaNkybc86UdHrH0/anQq6XTkgCYB3IwOB3AK5hnXDj+grn+woPDxbu3W68oqJ/gnDQg== X-Received: by 2002:a62:b618:: with SMTP id j24mr9943370pff.16.1590260293462; Sat, 23 May 2020 11:58:13 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58:12 -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/12] mm: add kiocb_wait_page_queue_init() helper Date: Sat, 23 May 2020 12:57:54 -0600 Message-Id: <20200523185755.8494-12-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 d3e63c9c61ae..def58de92053 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -493,6 +493,24 @@ 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) +{ + 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_queue *wait); From patchwork Sat May 23 18:57:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11566939 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 3E8151391 for ; Sat, 23 May 2020 18:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2688820FC3 for ; Sat, 23 May 2020 18:58:18 +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="E0uPtgkY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387569AbgEWS6R (ORCPT ); Sat, 23 May 2020 14:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728875AbgEWS6P (ORCPT ); Sat, 23 May 2020 14:58:15 -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 29B59C061A0E for ; Sat, 23 May 2020 11:58:15 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id z15so2952652pjb.0 for ; Sat, 23 May 2020 11:58:15 -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=GQtcjtwnU9F7a1xhLgA90kANNYHFVxRq3n7Obk4hkPQ=; b=E0uPtgkYhXBae4y7rlBd21x1yAP+XlS0DVODNinqmDmyAgdYw2RsQ25SLxSF6ERpv1 veDVT0mpV7fEOKRNLTGkblV6lALQZ7PV9rXDGl2Bb1su+TuWnaE6Jm8bR0c4ZKs+8Cm5 sg5/gBNyxUSGxZBGBWMQ/mEMbxvZQZqOzwFTA9uHjv1f7B4gDztH1Yeak04JrtR2nFET JA/Xt+M3L1U8nLvWKWmX/YQumQTeD9jpadLQqXeXEqrTZYyncyoQBYa/uE8q5T+CZuhK Q0VUcexOGDzE/0KhBGJz3nHdLRM0fCW1MUKHVHw/Au0TxS0SGODZlE1ydZI+ZkrfDc+p BIuA== 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=GQtcjtwnU9F7a1xhLgA90kANNYHFVxRq3n7Obk4hkPQ=; b=fInBtsfl6bMKuCLzMZuu0yUqMjfPP7kojixy6VpkqBygoA+weN1OPUTkB/eqA4SRbS Tb2/Aoe5cBaYq2lE+WW+VymB6l0ojtlFL2XGhzAGgG/2NdsCKLVFL+1+UZzBjCvfLTJZ s2c8UZ9B3TeqBk4bgLQMP9x0TnZLitZnryAMin1TSWYom6i2+VDtB6EU6W0sWWTRrQlf Zt61esis0LgDwwMxAOoYM04sNyWvrQWtS2uhcuu9iyW22RXAnmzLP7sVMsmOFC3kAeaA XWDElmpmc45+ryLpNMBWXZS3ORZo1r2v0M65XQxl0UCJeOhQqTFVleUittDE1bEfLG2x TPUg== X-Gm-Message-State: AOAM531jN52Aa0WuzRfnKSSascXt6nYzvXn7M85ziXEYfpPQLFRRyod8 xuEDUV2+ryXTi+uypvWwAu7MgA== X-Google-Smtp-Source: ABdhPJx4KsH8h/drBYUvQJv/Dz+r/aEgN2c8froIAby4k4P0elQuuxHZl85dOhwf7AOlLjolOCHVug== X-Received: by 2002:a17:902:bf08:: with SMTP id bi8mr19450469plb.319.1590260294621; Sat, 23 May 2020 11:58:14 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c94:a67a:9209:cf5f]) by smtp.gmail.com with ESMTPSA id 25sm9297319pjk.50.2020.05.23.11.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2020 11:58:14 -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 12/12] io_uring: support true async buffered reads, if file provides it Date: Sat, 23 May 2020 12:57:55 -0600 Message-Id: <20200523185755.8494-13-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200523185755.8494-1-axboe@kernel.dk> References: <20200523185755.8494-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 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index e95481c552ff..dd532d2634c2 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_queue wpq; + struct callback_head task_work; }; struct io_async_ctx { @@ -2568,6 +2570,99 @@ 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; + + /* 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_queue_init(kiocb, &req->io->rw.wpq, + 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 +2696,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 +2715,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; } }