Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp804676rdb; Fri, 17 Nov 2023 13:19:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvWD29CpLwRScHR9RzYdwzwoIDuFqiZAMAFskuzPmoKcYQWE+efwNR7e08hx9nsibHMgwa X-Received: by 2002:a05:6e02:16c6:b0:35a:d63f:f559 with SMTP id 6-20020a056e0216c600b0035ad63ff559mr958762ilx.27.1700255941067; Fri, 17 Nov 2023 13:19:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700255941; cv=none; d=google.com; s=arc-20160816; b=zKOkeYKCFi0mEap3mBwJV8o/5hJwGTc5kgBm5FD+cz0fmrxJn2hLdBHLBZCbkQ1cO+ nPCShnoVbHLIpD1XgnODijFig887S8XW0u6lCAne9NhTOf8TS3GJHoZY1m96l7AsWljW tsxGJRrhRYoDwSqaNgsDiyEmwtpTJetOET30/BoVQyef3FQbi/k0dYg/qTEassFndzbA N9PpUbdbNvhhKKY8oUv2N5l9CkRo5Q7cUOwmqSf9tLKU+XtRbng/X9FK2XnTZ+3K275Z UQclgQzAIzACROcYHN2yh95VaZYFp0kwYVLdhejisyjiS/wPvAkUpfbgTowuYwo7RHs8 PKxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YCXtE3Gqov3oA1rKgjLh+er5qsDXpT3dWhNn5qjdKp8=; fh=lVY/c7gYUTDnyYYKKvGQU3Q29dA69hck6eN/HP5dBQ0=; b=rSUcjH2Jzn8lZm6FXnd+phOEVy/cmCzKhAQ+cMAKBUMnKMAp4u2ENbGNBWHpEQCEeE nvVLGo3dCFFqfYp7GLIK7iIKue3tl1RkmvvrbLiHjOu8K7pVvBvEfCEQ1y05m16oUQkk JsboFpbrCf/WdnmcTDL5yNCLeBpu5qcRRCPzt+NoYA6u1PRK7pGF0fhLQ1qsRnXYBTJG 4gt6laWkcoBHiP2/6919i3Ec0GbFISmV5WWYWQIblSXN0ozOzOl/IrolwBNKYF3VK5F4 ocMRaqEgZ5F2M2z51KbIuGK1JoEz03djxJRuU8UnWoG/ZCDN/0qgaXdLyLfCRG4E0EeA pszQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZMFDyCDp; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 3-20020a630803000000b005c1b3102abasi2793132pgi.656.2023.11.17.13.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:19:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZMFDyCDp; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B11E382BB572; Fri, 17 Nov 2023 13:18:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346376AbjKQVSs (ORCPT + 99 others); Fri, 17 Nov 2023 16:18:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235845AbjKQVSb (ORCPT ); Fri, 17 Nov 2023 16:18:31 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 220802D67 for ; Fri, 17 Nov 2023 13:17:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255855; 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=ZMFDyCDpl7Nm0R/iXKuH4EDFIAUVBtT11oWWcRf1T0g9xaHWzF22WMsrV72WxIF4J/CxER IhrA4163lOSvrdE4qwAOOW74PGr0lhLt8+VHGwL0MLZhfh3E+WUI9Knld6U4/90fvS7rl7 Gtz6AAer5nkGnIiMvzgvu8vnrqymSPA= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 13:18:59 -0800 (PST) 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)); }