From patchwork Fri Oct 13 15:56:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 152619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1990130vqb; Fri, 13 Oct 2023 08:59:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2wRyokZrLWEw4jWT7BH4rh4HgREJAbZn1Pz223ZOJjpZ5hjNSgxRA5PoQX0zJzg87VRVu X-Received: by 2002:a05:6359:6418:b0:166:8ba6:d36d with SMTP id sh24-20020a056359641800b001668ba6d36dmr4514303rwb.0.1697212798082; Fri, 13 Oct 2023 08:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697212798; cv=none; d=google.com; s=arc-20160816; b=PSAH3hsMFMqY8Qzv5nAIYcg/QbK4AeSgTPv36s8tw9erEYn4EPzDpZWUPSlunwMG+x AsJBsxrZLIO7otdD2j1J5G+tNyzGLUzx+UDjqVWNTsef0BWEXzEsEPUAQW50tDs/8PdI yiI1ROweZqfEtMOYJMXV3yaDV57Ir1EdvYIQfpg06a9ZIpWPw+uz5FXmdlkhGDlPQ/vJ OugL57+Fr/+xm6wjHlkj7HMxp1SvtgUEW4blrvmn2eNX1IwJ4HZUFMFL7Uo7m3FcQ2bF ZYNfiDG+lMyeiRR/ea+4Vkh8GdDdSnViOjR2joEwlS4PpMlG1eE2vFyPDjUNAqOl4K9+ rQEQ== 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=gcj4568/Cja75cJgRJVpO1Pa05t3rY5GzidcrAxRiJc=; fh=jmUmYsO8YmwX20Dqv2n3fkhLiq7FjoQi2Bp7neHz30s=; b=DzeV7Scb69wu0CAjf54Ipaa4ct7qXb70Cn80+TRoGtm+sm2Mhw6FLDfX3wqWZxQFDx gfuFqLQlkN0tuKMh0GjJbJws9mhSpjZnwtUeyyjl/yFEkDQkrctseEcZNYJR3E9z73hl taDsM/c48c5CVOYk2xj3H8yXWEzgUXXfmreZzFuiQJ/z2TUNjdqTyqvVe+iRlJATHxO2 CjCj+pHzyBtuMnzZuklxGbBXnbBBeXczzJlkvAnSyMBIcwIILbXCmB+TpAnlH3R3UEgt iePsJLwUD7Qy8UFHbuvk8kyBBuKCyTygJl/jPqOgcvyd0mA+gVqW9RwHH9EXTdFVy5kT S0Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ClXdZA06; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h62-20020a638341000000b005aaf29151acsi1686530pge.834.2023.10.13.08.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 08:59:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=ClXdZA06; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 3475E831335F; Fri, 13 Oct 2023 08:59:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232589AbjJMP7q (ORCPT + 19 others); Fri, 13 Oct 2023 11:59:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232815AbjJMP7Z (ORCPT ); Fri, 13 Oct 2023 11:59:25 -0400 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 B0190FD for ; Fri, 13 Oct 2023 08:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697212676; 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=gcj4568/Cja75cJgRJVpO1Pa05t3rY5GzidcrAxRiJc=; b=ClXdZA06t0LPu3bjMvmBN7lvq9onoyvmzPfv+kz2ojWj4MguAmFNirC0+9iyKc8QcsrwxB XGr69BU9eDhhfEWDWrbftU3E2udBejZ+VXkMZV2zV5u3smN37sTTtjGmq6Psp1Ndvm2Ayz T8FgtTAw6c3Qm7D5byWw3k33xP4dGYc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-pbz5bDgbMkSmeASAhSIaXA-1; Fri, 13 Oct 2023 11:57:46 -0400 X-MC-Unique: pbz5bDgbMkSmeASAhSIaXA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EB33862F29; Fri, 13 Oct 2023 15:57:45 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0621C492BD9; Fri, 13 Oct 2023 15:57:42 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , 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, linux-cachefs@redhat.com Subject: [RFC PATCH 04/53] netfs: Allow the netfs to make the io (sub)request alloc larger Date: Fri, 13 Oct 2023 16:56:37 +0100 Message-ID: <20231013155727.2217781-5-dhowells@redhat.com> In-Reply-To: <20231013155727.2217781-1-dhowells@redhat.com> References: <20231013155727.2217781-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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 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]); Fri, 13 Oct 2023 08:59:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779656606998905239 X-GMAIL-MSGID: 1779656606998905239 Allow the network filesystem to specify extra space to be allocated on the end of the io (sub)request. This allows cifs, for example, to use this space rather than allocating its own cifs_readdata struct. 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/objects.c | 7 +++++-- include/linux/netfs.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index e41f9fc9bdd2..2f1865ff7cce 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -22,7 +22,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, struct netfs_io_request *rreq; int ret; - rreq = kzalloc(sizeof(struct netfs_io_request), GFP_KERNEL); + rreq = kzalloc(ctx->ops->io_request_size ?: sizeof(struct netfs_io_request), + GFP_KERNEL); if (!rreq) return ERR_PTR(-ENOMEM); @@ -116,7 +117,9 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq { struct netfs_io_subrequest *subreq; - subreq = kzalloc(sizeof(struct netfs_io_subrequest), GFP_KERNEL); + subreq = kzalloc(rreq->netfs_ops->io_subrequest_size ?: + sizeof(struct netfs_io_subrequest), + GFP_KERNEL); if (subreq) { INIT_LIST_HEAD(&subreq->rreq_link); refcount_set(&subreq->ref, 2); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index b92e982ac4a0..6942b8cf03dc 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -214,6 +214,8 @@ struct netfs_io_request { * Operations the network filesystem can/must provide to the helpers. */ struct netfs_request_ops { + unsigned int io_request_size; /* Alloc size for netfs_io_request struct */ + unsigned int io_subrequest_size; /* Alloc size for netfs_io_subrequest struct */ int (*init_request)(struct netfs_io_request *rreq, struct file *file); void (*free_request)(struct netfs_io_request *rreq); int (*begin_cache_operation)(struct netfs_io_request *rreq);