Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5392469rdb; Wed, 13 Dec 2023 07:28:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJl1wV1bXDflt+QBA0JkVgzEIqDdSd6CPiW6VrNG9n70pXqJsLnYSz82xcC5nylXNcLF6I X-Received: by 2002:a05:6a20:12c5:b0:18f:cc3c:be54 with SMTP id v5-20020a056a2012c500b0018fcc3cbe54mr4709243pzg.16.1702481329596; Wed, 13 Dec 2023 07:28:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702481329; cv=none; d=google.com; s=arc-20160816; b=MXdCV8QhtHHvSROS90yGqPMWi+1ghWIC4ZlwO50Fy7PgtdDn+LoE608VsRBjVMgPpg f3ydB73BJAyHV/Mp2W/d7j0MReVIoOJ20QuLF9q1ID/FAabLlbybRzVnGVzhqRmvmgL1 Mj4V/ctLi9zBhe1ZYQTLf7z9IYWRjBSsKsNQcCirXDRqxdk3Va8VbRS3RkSKV7gj1qRN DL7tPyoMNsVOJgb3njxPwR27O2IxIVJVpWyjv7OoXO9l/1cnxINUpQHQ2hdDQ5DWgtKu 9gPAiv1x+cZ49CDRAIQneE2cKbaPUHAgECEw+79fbZi92IBJ25kDSc6uTp9U3zn6ecF2 W29A== 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=KbBg4oLyg/4VjucqWLPnAUrUGVI7xibirsiFMNrNygw=; fh=ib4gl95HfLmZdfX9QIMf3rTepWCH9JlNymcDKJTPhJg=; b=fuMuYOdpnW3PlQ8dPmt2BFP8T+bL47K9rjWBzybXUmUnWyuy8Ol+bCZjzUfXTeJfAS 0M1Et4uJXB2/DO01n1Kl7+MA0dLKD/xhsvjRgSRmTS1o5fh9fxGEdi0sXT8OLo/5iRJk 5fO0T1jNWyCVVWtm9WriQ1DsrO4vGwPBrLHEz40DveNhfAscJHrmNFYseqbk/PI3Xrne r6ZzlrnJ7FKEz7mKLCiftKwVyRnseHVEp1qpVID8iBffHIFD1WuQP1eD/1B+7GwWEttb 0sTNyUr/nMLtcdLDHlIaKynsVvNX0hon7UQ4mSnPJ8GylcbbHT4JwnzC47EAiHCRGTNx p4SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e7r3PqB2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-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. [23.128.96.37]) by mx.google.com with ESMTPS id k16-20020a63d850000000b005740b4723f9si9684710pgj.811.2023.12.13.07.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 07:28:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e7r3PqB2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-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 85CCB8030B51; Wed, 13 Dec 2023 07:28:47 -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 S1442194AbjLMP2a (ORCPT + 99 others); Wed, 13 Dec 2023 10:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442179AbjLMP1y (ORCPT ); Wed, 13 Dec 2023 10:27:54 -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 0959F1731 for ; Wed, 13 Dec 2023 07:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702481180; 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=KbBg4oLyg/4VjucqWLPnAUrUGVI7xibirsiFMNrNygw=; b=e7r3PqB2vAv8B2rswgc1BUQ+c/EHWz8K6LVhVxYc6pEmwZK8ndjW1R7zR8a7Fq0srSrslG VUmU+K85t8R92UjmaRuTTV+S1qzPEC4tS5j5Pu2izjPF/hHov5vPsZCEIYKAhQ7LTwLcYR HRlXHiXWS2wRZVha5SJ2SSqD3Gt58GY= 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-16-K1t_OTENORi1A-IFlHrJWg-1; Wed, 13 Dec 2023 10:25:59 -0500 X-MC-Unique: K1t_OTENORi1A-IFlHrJWg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 797C53811F42; Wed, 13 Dec 2023 15:25:50 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD51451E3; Wed, 13 Dec 2023 15:25:46 +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 v4 27/39] netfs: Allocate multipage folios in the writepath Date: Wed, 13 Dec 2023 15:23:37 +0000 Message-ID: <20231213152350.431591-28-dhowells@redhat.com> In-Reply-To: <20231213152350.431591-1-dhowells@redhat.com> References: <20231213152350.431591-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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_BLOCKED,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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Dec 2023 07:28:47 -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 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)); }