Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1950425rdb; Thu, 7 Dec 2023 13:31:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS6QVJISFUubYRJLmyW/r+dYf+p+6oF2t0ZOGexoGBIdWzFuNIrQzTjTza70f608ecNJ64 X-Received: by 2002:a05:6a20:cea7:b0:18f:97c:4f6c with SMTP id if39-20020a056a20cea700b0018f097c4f6cmr2644470pzb.120.1701984672906; Thu, 07 Dec 2023 13:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701984672; cv=none; d=google.com; s=arc-20160816; b=EmzBbaZlF9u+uXcEgkP7ufg7xqutoFJmuEpH9XglQv5pkiYjImEJhYDDmzerYJjayL G0xs3dmUmUHxWF54hAjfaREohGTOl0pJseM2lNrW7xZBvOrkKBUpf6+GXDCwzyohZwHE HCk/OdozXCviGvZUHdqWt5+C3bJf9vrEEfe+ug7+fsnRK+elj8ZtZVVz+eUzwHA+fpvs N40xQIniNG31tv3nHowzHZH2U+hLmcP3G6Us1rUBPqcldpaLd0Y8ntrFfhxgCfLLlsUf zsuEoo5o66BZoHxgGXd4h53UNRicaD+OfbG3mBt40Qy0BdkbdjXTnffBPDPMk3Cz/w+B Qsbw== 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=qKaKkwweZS00JHJLn4SF0a3u3/8M9kaJh64u7aNSJy8zvjXr0uktUCDiKrm1ifGkoA IvZsC0+4mEXdiqVOPrGkXEcHyIygLzPP4YmFJBeSPvazzBWBugaaKYGLnNQnP7VTgTv2 3gwojT3hNQLjcYBdEHFT62i6F+UuFkIwq00meHQ6DtZ8I+Spd2epuvVRKvsm8EEgdOvc AqIm4e49U6RP/ryyxzV+e9SXnktpNzExe3qBEUQg8mJclXp6jKvrhZNnzf45gJH1ZXlu rC6qxsiexKbEwGWTtcK7Ts/zhp+dVGIvF6jmvV7pQaxppnVb0I8r9J5wuMCKvlNciHuf PaSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KAXAUa2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id b6-20020a6541c6000000b005bdfda8e044si297708pgq.775.2023.12.07.13.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 13:31:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KAXAUa2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 8C3C880958BB; Thu, 7 Dec 2023 13:30:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444173AbjLGVaa (ORCPT + 99 others); Thu, 7 Dec 2023 16:30:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235808AbjLGV3C (ORCPT ); Thu, 7 Dec 2023 16:29:02 -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 D16253583 for ; Thu, 7 Dec 2023 13:24:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701984239; 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=KAXAUa2+Hsc5XiMiC8a38wXUZOItXgm3DqyFFvQ08erH8T9Bs7ReH6Dotjdbh7JnilaeqZ lGwtqt6ehdxPOs/BQSCxQNJCi6m7M8Sd5lB2HKmq3KuLZwDMM7ePmaE5fwpzVdNYVS4/0e PpbBGXSrAxyCo6SUvzmMuPLd3ye1r0E= 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-64-QpeNj_4NMEmIciYa2Sj6iw-1; Thu, 07 Dec 2023 16:23:51 -0500 X-MC-Unique: QpeNj_4NMEmIciYa2Sj6iw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 2958A85A5B5; Thu, 7 Dec 2023 21:23:45 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A7CF492BC6; Thu, 7 Dec 2023 21:23:42 +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 v3 27/59] netfs: Allocate multipage folios in the writepath Date: Thu, 7 Dec 2023 21:21:34 +0000 Message-ID: <20231207212206.1379128-28-dhowells@redhat.com> In-Reply-To: <20231207212206.1379128-1-dhowells@redhat.com> References: <20231207212206.1379128-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 13:30:51 -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)); }