From patchwork Sun May 24 19:21: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: 11567629 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 399B21391 for ; Sun, 24 May 2020 19:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 217F4207C3 for ; Sun, 24 May 2020 19:23: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="gxGduZqo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388169AbgEXTXK (ORCPT ); Sun, 24 May 2020 15:23:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387794AbgEXTWP (ORCPT ); Sun, 24 May 2020 15:22:15 -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 71C2EC08C5C0 for ; Sun, 24 May 2020 12:22:14 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id t8so5532769pju.3 for ; Sun, 24 May 2020 12:22:14 -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=gxGduZqosF0z63K53o9awU20QA6ufSZ5TTqRe+tv3AOsZ2QlQ979YXr+1dskXq52Jk HS3I9zTGgZsmogN4rJCO292dN+jQ4Bh81nqndOGDqgUTCuNwtxtCzXuJPlAMKQRJ58uA DuMNOBDX6nN/HrDjMdSSysjmoxpz5chCYgMsvnmdpOOufOk2jA7gdSzJR/TzXpAMz7Lj M0TIw38/7f79f2cKH+xUDuzBnClVTmIWWKOLweF65hex28srdE77jZIapgVeALrqEfAA ocGg0o8OhrW4mbtznbLks7cKK3H/ZDmHlmgcJ/0qYgXMDuB9nDi7913IThDZ9hVUMz+H 0p2w== 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=H4E/Hf8SbUE+dcSJECVVrSaBdlJ8Ymok1OST/WEvZLcqXMTvno7FBVBB7PgDWeM015 0aHPMnlAQi8GubBIY/jWhLi6vv4bvNpik9icTobLSHq8sZ8sTWMHfZ5U+WZQbGpRsHaw MIWaw/zDwbP6wl01qCM9OpbAFRmo20kDiYQ5ZDhA9v2ONLMGi4omr17XCVFeKbajSyhY OochGhqxNGwxMAd7Ck90Kh5K/9dRstVNKGAe3vGcd9/juYXBHwHYO6dRXMXqSmpzlPHI Gd8hq5iMo5nfdp4aoAgouNgd2A6QFaH8338/XsI3FTw9REq1mYlMtp26ny0eyX4o1Z8L /v4A== X-Gm-Message-State: AOAM531MMAWlwyZoeJconwLiymljnH4drwwT8Vv/jPsoOyxwRX9vHcrZ 72j95HYBqehCfczFzdOeCuFeA/DLki5d5Q== X-Google-Smtp-Source: ABdhPJyWrtKyXRFlA4SwqdiGTTumD68oCqrgZnBOzPkJTTFSdRxzhdggPB+vLC5MAtEqdrvZvv1y/Q== X-Received: by 2002:a17:90a:648c:: with SMTP id h12mr17363317pjj.229.1590348133979; Sun, 24 May 2020 12:22:13 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:13 -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: Sun, 24 May 2020 13:21:55 -0600 Message-Id: <20200524192206.4093-2-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:21:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567627 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 2BA861391 for ; Sun, 24 May 2020 19:23:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BAAF20878 for ; Sun, 24 May 2020 19:23:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="bDCsFlze" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388116AbgEXTXI (ORCPT ); Sun, 24 May 2020 15:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387826AbgEXTWQ (ORCPT ); Sun, 24 May 2020 15:22:16 -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 DF460C08C5C3 for ; Sun, 24 May 2020 12:22:15 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id w20so2751216pga.6 for ; Sun, 24 May 2020 12:22: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=TvoN8a3WZmoogVlnFEo2G3/jPQNtfJ5pQXb6VgaLeNI=; b=bDCsFlzea2K8l+p3JSI1FKOJJN/iUIQ6L4QBMlcQQkwdth5Qd6xp5WdxsO74qmE2uH gNIh1EyuSNq8TGu/O7ma6Wj3V0zQVtIidIFWIuCFLubWqKuzAP4PXDF1hJoA51/djpKI q0zvlwJNSsDn7/d8IsO90pLEvLJ4/fbpE/Esp7nnNDq8iVLb0/yXGjvGDO+gXoaiK0lQ 8jTWUcQ5PJFDyZ1LXgDYg/fHHLW/+H+ST/d/eQGYBajLlCJ8srz2A+h4hzgkD6xjzjC+ Z1Wx1Og3DGA+JcEdbltZrVLu3VUXQrBccs+OnB77TKzta8olRRUlXDRQ0OrpShyD+I8t TR5g== 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=qxbNC7vHcyLPEXt7XVNTX82+jOEiNAJomPPYEm2MqxkbGVVkRugtUElkQqcFfGlBbF ruEZAxXdBC32MDwN1ScH4hqPXcuurxf1olM7Jl6pXlU+EuEsaMa0s0Ke1ucrwmSMbDtN k1NzJ71xsABE3BS8fp4HlRccib5WqwUtNS9uP6jV2dofjJYByBn8VU08qNwXl97Ia9DH X0vKEbDlLBv6XqVjxwoGs5+v80GGIXHAZnQWLI1Z4rN7k4/WliDlaaBgwZjqHar8xo6Q UQm8C2bSgEHe4zd6AF0XtQ3HxCV9B6xjL/7vUQRkvee95hhhy4hNwj2wZeQ/IdQV4DRS flWQ== X-Gm-Message-State: AOAM531oHFuRde2Yl4Ah1AFi+cOE2zNUpRke8C0s1YziKqHAA07XjoIF v6V/u56sguOdNu+w3e4AopBy8g== X-Google-Smtp-Source: ABdhPJx6z/j631C9MW2+QGijdBHUqXND2T9T9W5iLJ8e7Bn0BROk5FXSSQIO1YnaN48IleZiosazmw== X-Received: by 2002:a63:e256:: with SMTP id y22mr23124889pgj.441.1590348135428; Sun, 24 May 2020 12:22:15 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22: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 02/12] mm: allow read-ahead with IOCB_NOWAIT set Date: Sun, 24 May 2020 13:21:56 -0600 Message-Id: <20200524192206.4093-3-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:21:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567623 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 B639060D for ; Sun, 24 May 2020 19:23:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9EF3C207C3 for ; Sun, 24 May 2020 19:23:01 +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="2Ls3+QLC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388186AbgEXTXB (ORCPT ); Sun, 24 May 2020 15:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388112AbgEXTWS (ORCPT ); Sun, 24 May 2020 15:22:18 -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 41DBAC08C5C0 for ; Sun, 24 May 2020 12:22:17 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id v2so2857485pfv.7 for ; Sun, 24 May 2020 12:22:17 -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=2Ls3+QLCLeno0jCON841EcWXGQKWPnDvCePQ3gzUcj9mNawaAgmwjotTCl0/7xbnda rfxeTUTHpN3qCYhSv6xAt8Ant4ZfpAttPgjaMPnqiBrqlKdjHbTCVwhoAj8/Hb970o35 6v3SO2V1GK52FaER0WaJA+/6MYb7O1/C9c2j1MWKSLceSlecvpDxRZr5wYCbQ3y3sT1F vp3sOzstbaxM5MzE8nggK0lWKSOdFNKCUjqvlIACct9959BpZmY5bBCc84O/BXO9klJw KD55lffQl2jrhCxficFT0VRaS/iOfhiJ8jApT9QjIGenWhJtjx7T0ZT6PipOddmqq97e PS3Q== 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=ah0mzpBIBp3D5eNTlZbefs8qKFvoLvnBDWOtceCmJKEmNiFTqqsYgdf4ZvlNe4VYPo jpWCL60Uj7lYJkFfhCHuiCQAACKD2Fne46cEHY+xeipnvFt/dYzcgmu9vxfm4cCsBlUQ uGqoWCrabAbDO2HZxMB/2PE8mfUosdml5PaIa+jHaC9lhB0KFrKJ4xqUdJhVwRfwmHGs XYdSP6/vngAZrFsaEYW50fBzoDL5T0H93/AyBllOFyNL+Lo9LybEq0vdKMiuIj100a4b 2ytHG5jggwPqNEsNhbLfBIl/8Y0VJ8WTJORMSNr4eN+E4rMlhm2vryISpy4nY5UP7jpz eWqg== X-Gm-Message-State: AOAM531bmlxk3vbaLZ4DGfnq5CI3ZQvHRN5qUYjN58+fXwEqmL7Y1B5c bx7UXhkxjGBFZEolQcqgT8qV6w== X-Google-Smtp-Source: ABdhPJyhydzeyBlKQCRTW6m8/JKp1oOARrRFIDQLFSR3T+UzUCwXLRBHN9D1E2V8YIjgAYJPFkMCtw== X-Received: by 2002:a63:dd0c:: with SMTP id t12mr23468725pgg.293.1590348136731; Sun, 24 May 2020 12:22:16 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:16 -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: Sun, 24 May 2020 13:21:57 -0600 Message-Id: <20200524192206.4093-4-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:21:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567587 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 C017160D for ; Sun, 24 May 2020 19:22:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A333A207C3 for ; Sun, 24 May 2020 19:22:22 +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="V4mIXVQF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388169AbgEXTWV (ORCPT ); Sun, 24 May 2020 15:22:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387744AbgEXTWT (ORCPT ); Sun, 24 May 2020 15:22:19 -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 9C171C061A0E for ; Sun, 24 May 2020 12:22:18 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id z64so3423148pfb.1 for ; Sun, 24 May 2020 12:22:18 -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=dRxVLULuo23vPsgtEWsGYGFpCYUxsZhIaT6u42Hql2E=; b=V4mIXVQFyA2xlU324aezgz7hoH5/kwrcukrZDA1MEw3qMNYi6vXFPLbiXDJ35lEn1M cz+I3E0aSOYnWOWKnM05PwTsEls9yrhFa1tZ/Oyxfddc2RtB03mcUSpferTg5lavJIqJ Dj5UTA49dxBRYaCq/zzgZHSotdJgYJMe4YTpXOUfPwjxszbv2+Rj3Diq6hu6rCdGQgeR jCdV/0Q2QAhgKJmNRqUY3HFNQUHsB+4Yt2ZVj5amRvJ7o3JkwGLTixFLXi1j/pnfGltP 8shg/8s9ZL/+mu2rqdj8zLMzh+R2KH1VtFdrw+ufEj28wz2kyOkdQqQeGPprP02KtqDR DvoA== 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=dRxVLULuo23vPsgtEWsGYGFpCYUxsZhIaT6u42Hql2E=; b=iWh1u/Aqjb6+R4g/5sDG32vCZT88Lrz1W+MBTWoPlj01/cYwHzCixN7nd2Z8GRGUaW NWjhX4PNWPufghsoWXq+pESS5uspNDdpKkqVchkoWMth6y1HlBSzuzRZJX7DbeakmB72 IRkYkRlVej5nKynNoIXYtCqVx3TSuZx2Yh19BiEa5b4viSqGYVD5q8UVAe8jHyPZduh9 NqXJS+H8bOSrrxQt6C29EeBh00eZ+HTM/mavF7veizaF4m0wweiJ25Autv8GNu6tiDS0 BKRJyVwYRlX51GERo3hxy967+STStJbLXkZO66+/6UR0dau6h5Oxx4vKedG8eV5Fincv FN5g== X-Gm-Message-State: AOAM531LVTTOec4R/zp7GvsIaW5CjH6N4MEBM1ZtZe2xEILwjbdH1t8s WZfKY2SEWz3rgkKojw8CCSWbFQ== X-Google-Smtp-Source: ABdhPJxHDlFcrCLi5owVvTlCdr8UZ55c4LZkRSpCvAXkOESdBdFKXVcEhLCnvkoAqx+qXu+nn3WEWg== X-Received: by 2002:a63:712:: with SMTP id 18mr22778908pgh.96.1590348138120; Sun, 24 May 2020 12:22:18 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:17 -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: Sun, 24 May 2020 13:21:58 -0600 Message-Id: <20200524192206.4093-5-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 | 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 7e84d823c6a8..5a5434ff7543 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 Sun May 24 19:21:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567589 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 38E471391 for ; Sun, 24 May 2020 19:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2221A20825 for ; Sun, 24 May 2020 19:22:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="OxFpYtFB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388154AbgEXTWW (ORCPT ); Sun, 24 May 2020 15:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388139AbgEXTWV (ORCPT ); Sun, 24 May 2020 15:22:21 -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 EDC49C08C5C4 for ; Sun, 24 May 2020 12:22:19 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id z64so3423165pfb.1 for ; Sun, 24 May 2020 12:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ooHBrOZD/3Y3JOqiI+j5WGnGx9rNLKp4UPlTrA3k0fA=; b=OxFpYtFBwzHltasPWMU+lcpGv4rU/W2vOx/T4krzJTwDePkK92WnP8Q9D4KmLLpY6f Gd2powlWYp6amNjj/pqEmErKe4G4P2gbejJam6uJcPC941s8l3j4LkrKcWofDhf2REGi YTJZ81xesGaQk5qxaVPuAbcllAJUCMysF5nbqjuG4CmorTuNG9vIpk0d1uNk8acf8Rff 1jlX4yGiljx2GdZ16Qma2k/cZGqRuC3kacJw2yDCzjvloXbodfZK/edA2Q6I/0OGROAn 1nP5uZaH7v6Ns2RKRSS6SiYvJFi0QZwo9hTw2Aqe4//xgAmUbZgp7F+hMebtqROV82zc 2Wlw== 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=W2fJJVB4I+e2HOXBRhDqrLnOZ2bWM9BRWYq12fzvwZxGp3pPUlBlTPX0RMqIsz3PUU FsBg1XXLnu2XNT6CZ7VEcsiYwX4pmONCnfA+2mY66kI2z0P3TmCQM/biJwGh9/UZFsJ3 lLN06zw4b3XyCEFg8i/+UPOq6+KPOU74KcXSjjFOKV5zhImq9t6yvKoooMKadZ1LOk5K iFjqHDk7t/olECreFzbDFbzzgcNU/3Grcv7oJiS4LAYW+LGiyQnAOuNz2qQwgEeWbx43 XlbOSpaDU4/Tt3693pUnY1dt/VjB4oNSI+Xx4+O9vveUh4JW+8+ZYsiGNCfVZvlJq4bu vZxQ== X-Gm-Message-State: AOAM530NA7Nsg8N3OJsuJawinMat7G4MRuqdkS0mWLzipIMQ4opmn0ep Vlt2EAGbdcTi4WO/9v9wbipbog== X-Google-Smtp-Source: ABdhPJwRpkNyoDLEGaBTPeF9s7BrdfA7F20JjdHpfn1NdnYqPnUj6c2W2tKIFVS9+VwQSQs0Ka0myQ== X-Received: by 2002:a63:381c:: with SMTP id f28mr22576826pga.361.1590348139455; Sun, 24 May 2020 12:22:19 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:18 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 05/12] mm: support async buffered reads in generic_file_buffered_read() Date: Sun, 24 May 2020 13:21:59 -0600 Message-Id: <20200524192206.4093-6-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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..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 Sun May 24 19:22:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567593 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 BBDA860D for ; Sun, 24 May 2020 19:22:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5743207C3 for ; Sun, 24 May 2020 19:22:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="rMshiG8E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388194AbgEXTWW (ORCPT ); Sun, 24 May 2020 15:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388151AbgEXTWV (ORCPT ); Sun, 24 May 2020 15:22:21 -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 4CB65C05BD43 for ; Sun, 24 May 2020 12:22:21 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id b190so7934553pfg.6 for ; Sun, 24 May 2020 12:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8utbws1RCqk2LlI7/gkB8i1cj/u48CIh6THWzODOXyg=; b=rMshiG8EIIFNL1uMBODlvvuf94bqJViNg5UM86151u5U7d6woOiNbIvEQgdvWkip2Z 4g9+5vHQOuzDMROosjj+bj6Blg/CLhLK5vEV3DBUFxBJkdjuCBSJsZRKwURHWVWuMvkG 8jOvtNQ6v64rSK/PJ1hg5+MO4hooCsE1eQwTAJTNiMD2VkHEx49zfrV59k1lyHvzxKNm tkmEJZl8YFSE/WZHCITDnBiis68jg0iqL//e/vmY2lJYseDiXfhsax3yzBXAV7qmApls ZMNQZ+Ki+d8QjYjq28AecXUf5Zy5QTI48QVIQDsbVIfZPAMh4PfdChp/zHXp9Qzbt71H d/xw== 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=8utbws1RCqk2LlI7/gkB8i1cj/u48CIh6THWzODOXyg=; b=P/4iIZQ81D7p2vDvo6rCAGB7UYoGP/+QTVg7Y/t3lF5erc+rjLdf6sMsoYSlUwwYSf NarDF1XHD6Qmvimr5u/pZQhi8y0QRmKyEJU1KEr0XyoEG8mD74PSW4FDdBfU9A9nK/ss n2u9JB2RDAhItwZMi18PhqsWddYFIGN03McxpmjTcYteHwwBIJMGbRbToU2SskwmX+uU vbnILOIaSt6ynR+t2n5SUPXKV6gYArsTl3/m91JcIN1kWsBFJQwkc/NDd0IvkQpDr1ua fUyCeZSQEmXT4yr40kDGVgPTkX992Arc+scOXaz38hVb8Wp2+vpGXTsItfj1GS5HmKw2 C3Gw== X-Gm-Message-State: AOAM532iFnoyGSSMqJcjxAaQIHWSrwe8z6TrRWsasfQEQXIhHGZ8cz8N v+8uFrBti2scqvLUKaxqExlPUg== X-Google-Smtp-Source: ABdhPJyYufZlJWGWTLeLNJcHAXoCD/f3jIKpvGkaNmPBexGhsJfRzmJtp4GI8lKYiNDw6AyYjV81Lg== X-Received: by 2002:a63:1312:: with SMTP id i18mr6502381pgl.142.1590348140858; Sun, 24 May 2020 12:22:20 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:20 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 06/12] fs: add FMODE_BUF_RASYNC Date: Sun, 24 May 2020 13:22:00 -0600 Message-Id: <20200524192206.4093-7-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 5a5434ff7543..f7b1eb765c6e 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 Sun May 24 19:22:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567621 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 B80511391 for ; Sun, 24 May 2020 19:22:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A04CD207C3 for ; Sun, 24 May 2020 19:22:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="NPeCR6em" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388337AbgEXTW6 (ORCPT ); Sun, 24 May 2020 15:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388186AbgEXTWW (ORCPT ); Sun, 24 May 2020 15:22:22 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EAD1C05BD43 for ; Sun, 24 May 2020 12:22:22 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id a13so6695619pls.8 for ; Sun, 24 May 2020 12:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7SUIxRwptQ6YWj2W/l7Dp7FzKmS+sjQ+qLVh2r/v7CQ=; b=NPeCR6emidz98WZUlUAJQJvu8yY4olakxpRVboFdYQ9gU2zAwBFJJgv8zDi2J9Q1YM Z/b4UhpnuDwQvV3ZhmPICnBIzrHFiyxbMWvdinwCY6jB6sMRYGOoel9XhNrjtee5mnQ5 rBuzYQwJFLAAE0y5sLi2JUrEug9+S+fE/nHUGUOdY7CfJCpAReJHQGMuN8qtMuJc7GsX go5TMWjy5nn8UQ5E/W9nuRIRQOaqHEr941b8sqWjEJA1JUGIPQCwN0jiwlzb5NeZnKm/ jEuNrO65+baf53dmU14kvWGMw+xqGw0WJypQDbPZWcbwZjTmK/SktWhKYi5H26vCKl7V k3Pw== 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=L5wCh1LPV5qhghm2CKXriUfTAqZK8xGPZvgmdo3zVr10LOam3Jut5odCaMdjWTepl5 9ZGpYNJt+zxh+KX1/F4U/7u7UwyrZLNsSYX+6Hk3oz4RmMYb6yFZ5zNqVzXkJQgx3Jcy 9tnq4po89ZpdVor2FnjIQk025zqZBM3BBT0HCmrBaC54MGeLxlBAKbYHtAN3/9ynccr6 IvTQb347S2qP0hM99jQQbZvE95PreFziixR7HnxU7lF2R4Dr3edusPv/nBekxSAkaFDX MqIkiPFzmvBdeimb1oiaMXTBxDt3AabitP90Zaf5nBGpXxyGEjLJvqfTr6J9AZUIfQjd CnzQ== X-Gm-Message-State: AOAM530Hw9955+SbzSKdYUbvvT5FafBYLvdMmL27siWLD3ZIHu6NhEBW 3sEzLfuvZetXZ9aU6QY7Br00Hp2yuiqC8w== X-Google-Smtp-Source: ABdhPJyVkJr3aVXSWL6AsAVEub8xJtYv78/J0qU/nA6EVR06VnyscVr47TXcn5OopxXRfYsxyeWx2w== X-Received: by 2002:a17:90a:d191:: with SMTP id fu17mr17281565pjb.228.1590348142170; Sun, 24 May 2020 12:22:22 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:21 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 07/12] ext4: flag as supporting buffered async reads Date: Sun, 24 May 2020 13:22:01 -0600 Message-Id: <20200524192206.4093-8-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:22:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567617 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 833651391 for ; Sun, 24 May 2020 19:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 629C7207C3 for ; Sun, 24 May 2020 19:22:45 +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="FrXCWih/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388222AbgEXTWZ (ORCPT ); Sun, 24 May 2020 15:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388212AbgEXTWY (ORCPT ); Sun, 24 May 2020 15:22:24 -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 D0EC9C08C5C2 for ; Sun, 24 May 2020 12:22:23 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id a13so6695633pls.8 for ; Sun, 24 May 2020 12:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4QX6izj81MoWvGB/E4/khaJEguGwrdsEfxjduXmAWvc=; b=FrXCWih/fqy5rFigNvFp2soetQnTjk3UWgjf1t5Fq9zUKajb6xucJmoe4faadG/Dmc Lj7A8hdDcSd7cwHUcnjgUu9TkCTHTVgWOuBdk6bdc2aSoswqnHSy3nb37tiShQKrRgwU kQGRSX/5Ki0ECJ1FKNiSS5m/Un75CkOharfLmwwahvohU6GmkkVM8hyoaWdv2bMn8DL+ UUnlV+L9+B+Jj9LPHpFsrshojMI4VFzFwwfeQ/C5Uc0g/CKzE2PcxT0SqhVO8/D14I3X LUxExRTj+3BF9xbf6ZL8baH0FFQafDwnYkxJYf311W2Wnbkzfk3xuzawz1p9wlX71+uX ZuyA== 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=evVOV8FNmWyS0zYFNqBpLzCiiYsvgF/DcGG1L/AR9jiOP5u4dB441Zky5MnRWeeFgS CF5YmjarMptDWAJA89tds2lTjKCCn0ecKYEgC/wVcDIIEJ9GIXVgMHsmLplkWcKXvIec 2HkmDNGnK9T/+NPAkI5aJJGtnd1dHNdw945rj+7VT5kZzcdXxAOCoKgA8OdOLl8mrjJU FAHncEL14IO6V2MhjFEg7PYvkMmgOeqil6u4X+0RkkJjX404lhQ6tSKZftHT41nqUth6 yxXGUDZbTVa/SB79/nt2N0OwneJnBf3MnLJoZ5BTYMZ2nD+H3Mxp7CCwKyEijB9DPFK2 lHwA== X-Gm-Message-State: AOAM532qXNNmIdZTlgsY7g05w+5UWco003Yf35d+yCyYEXcox09TA553 +HS1AdlN8tNn0fyd/wkQeC/Lyg== X-Google-Smtp-Source: ABdhPJyjDCYHAk0AUhemwGeKPxGqOTLpvrciZlQVB8VBWPs9J2AE+uiuLeGMBoKTiCckFgaWydI+aw== X-Received: by 2002:a17:90a:1303:: with SMTP id h3mr15729181pja.44.1590348143383; Sun, 24 May 2020 12:22:23 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:22 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 08/12] block: flag block devices as supporting IOCB_WAITQ Date: Sun, 24 May 2020 13:22:02 -0600 Message-Id: <20200524192206.4093-9-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:22:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567613 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 AEBB160D for ; Sun, 24 May 2020 19:22:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D86F20825 for ; Sun, 24 May 2020 19:22: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="AYei7bDK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388243AbgEXTW1 (ORCPT ); Sun, 24 May 2020 15:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388212AbgEXTW0 (ORCPT ); Sun, 24 May 2020 15:22:26 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA8CC061A0E for ; Sun, 24 May 2020 12:22:25 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id d3so6701299pln.1 for ; Sun, 24 May 2020 12:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=39qQrTBLEctUrGanLy/C45/WjdVfQkC7faPzmr+qhpI=; b=AYei7bDKo4OkFtepp3xg4zfIw0hnd0Ebv9o/8vOyKbFHZ8InT64M5SLPyKbX5X3sUK Fkh7pM1hAJFMjnux/MH3PsrYNU/IaoreI0I/UUZHTe9NxJWQKmxRBMtdWR0udtiIbeCb FbxxIyYfHNT7MeXwmxuPM/7LHoWK8VkstsOX8wEOu3N5XhIfsuTIrmRWTVi0+n8wkRb7 DNDwTBRW8SzP5mVNKj3+C6xyivFrnnJeUTG5ro7J3AmMh1Q5eZRP+8NIJUqmNnigS3cu DHQtC5SBLkYMeJN9r23BQVb8ndCYHRhxM7a0nMmr6b8oFKNZjU2N+KNcXWF6qvyESK5u YF5Q== 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=grloRgO4vrRyjHYvv/H0bCvgbrAcF8skoays0kKFsZh+YCURS0wXHXk43Lg3xc3IDz 7ev970AWKw9M3tbVQMTg3/Pvw5DrNArx2VzzfM8P5A/iqVv6/S3C9W89YLcJpdAsjG05 1vfdcuvFHc+ZcP1OtRalUz9vGT941YfOlLTnDSVEC8DY5EHnzo6tMv0DdFkL92zeWpZR hxJCWymEjXbeEZQ5kavYaRO9RQxO5Lays5f3yEDdV2IxjSolFl3B2RekChAK5TYQJoCK ay/Nut9qQ5EVgdWdyOHeEuGxs7M11nsCMQI38ZRDZKhhyJSo8rU0eS0tTxK+ppkF3rc9 N5AQ== X-Gm-Message-State: AOAM531yN7VRDr/A97HiFFdI2TS69HnzaeucmQqlu/sLhKu8wfCh/LRF BPhTp/hxfrBMF5A6xIvoM1p8WA== X-Google-Smtp-Source: ABdhPJz6bGpR32ObwKt+551KDTdoAZNVR9ZlVB3PlXK2+knHsCmS9S73FZQgm9i0pCo/tlaxVlOxZQ== X-Received: by 2002:a17:90a:2e8a:: with SMTP id r10mr6482101pjd.33.1590348144618; Sun, 24 May 2020 12:22:24 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:24 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 09/12] xfs: flag files as supporting buffered async reads Date: Sun, 24 May 2020 13:22:03 -0600 Message-Id: <20200524192206.4093-10-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:22:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567619 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 8A7C560D for ; Sun, 24 May 2020 19:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AE01207C3 for ; Sun, 24 May 2020 19:22:46 +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="uRHMeG7h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388127AbgEXTWp (ORCPT ); Sun, 24 May 2020 15:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388232AbgEXTW0 (ORCPT ); Sun, 24 May 2020 15:22:26 -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 57175C05BD43 for ; Sun, 24 May 2020 12:22:26 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id 5so7646604pjd.0 for ; Sun, 24 May 2020 12:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mDbeWlveWyEr17EututM6ewZlLrenoq+wrG4TB+c+O8=; b=uRHMeG7h0qyUWA7vuWqk7MVYR+0HFA9+hLVEVjHnDq9/bGqeemt5utvzvZZgUdnrIy U+lba7Qp6iQLZ4c8z3yex1xsl7NBK51bH9ntOiA1bzrAsnflM9kzXN7kNcJ7N0emlteQ f6PTLXDnlvMvkO0+xbsF0n3KM+R3esV6iaI/VrxgFuKg6m/QCwh29NieyfZ0bGIkLBzC N0tz472lFi/FcUthEq7qQBwQ8YXqMbnsRrwlnS1p3BAEfpEt6RqH5JLCBFEKqy0ijFcH WD0e0R9E3NAVkMWZKPvQJyEy1N1km2FpSHT2g5nK9H0/Uh1ImNoyNvY6xNut1BwqV9ew Tb8Q== 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=O221G0Y2NrL4ZtQ+68nHrxNIOWARxQoGzxBqcr8DU2p8p2qYc7UbL1luLT4E7yUVjp VMZ1eWYB4OL9I4dcjLa1HPEMOkk8sYSolczXPUG9TolewOhe/DZJoWOdTnWoof1pEaYz JYQ0pshAjCHszVittDCwpVjt3Q89wAmpc/UlFYuWm2G7UxU9oQN+4kpqGzQaqqyVof8J ZqM3lk564fzvP+73PvjezftLbrFtPJa5ChbTxOMU7Vn9she4tY5PKszNvXCZ7dOAITfT hstPf2J3PRHI03Dmp35J71lqcfkQTx0WnNBS1kMUf441K0qjd8TYlEIU+z6YLduGSDHg TgkA== X-Gm-Message-State: AOAM532334HxU09jzJd17+8TBTVo5UsUL3kSuLTATBufSRThbyBIzDoc 6f5WrSYYbwIuZTnHeoBZ8vvDXA== X-Google-Smtp-Source: ABdhPJx5oK/myeVn3bRCetPZQwQdNS3kfvzT2VTrfAxdR1BbKcm7G7xwvH5T6Twt2b9anXcaIgaOgg== X-Received: by 2002:a17:90a:fd85:: with SMTP id cx5mr16698146pjb.146.1590348145904; Sun, 24 May 2020 12:22:25 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:25 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 10/12] btrfs: flag files as supporting buffered async reads Date: Sun, 24 May 2020 13:22:04 -0600 Message-Id: <20200524192206.4093-11-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 Sun May 24 19:22:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567615 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 CA66D1391 for ; Sun, 24 May 2020 19:22:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2CC3207C3 for ; Sun, 24 May 2020 19:22: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="TglGLCKY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388029AbgEXTWk (ORCPT ); Sun, 24 May 2020 15:22:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388250AbgEXTW2 (ORCPT ); Sun, 24 May 2020 15:22:28 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC94C08C5C1 for ; Sun, 24 May 2020 12:22:27 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id f4so7764330pgi.10 for ; Sun, 24 May 2020 12:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=egusxH2Kf4IsegITvpm+Q3F8VxKliDk7k1e8lkissGM=; b=TglGLCKYUK3IUheNw2tbkabE4Tsvn6fX7wkDCP1B329i3fyJ7ym0/4jC6PlxFEJkCh xq1XNX2hwngAJ5RcbIVexVcP9jjvdaD9osyY+kMe+yMGUekQEI9NIpkmMfLWwshr5yaT 9x1b/h2VkjbTsRSyVybp3IKTaneYp2AbkvguvjSaI6bwG+QNsK/bdCW5gf+XuRt4xgqE Ve96sQETJ61P1rmIYCDy5zh+xyCExYatJgRwEB3WAFACCj4ZKPLryT+2Z3vNLi5FK4vI pcc4/jxFI1Biav3NYID6de289fcInGHFS4DS31EtXvYZlBGY5Kh1XFpLtfn3lKFAilan CVUQ== 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=X+c7stXaDYaQca8v5Yh7cdc214AjG9YuiFlUJwCYMNyHJDOJIWflRjTylhVFobXmFh +4Yi96O/9qMTFo+PPy1rNGUzIL6OIwejw63lybO1qUDv0kxTEs0xj+3lSOc3lPcQBPNF 0x/cN6m5VoFMGPyFk5WO/goTtQ1vntqmXI7v0mD1JeIJcvzIzfBoiDl06uR48d27HoIq nHYSvsz+UCQLOd+yF55Et2AFd2aMBdJYMq3bJzUXv250vr2pfD9s+syxcL8Qb9RbOBV1 UL4aiv2JCKUE5ijrxhDD70cVKNfkcHypOzgrniL0pqCkUtwfTqE7VxNN1ut1GghdobLh dR6A== X-Gm-Message-State: AOAM5314y5151EYrBrvQTiO8H45wyJRZEn01gLD02u5zROf8VIwMqW9V We11v+zQuGB+muex0q0U/kCJhL8eygs6MA== X-Google-Smtp-Source: ABdhPJxKr0QyshEARDFf894CnVwX/DlbGPjUKUr7q571X3XzSjjUdNUUq4yA3N0OBw7dm2okvEdSNw== X-Received: by 2002:a63:1d4:: with SMTP id 203mr22607763pgb.74.1590348147189; Sun, 24 May 2020 12:22:27 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:26 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 11/12] mm: add kiocb_wait_page_queue_init() helper Date: Sun, 24 May 2020 13:22:05 -0600 Message-Id: <20200524192206.4093-12-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 | 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 Sun May 24 19:22:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11567609 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 3CB8C1391 for ; Sun, 24 May 2020 19:22:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CFA620825 for ; Sun, 24 May 2020 19:22:39 +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="gwUf5uPg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388295AbgEXTWf (ORCPT ); Sun, 24 May 2020 15:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388252AbgEXTW3 (ORCPT ); Sun, 24 May 2020 15:22:29 -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 E8D2AC061A0E for ; Sun, 24 May 2020 12:22:28 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 23so7932519pfy.8 for ; Sun, 24 May 2020 12:22: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=kF6sqIhK1kfWOOpnyDDaJ/ad9nyWKxvOfw+GwZJVlBw=; b=gwUf5uPgRtpjmEmdekl/X9t1p9KbSX8a5FZv451K+HmJ+E2Dxys7Iv+FahH6uXL921 Rl0Y5qaKfAJ0eZcvKH/3dgpG1oRJgXwwEQ7iU6vxiUjCHxy0LS/4Ic8jVU2Eu3LjGmN+ rldYhIDm4b83DiavFv7abtxG5uSAqnGPy1LA2qmghBtOgoOmXtFwoiT5QoL4RP+GyKi5 1QI5nAo9rFdzTXerS1E2gsghoGegqw49q0HHU6kI2nExtUVM3eLuYmzJ1n/wMbwh8yfT eVLUkBm32Dohxe4j71zdA/Dwmp7n/74hzA14Gx+QYz6Ec4eNIJvrlpSZtpUFZSxOOiyo U7Fg== 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=kF6sqIhK1kfWOOpnyDDaJ/ad9nyWKxvOfw+GwZJVlBw=; b=fHBSaAJ2k4GsU0jvy8MecadUJIzENzycPsqNl+WKOi9A/z2VFfrcq4AoDtHJBL63rB /a7JqRjD2ZSg8xkPf+nH93aUIcF+20NVFKszBryDWInKUE2ZVSGTVLeGpwBHdpdA7vLH qUWFI0sWcNe37qE9E0P5cUawDHUBdYDVD7MRzfQQknZcGWwMNgx6/HBXuMPbBEcWZx9a WpxbdUxm1ivOFR9jjBbmrKihPW7fy8MNMbaXhRQanreU9yK0GxmtBz2b1XnlDy0dD4OQ sxiiaJeEoA4uNdVGpl9N/AJH45EoKH/H8r/sGgtm/Bj21p8zwCvOrjvFzIshhvqmMzwe gk5A== X-Gm-Message-State: AOAM530fsws6JoQiFMhc4W+nKa0umhKTn9q3//hVWGQjQXmf+hUJAGPD e7DEpYDMhS8eLKc17rxAsPCw1SaQ2qtC4g== X-Google-Smtp-Source: ABdhPJw949rfc/hqYgfl8eQoUT5vJ4BjzwrkpBKSe+ivpeT8GSGdsUzSxxCDQRY+v8G1lA3nTvPojA== X-Received: by 2002:a63:5b0e:: with SMTP id p14mr2275730pgb.43.1590348148417; Sun, 24 May 2020 12:22:28 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:c871:e701:52fa:2107]) by smtp.gmail.com with ESMTPSA id t21sm10312426pgu.39.2020.05.24.12.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 12:22:27 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jens Axboe Subject: [PATCH 12/12] io_uring: support true async buffered reads, if file provides it Date: Sun, 24 May 2020 13:22:06 -0600 Message-Id: <20200524192206.4093-13-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200524192206.4093-1-axboe@kernel.dk> References: <20200524192206.4093-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 | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index e95481c552ff..23073857239c 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,112 @@ 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_read(struct io_kiocb *req, bool force_nonblock) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; @@ -2601,6 +2709,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 +2728,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; } }