Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp591723lqh; Thu, 28 Mar 2024 10:16:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwbRf4trMzjQs0sOTT65gavqfqO1o2UmUpPfuUJMbz2gxOk4qq816VeApf/KkX6IXnFsJuzXfIy4LzJPfIbqKFdKSenJ31hNTwrlP6mw== X-Google-Smtp-Source: AGHT+IFZx+0Q7rIP70wS8BLSZf9/FBcgug+pF/tBOCw1bgyr5bNo8PoIPj5NyO6zkoKeuz1jA8tc X-Received: by 2002:a05:6870:d113:b0:229:f06b:17fc with SMTP id e19-20020a056870d11300b00229f06b17fcmr3770691oac.24.1711646206604; Thu, 28 Mar 2024 10:16:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711646206; cv=pass; d=google.com; s=arc-20160816; b=EtDn0TTRA+CPCeZLEhPgvGnn2qF+QHzTaaMduKIzf47I0pF1cDUKRCYAEmygWSDA2N /fiiNxzpjOKpvOzQd1CRD1ualw2vLK+S8CBW36Raq/R68N9X+KxVDR9mnDHutk6Uuiqf RXLLyC4PB5Xfdn+/h8FQq9YHHC3Di7y6PrmS/SDp9TU/8IjS+BvnETXmDe6P93sa/dwu ncacgLr6TnZ6GpwVp6xBPzEgzC5uKREP5exfoVP9y9CFtsPHJmXdbJbGtL9RmTVlru/7 TO68bETeGRWTvYQRlPoPf9PPqRtsE4/he3La4+pJ5tZouUltfaHERX7llstyCdr0zsPm TcqA== ARC-Message-Signature: i=2; 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=FdETRfB8DnsEfVd472r7IU+9uzPySp2hW2I+XAgROTY=; fh=qGO61KcqD8nwg5doI1799cWr3E7eI1fHmScYq/qreMg=; b=FFk8ZxR6puVXqUEUHfUFw8zMe7aeyPxeH31CGnODucgiL2TCwFiSqxzPl/UWFE1OOh LEpF8efSmpW9O3FxPe8e9sj6K90p84z4XZUmC25rpQnrW6De+5IKH3+OOHR1wF09K7bo 51+9z/p02FC3GgUCTgXRd7AqRxTJyGNCQyQbrxufwix936zoZbjOE2b+f7haRt68LzeT DyWrHgGliiEIstIMp2jfZTfioxOQmdwVpNiS5kafhLeBVgb3vTAwy9bsb7939KTeEqCk TYWPSL4Jv4AFQmmAxsOqd27kBWOHc1WfeXm+gfhLGpKnOUxdgPy+gE5JgQLPUeLpdAZS ldXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R+lMY3K4; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123325-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123325-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x3-20020a056a00270300b006e659df8931si1792473pfv.380.2024.03.28.10.16.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 10:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123325-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R+lMY3K4; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123325-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123325-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D1A09B231E8 for ; Thu, 28 Mar 2024 17:02:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7E81137740; Thu, 28 Mar 2024 17:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R+lMY3K4" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 3D5F3136E23 for ; Thu, 28 Mar 2024 17:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645208; cv=none; b=r43OBpWAtVtVBc3LCseqBrb1PQ0doWdOjIYbY5SjvAWoipN/lExNshJIDhwOqmScPu5mCQohnzTB0/9q6i7JiySRGXIjghZc+vlyBXhNwp9lQD1Vqwo2eFrWbr+Bv/jtykSddkckjC3SsW8R6eIpJ+DsdrLHnsg7JZJ3W33lfJM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645208; c=relaxed/simple; bh=1H+o+v897zLhA37MJj9BJEjve71vHhPdyEjqxJssFSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+LoByZoCNDGF/6k/NQ5HZae95XWVqVsIACCirnegTOmKCO3QZuFa+9WRg9MxZCbwnAno71ePKuHpnpljCp2tu5cEp9iKOe7Cr4CXma1kJJoFzmVsG7KO3ST/oSz7ow33qgsABBWymTnxOMI1RWFUvlTZimXu9/709mW5EbjelQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=R+lMY3K4; arc=none smtp.client-ip=170.10.133.124 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=1711645206; 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=FdETRfB8DnsEfVd472r7IU+9uzPySp2hW2I+XAgROTY=; b=R+lMY3K4u8aEFaVCjYaXD0JtSBB6E+mqBZ9wrsnhMIV27vlPSeCG05VmHz10UT2CJBep99 Z7GXYHVjehK2kJG6UgQOeAGcw3PiFzBGCGlY6lif65/hua65fR9NbXz0j3WQFBMY4SpwwM av0O5sFH/IIPWpRuJx/xeIeLpFEiSuw= 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-400-B-6RQZNSNq6woioU60vOtQ-1; Thu, 28 Mar 2024 13:00:00 -0400 X-MC-Unique: B-6RQZNSNq6woioU60vOtQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 E51281C2CDE3; Thu, 28 Mar 2024 16:59:59 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id F29CF2166B31; Thu, 28 Mar 2024 16:59:57 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Jeff Layton , Matthew Wilcox , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Christian Brauner , netfs@lists.linux.dev, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH v6 08/15] cifs: Add mempools for cifs_io_request and cifs_io_subrequest structs Date: Thu, 28 Mar 2024 16:57:59 +0000 Message-ID: <20240328165845.2782259-9-dhowells@redhat.com> In-Reply-To: <20240328165845.2782259-1-dhowells@redhat.com> References: <20240328165845.2782259-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Add mempools for the allocation of cifs_io_request and cifs_io_subrequest structs for netfslib to use so that it can guarantee eventual allocation in writeback. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/smb/client/cifsfs.c | 55 +++++++++++++++++++++++++++++++++++++++- fs/smb/client/cifsglob.h | 2 ++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 2dd29663dab1..d8c31383752a 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -370,9 +370,13 @@ static struct kmem_cache *cifs_inode_cachep; static struct kmem_cache *cifs_req_cachep; static struct kmem_cache *cifs_mid_cachep; static struct kmem_cache *cifs_sm_req_cachep; +static struct kmem_cache *cifs_io_request_cachep; +static struct kmem_cache *cifs_io_subrequest_cachep; mempool_t *cifs_sm_req_poolp; mempool_t *cifs_req_poolp; mempool_t *cifs_mid_poolp; +mempool_t cifs_io_request_pool; +mempool_t cifs_io_subrequest_pool; static struct inode * cifs_alloc_inode(struct super_block *sb) @@ -1746,6 +1750,48 @@ static void destroy_mids(void) kmem_cache_destroy(cifs_mid_cachep); } +static int cifs_init_netfs(void) +{ + cifs_io_request_cachep = + kmem_cache_create("cifs_io_request", + sizeof(struct netfs_io_request), 0, + SLAB_HWCACHE_ALIGN, NULL); + if (!cifs_io_request_cachep) + goto nomem_req; + + if (mempool_init_slab_pool(&cifs_io_request_pool, 100, cifs_io_request_cachep) < 0) + goto nomem_reqpool; + + cifs_io_subrequest_cachep = + kmem_cache_create("cifs_io_subrequest", + sizeof(struct cifs_io_subrequest), 0, + SLAB_HWCACHE_ALIGN, NULL); + if (!cifs_io_subrequest_cachep) + goto nomem_subreq; + + if (mempool_init_slab_pool(&cifs_io_subrequest_pool, 100, cifs_io_subrequest_cachep) < 0) + goto nomem_subreqpool; + + return 0; + +nomem_subreqpool: + kmem_cache_destroy(cifs_io_subrequest_cachep); +nomem_subreq: + mempool_destroy(&cifs_io_request_pool); +nomem_reqpool: + kmem_cache_destroy(cifs_io_request_cachep); +nomem_req: + return -ENOMEM; +} + +static void cifs_destroy_netfs(void) +{ + mempool_destroy(&cifs_io_subrequest_pool); + kmem_cache_destroy(cifs_io_subrequest_cachep); + mempool_destroy(&cifs_io_request_pool); + kmem_cache_destroy(cifs_io_request_cachep); +} + static int __init init_cifs(void) { @@ -1843,10 +1889,14 @@ init_cifs(void) if (rc) goto out_destroy_deferredclose_wq; - rc = init_mids(); + rc = cifs_init_netfs(); if (rc) goto out_destroy_inodecache; + rc = init_mids(); + if (rc) + goto out_destroy_netfs; + rc = cifs_init_request_bufs(); if (rc) goto out_destroy_mids; @@ -1901,6 +1951,8 @@ init_cifs(void) cifs_destroy_request_bufs(); out_destroy_mids: destroy_mids(); +out_destroy_netfs: + cifs_destroy_netfs(); out_destroy_inodecache: cifs_destroy_inodecache(); out_destroy_deferredclose_wq: @@ -1937,6 +1989,7 @@ exit_cifs(void) #endif cifs_destroy_request_bufs(); destroy_mids(); + cifs_destroy_netfs(); cifs_destroy_inodecache(); destroy_workqueue(deferredclose_wq); destroy_workqueue(cifsoplockd_wq); diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 6436d360b9f4..057a7933b175 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -2089,6 +2089,8 @@ extern __u32 cifs_lock_secret; extern mempool_t *cifs_sm_req_poolp; extern mempool_t *cifs_req_poolp; extern mempool_t *cifs_mid_poolp; +extern mempool_t cifs_io_request_pool; +extern mempool_t cifs_io_subrequest_pool; /* Operations for different SMB versions */ #define SMB1_VERSION_STRING "1.0"