From patchwork Wed May 18 23:36:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854303 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 C2297C433EF for ; Wed, 18 May 2022 23:37:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BD746B0072; Wed, 18 May 2022 19:37:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26D0D6B0073; Wed, 18 May 2022 19:37:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1345D6B0074; Wed, 18 May 2022 19:37:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 023126B0072 for ; Wed, 18 May 2022 19:37:20 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BC3FE60990 for ; Wed, 18 May 2022 23:37:20 +0000 (UTC) X-FDA: 79480477440.06.BA7B2D1 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf28.hostedemail.com (Postfix) with ESMTP id 8F645C0008 for ; Wed, 18 May 2022 23:36:53 +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 24IN6CMm017452 for ; Wed, 18 May 2022 16:37:19 -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=4M9otmUSBPXBBIlvkoz2+qN3jsxgZUZNyrlzFng/Fh4=; b=POBgelXbYNsaiAUYMexkZx0HRdvmZGjOoWoCWzuEijHjx7rR3J0hf+Hbvy7VY06dMEXv ZTWYtmZQSh3Enb2LR4NmkJOtdsBbTP4FyO7AU0oe+paPeZopko3tquoZfIJouQKBcg/j d968XtoLYqOBu3nQSHH2kuJydmf9clJ0qrw= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4ck0m9u6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:19 -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.28; Wed, 18 May 2022 16:37:17 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id A5CF2F3ED851; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 01/18] block: Add check for async buffered writes to generic_write_checks Date: Wed, 18 May 2022 16:36:52 -0700 Message-ID: <20220518233709.1937634-2-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: erYt7mOp8PbKOoAK-t2AymHupU37B6fy X-Proofpoint-ORIG-GUID: erYt7mOp8PbKOoAK-t2AymHupU37B6fy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8F645C0008 X-Stat-Signature: 5so9h9oacrowkb3xn3e4dm3fth3gywuq Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=POBgelXb; spf=none (imf28.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917013-41277 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 | 4 +++- include/linux/fs.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/read_write.c b/fs/read_write.c index e643aec2b0ef..544d4df33f4f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1633,7 +1633,9 @@ 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 Wed May 18 23:36:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854307 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 13EDCC433FE for ; Wed, 18 May 2022 23:37:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5560E6B0078; Wed, 18 May 2022 19:37:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 505186B007B; Wed, 18 May 2022 19:37:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30A016B007D; Wed, 18 May 2022 19:37:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2269A6B0078 for ; Wed, 18 May 2022 19:37:31 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 030A260A0C for ; Wed, 18 May 2022 23:37:31 +0000 (UTC) X-FDA: 79480477902.18.6F019C2 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf22.hostedemail.com (Postfix) with ESMTP id 310B8C00CF for ; Wed, 18 May 2022 23:37:28 +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 24IN6GX8013646 for ; Wed, 18 May 2022 16:37:29 -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=lZIeDar6iffAPAqm9vwH+yk5HrHlGopylmDYDhy4lR9yPqoh1s7gCgwl+0rqQERESIoG 6fdHlWKSqpW/wyZtENc1xnvV3Ttr/WPqq5/Vb0jCNP7gdpfwoBh+wzonChZRqekfi0g1 eoRWm1++dyIS/I9k2zeyq0/qeNrcX5vo214= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4dea3tk3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:29 -0700 Received: from twshared8307.18.frc3.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.28; Wed, 18 May 2022 16:37:27 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id ABAB0F3ED855; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 02/18] iomap: Add iomap_page_create_gfp to allocate iomap_pages Date: Wed, 18 May 2022 16:36:53 -0700 Message-ID: <20220518233709.1937634-3-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: DMJXDtIjfmyOZMF4sXKyCAjRXDlW5Fx3 X-Proofpoint-GUID: DMJXDtIjfmyOZMF4sXKyCAjRXDlW5Fx3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Stat-Signature: t63z4f83ok86w8y9z9gk4oq5jsqxqsyw X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 310B8C00CF Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=lZIeDar6; spf=none (imf22.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-HE-Tag: 1652917048-745659 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 Wed May 18 23:36:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854309 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 49F3DC433EF for ; Wed, 18 May 2022 23:37:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6D4C6B007B; Wed, 18 May 2022 19:37:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1B216B007D; Wed, 18 May 2022 19:37:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE41E6B007E; Wed, 18 May 2022 19:37:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AA39C6B007B for ; Wed, 18 May 2022 19:37:33 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 793BC32C4E for ; Wed, 18 May 2022 23:37:33 +0000 (UTC) X-FDA: 79480477986.18.87E2C9F Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf13.hostedemail.com (Postfix) with ESMTP id 0A4CD200D2 for ; Wed, 18 May 2022 23:37:09 +0000 (UTC) Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24IN6El5011573 for ; Wed, 18 May 2022 16:37:31 -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=O34zXZfbu8NoYple9DJ1IAcETJnoAkNzVvAkSIEVGtY=; b=ojJZ+a0ZQOhMxn0kiS2yUb6+B26dN8juCZOUR9H9tYlByhl/k4vKBSEToffis5giSoRr A3dLX8mRyrgRZHummug5xN44xcgdj2s0BB2rntdytgScetDPTgf3iPRTqCWiuqbM7blC IfwuI7NoSZ99+TU9LGDRshfQ/ZHXZjXuWR0= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4frtanp2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:31 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c085:208::f) 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.28; Wed, 18 May 2022 16:37:26 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id B3375F3ED857; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 03/18] iomap: Use iomap_page_create_gfp() in __iomap_write_begin Date: Wed, 18 May 2022 16:36:54 -0700 Message-ID: <20220518233709.1937634-4-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 5jxLRbSWRZt3SLTe-CvluVt-ep8kW8Jy X-Proofpoint-ORIG-GUID: 5jxLRbSWRZt3SLTe-CvluVt-ep8kW8Jy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=ojJZ+a0Z; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf13.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0A4CD200D2 X-Rspam-User: X-Stat-Signature: tm5ontcm9dcbpbepy4p49c3zwp49yn6e X-HE-Tag: 1652917029-826851 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 85aa32f50db0..6b06fd358958 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -572,17 +572,21 @@ 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); + 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 Wed May 18 23:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854305 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 67CB7C433EF for ; Wed, 18 May 2022 23:37:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 050F56B0074; Wed, 18 May 2022 19:37:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F17E86B0075; Wed, 18 May 2022 19:37:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDEC66B0078; Wed, 18 May 2022 19:37:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CFAE76B0074 for ; Wed, 18 May 2022 19:37:26 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id B145C606E3 for ; Wed, 18 May 2022 23:37:26 +0000 (UTC) X-FDA: 79480477692.03.55C1A68 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf28.hostedemail.com (Postfix) with ESMTP id 8AB00C0002 for ; Wed, 18 May 2022 23:36:59 +0000 (UTC) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24IN6DAt013732 for ; Wed, 18 May 2022 16:37:25 -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=uMreEmlHFQs4cRQDPSVDEcfGskyeRmQunpQrHflgGXo=; b=iYcBMOyFLuURxDuGeLOefXRBk8whxBhvRgkMKIVzhTvR2aIuPuOr2g+gN04wQj25y2Dt AzCirHN5PNGT7w7yoMyl3AbRmWumnFWLyb764q8bjcLfd5x5xShOJDmjnMHfvxGCWVF5 2wCQ65fuXvW1QYiutCHg76MQK3Flam/T9oU= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4d823xh5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:25 -0700 Received: from twshared10276.08.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.28; Wed, 18 May 2022 16:37:23 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id B9B54F3ED859; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 04/18] iomap: Add async buffered write support Date: Wed, 18 May 2022 16:36:55 -0700 Message-ID: <20220518233709.1937634-5-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: FlTm8B8628_9vt4_Cr3m5JYKjabVjoVV X-Proofpoint-ORIG-GUID: FlTm8B8628_9vt4_Cr3m5JYKjabVjoVV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Stat-Signature: doja3qpfwud4ysm6qugk4j4ebpoaia43 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8AB00C0002 X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=iYcBMOyF; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf28.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com" X-HE-Tag: 1652917019-750345 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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 6b06fd358958..b029e2b10e07 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -580,12 +580,18 @@ 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_NOWAIT; if (folio_test_uptodate(folio)) return 0; folio_clear_error(folio); 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, @@ -602,6 +608,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); @@ -632,6 +640,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); @@ -789,6 +800,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; @@ -844,6 +859,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 Wed May 18 23:36:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854306 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 50AD9C433EF for ; Wed, 18 May 2022 23:37:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D91BA6B0075; Wed, 18 May 2022 19:37:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D42A96B0078; Wed, 18 May 2022 19:37:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0AB86B007B; Wed, 18 May 2022 19:37:30 -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 B1A786B0075 for ; Wed, 18 May 2022 19:37:30 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 8C95F80610 for ; Wed, 18 May 2022 23:37:30 +0000 (UTC) X-FDA: 79480477860.21.8511A2F Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf29.hostedemail.com (Postfix) with ESMTP id EEB441200E9 for ; Wed, 18 May 2022 23:37:20 +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 24IN6GX7013646 for ; Wed, 18 May 2022 16:37:29 -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=xpR2o1MxE5h1TGY+8JuoVPirJk4Gk5FbraTEzaT2FUw=; b=NxtOGpNELQR0iKNa6NkY8GykTHgy56E1e+FzzhdFbAorfvsS0/iCA4LhnT1ogMVEqS3W zPZDlChdE2JRBrrPAIHL13QINSSFsFiATbc4JFNf2ZU5Wy9YLw7brrkIirUNoNF8/R+e nFlNcxB+WpWJrtIBHgIg8Ds1XMg0uZvJwbU= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4dea3tk3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:28 -0700 Received: from twshared4937.07.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.28; Wed, 18 May 2022 16:37:26 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id C06F6F3ED85B; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 05/18] xfs: Add iomap async buffered write support Date: Wed, 18 May 2022 16:36:56 -0700 Message-ID: <20220518233709.1937634-6-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: Tic9nsfDqLosF6g93f0Wtmi1rGR5jXYr X-Proofpoint-GUID: Tic9nsfDqLosF6g93f0Wtmi1rGR5jXYr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Stat-Signature: 7p8rtea8uyrriwr9osgs84jornp94gir X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EEB441200E9 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=NxtOGpNE; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf29.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com" X-HE-Tag: 1652917040-770351 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 Wed May 18 23:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854314 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 410B4C4332F for ; Wed, 18 May 2022 23:37:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD0DB8D0001; Wed, 18 May 2022 19:37:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7FB18D0002; Wed, 18 May 2022 19:37:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1FB88D0001; Wed, 18 May 2022 19:37:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 905808D0002 for ; Wed, 18 May 2022 19:37:42 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 6834C606D9 for ; Wed, 18 May 2022 23:37:42 +0000 (UTC) X-FDA: 79480478364.06.B45C8A6 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf01.hostedemail.com (Postfix) with ESMTP id B29B8400DB for ; Wed, 18 May 2022 23:37:41 +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 24IN6OHY014037 for ; Wed, 18 May 2022 16:37:40 -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=LjQjeu05KJ6rwhAZwVJii+/tlMhhh5HkUUbhHoJms8c=; b=qOgnI2YbIv9/5s9m6mk6DoODtHG46NDgGVf3KaJrf8F2X+rm16Y6aE0mOIWrtI4PYm3o Tx1p4Awqz05hIkpwB1r/ToZl1YT4Iesd70+If1NeiO58HGiwrmVB0GX9eidlQh5xbw+0 7A/uGNqma9LqocbvWyNWD9kyIsoC8dZeitg= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4dea3tm0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:40 -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.28; Wed, 18 May 2022 16:37:38 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id C6D65F3ED85D; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 06/18] fs: Split off remove_needs_file_privs() __remove_file_privs() Date: Wed, 18 May 2022 16:36:57 -0700 Message-ID: <20220518233709.1937634-7-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: DkBdm3rR2XVVWsyBg_84l8nl9V8fOvQG X-Proofpoint-GUID: DkBdm3rR2XVVWsyBg_84l8nl9V8fOvQG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B29B8400DB X-Stat-Signature: 1jd4ptqryauecbo9s6jcafkaakna85ic Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=qOgnI2Yb; spf=none (imf01.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917061-475031 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 remove_needs_file_privs() from the function __remove_file_privs() from the function file_remove_privs(). No intended functional changes in this patch. Signed-off-by: Stefan Roesch --- fs/inode.c | 75 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 9d9b422504d1..1bb8b7db836f 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 file_needs_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,42 @@ 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 __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; } + +/** + * file_remove_privs - remove special file privileges (suid, capabilities) + * @file: file to remove privileges from + * + * When file is modified by a write or truncation ensure that special + * file privileges are removed. + * + * Return: 0 on success, negative errno on failure. + */ +int file_remove_privs(struct file *file) +{ + struct dentry *dentry = file_dentry(file); + struct inode *inode = file_inode(file); + int kill; + + kill = file_needs_remove_privs(inode, dentry); + if (kill <= 0) + return kill; + + return __file_remove_privs(file, inode, dentry, kill); +} EXPORT_SYMBOL(file_remove_privs); /** @@ -2090,18 +2107,36 @@ int file_update_time(struct file *file) } EXPORT_SYMBOL(file_update_time); -/* Caller must hold the file's inode lock */ +/** + * file_modified - handle mandated vfs changes when modifying a file + * @file: file that was modified + * + * When file has been modified ensure that special + * file privileges are removed and time settings are updated. + * + * Context: Caller must hold the file's inode lock. + * + * Return: 0 on success, negative errno on failure. + */ 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 = file_needs_remove_privs(inode, dentry); + if (ret < 0) + return ret; + + if (ret > 0) { + ret = __file_remove_privs(file, inode, dentry, ret); + if (ret) + return ret; + } if (unlikely(file->f_mode & FMODE_NOCMTIME)) return 0; From patchwork Wed May 18 23:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854308 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 11518C433FE for ; Wed, 18 May 2022 23:37:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99BE76B007D; Wed, 18 May 2022 19:37:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94AE16B007E; Wed, 18 May 2022 19:37:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EBFC6B0080; Wed, 18 May 2022 19:37:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6C50F6B007D for ; Wed, 18 May 2022 19:37:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 47FEF209B8 for ; Wed, 18 May 2022 23:37:36 +0000 (UTC) X-FDA: 79480478112.29.E919D0E Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf14.hostedemail.com (Postfix) with ESMTP id E189B10000C for ; Wed, 18 May 2022 23:37:32 +0000 (UTC) Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24IN6ElH011573 for ; Wed, 18 May 2022 16:37:34 -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=4Gs4vhLGOpR5fcqmlVRzzwre6v2yRJXtVCNsF05UpCw=; b=eEB8ByU2Los9/rLy8D8jn0Nsf8J4vbxEiBpGl/CicapiPmHCNEM4Y6KVdaI7hWynze1d rJzW2GCdwxGmzrVh+wtUk3Hq9Er78K/AumPLLZvfW26Oc5nTsL9LF/4TUTqVR6SY5ErP HDO3BcZvXxtsXuNDUdLWpg5jrJb49+AC1TY= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4frtanp2-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:34 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c085:208::f) 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.28; Wed, 18 May 2022 16:37:28 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id CEC84F3ED85F; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 07/18] fs: Split off file_needs_update_time and __file_update_time Date: Wed, 18 May 2022 16:36:58 -0700 Message-ID: <20220518233709.1937634-8-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 3s5ZNxz0U-FiQw6qCOEWiSAcIoDk0B34 X-Proofpoint-ORIG-GUID: 3s5ZNxz0U-FiQw6qCOEWiSAcIoDk0B34 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E189B10000C X-Stat-Signature: zmdb91enob1ehwfkxp6143mcjj95rac8 X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=eEB8ByU2; spf=none (imf14.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917052-690973 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 file_needs_update_time() and __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 | 75 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 1bb8b7db836f..4bb7f583cc6b 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2059,35 +2059,19 @@ 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 file_needs_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; /* 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)) @@ -2096,15 +2080,49 @@ int file_update_time(struct file *file) if (!sync_it) return 0; - /* Finally allowed to write? Takes lock. */ - if (__mnt_want_write_file(file)) - return 0; + return sync_it; +} + +static int __file_update_time(struct inode *inode, struct file *file, + struct timespec64 *now, int sync_mode) +{ + int ret = 0; - ret = inode_update_time(inode, &now, sync_it); - __mnt_drop_write_file(file); + /* try to update time settings */ + if (!__mnt_want_write_file(file)) { + 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 updates via this function with the _NOCMTIME inode + * flag, e.g. for network filesystem where these imestamps are handled + * by the server. This can return an error for file systems who need to + * allocate space in order to update an inode. + * + * Return: 0 on success, negative errno on failure. + */ +int file_update_time(struct file *file) +{ + int ret; + struct inode *inode = file_inode(file); + struct timespec64 now = current_time(inode); + + ret = file_needs_update_time(inode, file, &now); + if (ret <= 0) + return ret; + + return __file_update_time(inode, file, &now, ret); +} EXPORT_SYMBOL(file_update_time); /** @@ -2123,6 +2141,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. @@ -2141,7 +2160,11 @@ int file_modified(struct file *file) if (unlikely(file->f_mode & FMODE_NOCMTIME)) return 0; - return file_update_time(file); + ret = file_needs_update_time(inode, file, &now); + if (ret <= 0) + return ret; + + return __file_update_time(inode, file, &now, ret); } EXPORT_SYMBOL(file_modified); From patchwork Wed May 18 23:36:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854310 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 56002C433FE for ; Wed, 18 May 2022 23:37:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 777C56B007E; Wed, 18 May 2022 19:37:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 728296B0080; Wed, 18 May 2022 19:37:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A1846B0081; Wed, 18 May 2022 19:37:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4A26F6B007E for ; Wed, 18 May 2022 19:37:38 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 20C9131DD1 for ; Wed, 18 May 2022 23:37:38 +0000 (UTC) X-FDA: 79480478196.17.D0586A7 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf26.hostedemail.com (Postfix) with ESMTP id 29E791400D8 for ; Wed, 18 May 2022 23:37: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 24IN6EQF020664 for ; Wed, 18 May 2022 16:37: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=pHW2Lw/6eT2sNvHMajNKUy9KO3GFkUkQfmb833jlb7s=; b=Og5jnRFhOU9OK0iQ03fMShS/ysno+vhe5RPnwuyRGG2l+RPOqUd5q+SI+SQfFsl8Sbm7 +2dxtyDICSGgje7Qe5YaD18+etlLKYxkQ3e3VJSAHweQ1ZqD13Pw5ZbTLXtPD5+yomWY 0CSqLUbFFLxTdHiiyZ61olbnG4U8ymFTJrM= Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net (PPS) with ESMTPS id 3g4myhr7ej-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:36 -0700 Received: from twshared24024.25.frc3.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.28; Wed, 18 May 2022 16:37:34 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id D6771F3ED861; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 08/18] xfs: Enable async write file modification handling. Date: Wed, 18 May 2022 16:36:59 -0700 Message-ID: <20220518233709.1937634-9-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: pdx-EmF9CvKUeFA-ErNaH5ukOWslYbe0 X-Proofpoint-GUID: pdx-EmF9CvKUeFA-ErNaH5ukOWslYbe0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 29E791400D8 X-Stat-Signature: owcpe4zftgzxne9uxahwtudrxc5mpd1b X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=Og5jnRFh; spf=none (imf26.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917053-491198 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 file_modified() function 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 of io-uring. Signed-off-by: Stefan Roesch --- fs/inode.c | 25 ++++++++++++++++++++++++- fs/xfs/xfs_file.c | 2 +- include/linux/fs.h | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 4bb7f583cc6b..3a5d0fa468ab 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2137,6 +2137,27 @@ EXPORT_SYMBOL(file_update_time); * Return: 0 on success, negative errno on failure. */ int file_modified(struct file *file) +{ + return file_modified_async(file, 0); +} +EXPORT_SYMBOL(file_modified); + +/** + * file_modified_async - handle mandated vfs changes when modifying a file + * @file: file that was modified + * @flags: kiocb flags + * + * When file has been modified ensure that special + * file privileges are removed and time settings are updated. + * + * If IOCB_NOWAIT is set, special file privileges will not be removed and + * time settings will not be updated. It will return -EAGAIN. + * + * Context: Caller must hold the file's inode lock. + * + * Return: 0 on success, negative errno on failure. + */ +int file_modified_async(struct file *file, int flags) { int ret; struct dentry *dentry = file_dentry(file); @@ -2163,10 +2184,12 @@ int file_modified(struct file *file) ret = file_needs_update_time(inode, file, &now); if (ret <= 0) return ret; + if (flags & IOCB_NOWAIT) + return -EAGAIN; return __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 3b479d02e210..9760283af7dc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2382,6 +2382,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 Wed May 18 23:37:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854312 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 45B50C433EF for ; Wed, 18 May 2022 23:37:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41D496B0081; Wed, 18 May 2022 19:37:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CBCA6B0082; Wed, 18 May 2022 19:37:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21F2D6B0085; Wed, 18 May 2022 19:37:42 -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 053706B0082 for ; Wed, 18 May 2022 19:37:42 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DA8D12090B for ; Wed, 18 May 2022 23:37:41 +0000 (UTC) X-FDA: 79480478322.07.B45C3C6 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf10.hostedemail.com (Postfix) with ESMTP id F11A3C00AB for ; Wed, 18 May 2022 23:37:10 +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 24IN6Glu005887 for ; Wed, 18 May 2022 16:37:40 -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=YjR6bHdDemShrFnRSFoy0SU6vrzP5IeqvXhPCERFUGY=; b=Vj84wixRIzTnyHpWspgB0LqWOEa3kEBDkIN2GPDg1axkr+4mlCqzGxYxuTQekvkAuC7f uhj6Wa7ItvBct86J1Y/Lab7Iaeq+7Xy0LRtsNKQAXTKwr2aXETCmbbPAhubBEactY4Ke A0FmkwAv+xzeq45zTlaehPwhpn28aYQNIrY= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4ey1k1nv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:40 -0700 Received: from twshared8307.18.frc3.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.28; Wed, 18 May 2022 16:37:38 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id DD709F3ED863; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 09/18] fs: Optimization for concurrent file time updates. Date: Wed, 18 May 2022 16:37:00 -0700 Message-ID: <20220518233709.1937634-10-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 9NKL1bp7td6lc5Ycr3pCyXxEh31NEtZ1 X-Proofpoint-GUID: 9NKL1bp7td6lc5Ycr3pCyXxEh31NEtZ1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=Vj84wixR; spf=none (imf10.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: F11A3C00AB X-Stat-Signature: 7bq3rjtqjuk1parcxhid9kkihn8na5oj X-HE-Tag: 1652917030-694685 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 S_PENDING_TIME flag. If an async buffered write needs to update the time, it cannot be processed in the fast path of io-uring. When a time update is pending this flag is set for async buffered writes. Other concurrent async buffered writes for the same file do not need to wait while this time update is pending. This reduces the number of async buffered writes that need to get punted to the io-workers in io-uring. Signed-off-by: Stefan Roesch --- fs/inode.c | 11 +++++++++-- include/linux/fs.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 3a5d0fa468ab..5c5021787780 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2184,10 +2184,17 @@ int file_modified_async(struct file *file, int flags) ret = file_needs_update_time(inode, file, &now); if (ret <= 0) return ret; - if (flags & IOCB_NOWAIT) + if (flags & IOCB_NOWAIT) { + if (IS_PENDING_TIME(inode)) + return 0; + + inode->i_flags |= S_PENDING_TIME; return -EAGAIN; + } - return __file_update_time(inode, file, &now, ret); + ret = __file_update_time(inode, file, &now, ret); + inode->i_flags &= ~S_PENDING_TIME; + return ret; } EXPORT_SYMBOL(file_modified_async); diff --git a/include/linux/fs.h b/include/linux/fs.h index 9760283af7dc..5f3aaf61fb4b 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 Wed May 18 23:37:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854315 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 97CC9C433F5 for ; Wed, 18 May 2022 23:37:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1E548D0003; Wed, 18 May 2022 19:37:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C31A38D0002; Wed, 18 May 2022 19:37:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A85178D0003; Wed, 18 May 2022 19:37:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8995A8D0002 for ; Wed, 18 May 2022 19:37:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 58C13209B8 for ; Wed, 18 May 2022 23:37:45 +0000 (UTC) X-FDA: 79480478490.27.3139FAB Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf09.hostedemail.com (Postfix) with ESMTP id 44B0B1400B4 for ; Wed, 18 May 2022 23:37:34 +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 24IN6AdS017366 for ; Wed, 18 May 2022 16:37:43 -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=i6RESA2kBFbZf2YcYKS9NClp2rdwS4z3e5YrkTDrp5aQB3JPLVdlytwpVGLaoojFgIFG fOUNWAAU+p9M23iJxh3uuhMsjYlkvF+SRyBlyCNt0jLDi1Sv6Nr8XAD0gZrBAN1rVLay VV1wCr4qjitYxB6F7cIAO1jZh82uTcaZ7Ec= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4ck0m9vj-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:43 -0700 Received: from twshared4937.07.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.28; Wed, 18 May 2022 16:37:38 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id E5A10F3ED865; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 10/18] xfs: Add async buffered write support Date: Wed, 18 May 2022 16:37:01 -0700 Message-ID: <20220518233709.1937634-11-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 39jxkjlEg_w9Y_TQmB2EdhBJpZAxw0Nx X-Proofpoint-ORIG-GUID: 39jxkjlEg_w9Y_TQmB2EdhBJpZAxw0Nx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 44B0B1400B4 X-Stat-Signature: whibgrnobsgn3ysxpgix341owg455kuh Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=i6RESA2k; spf=none (imf09.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917054-496985 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 Wed May 18 23:37:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854313 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 C4CE4C4321E for ; Wed, 18 May 2022 23:37:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 732C86B0082; Wed, 18 May 2022 19:37:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 553358D0001; Wed, 18 May 2022 19:37:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E4486B0083; Wed, 18 May 2022 19:37:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1DCE46B0081 for ; Wed, 18 May 2022 19:37:42 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EF6AA31DD1 for ; Wed, 18 May 2022 23:37:41 +0000 (UTC) X-FDA: 79480478322.03.FBF0D8B Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf30.hostedemail.com (Postfix) with ESMTP id 866298000A for ; Wed, 18 May 2022 23:37:17 +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 24INKaEP016569 for ; Wed, 18 May 2022 16:37:41 -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=obXWAbHm9xVuJ4SSxrm0Tz5QiPhr9yomkEgpd2BpiO4WjPjtVfdP+NfmD/+Rahtfr1qE BVQPaeHZ3q0u27VHwxJLnznlMx+U2+rjgmOF3SLios3XkSHoZoRaq4K6lLVRLtfeHEmO yIrXm1iQDSdjidF4EICsYYmEwEsXycHESaI= Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net (PPS) with ESMTPS id 3g5acy02tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:40 -0700 Received: from twshared35748.07.ash9.facebook.com (2620:10d:c085:208::f) 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.28; Wed, 18 May 2022 16:37:39 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id EBEC6F3ED867; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 11/18] io_uring: Add support for async buffered writes Date: Wed, 18 May 2022 16:37:02 -0700 Message-ID: <20220518233709.1937634-12-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: EHCqHe1DFKv46Hs_X-28YduY1UWzEH8x X-Proofpoint-GUID: EHCqHe1DFKv46Hs_X-28YduY1UWzEH8x X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspamd-Queue-Id: 866298000A X-Stat-Signature: kx9fcadkfhjgr86n9rfcw5z6178bw3j1 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=obXWAbHm; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf30.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=6137e46c81=shr@fb.com" X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652917037-102610 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 Wed May 18 23:37: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: 12854318 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 60E77C433FE for ; Wed, 18 May 2022 23:37:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83D6B8D0007; Wed, 18 May 2022 19:37:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0EA8D0002; Wed, 18 May 2022 19:37:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 616608D0007; Wed, 18 May 2022 19:37:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 44DEA8D0002 for ; Wed, 18 May 2022 19:37:52 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1A97B7EB for ; Wed, 18 May 2022 23:37:52 +0000 (UTC) X-FDA: 79480478784.06.5961267 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf23.hostedemail.com (Postfix) with ESMTP id B8CAF1400CE for ; Wed, 18 May 2022 23:37:33 +0000 (UTC) Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24IN6GBV011668 for ; Wed, 18 May 2022 16:37: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=3zHDjbn72NXSBweb9g6a0xThug/NIwNbovojkJVDB2M=; b=di3baeMW3rzcrQoGRLWCiG7GZRUkxeggm5fvoPbuu/EkrYSB1uv+z7CzQgfgLD2qfQbD iD0614dSJ0xYKMPQawmxHAAobxJZO7uXFn4jGgtXTVNa/DDHTQEBgDQlu7i7OBDjXXJa +pl70FPALuSEn1NGYGVEw2kbGyLrmGQv/TQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4frtanqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:50 -0700 Received: from twshared8508.05.ash9.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.28; Wed, 18 May 2022 16:37:49 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id F1ED2F3ED869; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 12/18] mm: Move starting of background writeback into the main balancing loop Date: Wed, 18 May 2022 16:37:03 -0700 Message-ID: <20220518233709.1937634-13-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: Vos-a2JiTfbvDNW_Xv23oad8sflN3orD X-Proofpoint-ORIG-GUID: Vos-a2JiTfbvDNW_Xv23oad8sflN3orD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=di3baeMW; spf=none (imf23.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B8CAF1400CE X-Stat-Signature: ksq4bkrcfu8w7zy1jcistewib1izxdww X-HE-Tag: 1652917053-482743 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: From: Jan Kara We start background writeback if we are over background threshold after exiting the main loop in balance_dirty_pages(). This may result in basing the decision on already stale values (we may have slept for significant amount of time) and it is also inconvenient for refactoring needed for async dirty throttling. Move the check into the main waiting loop. Signed-off-by: Jan Kara Signed-off-by: Stefan Roesch --- mm/page-writeback.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7e2da284e427..8e5e003f0093 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1618,6 +1618,19 @@ static void balance_dirty_pages(struct bdi_writeback *wb, } } + /* + * In laptop mode, we wait until hitting the higher threshold + * before starting background writeout, and then write out all + * the way down to the lower threshold. So slow writers cause + * minimal disk activity. + * + * In normal mode, we start background writeout at the lower + * background_thresh, to keep the amount of dirty memory low. + */ + if (!laptop_mode && nr_reclaimable > gdtc->bg_thresh && + !writeback_in_progress(wb)) + wb_start_background_writeback(wb); + /* * Throttle it only when the background writeback cannot * catch-up. This avoids (excessively) small writeouts @@ -1648,6 +1661,7 @@ static void balance_dirty_pages(struct bdi_writeback *wb, break; } + /* Start writeback even when in laptop mode */ if (unlikely(!writeback_in_progress(wb))) wb_start_background_writeback(wb); @@ -1814,23 +1828,6 @@ static void balance_dirty_pages(struct bdi_writeback *wb, if (!dirty_exceeded && wb->dirty_exceeded) wb->dirty_exceeded = 0; - - if (writeback_in_progress(wb)) - return; - - /* - * In laptop mode, we wait until hitting the higher threshold before - * starting background writeout, and then write out all the way down - * to the lower threshold. So slow writers cause minimal disk activity. - * - * In normal mode, we start background writeout at the lower - * background_thresh, to keep the amount of dirty memory low. - */ - if (laptop_mode) - return; - - if (nr_reclaimable > gdtc->bg_thresh) - wb_start_background_writeback(wb); } static DEFINE_PER_CPU(int, bdp_ratelimits); From patchwork Wed May 18 23:37: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: 12854311 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 52FFCC433F5 for ; Wed, 18 May 2022 23:37:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBD266B0080; Wed, 18 May 2022 19:37:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6B5C6B0081; Wed, 18 May 2022 19:37:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C32B96B0082; Wed, 18 May 2022 19:37:41 -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 AF0B66B0080 for ; Wed, 18 May 2022 19:37:41 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8076732CD3 for ; Wed, 18 May 2022 23:37:41 +0000 (UTC) X-FDA: 79480478322.24.5FA7119 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf13.hostedemail.com (Postfix) with ESMTP id F3A41200D1 for ; Wed, 18 May 2022 23:37:17 +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 24INKc0t016633 for ; Wed, 18 May 2022 16:37:40 -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=JmNWcJ9S5BuVrDagcKBT8mAi6jQ8Go8fzpG+AeBXTsU=; b=nSwV6TGxyQ1d+z1t1nufrNDKyWZZ7Vk2UQBgZtiC99UTelKAvXo9bnE948IxFDHIruUI 0xyzfpeMMRlwHR0oMu0tY6UwWtnfY882azN19J5fEpknCab2F4DWxKQ2QyhKGOnv4MiY ezOPvNThFJ84G2fIFdPsIFcwYh3Py7pWl6A= Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net (PPS) with ESMTPS id 3g5acy02th-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:40 -0700 Received: from twshared6696.05.ash7.facebook.com (2620:10d:c085:108::4) 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.28; Wed, 18 May 2022 16:37:38 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 05A86F3ED86B; Wed, 18 May 2022 16:37:13 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 13/18] mm: Move updates of dirty_exceeded into one place Date: Wed, 18 May 2022 16:37:04 -0700 Message-ID: <20220518233709.1937634-14-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 3X2v1NMSVTNLo5zwGR7MnFOuHyBoE1wp X-Proofpoint-GUID: 3X2v1NMSVTNLo5zwGR7MnFOuHyBoE1wp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: F3A41200D1 X-Stat-Signature: iyunga41zfymufks1ri7sahc7689wgx1 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=nSwV6TGx; spf=none (imf13.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917037-841942 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: From: Jan Kara Transition of wb->dirty_exceeded from 0 to 1 happens before we go to sleep in balance_dirty_pages() while transition from 1 to 0 happens when exiting from balance_dirty_pages(), possibly based on old values. This does not make a lot of sense since wb->dirty_exceeded should simply reflect whether wb is over dirty limit and so we should ratelimit entering to balance_dirty_pages() less. Move the two updates together. Signed-off-by: Jan Kara Signed-off-by: Stefan Roesch --- mm/page-writeback.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 8e5e003f0093..89dcc7d8395a 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1720,8 +1720,8 @@ static void balance_dirty_pages(struct bdi_writeback *wb, sdtc = mdtc; } - if (dirty_exceeded && !wb->dirty_exceeded) - wb->dirty_exceeded = 1; + if (dirty_exceeded != wb->dirty_exceeded) + wb->dirty_exceeded = dirty_exceeded; if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) + BANDWIDTH_INTERVAL)) @@ -1825,9 +1825,6 @@ static void balance_dirty_pages(struct bdi_writeback *wb, if (fatal_signal_pending(current)) break; } - - if (!dirty_exceeded && wb->dirty_exceeded) - wb->dirty_exceeded = 0; } static DEFINE_PER_CPU(int, bdp_ratelimits); From patchwork Wed May 18 23:37: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: 12854319 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 13CDEC433EF for ; Wed, 18 May 2022 23:37:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6E208D0008; Wed, 18 May 2022 19:37:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C57EA8D0002; Wed, 18 May 2022 19:37:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF9118D0008; Wed, 18 May 2022 19:37:53 -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 986B78D0002 for ; Wed, 18 May 2022 19:37:53 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6EC9932C5C for ; Wed, 18 May 2022 23:37:53 +0000 (UTC) X-FDA: 79480478826.30.4A3EA3B Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf23.hostedemail.com (Postfix) with ESMTP id 130A81400CF for ; Wed, 18 May 2022 23:37:34 +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 24IN6GVT013659 for ; Wed, 18 May 2022 16:37:51 -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=UBS18O+BsnzFCTIQhXny5YXEO4wIVCIzwj+tQ4lzVAU=; b=Kk1yA29IoHeTQzOk5Z0YomInehR7eRz/cEds+Cfb3ngjghwXRTGZ8yFezu/AdGHqqQHW qmcxx+RPJYfbbQY20GlcvXMBqhDEK7URqp6Yac2tUf7zf1F0IhFxbgqKi/0+EMcjNXrw rMAFqUnod8Uo8K6YzQ9SwjEFRPsv2B6n/c8= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4dea3tms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:51 -0700 Received: from twshared8307.18.frc3.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.28; Wed, 18 May 2022 16:37:50 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 0C42BF3ED86D; Wed, 18 May 2022 16:37:13 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 14/18] mm: Prepare balance_dirty_pages() for async buffered writes Date: Wed, 18 May 2022 16:37:05 -0700 Message-ID: <20220518233709.1937634-15-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: c_Pk113vQK4SA51pwfnXwDf2Favvii7Q X-Proofpoint-GUID: c_Pk113vQK4SA51pwfnXwDf2Favvii7Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 130A81400CF X-Stat-Signature: s3ha6byq1a51womebiuaw3r3o1q8fcri Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=Kk1yA29I; spf=none (imf23.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917054-372736 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: From: Jan Kara If balance_dirty_pages() gets called for async buffered write, we don't want to wait. Instead we need to indicate to the caller that throttling is needed so that it can stop writing and offload the rest of the write to a context that can block. Signed-off-by: Jan Kara Signed-off-by: Stefan Roesch --- mm/page-writeback.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 89dcc7d8395a..fc3b79acd90b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1545,8 +1545,8 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) * 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 int balance_dirty_pages(struct bdi_writeback *wb, + unsigned long pages_dirtied, bool nowait) { struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) }; struct dirty_throttle_control mdtc_stor = { MDTC_INIT(wb, &gdtc_stor) }; @@ -1566,6 +1566,7 @@ static void balance_dirty_pages(struct bdi_writeback *wb, struct backing_dev_info *bdi = wb->bdi; bool strictlimit = bdi->capabilities & BDI_CAP_STRICTLIMIT; unsigned long start_time = jiffies; + int ret = 0; for (;;) { unsigned long now = jiffies; @@ -1794,6 +1795,10 @@ static void balance_dirty_pages(struct bdi_writeback *wb, period, pause, start_time); + if (nowait) { + ret = -EAGAIN; + break; + } __set_current_state(TASK_KILLABLE); wb->dirty_sleep = now; io_schedule_timeout(pause); @@ -1825,6 +1830,7 @@ static void balance_dirty_pages(struct bdi_writeback *wb, if (fatal_signal_pending(current)) break; } + return ret; } static DEFINE_PER_CPU(int, bdp_ratelimits); @@ -1906,7 +1912,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) preempt_enable(); if (unlikely(current->nr_dirtied >= ratelimit)) - balance_dirty_pages(wb, current->nr_dirtied); + balance_dirty_pages(wb, current->nr_dirtied, false); wb_put(wb); } From patchwork Wed May 18 23:37: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: 12854320 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 95212C433FE for ; Wed, 18 May 2022 23:37:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D8238D0009; Wed, 18 May 2022 19:37:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 889188D0002; Wed, 18 May 2022 19:37:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68DE78D0009; Wed, 18 May 2022 19:37: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 4DABD8D0002 for ; Wed, 18 May 2022 19:37:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3343E31DD1 for ; Wed, 18 May 2022 23:37:54 +0000 (UTC) X-FDA: 79480478868.21.BD5AC37 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf06.hostedemail.com (Postfix) with ESMTP id D6A071800CD for ; Wed, 18 May 2022 23:37:50 +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 24IN6Eqf007654 for ; Wed, 18 May 2022 16:37: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=fNgFPteUPRSul4YL74K0HyPjAeD4pJsVpM/yBNzJ9mk=; b=jt+h995YXw8439ZAsanKmo0IQots139EyYPv+T82ddhOJ2QmthafY+Xb4dZ9gfzTEvHh UhA8i/PVaEJPKO6Pyf9RYOuD4ZFA+HIclSRW0asm2iVRxwrqPNcSfAJlHXm80uIEe188 gX/mPFsUykf83G+FtTgd2ShLjkWOOwNp7vo= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4p9gfta3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:52 -0700 Received: from twshared35748.07.ash9.facebook.com (2620:10d:c085:208::f) 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.28; Wed, 18 May 2022 16:37:51 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 137DBF3ED86F; Wed, 18 May 2022 16:37:13 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 15/18] mm: Add balance_dirty_pages_ratelimited_async() function Date: Wed, 18 May 2022 16:37:06 -0700 Message-ID: <20220518233709.1937634-16-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: H7Uw4gpScHMcU9d7rVEy3JBS-7SxvrOm X-Proofpoint-GUID: H7Uw4gpScHMcU9d7rVEy3JBS-7SxvrOm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspamd-Queue-Id: D6A071800CD X-Stat-Signature: cx6ubq9qhm6s5ipiudoxneiaygseo73m X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=jt+h995Y; spf=none (imf06.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspamd-Server: rspam09 X-HE-Tag: 1652917070-941442 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 helper function balance_dirty_pages_ratelimited_flags(). It adds the parameter no_wait to balance_dirty_pages_ratelimited(). For async buffered writes no_wait will be true. A new function called balance_dirty_pages_ratelimited_async() is introduced that calls balance_dirty_pages_ratelimited_flags with no_wait set to true. If write throttling is enabled, it retuns -EAGAIN, so the write request can be punted to the io-uring worker. For non-async writes the current behavior is maintained. Signed-off-by: Stefan Roesch --- include/linux/writeback.h | 1 + mm/page-writeback.c | 60 +++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index fec248ab1fec..15eb0242d3ef 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_async(struct address_space *mapping); 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 fc3b79acd90b..d6a67fc07c55 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1851,28 +1851,18 @@ 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) +static int balance_dirty_pages_ratelimited_flags(struct address_space *mapping, + bool no_wait) { 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); @@ -1912,12 +1902,52 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) preempt_enable(); if (unlikely(current->nr_dirtied >= ratelimit)) - balance_dirty_pages(wb, current->nr_dirtied, false); + balance_dirty_pages(wb, current->nr_dirtied, no_wait); 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); +/** + * balance_dirty_pages_ratelimited_async - 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. + * + * This is the async version of the API. It only checks if it is required to + * balance dirty pages. In case it needs to balance dirty pages, it returns + * -EAGAIN. + */ +int balance_dirty_pages_ratelimited_async(struct address_space *mapping) +{ + return balance_dirty_pages_ratelimited_flags(mapping, true); +} +EXPORT_SYMBOL(balance_dirty_pages_ratelimited_async); + /** * wb_over_bg_thresh - does @wb need to be written back? * @wb: bdi_writeback of interest From patchwork Wed May 18 23:37: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: 12854317 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 B1772C4332F for ; Wed, 18 May 2022 23:37:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63F3C8D0006; Wed, 18 May 2022 19:37:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F5898D0002; Wed, 18 May 2022 19:37:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B73F8D0006; Wed, 18 May 2022 19:37:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 38A5B8D0002 for ; Wed, 18 May 2022 19:37:50 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1B92F606EA for ; Wed, 18 May 2022 23:37:50 +0000 (UTC) X-FDA: 79480478700.24.EE60EC2 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf29.hostedemail.com (Postfix) with ESMTP id 7FA2B1200E9 for ; Wed, 18 May 2022 23:37:40 +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 24IN6FBU013632 for ; Wed, 18 May 2022 16:37: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=YqpL7bjIpVC1T97cqx5/U3u744Lv+NFWKctjbk1tsPQ=; b=O1yAb8w1N1LFimCUIL56ovslFW04+3z1OBoK0HbYYJD3Hg8811rHF5Lil5O5Y4VLZ3e3 ulSJsERiQrFtWbMGxyYFJUuXFE8hlHLPIZ94ZOayu1XuOy6BSMoH2JF95wUxJonWRjRk VvisvwnPyknlbE3H4mF27BmlTk/eVcEzbTU= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4dea3tmh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:48 -0700 Received: from twshared11660.23.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.28; Wed, 18 May 2022 16:37:46 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 19715F3ED871; Wed, 18 May 2022 16:37:13 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 16/18] iomap: Use balance_dirty_pages_ratelimited_flags in iomap_write_iter Date: Wed, 18 May 2022 16:37:07 -0700 Message-ID: <20220518233709.1937634-17-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: xdk9HoACo7UB_hnseWdEpZtIsszH1j0Q X-Proofpoint-GUID: xdk9HoACo7UB_hnseWdEpZtIsszH1j0Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 7FA2B1200E9 X-Stat-Signature: xx36n9sumnwx5ghzom17htceiaf3opdf Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=O1yAb8w1; spf=none (imf29.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917060-414032 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 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index b029e2b10e07..2b85ddfa6ea1 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -784,6 +784,7 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) do { struct folio *folio; struct page *page; + struct address_space *i_mapping = iter->inode->i_mapping; unsigned long offset; /* Offset into pagecache page */ unsigned long bytes; /* Bytes to write to page */ size_t copied; /* Bytes copied from user */ @@ -792,6 +793,14 @@ 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: + if (iter->flags & IOMAP_NOWAIT) { + status = balance_dirty_pages_ratelimited_async(i_mapping); + if (unlikely(status)) + break; + } else { + balance_dirty_pages_ratelimited(i_mapping); + } + if (bytes > length) bytes = length; @@ -815,7 +824,7 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) break; page = folio_file_page(folio, pos >> PAGE_SHIFT); - if (mapping_writably_mapped(iter->inode->i_mapping)) + if (mapping_writably_mapped(i_mapping)) flush_dcache_page(page); copied = copy_page_from_iter_atomic(page, offset, bytes, i); @@ -840,8 +849,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 Wed May 18 23:37: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: 12854316 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 66F9BC433FE for ; Wed, 18 May 2022 23:37:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04BF18D0005; Wed, 18 May 2022 19:37:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3D918D0002; Wed, 18 May 2022 19:37:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDEE08D0005; Wed, 18 May 2022 19:37:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CEB738D0002 for ; Wed, 18 May 2022 19:37:49 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A9C3032CD3 for ; Wed, 18 May 2022 23:37:49 +0000 (UTC) X-FDA: 79480478658.17.4D987DA Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf06.hostedemail.com (Postfix) with ESMTP id 4DEA71800C8 for ; Wed, 18 May 2022 23:37:46 +0000 (UTC) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24IN6DVn013743 for ; Wed, 18 May 2022 16:37: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=UfD+h75jLCqmGcJIFVAad9rZN/r0VFdoC8EFOxTjfII=; b=i58D+I90ENcKWDEIn+39KABa/vBhgbCZ8c1ltuuinljhAvhwZ0ffU5CjGqzEx4x/iDpK /nIRvKZ+hTjP7eUGroFB44Cz5Q9ISafzTsU2CDfoPxWAtyqjk65HtGVMDIl0dAVsWywY T5iOilpf5MaEE4iWI/xtI6kqD0z4fw6Fp38= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4d823xjw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:47 -0700 Received: from twshared11660.23.frc3.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.28; Wed, 18 May 2022 16:37:46 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 201BEF3ED873; Wed, 18 May 2022 16:37:13 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 17/18] io_uring: Add tracepoint for short writes Date: Wed, 18 May 2022 16:37:08 -0700 Message-ID: <20220518233709.1937634-18-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 5cvA5EuZij4UdG6kjm5wDbSs73Xq1Hzs X-Proofpoint-ORIG-GUID: 5cvA5EuZij4UdG6kjm5wDbSs73Xq1Hzs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=i58D+I90; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf06.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4DEA71800C8 X-Rspam-User: X-Stat-Signature: s85h3h3ppggjam8gpeswdokh19yqrx1w X-HE-Tag: 1652917066-515849 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 Wed May 18 23:37: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: 12854321 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 DE66AC433F5 for ; Wed, 18 May 2022 23:37:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD3728D000A; Wed, 18 May 2022 19:37:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5DC38D0002; Wed, 18 May 2022 19:37:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AF978D000A; Wed, 18 May 2022 19:37:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7522A8D0002 for ; Wed, 18 May 2022 19:37:55 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 4309680610 for ; Wed, 18 May 2022 23:37:55 +0000 (UTC) X-FDA: 79480478910.23.EE70F1C Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf24.hostedemail.com (Postfix) with ESMTP id AE952180008 for ; Wed, 18 May 2022 23:37:43 +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 24IN6GVW013659 for ; Wed, 18 May 2022 16:37: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=mezo8o29O3Ay9l7JyNHPANH1KNPPbed3umcUOpvhL7Q=; b=AXaNpkBRTlHVDouo3dfP7d6mMFiRffsqWjgdgfUxOoDy4dobjmpAndPQE4XiA+YczwK3 k73HxMN3ht/VMAcus+WZEisJSH6zWna/S0sTdrM7CtkIuDMzzjVFRWfGAtDnU3Wve8a3 Dt1pwplw+INpAv7tCg2x4FgmmC3Z1KxGqig= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4dea3tms-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:53 -0700 Received: from twshared11660.23.frc3.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.28; Wed, 18 May 2022 16:37:51 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 26EB2F3ED875; Wed, 18 May 2022 16:37:13 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 18/18] xfs: Enable async buffered write support Date: Wed, 18 May 2022 16:37:09 -0700 Message-ID: <20220518233709.1937634-19-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 1bNsGO1_TMVN4z5nDYT3HY4h7_XWd0KM X-Proofpoint-GUID: 1bNsGO1_TMVN4z5nDYT3HY4h7_XWd0KM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_06,2022-05-17_02,2022-02-23_01 X-Rspamd-Queue-Id: AE952180008 X-Stat-Signature: jj6s5ofgrbyd4jeqp9jecxzcc69z4rmz Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=AXaNpkBR; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf24.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com" X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652917063-82850 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; }