From patchwork Fri Nov 17 21:15:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13459581 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 17F1AC072A2 for ; Fri, 17 Nov 2023 21:17:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A4E18D004F; Fri, 17 Nov 2023 16:17:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 903638D001C; Fri, 17 Nov 2023 16:17:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A4E98D004F; Fri, 17 Nov 2023 16:17:37 -0500 (EST) 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 669CC8D001C for ; Fri, 17 Nov 2023 16:17:37 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4221740DCC for ; Fri, 17 Nov 2023 21:17:37 +0000 (UTC) X-FDA: 81468707754.04.3A22107 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 715ED140029 for ; Fri, 17 Nov 2023 21:17:35 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XxcNFTmx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1700255855; 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=YCXtE3Gqov3oA1rKgjLh+er5qsDXpT3dWhNn5qjdKp8=; b=TA4sjnecAbA2cHg3JacFGjnXs7ot69Ck+0rCzRolJd0etOFElJZkGXOFt3ugRkTNacpUCq Kc6D9LyPEngPbzbE5qzSW8B8RUdLS01bpNHUlLyorGGn1OGQHCbgm2wjo7erhpdbDUiyzp bdwf5GuGw9/6pcjV5kw0sOC7vSD+jfA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XxcNFTmx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1700255855; a=rsa-sha256; cv=none; b=uUui1P+WcT4No0hCi3ij2YdAtc+YMQ+LqnNSjLreb939aiCZeL9GpGGuMrQuPO2OkHTYKV aBh0pKYVPtMGswnd2VFhWN3NlByZy+Eb21JOpTOkevRL+s7mTgUe6m1QZWgiu0NpCUUUAX 0toiEnS7LE+NqU8vJVa66/32HpyaCOo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255854; 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=YCXtE3Gqov3oA1rKgjLh+er5qsDXpT3dWhNn5qjdKp8=; b=XxcNFTmxl2DuPZkIeld7HCzLRUCk1gDbD0py5YzP8vTqoKW0FJ//KFQBwDfafiCZEs5kBN e13TbLQqpg81ZIHi0WIDxq9r53/SXQVJdLDjhMXJNpggCFfxbj8jftN8wCZjaoi5oocJZn ZaLKG1Les74inx3kRpfFU/ZLzKF+dEU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-N7HNf3GGO_Wm-mBZutpn_g-1; Fri, 17 Nov 2023 16:17:30 -0500 X-MC-Unique: N7HNf3GGO_Wm-mBZutpn_g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 C1644811E8E; Fri, 17 Nov 2023 21:17:29 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 234291121306; Fri, 17 Nov 2023 21:17:27 +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 , 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 v2 24/51] netfs: Allocate multipage folios in the writepath Date: Fri, 17 Nov 2023 21:15:16 +0000 Message-ID: <20231117211544.1740466-25-dhowells@redhat.com> In-Reply-To: <20231117211544.1740466-1-dhowells@redhat.com> References: <20231117211544.1740466-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspam-User: X-Stat-Signature: a636ragn8ax96w48fpmdmn6i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/aCHMs3CyUkblOQXfzE5GmuCFO65caU94FIXRVx/o1nYw9rqEpCC8MZVX+x++yQKnlwWjTfbzPK0yCUY8D+kWj1tNqt+gDV+gVuaBBoeC6QLszG4eimLDINd9wj2Vdy5YdVpk/C66LdSSz4/VpcdubtGma5xMNGuKeybCGaNPOqG2NKhLWKl8Dn+Pyva52S44gcF45UXuhhzVJoH3kTWC0YrsopQqT/Mff5KulbeLBE7I14ERaLIXHObryIPd8qIWesqW1RREnmwO7olj/A 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 cc: 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 406c3f3666fa..4de6a12149e4 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)); }