linux/vfsops: add vfs_t allocator, make public

In a few commits, we're going  to need to allocate and free vfs_t from
zpl_super.c as well, so lets keep them uniform.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@truenas.com>
Closes #18377
This commit is contained in:
Rob Norris
2026-03-26 11:05:59 +11:00
committed by Tony Hutter
parent 9b8ccbd2cb
commit 7843c42b27
2 changed files with 15 additions and 3 deletions
+11 -3
View File
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
* Copyright (c) 2026, TrueNAS.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -110,7 +111,15 @@ static const match_table_t zpl_tokens = {
{ TOKEN_LAST, NULL },
};
static void
vfs_t *
zfsvfs_vfs_alloc(void)
{
vfs_t *vfsp = kmem_zalloc(sizeof (vfs_t), KM_SLEEP);
mutex_init(&vfsp->vfs_mntpt_lock, NULL, MUTEX_DEFAULT, NULL);
return (vfsp);
}
void
zfsvfs_vfs_free(vfs_t *vfsp)
{
if (vfsp != NULL) {
@@ -220,8 +229,7 @@ zfsvfs_parse_options(char *mntopts, vfs_t **vfsp)
vfs_t *tmp_vfsp;
int error;
tmp_vfsp = kmem_zalloc(sizeof (vfs_t), KM_SLEEP);
mutex_init(&tmp_vfsp->vfs_mntpt_lock, NULL, MUTEX_DEFAULT, NULL);
tmp_vfsp = zfsvfs_vfs_alloc();
if (mntopts != NULL) {
substring_t args[MAX_OPT_ARGS];