From patchwork Thu Dec 21 13:23:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 182222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp408558dyi; Thu, 21 Dec 2023 05:29:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOHnzXLN2Xw7TElfEbKmY7GdoBLgbKwGGmaH6eG0EsI48WTPyARjPaBK4qbTvWX23IgRIa X-Received: by 2002:a50:8a86:0:b0:553:33b6:36d8 with SMTP id j6-20020a508a86000000b0055333b636d8mr4539872edj.76.1703165359432; Thu, 21 Dec 2023 05:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703165359; cv=none; d=google.com; s=arc-20160816; b=R3DrrWU/km5wPFjGIeRltRutU3VsXcEdtVo/l4KHTECUf3tHocQGcL5lcBhoWEifDO 9LKBZW4OAJxB2LhBhrJ2FKFz28NN5LhN5FiYPpj5NRsf6zXB0Lt4qjFlB+9NHn91dbNG 3ygrxDL4hmrk/XmhMi1BXQd5eDZrUDEGUEKyP5ONPgvorTNbkMyVffpp3wzUaO0ipt4I PIAnwVfm3MXqQgdQ0/tUyJKQh7ZuW+P06UJhSSugNWuMaTxVD86RriTBQVNbtCcDp78I Cbo9AA2328fA9YgrEatxiw82BJofQ/PsRefpduRDR0RZhebqlppkjIEutIo/jcZ8sCxn WVYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OUiNmCjPvqOiTp/4UL00+cVpBnekg0L/g2EBDkgOp3k=; fh=ib4gl95HfLmZdfX9QIMf3rTepWCH9JlNymcDKJTPhJg=; b=xTzTQrmuaUu4Df40mxrLssPumGyByQVOqgO0+fpnDSOmDPWyq/vZmS/rcRe4cU4uSj iUD8Q/Bjnxx4kt/JjKs4ecwdSw4E9AS7r6YXnLU8n3tBKHye2k2+dypow61rMeda43k7 berhG7JhujxVGdPe9PAWf1lRxvjQ57EBwe+NoNTQDMQwRFMWii76doyjfh8XL4hM1DAg ZyW3CAcpMzAcq7J1cQzC5HZwr6wezglRP5iSHqIAp7mbrBG9klZUsOCvdqkWnsTgDaud 8qv5Z6+ytapTek6IIsssqwQJ8EX0LOKL9CvSC6mhw2veE9XBms2EL6W04HOxM/dYP4Al BZ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DQMSBwS2; spf=pass (google.com: domain of linux-kernel+bounces-8454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8454-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e14-20020a50a68e000000b00553e18158c8si836425edc.302.2023.12.21.05.29.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 05:29:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DQMSBwS2; spf=pass (google.com: domain of linux-kernel+bounces-8454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8454-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1208A1F20588 for ; Thu, 21 Dec 2023 13:29:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBD3D7AE74; Thu, 21 Dec 2023 13:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DQMSBwS2" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D09AE7A229 for ; Thu, 21 Dec 2023 13:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703165083; 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=OUiNmCjPvqOiTp/4UL00+cVpBnekg0L/g2EBDkgOp3k=; b=DQMSBwS2KB+Uz1rRg8mN55CWTFbEWmJLfpWk3XN+zS8aMq9WU0ZtbxK0WhSQG6xbDxUP2P K/PfDJtzTviqbiu5Qe66ry+6oIf9wrvqYgfE2HEsjMXwos0pZXL9pZZv7kbPnJ3GcSqo0A EqAudlc7/bHaADlbddBiomnSxlpjILM= 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-673-SL0um2dhP2aWOnnR2kR2cw-1; Thu, 21 Dec 2023 08:24:41 -0500 X-MC-Unique: SL0um2dhP2aWOnnR2kR2cw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 5E6B2185A78A; Thu, 21 Dec 2023 13:24:40 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.39.195.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FD1B40C6EB9; Thu, 21 Dec 2023 13:24:37 +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 v5 09/40] netfs: Allow the netfs to make the io (sub)request alloc larger Date: Thu, 21 Dec 2023 13:23:04 +0000 Message-ID: <20231221132400.1601991-10-dhowells@redhat.com> In-Reply-To: <20231221132400.1601991-1-dhowells@redhat.com> References: <20231221132400.1601991-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785898319750582280 X-GMAIL-MSGID: 1785898319750582280 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 Reviewed-by: 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 85f428fc52e6..c4229c5f3f54 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); @@ -114,7 +115,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 7244ddebd974..d6f27000eeb0 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -210,6 +210,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);