From patchwork Mon May 16 16:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8720C433EF for ; Mon, 16 May 2022 16:48:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F5E26B0071; Mon, 16 May 2022 12:48:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67E4A6B0072; Mon, 16 May 2022 12:48:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FC4A6B0074; Mon, 16 May 2022 12:48:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3E3696B0071 for ; Mon, 16 May 2022 12:48:34 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 09B2121C34 for ; Mon, 16 May 2022 16:48:34 +0000 (UTC) X-FDA: 79472189748.24.95DDF40 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf05.hostedemail.com (Postfix) with ESMTP id 84D611000A8 for ; Mon, 16 May 2022 16:48:11 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 24GFuohw010287 for ; Mon, 16 May 2022 09:48:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=RE5Ox9xrEwOzRKnjCVzMX1uqjY05JgL92w/a4ut+Iv0=; b=N8E6TStD7MRj3IhZgjcl/LRTtChYzn8nTonZVvZtFqJx8JBoyUlGMZC4zVxcEMd4HhuO ogc6Y605nXmqzC+WyBsfct70eXCr2CqekgoDJQD9HLA5hA2Xj1KWYUyljwkvbi7aV1HP 18VfjgSa47O3t+i9pk6JiPbpxXdLjnAsIjA= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3g27x9b0c6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:32 -0700 Received: from twshared8508.05.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:32 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 3B0C1F146DD1; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 01/16] block: add check for async buffered writes to generic_write_checks Date: Mon, 16 May 2022 09:47:03 -0700 Message-ID: <20220516164718.2419891-2-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 6rAP_8F6q_kOWyTF5_W8WMo1uLB47C2p X-Proofpoint-ORIG-GUID: 6rAP_8F6q_kOWyTF5_W8WMo1uLB47C2p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=N8E6TStD; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf05.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 84D611000A8 X-Rspam-User: X-Stat-Signature: yj6fzf5si6x1qycnx4z3xrpqph9npb6y X-HE-Tag: 1652719691-341520 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces the flag FMODE_BUF_WASYNC. If devices support async buffered writes, this flag can be set. It also modifies the check in generic_write_checks to take async buffered writes into consideration. Signed-off-by: Stefan Roesch --- fs/read_write.c | 3 ++- include/linux/fs.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/read_write.c b/fs/read_write.c index e643aec2b0ef..f75d75f7bc84 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1633,7 +1633,8 @@ int generic_write_checks_count(struct kiocb *iocb, loff_t *count) if (iocb->ki_flags & IOCB_APPEND) iocb->ki_pos = i_size_read(inode); - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) + if ((iocb->ki_flags & IOCB_NOWAIT) && + !((iocb->ki_flags & IOCB_DIRECT) || (file->f_mode & FMODE_BUF_WASYNC))) return -EINVAL; return generic_write_check_limits(iocb->ki_filp, iocb->ki_pos, count); diff --git a/include/linux/fs.h b/include/linux/fs.h index bbde95387a23..3b479d02e210 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -177,6 +177,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, /* File supports async buffered reads */ #define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000) +/* File supports async nowait buffered writes */ +#define FMODE_BUF_WASYNC ((__force fmode_t)0x80000000) + /* * Attribute flags. These should be or-ed together to figure out what * has been changed! From patchwork Mon May 16 16:47:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3563C433FE for ; Mon, 16 May 2022 16:48:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 743D56B0072; Mon, 16 May 2022 12:48:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A50B6B0074; Mon, 16 May 2022 12:48:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51FF46B0075; Mon, 16 May 2022 12:48:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3F9CC6B0072 for ; Mon, 16 May 2022 12:48:36 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 16C2C30D12 for ; Mon, 16 May 2022 16:48:36 +0000 (UTC) X-FDA: 79472189832.31.9456B47 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf09.hostedemail.com (Postfix) with ESMTP id D6318140041 for ; Mon, 16 May 2022 16:48:25 +0000 (UTC) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GGHCD7006198 for ; Mon, 16 May 2022 09:48:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=5kC+EaG8kC1NKMRTCYxqHhGLne8jSvz8PgxcvPIUop4=; b=NNrDPrekHFh8/hRBV4DG1HSO6+lYTlDlJTwP4RIGFFPSb1ymrGdMORfZamumZy2sTlyB Yebt9pO66VbOEaR5lEromYd34UgkpVJ7NcGAJnVFGAFXzDX6KFB7NbYjiafECG9a7a91 jiti1tPvMGPOwBXZSO2pqAiTo5Ta+HZikME= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g2a8u2m99-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:34 -0700 Received: from twshared6696.05.ash7.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c085:21d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:33 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 423C4F146DD3; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 02/16] iomap: add iomap_page_create_gfp to allocate iomap_pages Date: Mon, 16 May 2022 09:47:04 -0700 Message-ID: <20220516164718.2419891-3-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: ZftwLJ8DpZnt-e3jWM-owtuaxzdlNmZl X-Proofpoint-GUID: ZftwLJ8DpZnt-e3jWM-owtuaxzdlNmZl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Stat-Signature: 6he8adf476aq1h8j18i4hp6hxdmk3wrj X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D6318140041 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=NNrDPrek; spf=none (imf09.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-HE-Tag: 1652719705-410062 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add the function iomap_page_create_gfp() to be able to specify gfp flags and to pass in the number of blocks per folio in the function iomap_page_create_gfp(). No intended functional changes in this patch. Signed-off-by: Stefan Roesch --- fs/iomap/buffered-io.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 8ce8720093b9..85aa32f50db0 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -43,17 +43,27 @@ static inline struct iomap_page *to_iomap_page(struct folio *folio) static struct bio_set iomap_ioend_bioset; +/** + * iomap_page_create_gfp : Create and initialize iomap_page for folio. + * @inode : Pointer to inode + * @folio : Pointer to folio + * @nr_blocks : Number of blocks in the folio + * @gfp : gfp allocation flags + * + * This function returns a newly allocated iomap for the folio with the settings + * specified in the gfp parameter. + * + **/ static struct iomap_page * -iomap_page_create(struct inode *inode, struct folio *folio) +iomap_page_create_gfp(struct inode *inode, struct folio *folio, + unsigned int nr_blocks, gfp_t gfp) { - struct iomap_page *iop = to_iomap_page(folio); - unsigned int nr_blocks = i_blocks_per_folio(inode, folio); + struct iomap_page *iop; - if (iop || nr_blocks <= 1) + iop = kzalloc(struct_size(iop, uptodate, BITS_TO_LONGS(nr_blocks)), gfp); + if (!iop) return iop; - iop = kzalloc(struct_size(iop, uptodate, BITS_TO_LONGS(nr_blocks)), - GFP_NOFS | __GFP_NOFAIL); spin_lock_init(&iop->uptodate_lock); if (folio_test_uptodate(folio)) bitmap_fill(iop->uptodate, nr_blocks); @@ -61,6 +71,18 @@ iomap_page_create(struct inode *inode, struct folio *folio) return iop; } +static struct iomap_page * +iomap_page_create(struct inode *inode, struct folio *folio) +{ + struct iomap_page *iop = to_iomap_page(folio); + unsigned int nr_blocks = i_blocks_per_folio(inode, folio); + + if (iop || nr_blocks <= 1) + return iop; + + return iomap_page_create_gfp(inode, folio, nr_blocks, GFP_NOFS | __GFP_NOFAIL); +} + static void iomap_page_release(struct folio *folio) { struct iomap_page *iop = folio_detach_private(folio); From patchwork Mon May 16 16:47:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2B8DC433EF for ; Mon, 16 May 2022 16:48:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 437776B0074; Mon, 16 May 2022 12:48:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C1BB6B0075; Mon, 16 May 2022 12:48:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C5086B0078; Mon, 16 May 2022 12:48:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F37416B0074 for ; Mon, 16 May 2022 12:48:36 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D4F4821C5B for ; Mon, 16 May 2022 16:48:36 +0000 (UTC) X-FDA: 79472189832.04.834C211 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf06.hostedemail.com (Postfix) with ESMTP id BCB88180047 for ; Mon, 16 May 2022 16:48:33 +0000 (UTC) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 24GGBLOW005545 for ; Mon, 16 May 2022 09:48:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=DMxeTOpqCEe+Tvocr/V6khKpI6cObsPyGo88EBQxCYQ=; b=RpoCk+OMgk5qnqxR0wkNFB1Qmw37lZHA94WauSVkEYplpxcApNCtzDksIb9+kjQuH9Ys BiMRLp/xXvqL/QTqIrVIhURRfgj4OJPuVVgzCxkUV59DSEpBB+q+P8eMm9+RXYd9vo8E VC5Ze8DYVMdN4lTvFmK3NsK0pEe0gZRVNPA= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 3g283way8d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:35 -0700 Received: from twshared10276.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:34 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 48B43F146DD5; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 03/16] iomap: use iomap_page_create_gfp() in __iomap_write_begin Date: Mon, 16 May 2022 09:47:05 -0700 Message-ID: <20220516164718.2419891-4-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: mn7YDhIZvzlngp7Qb7x911MQ9Qxn0kGr X-Proofpoint-ORIG-GUID: mn7YDhIZvzlngp7Qb7x911MQ9Qxn0kGr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BCB88180047 X-Stat-Signature: cke5ody7kskjxs3g6bhq6f55bdy4y9gc X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=RpoCk+OM; spf=none (imf06.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719713-838553 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This change uses the new iomap_page_create_gfp() function in the function __iomap_write_begin(). No intended functional changes in this patch. Signed-off-by: Stefan Roesch --- fs/iomap/buffered-io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 85aa32f50db0..1ffdc7078e7d 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -572,17 +572,22 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos, size_t len, struct folio *folio) { const struct iomap *srcmap = iomap_iter_srcmap(iter); - struct iomap_page *iop = iomap_page_create(iter->inode, folio); + struct iomap_page *iop = to_iomap_page(folio); loff_t block_size = i_blocksize(iter->inode); loff_t block_start = round_down(pos, block_size); loff_t block_end = round_up(pos + len, block_size); + unsigned int nr_blocks = i_blocks_per_folio(iter->inode, folio); size_t from = offset_in_folio(folio, pos), to = from + len; size_t poff, plen; + gfp_t gfp = GFP_NOFS | __GFP_NOFAIL; if (folio_test_uptodate(folio)) return 0; folio_clear_error(folio); + if (!iop && nr_blocks > 1) + iop = iomap_page_create_gfp(iter->inode, folio, nr_blocks, gfp); + do { iomap_adjust_read_range(iter->inode, folio, &block_start, block_end - block_start, &poff, &plen); From patchwork Mon May 16 16:47:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851146 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFC08C433F5 for ; Mon, 16 May 2022 16:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D2926B007E; Mon, 16 May 2022 12:48:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 631476B007D; Mon, 16 May 2022 12:48:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4854D6B007E; Mon, 16 May 2022 12:48:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 12FC26B007D for ; Mon, 16 May 2022 12:48:39 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 92ABC614A5 for ; Mon, 16 May 2022 16:48:38 +0000 (UTC) X-FDA: 79472189916.03.79B6641 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf17.hostedemail.com (Postfix) with ESMTP id 20E64400C8 for ; Mon, 16 May 2022 16:48:14 +0000 (UTC) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GGYVws010872 for ; Mon, 16 May 2022 09:48:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=9jzwUncG3kNO+MRv998diITiMaJS+Sv/ZWH/LB7G0QY=; b=EGe/EZMbU+O3Zbt31iwCX4Kz81POhCB48ARAWIyXDqMCv1a5CMInAYdh2dgWAqT1iZXw 7YDDdzjaX4mEWIfcgVXMdzH/eAUeGvTkQtAAbUdUxonFYtEcUUC0uOsvomgQR3oRGpZ/ vNlSotGX69+EdjJPkQC5j8uMJ9WTPXf+1U0= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g2a5yaken-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:37 -0700 Received: from twshared35748.07.ash9.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:35 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 513F5F146DD7; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 04/16] iomap: add async buffered write support Date: Mon, 16 May 2022 09:47:06 -0700 Message-ID: <20220516164718.2419891-5-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 7t-XWmastXSqi4GcpFlGDngLAWF7Rmsu X-Proofpoint-GUID: 7t-XWmastXSqi4GcpFlGDngLAWF7Rmsu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Queue-Id: 20E64400C8 X-Stat-Signature: 31icqdhkmysdqhkjmt8s5phwfuffd5qg Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b="EGe/EZMb"; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf17.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com" X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652719694-792247 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds async buffered write support to iomap. The support is focused on the changes necessary to support XFS with iomap. Support for other filesystems might require additional changes. Signed-off-by: Stefan Roesch --- fs/iomap/buffered-io.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 1ffdc7078e7d..ceb3091f94c2 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -580,13 +580,20 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos, size_t from = offset_in_folio(folio, pos), to = from + len; size_t poff, plen; gfp_t gfp = GFP_NOFS | __GFP_NOFAIL; + bool no_wait = (iter->flags & IOMAP_NOWAIT); + + if (no_wait) + gfp = GFP_NOIO; if (folio_test_uptodate(folio)) return 0; folio_clear_error(folio); - if (!iop && nr_blocks > 1) + if (!iop && nr_blocks > 1) { iop = iomap_page_create_gfp(iter->inode, folio, nr_blocks, gfp); + if (no_wait && !iop) + return -EAGAIN; + } do { iomap_adjust_read_range(iter->inode, folio, &block_start, @@ -603,6 +610,8 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos, if (WARN_ON_ONCE(iter->flags & IOMAP_UNSHARE)) return -EIO; folio_zero_segments(folio, poff, from, to, poff + plen); + } else if (no_wait) { + return -EAGAIN; } else { int status = iomap_read_folio_sync(block_start, folio, poff, plen, srcmap); @@ -633,6 +642,9 @@ static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos, unsigned fgp = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE | FGP_NOFS; int status = 0; + if (iter->flags & IOMAP_NOWAIT) + fgp |= FGP_NOWAIT; + BUG_ON(pos + len > iter->iomap.offset + iter->iomap.length); if (srcmap != &iter->iomap) BUG_ON(pos + len > srcmap->offset + srcmap->length); @@ -790,6 +802,10 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) * Otherwise there's a nasty deadlock on copying from the * same page as we're writing to, without it being marked * up-to-date. + * + * For async buffered writes the assumption is that the user + * page has already been faulted in. This can be optimized by + * faulting the user page in the prepare phase of io-uring. */ if (unlikely(fault_in_iov_iter_readable(i, bytes) == bytes)) { status = -EFAULT; @@ -845,6 +861,9 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, }; int ret; + if (iocb->ki_flags & IOCB_NOWAIT) + iter.flags |= IOMAP_NOWAIT; + while ((ret = iomap_iter(&iter, ops)) > 0) iter.processed = iomap_write_iter(&iter, i); if (iter.pos == iocb->ki_pos) From patchwork Mon May 16 16:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6DC1C433EF for ; Mon, 16 May 2022 16:48:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0CEA6B0078; Mon, 16 May 2022 12:48:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E95E06B007B; Mon, 16 May 2022 12:48:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D36166B007D; Mon, 16 May 2022 12:48:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C04566B0078 for ; Mon, 16 May 2022 12:48:38 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 96FEB81463 for ; Mon, 16 May 2022 16:48:38 +0000 (UTC) X-FDA: 79472189916.25.B66A387 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf30.hostedemail.com (Postfix) with ESMTP id 9F46B800C0 for ; Mon, 16 May 2022 16:48:15 +0000 (UTC) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GB5rPa007155 for ; Mon, 16 May 2022 09:48:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=uSExTQp1mBOLjPITMmOyzTZ7pNScVBnQfYVTQnZots8=; b=lX7WyPky4+6RmHxwMJhWHxziMfeLQPlhWLW0+Iy8pVp9hLOSyewUNVkfgnfC/MX21S/7 0dlyIJmb0jGgXMPpXFzdN0iZHIIdb1KjTjOu8C/M5U+pz6+6asR5sX1tDjah5D06udbz Y8F92H7pHwS4vQTxFA3ZrMcAxbwsHyVM/tU= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g27rnu22b-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:36 -0700 Received: from twshared6696.05.ash7.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:35 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 58101F146DD9; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 05/16] xfs: add iomap async buffered write support Date: Mon, 16 May 2022 09:47:07 -0700 Message-ID: <20220516164718.2419891-6-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: XiaFRhqbJcxSaEITWJDNJxbIcSfUkT7o X-Proofpoint-GUID: XiaFRhqbJcxSaEITWJDNJxbIcSfUkT7o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9F46B800C0 X-Stat-Signature: f7m7drzudbi8689xyynrpor6uxrbxsx3 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=lX7WyPky; spf=none (imf30.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719695-944400 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the async buffered write support to the iomap layer of XFS. If a lock cannot be acquired or additional reads need to be performed, the request will return -EAGAIN in case this is an async buffered write request. This patch changes the helper function xfs_ilock_for_iomap such that the lock mode needs to be passed in. Signed-off-by: Stefan Roesch --- fs/xfs/xfs_iomap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index e552ce541ec2..1aea962262ad 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -659,7 +659,7 @@ xfs_ilock_for_iomap( unsigned flags, unsigned *lockmode) { - unsigned mode = XFS_ILOCK_SHARED; + unsigned int mode = *lockmode; bool is_write = flags & (IOMAP_WRITE | IOMAP_ZERO); /* @@ -737,7 +737,7 @@ xfs_direct_write_iomap_begin( int nimaps = 1, error = 0; bool shared = false; u16 iomap_flags = 0; - unsigned lockmode; + unsigned int lockmode = XFS_ILOCK_SHARED; ASSERT(flags & (IOMAP_WRITE | IOMAP_ZERO)); @@ -881,18 +881,22 @@ xfs_buffered_write_iomap_begin( bool eof = false, cow_eof = false, shared = false; int allocfork = XFS_DATA_FORK; int error = 0; + unsigned int lockmode = XFS_ILOCK_EXCL; if (xfs_is_shutdown(mp)) return -EIO; /* we can't use delayed allocations when using extent size hints */ - if (xfs_get_extsz_hint(ip)) + if (xfs_get_extsz_hint(ip)) { return xfs_direct_write_iomap_begin(inode, offset, count, flags, iomap, srcmap); + } ASSERT(!XFS_IS_REALTIME_INODE(ip)); - xfs_ilock(ip, XFS_ILOCK_EXCL); + error = xfs_ilock_for_iomap(ip, flags, &lockmode); + if (error) + return error; if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) || XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) { @@ -1167,7 +1171,7 @@ xfs_read_iomap_begin( xfs_fileoff_t end_fsb = xfs_iomap_end_fsb(mp, offset, length); int nimaps = 1, error = 0; bool shared = false; - unsigned lockmode; + unsigned int lockmode = XFS_ILOCK_SHARED; ASSERT(!(flags & (IOMAP_WRITE | IOMAP_ZERO))); From patchwork Mon May 16 16:47:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4711EC4332F for ; Mon, 16 May 2022 16:48:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65C6B6B007B; Mon, 16 May 2022 12:48:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E3726B007D; Mon, 16 May 2022 12:48:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 399AB6B0080; Mon, 16 May 2022 12:48:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 21F116B007B for ; Mon, 16 May 2022 12:48:40 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id E94C11214B9 for ; Mon, 16 May 2022 16:48:39 +0000 (UTC) X-FDA: 79472189958.08.1C203EE Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf02.hostedemail.com (Postfix) with ESMTP id 2DA3980008 for ; Mon, 16 May 2022 16:48:29 +0000 (UTC) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24G9vTN5008840 for ; Mon, 16 May 2022 09:48:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=ZB0I0bygTGrWfOs7D0mNHGqlVbLHHpR2apSClL45abY=; b=euqVurTK/gZEO85M875k+9xB1Qj3rwAcCydyzNZvix+svD/mTouDXWZeJ8dgDvHxGSFA k1vjJonSlB2OJ0Th4VvvtHdJaFx2STR55xu42cQtX+nOD4sE+VajDhFTQ1FEkKjLsu33 GlK4zG24OjuibZRUwb0vMlBOusEBeaAW2vk= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g27rnu22p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:38 -0700 Received: from twshared6696.05.ash7.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:21d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:37 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 5E6E2F146DDB; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 06/16] fs: split off need_remove_file_privs() do_remove_file_privs() Date: Mon, 16 May 2022 09:47:08 -0700 Message-ID: <20220516164718.2419891-7-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: BJYGfL_ylHhUwd8chv4FadnacUVMxkN9 X-Proofpoint-GUID: BJYGfL_ylHhUwd8chv4FadnacUVMxkN9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2DA3980008 X-Stat-Signature: o4ztmsec9jy6medh4ir7gnzgakptan35 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=euqVurTK; spf=none (imf02.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719709-981976 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This splits off the function need_remove_file_privs() from the function do_remove_file_privs() from the function file_remove_privs(). No intended functional changes in this patch. Signed-off-by: Stefan Roesch --- fs/inode.c | 57 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 9d9b422504d1..a6d70a1983f8 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2010,17 +2010,8 @@ static int __remove_privs(struct user_namespace *mnt_userns, return notify_change(mnt_userns, dentry, &newattrs, NULL); } -/* - * Remove special file priviledges (suid, capabilities) when file is written - * to or truncated. - */ -int file_remove_privs(struct file *file) +static int need_file_remove_privs(struct inode *inode, struct dentry *dentry) { - struct dentry *dentry = file_dentry(file); - struct inode *inode = file_inode(file); - int kill; - int error = 0; - /* * Fast path for nothing security related. * As well for non-regular files, e.g. blkdev inodes. @@ -2030,16 +2021,37 @@ int file_remove_privs(struct file *file) if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode)) return 0; - kill = dentry_needs_remove_privs(dentry); - if (kill < 0) - return kill; - if (kill) - error = __remove_privs(file_mnt_user_ns(file), dentry, kill); + return dentry_needs_remove_privs(dentry); +} + +static int do_file_remove_privs(struct file *file, struct inode *inode, + struct dentry *dentry, int kill) +{ + int error = 0; + + error = __remove_privs(file_mnt_user_ns(file), dentry, kill); if (!error) inode_has_no_xattr(inode); return error; } + +/* + * Remove special file privileges (suid, capabilities) when file is written + * to or truncated. + */ +int file_remove_privs(struct file *file) +{ + struct dentry *dentry = file_dentry(file); + struct inode *inode = file_inode(file); + int kill; + + kill = need_file_remove_privs(inode, dentry); + if (kill <= 0) + return kill; + + return do_file_remove_privs(file, inode, dentry, kill); +} EXPORT_SYMBOL(file_remove_privs); /** @@ -2093,15 +2105,22 @@ EXPORT_SYMBOL(file_update_time); /* Caller must hold the file's inode lock */ int file_modified(struct file *file) { - int err; + int ret; + struct dentry *dentry = file_dentry(file); + struct inode *inode = file_inode(file); /* * Clear the security bits if the process is not being run by root. * This keeps people from modifying setuid and setgid binaries. */ - err = file_remove_privs(file); - if (err) - return err; + ret = need_file_remove_privs(inode, dentry); + if (ret < 0) { + return ret; + } else if (ret > 0) { + ret = do_file_remove_privs(file, inode, dentry, ret); + if (ret) + return ret; + } if (unlikely(file->f_mode & FMODE_NOCMTIME)) return 0; From patchwork Mon May 16 16:47:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2EC9C4332F for ; Mon, 16 May 2022 16:48:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 633AD6B0081; Mon, 16 May 2022 12:48:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A3716B0082; Mon, 16 May 2022 12:48:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3984E6B0083; Mon, 16 May 2022 12:48:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 24A696B0081 for ; Mon, 16 May 2022 12:48:49 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 026F160772 for ; Mon, 16 May 2022 16:48:48 +0000 (UTC) X-FDA: 79472190378.31.C848F00 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf25.hostedemail.com (Postfix) with ESMTP id 1922DA009E for ; Mon, 16 May 2022 16:48:25 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 24GFibhJ016165 for ; Mon, 16 May 2022 09:48:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=ytINONjGb5g4AiCRPvl5zx2CjqhigNhOPZAk5ycuIEA=; b=V888tU8+rnxpRIkcK3Cwp13O4l7V8oOfFVTGIoGFzwDAqgLEkkMXYnKKk/7g90kgrdsc ZH3Uro3vm96cMB2mrgi1alyLZJDeITvN2aESHDbuTNz68yp4+AHReFVru0mDC4gT9te2 sccT0oQAk5zlKD3c6Va6fp0KPzuMw3P+IQc= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3g27x9b0e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:47 -0700 Received: from twshared10276.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::e) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:46 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 652D9F146DDD; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 07/16] fs: split off need_file_update_time and do_file_update_time Date: Mon, 16 May 2022 09:47:09 -0700 Message-ID: <20220516164718.2419891-8-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: cnuzZYMZQP7cHvIYKrCKriW6VD_RHcUO X-Proofpoint-ORIG-GUID: cnuzZYMZQP7cHvIYKrCKriW6VD_RHcUO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=V888tU8+; spf=none (imf25.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1922DA009E X-Stat-Signature: 16ghk6d9eo3m5umw59zpgjtqt4p38ofd X-HE-Tag: 1652719705-450278 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This splits off the functions need_file_update_time() and do_file_update_time() from the function file_update_time(). This is required to support async buffered writes. No intended functional changes in this patch. Signed-off-by: Stefan Roesch --- fs/inode.c | 71 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index a6d70a1983f8..1d0b02763e98 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2054,35 +2054,22 @@ int file_remove_privs(struct file *file) } EXPORT_SYMBOL(file_remove_privs); -/** - * file_update_time - update mtime and ctime time - * @file: file accessed - * - * Update the mtime and ctime members of an inode and mark the inode - * for writeback. Note that this function is meant exclusively for - * usage in the file write path of filesystems, and filesystems may - * choose to explicitly ignore update via this function with the - * S_NOCMTIME inode flag, e.g. for network filesystem where these - * timestamps are handled by the server. This can return an error for - * file systems who need to allocate space in order to update an inode. - */ - -int file_update_time(struct file *file) +static int need_file_update_time(struct inode *inode, struct file *file, + struct timespec64 *now) { - struct inode *inode = file_inode(file); - struct timespec64 now; int sync_it = 0; - int ret; + + if (unlikely(file->f_mode & FMODE_NOCMTIME)) + return 0; /* First try to exhaust all avenues to not sync */ if (IS_NOCMTIME(inode)) return 0; - now = current_time(inode); - if (!timespec64_equal(&inode->i_mtime, &now)) + if (!timespec64_equal(&inode->i_mtime, now)) sync_it = S_MTIME; - if (!timespec64_equal(&inode->i_ctime, &now)) + if (!timespec64_equal(&inode->i_ctime, now)) sync_it |= S_CTIME; if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode)) @@ -2091,15 +2078,49 @@ int file_update_time(struct file *file) if (!sync_it) return 0; + return sync_it; +} + +static int do_file_update_time(struct inode *inode, struct file *file, + struct timespec64 *now, int sync_mode) +{ + int ret; + /* Finally allowed to write? Takes lock. */ if (__mnt_want_write_file(file)) return 0; - ret = inode_update_time(inode, &now, sync_it); + ret = inode_update_time(inode, now, sync_mode); __mnt_drop_write_file(file); return ret; } + +/** + * file_update_time - update mtime and ctime time + * @file: file accessed + * + * Update the mtime and ctime members of an inode and mark the inode + * for writeback. Note that this function is meant exclusively for + * usage in the file write path of filesystems, and filesystems may + * choose to explicitly ignore update via this function with the + * S_NOCMTIME inode flag, e.g. for network filesystem where these + * timestamps are handled by the server. This can return an error for + * file systems who need to allocate space in order to update an inode. + */ + +int file_update_time(struct file *file) +{ + int err; + struct inode *inode = file_inode(file); + struct timespec64 now = current_time(inode); + + err = need_file_update_time(inode, file, &now); + if (err < 0) + return err; + + return do_file_update_time(inode, file, &now, err); +} EXPORT_SYMBOL(file_update_time); /* Caller must hold the file's inode lock */ @@ -2108,6 +2129,7 @@ int file_modified(struct file *file) int ret; struct dentry *dentry = file_dentry(file); struct inode *inode = file_inode(file); + struct timespec64 now = current_time(inode); /* * Clear the security bits if the process is not being run by root. @@ -2122,10 +2144,11 @@ int file_modified(struct file *file) return ret; } - if (unlikely(file->f_mode & FMODE_NOCMTIME)) - return 0; + ret = need_file_update_time(inode, file, &now); + if (ret <= 0) + return ret; - return file_update_time(file); + return do_file_update_time(inode, file, &now, ret); } EXPORT_SYMBOL(file_modified); From patchwork Mon May 16 16:47:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEE3BC4332F for ; Mon, 16 May 2022 16:48:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 633016B007D; Mon, 16 May 2022 12:48:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BAE56B0080; Mon, 16 May 2022 12:48:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 435386B0081; Mon, 16 May 2022 12:48:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2FD7B6B007D for ; Mon, 16 May 2022 12:48:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 08A841214BB for ; Mon, 16 May 2022 16:48:46 +0000 (UTC) X-FDA: 79472190252.25.5526267 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf22.hostedemail.com (Postfix) with ESMTP id 6BF2AC0048 for ; Mon, 16 May 2022 16:48:43 +0000 (UTC) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GDvXqO000579 for ; Mon, 16 May 2022 09:48:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=F0m1QmLNDQYiKaUS2R+sLft28q42+xh+blBDka8ibgQ=; b=ADZJyIrC6yEtr/AabhuuYoMTHD/5USOXxZ6P+RA/U7W/iYNBvkxpuCkGGLWdqld4PhXG L5mb3e/RmDOati8Z5yeLLZbskjWy4yHZr3jYRrDBX5BH+0rj93NMhHjp6nCcma1o8Te4 ET4/DqZ74OL+6/qYuyaMwj+zcpd+8Ijk7yQ= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g29xxjme1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:44 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:43 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 6B430F146DDF; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 08/16] fs: add pending file update time flag. Date: Mon, 16 May 2022 09:47:10 -0700 Message-ID: <20220516164718.2419891-9-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: srcP6OVdQyyeYuhBW1Pr2H5EALtRkGlO X-Proofpoint-ORIG-GUID: srcP6OVdQyyeYuhBW1Pr2H5EALtRkGlO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6BF2AC0048 X-Stat-Signature: io9bs3t4qxuuz6a7yjqqkqqu6f393t9k X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=ADZJyIrC; spf=none (imf22.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719723-965860 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces an optimization for the update time flag and async buffered writes. While an update of the file modification time is pending and is handled by the workers, concurrent writes do not need to wait for this time update to complete. Signed-off-by: Stefan Roesch --- fs/inode.c | 1 + include/linux/fs.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 1d0b02763e98..fd18b2c1b7c4 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2091,6 +2091,7 @@ static int do_file_update_time(struct inode *inode, struct file *file, return 0; ret = inode_update_time(inode, now, sync_mode); + inode->i_flags &= ~S_PENDING_TIME; __mnt_drop_write_file(file); return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index 3b479d02e210..3da641dfa6d9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2141,6 +2141,8 @@ struct super_operations { #define S_CASEFOLD (1 << 15) /* Casefolded file */ #define S_VERITY (1 << 16) /* Verity file (using fs/verity/) */ #define S_KERNEL_FILE (1 << 17) /* File is in use by the kernel (eg. fs/cachefiles) */ +#define S_PENDING_TIME (1 << 18) /* File update time is pending */ + /* * Note that nosuid etc flags are inode-specific: setting some file-system @@ -2183,6 +2185,7 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_ENCRYPTED(inode) ((inode)->i_flags & S_ENCRYPTED) #define IS_CASEFOLDED(inode) ((inode)->i_flags & S_CASEFOLD) #define IS_VERITY(inode) ((inode)->i_flags & S_VERITY) +#define IS_PENDING_TIME(inode) ((inode)->i_flags & S_PENDING_TIME) #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) From patchwork Mon May 16 16:47:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50FD6C43219 for ; Mon, 16 May 2022 16:48:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7473E6B0087; Mon, 16 May 2022 12:48:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A57F6B0083; Mon, 16 May 2022 12:48:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5201D6B0087; Mon, 16 May 2022 12:48:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 377896B0082 for ; Mon, 16 May 2022 12:48:50 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 0E4B381440 for ; Mon, 16 May 2022 16:48:50 +0000 (UTC) X-FDA: 79472190420.17.08B1B39 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf04.hostedemail.com (Postfix) with ESMTP id 492F1400CF for ; Mon, 16 May 2022 16:48:37 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 24GFibhM016165 for ; Mon, 16 May 2022 09:48:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=nn8G7Ds29e/TyBQLDgMvrLljDSKFPZQcqVlG8gvOL4c=; b=D7koE7U2o9BghY8UeNYKKZU4q+dyXMYIXbe+N77lQOlwRFPVh0eW6N75u1OPI27x43Gf 4ejEmBQL0NsZp2W5+/bNHAiiLQ4dvfroZywAH4JkHqMfIZrpkP4vD+1sg5l4kmBaO9S4 +7nm5mU6U3oT6AmRe9S8cl58PEYDBQfiW04= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3g27x9b0e9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:48 -0700 Received: from twshared10276.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::e) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:46 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 70F2FF146DE1; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 09/16] xfs: enable async write file modification handling. Date: Mon, 16 May 2022 09:47:11 -0700 Message-ID: <20220516164718.2419891-10-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 2_RYqDUDa1887W7AXcmiMMvWMaN6FS5M X-Proofpoint-ORIG-GUID: 2_RYqDUDa1887W7AXcmiMMvWMaN6FS5M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Stat-Signature: 7yc9pezoq4cxuoibioyhnpewddqdshd9 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 492F1400CF Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=D7koE7U2; spf=none (imf04.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-HE-Tag: 1652719717-198578 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This modifies xfs write checks to return -EAGAIN if the request either requires to remove privileges or needs to update the file modification time. This is required for async buffered writes, so the request gets handled in the io worker. Signed-off-by: Stefan Roesch --- fs/inode.c | 19 ++++++++++++++++++- fs/xfs/xfs_file.c | 2 +- include/linux/fs.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index fd18b2c1b7c4..40941feaec8d 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2126,6 +2126,13 @@ EXPORT_SYMBOL(file_update_time); /* Caller must hold the file's inode lock */ int file_modified(struct file *file) +{ + return file_modified_async(file, 0); +} +EXPORT_SYMBOL(file_modified); + +/* Caller must hold the file's inode lock */ +int file_modified_async(struct file *file, int flags) { int ret; struct dentry *dentry = file_dentry(file); @@ -2140,6 +2147,9 @@ int file_modified(struct file *file) if (ret < 0) { return ret; } else if (ret > 0) { + if (flags & IOCB_NOWAIT) + return -EAGAIN; + ret = do_file_remove_privs(file, inode, dentry, ret); if (ret) return ret; @@ -2148,10 +2158,17 @@ int file_modified(struct file *file) ret = need_file_update_time(inode, file, &now); if (ret <= 0) return ret; + if (flags & IOCB_NOWAIT) { + if (IS_PENDING_TIME(inode)) + return 0; + + inode->i_flags |= S_PENDING_TIME; + return -EAGAIN; + } return do_file_update_time(inode, file, &now, ret); } -EXPORT_SYMBOL(file_modified); +EXPORT_SYMBOL(file_modified_async); int inode_needs_sync(struct inode *inode) { diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 5bddb1e9e0b3..793918c83755 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -410,7 +410,7 @@ xfs_file_write_checks( spin_unlock(&ip->i_flags_lock); out: - return file_modified(file); + return file_modified_async(file, iocb->ki_flags); } static int diff --git a/include/linux/fs.h b/include/linux/fs.h index 3da641dfa6d9..5f3aaf61fb4b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2385,6 +2385,7 @@ static inline void file_accessed(struct file *file) } extern int file_modified(struct file *file); +extern int file_modified_async(struct file *file, int flags); int sync_inode_metadata(struct inode *inode, int wait); From patchwork Mon May 16 16:47:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6DB1C41535 for ; Mon, 16 May 2022 16:48:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E6476B0080; Mon, 16 May 2022 12:48:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 56E5D6B0081; Mon, 16 May 2022 12:48:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C2366B0082; Mon, 16 May 2022 12:48:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 207EF6B0080 for ; Mon, 16 May 2022 12:48:47 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EBCE921C29 for ; Mon, 16 May 2022 16:48:46 +0000 (UTC) X-FDA: 79472190252.20.583A2A7 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf29.hostedemail.com (Postfix) with ESMTP id 0BBE21200DD for ; Mon, 16 May 2022 16:48:37 +0000 (UTC) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GGA0uN004827 for ; Mon, 16 May 2022 09:48:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=LWT7/rgVKJvUBvBuLFTZOcg1EE8pCJNmk5mdhmfBzd4=; b=gZYxfK97wdUCGeLb5dvfu0lrsvtnU6sQ4ylHoOPsFriPUhIuHygm1DPCWIpRA2889ZF7 hFN+75O8pZjV+KEkHQDoqeqWWMc8VfEmjOFCWVRm0me5/L1B7g0lYTgUswB0dy1PuAgF 3jMXGvRdhk/Smye1vFnSNC++tvtejLNoryI= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g2a8u2mav-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:45 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:43 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 78798F146DE3; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 10/16] xfs: add async buffered write support Date: Mon, 16 May 2022 09:47:12 -0700 Message-ID: <20220516164718.2419891-11-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: ZAZeIpjM7dbQrrYliU4oL-9HNHZAIUY8 X-Proofpoint-GUID: ZAZeIpjM7dbQrrYliU4oL-9HNHZAIUY8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0BBE21200DD X-Stat-Signature: zzkjujg87wbaw9isbxndbacjj31g79rt X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=gZYxfK97; spf=none (imf29.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719717-796305 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the async buffered write support to XFS. For async buffered write requests, the request will return -EAGAIN if the ilock cannot be obtained immediately. This splits off a new helper xfs_ilock_inode from the existing helper xfs_ilock_iocb so it can be used for this function. The exising helper cannot be used as it hardcoded the inode to be used. Signed-off-by: Stefan Roesch --- fs/xfs/xfs_file.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 793918c83755..ad3175b7d366 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -190,14 +190,13 @@ xfs_file_fsync( return error; } -static int -xfs_ilock_iocb( - struct kiocb *iocb, +static inline int +xfs_ilock_xfs_inode( + struct xfs_inode *ip, + int flags, unsigned int lock_mode) { - struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); - - if (iocb->ki_flags & IOCB_NOWAIT) { + if (flags & IOCB_NOWAIT) { if (!xfs_ilock_nowait(ip, lock_mode)) return -EAGAIN; } else { @@ -222,7 +221,7 @@ xfs_file_dio_read( file_accessed(iocb->ki_filp); - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, XFS_IOLOCK_SHARED); if (ret) return ret; ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, 0, 0); @@ -244,7 +243,7 @@ xfs_file_dax_read( if (!iov_iter_count(to)) return 0; /* skip atime */ - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, XFS_IOLOCK_SHARED); if (ret) return ret; ret = dax_iomap_rw(iocb, to, &xfs_read_iomap_ops); @@ -264,7 +263,7 @@ xfs_file_buffered_read( trace_xfs_file_buffered_read(iocb, to); - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, XFS_IOLOCK_SHARED); if (ret) return ret; ret = generic_file_read_iter(iocb, to); @@ -343,7 +342,7 @@ xfs_file_write_checks( if (*iolock == XFS_IOLOCK_SHARED && !IS_NOSEC(inode)) { xfs_iunlock(ip, *iolock); *iolock = XFS_IOLOCK_EXCL; - error = xfs_ilock_iocb(iocb, *iolock); + error = xfs_ilock_xfs_inode(ip, iocb->ki_flags, *iolock); if (error) { *iolock = 0; return error; @@ -516,7 +515,7 @@ xfs_file_dio_write_aligned( int iolock = XFS_IOLOCK_SHARED; ssize_t ret; - ret = xfs_ilock_iocb(iocb, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); if (ret) return ret; ret = xfs_file_write_checks(iocb, from, &iolock); @@ -583,7 +582,7 @@ xfs_file_dio_write_unaligned( flags = IOMAP_DIO_FORCE_WAIT; } - ret = xfs_ilock_iocb(iocb, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); if (ret) return ret; @@ -659,7 +658,7 @@ xfs_file_dax_write( ssize_t ret, error = 0; loff_t pos; - ret = xfs_ilock_iocb(iocb, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); if (ret) return ret; ret = xfs_file_write_checks(iocb, from, &iolock); @@ -702,12 +701,11 @@ xfs_file_buffered_write( bool cleared_space = false; int iolock; - if (iocb->ki_flags & IOCB_NOWAIT) - return -EOPNOTSUPP; - write_retry: iolock = XFS_IOLOCK_EXCL; - xfs_ilock(ip, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); + if (ret) + return ret; ret = xfs_file_write_checks(iocb, from, &iolock); if (ret) From patchwork Mon May 16 16:47:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDA73C43217 for ; Mon, 16 May 2022 16:48:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A15316B0082; Mon, 16 May 2022 12:48:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94F8A8D0001; Mon, 16 May 2022 12:48:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BD336B0085; Mon, 16 May 2022 12:48:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3C7716B0083 for ; Mon, 16 May 2022 12:48:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 1532A1214A1 for ; Mon, 16 May 2022 16:48:50 +0000 (UTC) X-FDA: 79472190420.21.131BA96 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf21.hostedemail.com (Postfix) with ESMTP id 2FAFC1C0095 for ; Mon, 16 May 2022 16:48:39 +0000 (UTC) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24G40k8x017821 for ; Mon, 16 May 2022 09:48:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=fdXvE+WWGkZbdDWaaWcycrFeF07NZ6/Rt8YdakSfT7c=; b=BNEgrMDiGt3JuelVAO6zmhpCaZrTTQJya1mU512h9gW1L/l1G9VQ7piFoYN7rd7tkMLQ 8240OwI+Ot5CNadptvBncDbFXctvxbbAzCrLCoYeXiKKAHCuNOhY7OQzWBm7oQZF6aI9 ktZMocoDaVMnfP3+21ZE7//rwaXP1pE2fK4= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g27rnu242-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:48 -0700 Received: from twshared10276.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:46 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 7E299F146DE5; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 11/16] io_uring: add support for async buffered writes Date: Mon, 16 May 2022 09:47:13 -0700 Message-ID: <20220516164718.2419891-12-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: jQnCg9t8Ms9FcGr9ch6qf_ZhDPMjJBot X-Proofpoint-GUID: jQnCg9t8Ms9FcGr9ch6qf_ZhDPMjJBot X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=BNEgrMDi; spf=none (imf21.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2FAFC1C0095 X-Stat-Signature: 1hacc7j8qg7r6p4zz4icaj8k7n76y5ug X-HE-Tag: 1652719719-711814 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This enables the async buffered writes for the filesystems that support async buffered writes in io-uring. Buffered writes are enabled for blocks that are already in the page cache or can be acquired with noio. Signed-off-by: Stefan Roesch --- fs/io_uring.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 91de361ea9ab..f3aaac286509 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3746,7 +3746,7 @@ static inline int io_iter_do_read(struct io_kiocb *req, struct iov_iter *iter) return -EINVAL; } -static bool need_read_all(struct io_kiocb *req) +static bool need_complete_io(struct io_kiocb *req) { return req->flags & REQ_F_ISREG || S_ISBLK(file_inode(req->file)->i_mode); @@ -3875,7 +3875,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) } else if (ret == -EIOCBQUEUED) { goto out_free; } else if (ret == req->result || ret <= 0 || !force_nonblock || - (req->flags & REQ_F_NOWAIT) || !need_read_all(req)) { + (req->flags & REQ_F_NOWAIT) || !need_complete_io(req)) { /* read all, failed, already did sync or don't want to retry */ goto done; } @@ -3971,9 +3971,10 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags) if (unlikely(!io_file_supports_nowait(req))) goto copy_iov; - /* file path doesn't support NOWAIT for non-direct_IO */ - if (force_nonblock && !(kiocb->ki_flags & IOCB_DIRECT) && - (req->flags & REQ_F_ISREG)) + /* File path supports NOWAIT for non-direct_IO only for block devices. */ + if (!(kiocb->ki_flags & IOCB_DIRECT) && + !(kiocb->ki_filp->f_mode & FMODE_BUF_WASYNC) && + (req->flags & REQ_F_ISREG)) goto copy_iov; kiocb->ki_flags |= IOCB_NOWAIT; @@ -4027,6 +4028,24 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags) /* IOPOLL retry should happen for io-wq threads */ if (ret2 == -EAGAIN && (req->ctx->flags & IORING_SETUP_IOPOLL)) goto copy_iov; + + if (ret2 != req->result && ret2 >= 0 && need_complete_io(req)) { + struct io_async_rw *rw; + + /* This is a partial write. The file pos has already been + * updated, setup the async struct to complete the request + * in the worker. Also update bytes_done to account for + * the bytes already written. + */ + iov_iter_save_state(&s->iter, &s->iter_state); + ret = io_setup_async_rw(req, iovec, s, true); + + rw = req->async_data; + if (rw) + rw->bytes_done += ret2; + + return ret ? ret : -EAGAIN; + } done: kiocb_done(req, ret2, issue_flags); } else { From patchwork Mon May 16 16:47:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 145F1C433FE for ; Mon, 16 May 2022 16:48:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12A816B0083; Mon, 16 May 2022 12:48:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08E728D0001; Mon, 16 May 2022 12:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5BED6B0088; Mon, 16 May 2022 12:48:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B15506B0083 for ; Mon, 16 May 2022 12:48:51 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 900CE21C5B for ; Mon, 16 May 2022 16:48:51 +0000 (UTC) X-FDA: 79472190462.30.E17F32B Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf24.hostedemail.com (Postfix) with ESMTP id 1509118002A for ; Mon, 16 May 2022 16:48:40 +0000 (UTC) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GEaOPn028193 for ; Mon, 16 May 2022 09:48:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=95IBhF0kImkAgtFy9pvGGkvKxSMcZPFHzVuwJjta218=; b=J5H3334U8nQE+nIIeJJxiHMA2URK5rNv+mlmJPgIi2GmrINuOTwiwjIpwLolBXRi1oa0 1jINdLLVwinoxb+4yr9rwZwKTWTwArdsh4XZr59fUN6B4e/y2xPEOgtcfOpr8DjCsu9A F148IXT2LKBDOrePWybclVL48ym7cpkrQk0= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g29hu2rvr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:49 -0700 Received: from twshared35748.07.ash9.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:48 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 83FB7F146DE7; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 12/16] mm: factor out _balance_dirty_pages() from balance_dirty_pages() Date: Mon, 16 May 2022 09:47:14 -0700 Message-ID: <20220516164718.2419891-13-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: cdUKfUZ6CmLCYowUcbDm3tHYcFkRaQtR X-Proofpoint-GUID: cdUKfUZ6CmLCYowUcbDm3tHYcFkRaQtR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 1509118002A X-Stat-Signature: nj7eesxks6pifs5pjemfggs44qiymfhz Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=J5H3334U; spf=none (imf24.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719720-852152 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This factors out the for loop in balance_dirty_pages() into a new function called _balance_dirty_pages(). By factoring out this function the async write code can determine if it has to wait to throttle writes or not. The function _balance_dirty_pages() returns the sleep time. If the sleep time is greater 0, then the async write code needs to throttle. To maintain the context for consecutive calls of _balance_dirty_pages() and maintain the current behavior a new data structure called bdp_ctx has been introduced. Signed-off-by: Stefan Roesch --- mm/page-writeback.c | 452 +++++++++++++++++++++++--------------------- 1 file changed, 239 insertions(+), 213 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7e2da284e427..cbb74c0666c6 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -140,6 +140,29 @@ struct dirty_throttle_control { unsigned long pos_ratio; }; +/* context for consecutive calls to _balance_dirty_pages() */ +struct bdp_ctx { + long pause; + unsigned long now; + unsigned long start_time; + unsigned long task_ratelimit; + unsigned long dirty_ratelimit; + unsigned long nr_reclaimable; + int nr_dirtied_pause; + bool dirty_exceeded; + + struct dirty_throttle_control gdtc_stor; + struct dirty_throttle_control mdtc_stor; + struct dirty_throttle_control *sdtc; +} bdp_ctx; + +/* initialize _balance_dirty_pages() context */ +#define BDP_CTX_INIT(ctx, wb) \ + .gdtc_stor = { GDTC_INIT(wb) }, \ + .mdtc_stor = { MDTC_INIT(wb, &ctx.gdtc_stor) }, \ + .start_time = jiffies, \ + .dirty_exceeded = false + /* * Length of period for aging writeout fractions of bdis. This is an * arbitrarily chosen number. The longer the period, the slower fractions will @@ -1538,261 +1561,264 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) } } -/* - * balance_dirty_pages() must be called by processes which are generating dirty - * data. It looks at the number of dirty pages in the machine and will force - * the caller to wait once crossing the (background_thresh + dirty_thresh) / 2. - * If we're over `background_thresh' then the writeback threads are woken to - * perform some writeout. - */ -static void balance_dirty_pages(struct bdi_writeback *wb, - unsigned long pages_dirtied) +static inline int _balance_dirty_pages(struct bdi_writeback *wb, + unsigned long pages_dirtied, struct bdp_ctx *ctx) { - struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) }; - struct dirty_throttle_control mdtc_stor = { MDTC_INIT(wb, &gdtc_stor) }; - struct dirty_throttle_control * const gdtc = &gdtc_stor; - struct dirty_throttle_control * const mdtc = mdtc_valid(&mdtc_stor) ? - &mdtc_stor : NULL; - struct dirty_throttle_control *sdtc; - unsigned long nr_reclaimable; /* = file_dirty */ + struct dirty_throttle_control * const gdtc = &ctx->gdtc_stor; + struct dirty_throttle_control * const mdtc = mdtc_valid(&ctx->mdtc_stor) ? + &ctx->mdtc_stor : NULL; long period; - long pause; long max_pause; long min_pause; - int nr_dirtied_pause; - bool dirty_exceeded = false; - unsigned long task_ratelimit; - unsigned long dirty_ratelimit; struct backing_dev_info *bdi = wb->bdi; bool strictlimit = bdi->capabilities & BDI_CAP_STRICTLIMIT; - unsigned long start_time = jiffies; - for (;;) { - unsigned long now = jiffies; - unsigned long dirty, thresh, bg_thresh; - unsigned long m_dirty = 0; /* stop bogus uninit warnings */ - unsigned long m_thresh = 0; - unsigned long m_bg_thresh = 0; - - nr_reclaimable = global_node_page_state(NR_FILE_DIRTY); - gdtc->avail = global_dirtyable_memory(); - gdtc->dirty = nr_reclaimable + global_node_page_state(NR_WRITEBACK); + unsigned long dirty, thresh, bg_thresh; + unsigned long m_dirty = 0; /* stop bogus uninit warnings */ + unsigned long m_thresh = 0; + unsigned long m_bg_thresh = 0; - domain_dirty_limits(gdtc); + ctx->now = jiffies; + ctx->nr_reclaimable = global_node_page_state(NR_FILE_DIRTY); + gdtc->avail = global_dirtyable_memory(); + gdtc->dirty = ctx->nr_reclaimable + global_node_page_state(NR_WRITEBACK); - if (unlikely(strictlimit)) { - wb_dirty_limits(gdtc); + domain_dirty_limits(gdtc); - dirty = gdtc->wb_dirty; - thresh = gdtc->wb_thresh; - bg_thresh = gdtc->wb_bg_thresh; - } else { - dirty = gdtc->dirty; - thresh = gdtc->thresh; - bg_thresh = gdtc->bg_thresh; - } + if (unlikely(strictlimit)) { + wb_dirty_limits(gdtc); - if (mdtc) { - unsigned long filepages, headroom, writeback; + dirty = gdtc->wb_dirty; + thresh = gdtc->wb_thresh; + bg_thresh = gdtc->wb_bg_thresh; + } else { + dirty = gdtc->dirty; + thresh = gdtc->thresh; + bg_thresh = gdtc->bg_thresh; + } - /* - * If @wb belongs to !root memcg, repeat the same - * basic calculations for the memcg domain. - */ - mem_cgroup_wb_stats(wb, &filepages, &headroom, - &mdtc->dirty, &writeback); - mdtc->dirty += writeback; - mdtc_calc_avail(mdtc, filepages, headroom); - - domain_dirty_limits(mdtc); - - if (unlikely(strictlimit)) { - wb_dirty_limits(mdtc); - m_dirty = mdtc->wb_dirty; - m_thresh = mdtc->wb_thresh; - m_bg_thresh = mdtc->wb_bg_thresh; - } else { - m_dirty = mdtc->dirty; - m_thresh = mdtc->thresh; - m_bg_thresh = mdtc->bg_thresh; - } - } + if (mdtc) { + unsigned long filepages, headroom, writeback; /* - * Throttle it only when the background writeback cannot - * catch-up. This avoids (excessively) small writeouts - * when the wb limits are ramping up in case of !strictlimit. - * - * In strictlimit case make decision based on the wb counters - * and limits. Small writeouts when the wb limits are ramping - * up are the price we consciously pay for strictlimit-ing. - * - * If memcg domain is in effect, @dirty should be under - * both global and memcg freerun ceilings. + * If @wb belongs to !root memcg, repeat the same + * basic calculations for the memcg domain. */ - if (dirty <= dirty_freerun_ceiling(thresh, bg_thresh) && - (!mdtc || - m_dirty <= dirty_freerun_ceiling(m_thresh, m_bg_thresh))) { - unsigned long intv; - unsigned long m_intv; + mem_cgroup_wb_stats(wb, &filepages, &headroom, + &mdtc->dirty, &writeback); + mdtc->dirty += writeback; + mdtc_calc_avail(mdtc, filepages, headroom); -free_running: - intv = dirty_poll_interval(dirty, thresh); - m_intv = ULONG_MAX; + domain_dirty_limits(mdtc); - current->dirty_paused_when = now; - current->nr_dirtied = 0; - if (mdtc) - m_intv = dirty_poll_interval(m_dirty, m_thresh); - current->nr_dirtied_pause = min(intv, m_intv); - break; + if (unlikely(strictlimit)) { + wb_dirty_limits(mdtc); + m_dirty = mdtc->wb_dirty; + m_thresh = mdtc->wb_thresh; + m_bg_thresh = mdtc->wb_bg_thresh; + } else { + m_dirty = mdtc->dirty; + m_thresh = mdtc->thresh; + m_bg_thresh = mdtc->bg_thresh; } + } - if (unlikely(!writeback_in_progress(wb))) - wb_start_background_writeback(wb); + /* + * Throttle it only when the background writeback cannot + * catch-up. This avoids (excessively) small writeouts + * when the wb limits are ramping up in case of !strictlimit. + * + * In strictlimit case make decision based on the wb counters + * and limits. Small writeouts when the wb limits are ramping + * up are the price we consciously pay for strictlimit-ing. + * + * If memcg domain is in effect, @dirty should be under + * both global and memcg freerun ceilings. + */ + if (dirty <= dirty_freerun_ceiling(thresh, bg_thresh) && + (!mdtc || + m_dirty <= dirty_freerun_ceiling(m_thresh, m_bg_thresh))) { + unsigned long intv; + unsigned long m_intv; - mem_cgroup_flush_foreign(wb); +free_running: + intv = dirty_poll_interval(dirty, thresh); + m_intv = ULONG_MAX; + + current->dirty_paused_when = ctx->now; + current->nr_dirtied = 0; + if (mdtc) + m_intv = dirty_poll_interval(m_dirty, m_thresh); + current->nr_dirtied_pause = min(intv, m_intv); + return 0; + } + + if (unlikely(!writeback_in_progress(wb))) + wb_start_background_writeback(wb); + mem_cgroup_flush_foreign(wb); + + /* + * Calculate global domain's pos_ratio and select the + * global dtc by default. + */ + if (!strictlimit) { + wb_dirty_limits(gdtc); + + if ((current->flags & PF_LOCAL_THROTTLE) && + gdtc->wb_dirty < + dirty_freerun_ceiling(gdtc->wb_thresh, + gdtc->wb_bg_thresh)) + /* + * LOCAL_THROTTLE tasks must not be throttled + * when below the per-wb freerun ceiling. + */ + goto free_running; + } + + ctx->dirty_exceeded = (gdtc->wb_dirty > gdtc->wb_thresh) && + ((gdtc->dirty > gdtc->thresh) || strictlimit); + + wb_position_ratio(gdtc); + ctx->sdtc = gdtc; + + if (mdtc) { /* - * Calculate global domain's pos_ratio and select the - * global dtc by default. + * If memcg domain is in effect, calculate its + * pos_ratio. @wb should satisfy constraints from + * both global and memcg domains. Choose the one + * w/ lower pos_ratio. */ if (!strictlimit) { - wb_dirty_limits(gdtc); + wb_dirty_limits(mdtc); if ((current->flags & PF_LOCAL_THROTTLE) && - gdtc->wb_dirty < - dirty_freerun_ceiling(gdtc->wb_thresh, - gdtc->wb_bg_thresh)) + mdtc->wb_dirty < + dirty_freerun_ceiling(mdtc->wb_thresh, + mdtc->wb_bg_thresh)) /* - * LOCAL_THROTTLE tasks must not be throttled - * when below the per-wb freerun ceiling. + * LOCAL_THROTTLE tasks must not be + * throttled when below the per-wb + * freerun ceiling. */ goto free_running; } + ctx->dirty_exceeded |= (mdtc->wb_dirty > mdtc->wb_thresh) && + ((mdtc->dirty > mdtc->thresh) || strictlimit); - dirty_exceeded = (gdtc->wb_dirty > gdtc->wb_thresh) && - ((gdtc->dirty > gdtc->thresh) || strictlimit); + wb_position_ratio(mdtc); + if (mdtc->pos_ratio < gdtc->pos_ratio) + ctx->sdtc = mdtc; + } - wb_position_ratio(gdtc); - sdtc = gdtc; + if (ctx->dirty_exceeded && !wb->dirty_exceeded) + wb->dirty_exceeded = 1; - if (mdtc) { - /* - * If memcg domain is in effect, calculate its - * pos_ratio. @wb should satisfy constraints from - * both global and memcg domains. Choose the one - * w/ lower pos_ratio. - */ - if (!strictlimit) { - wb_dirty_limits(mdtc); - - if ((current->flags & PF_LOCAL_THROTTLE) && - mdtc->wb_dirty < - dirty_freerun_ceiling(mdtc->wb_thresh, - mdtc->wb_bg_thresh)) - /* - * LOCAL_THROTTLE tasks must not be - * throttled when below the per-wb - * freerun ceiling. - */ - goto free_running; - } - dirty_exceeded |= (mdtc->wb_dirty > mdtc->wb_thresh) && - ((mdtc->dirty > mdtc->thresh) || strictlimit); + if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) + + BANDWIDTH_INTERVAL)) + __wb_update_bandwidth(gdtc, mdtc, true); + + /* throttle according to the chosen dtc */ + ctx->dirty_ratelimit = READ_ONCE(wb->dirty_ratelimit); + ctx->task_ratelimit = ((u64)ctx->dirty_ratelimit * ctx->sdtc->pos_ratio) >> + RATELIMIT_CALC_SHIFT; + max_pause = wb_max_pause(wb, ctx->sdtc->wb_dirty); + min_pause = wb_min_pause(wb, max_pause, + ctx->task_ratelimit, ctx->dirty_ratelimit, + &ctx->nr_dirtied_pause); + + if (unlikely(ctx->task_ratelimit == 0)) { + period = max_pause; + ctx->pause = max_pause; + goto pause; + } + period = HZ * pages_dirtied / ctx->task_ratelimit; + ctx->pause = period; + if (current->dirty_paused_when) + ctx->pause -= ctx->now - current->dirty_paused_when; + /* + * For less than 1s think time (ext3/4 may block the dirtier + * for up to 800ms from time to time on 1-HDD; so does xfs, + * however at much less frequency), try to compensate it in + * future periods by updating the virtual time; otherwise just + * do a reset, as it may be a light dirtier. + */ + if (ctx->pause < min_pause) { + trace_balance_dirty_pages(wb, + ctx->sdtc->thresh, + ctx->sdtc->bg_thresh, + ctx->sdtc->dirty, + ctx->sdtc->wb_thresh, + ctx->sdtc->wb_dirty, + ctx->dirty_ratelimit, + ctx->task_ratelimit, + pages_dirtied, + period, + min(ctx->pause, 0L), + ctx->start_time); + if (ctx->pause < -HZ) { + current->dirty_paused_when = ctx->now; + current->nr_dirtied = 0; + } else if (period) { + current->dirty_paused_when += period; + current->nr_dirtied = 0; + } else if (current->nr_dirtied_pause <= pages_dirtied) + current->nr_dirtied_pause += pages_dirtied; + return 0; + } + if (unlikely(ctx->pause > max_pause)) { + /* for occasional dropped task_ratelimit */ + ctx->now += min(ctx->pause - max_pause, max_pause); + ctx->pause = max_pause; + } - wb_position_ratio(mdtc); - if (mdtc->pos_ratio < gdtc->pos_ratio) - sdtc = mdtc; - } +pause: + trace_balance_dirty_pages(wb, + ctx->sdtc->thresh, + ctx->sdtc->bg_thresh, + ctx->sdtc->dirty, + ctx->sdtc->wb_thresh, + ctx->sdtc->wb_dirty, + ctx->dirty_ratelimit, + ctx->task_ratelimit, + pages_dirtied, + period, + ctx->pause, + ctx->start_time); + + return ctx->pause; +} - if (dirty_exceeded && !wb->dirty_exceeded) - wb->dirty_exceeded = 1; - - if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) + - BANDWIDTH_INTERVAL)) - __wb_update_bandwidth(gdtc, mdtc, true); - - /* throttle according to the chosen dtc */ - dirty_ratelimit = READ_ONCE(wb->dirty_ratelimit); - task_ratelimit = ((u64)dirty_ratelimit * sdtc->pos_ratio) >> - RATELIMIT_CALC_SHIFT; - max_pause = wb_max_pause(wb, sdtc->wb_dirty); - min_pause = wb_min_pause(wb, max_pause, - task_ratelimit, dirty_ratelimit, - &nr_dirtied_pause); - - if (unlikely(task_ratelimit == 0)) { - period = max_pause; - pause = max_pause; - goto pause; - } - period = HZ * pages_dirtied / task_ratelimit; - pause = period; - if (current->dirty_paused_when) - pause -= now - current->dirty_paused_when; - /* - * For less than 1s think time (ext3/4 may block the dirtier - * for up to 800ms from time to time on 1-HDD; so does xfs, - * however at much less frequency), try to compensate it in - * future periods by updating the virtual time; otherwise just - * do a reset, as it may be a light dirtier. - */ - if (pause < min_pause) { - trace_balance_dirty_pages(wb, - sdtc->thresh, - sdtc->bg_thresh, - sdtc->dirty, - sdtc->wb_thresh, - sdtc->wb_dirty, - dirty_ratelimit, - task_ratelimit, - pages_dirtied, - period, - min(pause, 0L), - start_time); - if (pause < -HZ) { - current->dirty_paused_when = now; - current->nr_dirtied = 0; - } else if (period) { - current->dirty_paused_when += period; - current->nr_dirtied = 0; - } else if (current->nr_dirtied_pause <= pages_dirtied) - current->nr_dirtied_pause += pages_dirtied; +/* + * balance_dirty_pages() must be called by processes which are generating dirty + * data. It looks at the number of dirty pages in the machine and will force + * the caller to wait once crossing the (background_thresh + dirty_thresh) / 2. + * If we're over `background_thresh' then the writeback threads are woken to + * perform some writeout. + */ +static void balance_dirty_pages(struct bdi_writeback *wb, unsigned long pages_dirtied) +{ + int ret; + struct bdp_ctx ctx = { BDP_CTX_INIT(ctx, wb) }; + + for (;;) { + ret = _balance_dirty_pages(wb, current->nr_dirtied, &ctx); + if (!ret) break; - } - if (unlikely(pause > max_pause)) { - /* for occasional dropped task_ratelimit */ - now += min(pause - max_pause, max_pause); - pause = max_pause; - } -pause: - trace_balance_dirty_pages(wb, - sdtc->thresh, - sdtc->bg_thresh, - sdtc->dirty, - sdtc->wb_thresh, - sdtc->wb_dirty, - dirty_ratelimit, - task_ratelimit, - pages_dirtied, - period, - pause, - start_time); __set_current_state(TASK_KILLABLE); - wb->dirty_sleep = now; - io_schedule_timeout(pause); + wb->dirty_sleep = ctx.now; + io_schedule_timeout(ctx.pause); - current->dirty_paused_when = now + pause; + current->dirty_paused_when = ctx.now + ctx.pause; current->nr_dirtied = 0; - current->nr_dirtied_pause = nr_dirtied_pause; + current->nr_dirtied_pause = ctx.nr_dirtied_pause; /* * This is typically equal to (dirty < thresh) and can also * keep "1000+ dd on a slow USB stick" under control. */ - if (task_ratelimit) + if (ctx.task_ratelimit) break; /* @@ -1805,14 +1831,14 @@ static void balance_dirty_pages(struct bdi_writeback *wb, * more page. However wb_dirty has accounting errors. So use * the larger and more IO friendly wb_stat_error. */ - if (sdtc->wb_dirty <= wb_stat_error()) + if (ctx.sdtc->wb_dirty <= wb_stat_error()) break; if (fatal_signal_pending(current)) break; } - if (!dirty_exceeded && wb->dirty_exceeded) + if (!ctx.dirty_exceeded && wb->dirty_exceeded) wb->dirty_exceeded = 0; if (writeback_in_progress(wb)) @@ -1829,7 +1855,7 @@ static void balance_dirty_pages(struct bdi_writeback *wb, if (laptop_mode) return; - if (nr_reclaimable > gdtc->bg_thresh) + if (ctx.nr_reclaimable > ctx.gdtc_stor.bg_thresh) wb_start_background_writeback(wb); } From patchwork Mon May 16 16:47:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC472C433EF for ; Mon, 16 May 2022 16:48:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3ECD48D0003; Mon, 16 May 2022 12:48:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3741C8D0001; Mon, 16 May 2022 12:48:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19D288D0003; Mon, 16 May 2022 12:48:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0201C8D0001 for ; Mon, 16 May 2022 12:48:57 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CE8CE33F31 for ; Mon, 16 May 2022 16:48:56 +0000 (UTC) X-FDA: 79472190672.19.A028D46 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf03.hostedemail.com (Postfix) with ESMTP id 9D20420092 for ; Mon, 16 May 2022 16:48:46 +0000 (UTC) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GF657Y019213 for ; Mon, 16 May 2022 09:48:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=T6Nf5vvbSAgD76rs2Ks0JXOmFetMmsycSIKG8Fv6YWk=; b=C4vXe1DOYARU4E6ZwAe57ojhYXfaaT32ISu+1SkIAi2q2CQgsHeXVxYNDoJVrHVwhmYJ gEM6sQWDB6eMOmpKdS+g2K0uXxITuWsg4of1/sqhFJsYO59o8GuM8cohXQS7Fr8YPfcP hslOIdmb35IXVQfZqmJCGv1blE9eWw5wL3Y= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g2a4ntn7e-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:55 -0700 Received: from twshared10276.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:53 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 8986BF146DE9; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 13/16] mm: add balance_dirty_pages_ratelimited_flags() function Date: Mon, 16 May 2022 09:47:15 -0700 Message-ID: <20220516164718.2419891-14-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: XeHPmxlHh7cwMCA6VLFk9sczFMvJfnD9 X-Proofpoint-ORIG-GUID: XeHPmxlHh7cwMCA6VLFk9sczFMvJfnD9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9D20420092 X-Stat-Signature: xa1cfa91bfhmfpq4dhj7c6qsa5rgi6g7 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=C4vXe1DO; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf03.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com" X-Rspam-User: X-HE-Tag: 1652719726-20295 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the function balance_dirty_pages_ratelimited_flags(). It adds the parameter is_async to balance_dirty_pages_ratelimited(). In case this is an async write, it will call _balance_diirty_pages() to determine if write throttling needs to be enabled. If write throttling is enabled, it retuns -EAGAIN, so the write request can be punted to the io-uring worker. The new function is changed to return the sleep time, so callers can observe if the write has been punted. For non-async writes the current behavior is maintained. Signed-off-by: Stefan Roesch --- include/linux/writeback.h | 1 + mm/page-writeback.c | 48 ++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index fec248ab1fec..d589804bb3be 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -373,6 +373,7 @@ unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh); void wb_update_bandwidth(struct bdi_writeback *wb); void balance_dirty_pages_ratelimited(struct address_space *mapping); +int balance_dirty_pages_ratelimited_flags(struct address_space *mapping, bool is_async); bool wb_over_bg_thresh(struct bdi_writeback *wb); typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc, diff --git a/mm/page-writeback.c b/mm/page-writeback.c index cbb74c0666c6..78f1326f3f20 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1877,28 +1877,17 @@ static DEFINE_PER_CPU(int, bdp_ratelimits); */ DEFINE_PER_CPU(int, dirty_throttle_leaks) = 0; -/** - * balance_dirty_pages_ratelimited - balance dirty memory state - * @mapping: address_space which was dirtied - * - * Processes which are dirtying memory should call in here once for each page - * which was newly dirtied. The function will periodically check the system's - * dirty state and will initiate writeback if needed. - * - * Once we're over the dirty memory limit we decrease the ratelimiting - * by a lot, to prevent individual processes from overshooting the limit - * by (ratelimit_pages) each. - */ -void balance_dirty_pages_ratelimited(struct address_space *mapping) +int balance_dirty_pages_ratelimited_flags(struct address_space *mapping, bool is_async) { struct inode *inode = mapping->host; struct backing_dev_info *bdi = inode_to_bdi(inode); struct bdi_writeback *wb = NULL; int ratelimit; + int ret = 0; int *p; if (!(bdi->capabilities & BDI_CAP_WRITEBACK)) - return; + return ret; if (inode_cgwb_enabled(inode)) wb = wb_get_create_current(bdi, GFP_KERNEL); @@ -1937,10 +1926,37 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) } preempt_enable(); - if (unlikely(current->nr_dirtied >= ratelimit)) - balance_dirty_pages(wb, current->nr_dirtied); + if (unlikely(current->nr_dirtied >= ratelimit)) { + if (is_async) { + struct bdp_ctx ctx = { BDP_CTX_INIT(ctx, wb) }; + + ret = _balance_dirty_pages(wb, current->nr_dirtied, &ctx); + if (ret) + ret = -EAGAIN; + } else { + balance_dirty_pages(wb, current->nr_dirtied); + } + } wb_put(wb); + return ret; +} + +/** + * balance_dirty_pages_ratelimited - balance dirty memory state + * @mapping: address_space which was dirtied + * + * Processes which are dirtying memory should call in here once for each page + * which was newly dirtied. The function will periodically check the system's + * dirty state and will initiate writeback if needed. + * + * Once we're over the dirty memory limit we decrease the ratelimiting + * by a lot, to prevent individual processes from overshooting the limit + * by (ratelimit_pages) each. + */ +void balance_dirty_pages_ratelimited(struct address_space *mapping) +{ + balance_dirty_pages_ratelimited_flags(mapping, false); } EXPORT_SYMBOL(balance_dirty_pages_ratelimited); From patchwork Mon May 16 16:47:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A736BC433F5 for ; Mon, 16 May 2022 16:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2408D8D0002; Mon, 16 May 2022 12:48:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 176998D0001; Mon, 16 May 2022 12:48:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F318D8D0002; Mon, 16 May 2022 12:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DA0008D0001 for ; Mon, 16 May 2022 12:48:54 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AB61F33F37 for ; Mon, 16 May 2022 16:48:54 +0000 (UTC) X-FDA: 79472190588.30.F239FAD Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf25.hostedemail.com (Postfix) with ESMTP id D4517A002C for ; Mon, 16 May 2022 16:48:31 +0000 (UTC) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GFXdSl008181 for ; Mon, 16 May 2022 09:48:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=4KklUZPFX9fktoVM6Kmf3n/HljyGufq7o2WF5gt1Xgo=; b=dm8EctE0QrZ0gN2+q2lq3cWBuC/W5vK89F/UPK9Gpq1bhKUKogfBhL239fCCI5iMbQbR Zo+PVcuq8LckfaY6jHFgMDhcjRMnfhxW4Wwf6oYoYnYHV6vEaiOT372VxtsmoGk89JLA QRuS3+O6B/Hw9m9mh6GxXQZW6yOrdojJP0g= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g29xxjmf6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:53 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:51 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 8FF8FF146DEB; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 14/16] iomap: use balance_dirty_pages_ratelimited_flags in iomap_write_iter Date: Mon, 16 May 2022 09:47:16 -0700 Message-ID: <20220516164718.2419891-15-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: aQYloltHC1RxbDnAUKytFzNPWSdZV9iK X-Proofpoint-ORIG-GUID: aQYloltHC1RxbDnAUKytFzNPWSdZV9iK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D4517A002C X-Stat-Signature: xbdyqazgrwjzxw6jdhg91mtsg1x4334w X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=dm8EctE0; spf=none (imf25.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719711-46502 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This replaces the call to balance_dirty_pages_ratelimited() with the call to balance_dirty_pages_ratelimited_flags. This allows to specify if the write request is async or not. In addition this also moves the above function call to the beginning of the function. If the function call is at the end of the function and the decision is made to throttle writes, then there is no request that io-uring can wait on. By moving it to the beginning of the function, the write request is not issued, but returns -EAGAIN instead. io-uring will punt the request and process it in the io-worker. By moving the function call to the beginning of the function, the write throttling will happen one page later. Signed-off-by: Stefan Roesch --- fs/iomap/buffered-io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ceb3091f94c2..41a8e0bb2edd 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -794,6 +794,11 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) bytes = min_t(unsigned long, PAGE_SIZE - offset, iov_iter_count(i)); again: + status = balance_dirty_pages_ratelimited_flags(iter->inode->i_mapping, + (iter->flags & IOMAP_NOWAIT)); + if (unlikely(status)) + break; + if (bytes > length) bytes = length; @@ -842,8 +847,6 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) pos += status; written += status; length -= status; - - balance_dirty_pages_ratelimited(iter->inode->i_mapping); } while (iov_iter_count(i) && length); return written ? written : status; From patchwork Mon May 16 16:47:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 121CAC4332F for ; Mon, 16 May 2022 16:49:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 410538D0006; Mon, 16 May 2022 12:49:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C0588D0001; Mon, 16 May 2022 12:49:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E9D28D0006; Mon, 16 May 2022 12:49:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 03BE68D0001 for ; Mon, 16 May 2022 12:49:01 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B66DB6074B for ; Mon, 16 May 2022 16:49:00 +0000 (UTC) X-FDA: 79472190840.21.A2C9090 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf30.hostedemail.com (Postfix) with ESMTP id DCE2D80007 for ; Mon, 16 May 2022 16:48:37 +0000 (UTC) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GF657f019213 for ; Mon, 16 May 2022 09:48:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=UfD+h75jLCqmGcJIFVAad9rZN/r0VFdoC8EFOxTjfII=; b=iBjfdjKIckUqPOiHMiTPrsdQLxAb0+TVDGQA2Lrt08VvQKUQiwKmJOBIejPS/03K/diA eBhaHHA3rgRtRpJpgARe7F1z0aMCTAcwLOfDiGCFjkYrwVjIREVkiZMhwzdc0YEi9kDt KaaMo+6PAh21yuEM8s+tZZAdS5PDAgR4mz8= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g2a4ntn7e-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:59 -0700 Received: from twshared10276.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:55 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 9586DF146DED; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 15/16] io_uring: add tracepoint for short writes Date: Mon, 16 May 2022 09:47:17 -0700 Message-ID: <20220516164718.2419891-16-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: v2i1rrE6hepQw0KNXHXc0u2n_ey5q6NN X-Proofpoint-ORIG-GUID: v2i1rrE6hepQw0KNXHXc0u2n_ey5q6NN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Stat-Signature: or975xa3eidfe7ns6h7aek16dxtuwcdm X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DCE2D80007 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=iBjfdjKI; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf30.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com" X-HE-Tag: 1652719717-220815 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the io_uring_short_write tracepoint to io_uring. A short write is issued if not all pages that are required for a write are in the page cache and the async buffered writes have to return EAGAIN. Signed-off-by: Stefan Roesch --- fs/io_uring.c | 3 +++ include/trace/events/io_uring.h | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index f3aaac286509..7435a9c2007f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4032,6 +4032,9 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags) if (ret2 != req->result && ret2 >= 0 && need_complete_io(req)) { struct io_async_rw *rw; + trace_io_uring_short_write(req->ctx, kiocb->ki_pos - ret2, + req->result, ret2); + /* This is a partial write. The file pos has already been * updated, setup the async struct to complete the request * in the worker. Also update bytes_done to account for diff --git a/include/trace/events/io_uring.h b/include/trace/events/io_uring.h index cddf5b6fbeb4..661834361d33 100644 --- a/include/trace/events/io_uring.h +++ b/include/trace/events/io_uring.h @@ -543,6 +543,31 @@ TRACE_EVENT(io_uring_req_failed, (unsigned long long) __entry->pad2, __entry->error) ); +TRACE_EVENT(io_uring_short_write, + + TP_PROTO(void *ctx, u64 fpos, u64 wanted, u64 got), + + TP_ARGS(ctx, fpos, wanted, got), + + TP_STRUCT__entry( + __field(void *, ctx) + __field(u64, fpos) + __field(u64, wanted) + __field(u64, got) + ), + + TP_fast_assign( + __entry->ctx = ctx; + __entry->fpos = fpos; + __entry->wanted = wanted; + __entry->got = got; + ), + + TP_printk("ring %p, fpos %lld, wanted %lld, got %lld", + __entry->ctx, __entry->fpos, + __entry->wanted, __entry->got) +); + #endif /* _TRACE_IO_URING_H */ /* This part must be outside protection */ From patchwork Mon May 16 16:47:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12851157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46832C433F5 for ; Mon, 16 May 2022 16:49:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9B098D0005; Mon, 16 May 2022 12:49:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C230F8D0001; Mon, 16 May 2022 12:49:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEAA88D0005; Mon, 16 May 2022 12:49:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9ACAD8D0001 for ; Mon, 16 May 2022 12:49:00 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 7D5FB1214A1 for ; Mon, 16 May 2022 16:49:00 +0000 (UTC) X-FDA: 79472190840.08.7B855D8 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf16.hostedemail.com (Postfix) with ESMTP id 21303180010 for ; Mon, 16 May 2022 16:48:48 +0000 (UTC) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GEduGE008319 for ; Mon, 16 May 2022 09:48:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=mezo8o29O3Ay9l7JyNHPANH1KNPPbed3umcUOpvhL7Q=; b=dOWKddljHLiLqH6enz3FCUuE1EKK1FMPRjjc3y+O06gtjfUeMGFida1KPzkmZGAx+xv6 a/qZzDFHiYrtgjUpG2/cbfrB4IZxrMlsmIJ6P8aXAS6r2hTDRJK/BfyCZy+ya5wbssH8 vLe96TvqlNWULUbmucJD0xLPeiwYTc2hnTI= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g29xxjmfx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:59 -0700 Received: from twshared8307.18.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:58 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 9AA17F146DEF; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 16/16] xfs: enable async buffered write support Date: Mon, 16 May 2022 09:47:18 -0700 Message-ID: <20220516164718.2419891-17-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 5EByqubE90r3adb1w6CCa4ChifDYaAV2 X-Proofpoint-ORIG-GUID: 5EByqubE90r3adb1w6CCa4ChifDYaAV2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Stat-Signature: yh8i6ak8js5iuwmydwocxi8uaism6186 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=dOWKddlj; spf=none (imf16.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 21303180010 X-HE-Tag: 1652719728-855207 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This turns on the async buffered write support for XFS. Signed-off-by: Stefan Roesch --- 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 ad3175b7d366..af4fdc852da5 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1169,7 +1169,7 @@ xfs_file_open( return -EFBIG; if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; - file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; + file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC; return 0; }