From patchwork Thu Dec 21 13:23:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13501941 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 6CBD7C35274 for ; Thu, 21 Dec 2023 13:26:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E87138D0026; Thu, 21 Dec 2023 08:25:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E36C88D0023; Thu, 21 Dec 2023 08:25:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3B698D0026; Thu, 21 Dec 2023 08:25:56 -0500 (EST) 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 AF9528D0023 for ; Thu, 21 Dec 2023 08:25:56 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 89DB814079A for ; Thu, 21 Dec 2023 13:25:56 +0000 (UTC) X-FDA: 81590898312.17.278DC53 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id D0E9D140027 for ; Thu, 21 Dec 2023 13:25:54 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KQn29Db9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703165154; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sLOJZBQtHn1jVYDnU489+f18yhPIxwvphTv8wiLd2rs=; b=SextEa+51EvY3yTQJPU6eD3pbCyx58Eq37nyFm40d5O9Zz/G01hYK73QIdxMnfTI2AMINF n3EnFHjf0/GC7WluY+ioCe4Ke3mSU+55RoI823bfheoL4Gp9h0bqzN6bMfa1xuY17JbHpb X1ruP6VigXu+32iScJ9lrt4IB2tcRYU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KQn29Db9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703165154; a=rsa-sha256; cv=none; b=bzR8Lb69hylI/ylbhf3y66DSv6/nXd6kf2QpB4vk7nbHVp0a9pNW/L1yUNAy8U0xGrrwes r1xWk02p2AsOCQMkUx39M2Yhz/PJnBA2pu9WfMw8/Pemg1MFrPZOQLgzfYayGgpXnDn3uR 5MCcDPCgMRBkBA+G+B4EIP/lFub2xDM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703165154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sLOJZBQtHn1jVYDnU489+f18yhPIxwvphTv8wiLd2rs=; b=KQn29Db9jzDpaHKy31Y78Fqg7Je4e3KG7BJREji+x1yUJtHFbglxesHfIBPdf6FHAlWKPT IWkGqbmcmXKoWGQVovwJI6f8E7X4lQ+ziHP/RVkaynuRIAslCqYAXNseu1+gI6nYwxEZ97 P6PwlrAtJjv1jTP240ZknVOHZWnwdgw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-73qhAL2vNNqkaVOphF4Iig-1; Thu, 21 Dec 2023 08:25:49 -0500 X-MC-Unique: 73qhAL2vNNqkaVOphF4Iig-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B92C43C000B4; Thu, 21 Dec 2023 13:25:48 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.39.195.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id C415F2166B33; Thu, 21 Dec 2023 13:25:45 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Eric Van Hensbergen , Ilya Dryomov , Christian Brauner , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 27/40] netfs: Allocate multipage folios in the writepath Date: Thu, 21 Dec 2023 13:23:22 +0000 Message-ID: <20231221132400.1601991-28-dhowells@redhat.com> In-Reply-To: <20231221132400.1601991-1-dhowells@redhat.com> References: <20231221132400.1601991-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Rspam-User: X-Stat-Signature: mkc1bgjimspyhpa65ht8uh3r87pkjcoy X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D0E9D140027 X-HE-Tag: 1703165154-56054 X-HE-Meta: U2FsdGVkX18M8bailgBmoYScA8rzFQh/CNwLKSe9Fe2uTaLqhgVeJ06+bXBdnaTOTMLnVfLEC4MasCEEqtpG5weEIdICQbG4vuSSuzm5EVB6R1OYvVX+Pr+2fxYAxuIZMCMtXnJUQtNFf6+ZI7Qqywh5E46yz1CImRvdPAbXwxrzjKjtDeSpwxTfUEgKKlM/JjUacvGGUvy6EH6I5UAuhWUKQCHIcSYBhfGN3tN+4g+9AlPS/zReej8RrhKWf+hq/ZhArvxNilM+V951SinG2deik6c2a09pk3h9m4NLkwDCgw6EwmfM2o3zWJvBpvq1qgmz+OR6c1WqeZw/l+Rxb6zm5g1VIH04bfHvO6p/bfAPHwBHVt/Asj8u+DSCuZ3xNeNrg5KtU0beLMrrB9aN4IEh7j0xvmRgqWcPuk3lcSyxnZoFTp5L6ooHVXynZlhXbPgiBpGNcmfVmu89SRN9emaJXhy5QIQR0vP2ueTyqT9G4/JmK+HsUVga0CYcKUM1D416Uor6eqQ1hBJQIAg9WgdNMb6tfBGqcLcfVG6Unx1YoqwpGFCnWikc0OEohdXDzpOTrg+zV+yB3wRch48yONWapEgc22G051kMUb45IJqbr2DRh9xmQmD55Nf6SjGASbFjkcKppULLiOoxJ7WdPg41lk7LFv5ZMD54/RR1U6I/VALoyo8xl80MgaOdryGB4EPt5/1o9Zy/Ufj6E7S36xv1i+S8Wy2yzorTLhEXG0XmihpNdfCZ0vTerA3lcpGByqC2uvHg5Stu0asw244FH3MkX2czd79YlVmL+LKTwkLD0RVHuhm0MEqUgPKTHZFmBLBQT1zsHCy9wPt+X82UuRJtpaTy0LI/kPp1W3uT0K+pWVFDaJpPMLMJaxsoivKoqbxe4EQHs7SpwqPw15jAMg== 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: List-Subscribe: List-Unsubscribe: Allocate a multipage folio when copying data into the pagecache if possible if there's sufficient data to warrant it. Signed-off-by: David Howells Reviewed-by: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/buffered_write.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 6e7f06d9962d..b76688e98f81 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -84,14 +84,19 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx, } /* - * Grab a folio for writing and lock it. + * Grab a folio for writing and lock it. Attempt to allocate as large a folio + * as possible to hold as much of the remaining length as possible in one go. */ static struct folio *netfs_grab_folio_for_write(struct address_space *mapping, loff_t pos, size_t part) { pgoff_t index = pos / PAGE_SIZE; + fgf_t fgp_flags = FGP_WRITEBEGIN; - return __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, + if (mapping_large_folio_support(mapping)) + fgp_flags |= fgf_set_order(pos % PAGE_SIZE + part); + + return __filemap_get_folio(mapping, index, fgp_flags, mapping_gfp_mask(mapping)); }