Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/cddl/osnet/dist/uts/common/fs/zfs Enable the zvol m...
details: https://anonhg.NetBSD.org/src/rev/856c36dc1090
branches: trunk
changeset: 451423:856c36dc1090
user: hannken <hannken%NetBSD.org@localhost>
date: Wed May 22 08:45:32 2019 +0000
description:
Enable the zvol minor management to create and remove device nodes.
diffstat:
external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c | 12 ++--
external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c | 2 +-
external/cddl/osnet/dist/uts/common/fs/zfs/spa.c | 4 +-
external/cddl/osnet/dist/uts/common/fs/zfs/sys/zvol.h | 2 +-
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c | 12 +---
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c | 12 +++-
external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c | 47 ++++++++++++---
7 files changed, 61 insertions(+), 30 deletions(-)
diffs (truncated from 315 to 300 lines):
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dataset.c Wed May 22 08:45:32 2019 +0000
@@ -1612,7 +1612,7 @@
fnvlist_free(suspended);
}
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#ifdef _KERNEL
if (error == 0) {
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
@@ -2164,7 +2164,7 @@
dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp,
dsl_dataset_t *hds, void *arg)
{
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#ifdef _KERNEL
char *oldname, *newname;
#endif
@@ -2197,7 +2197,7 @@
dsl_dataset_phys(hds)->ds_snapnames_zapobj,
ds->ds_snapname, 8, 1, &ds->ds_object, tx));
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#ifdef _KERNEL
oldname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
newname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
@@ -2640,7 +2640,7 @@
dsl_dir_t *odd = NULL;
uint64_t oldnext_obj;
int64_t delta;
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
char *oldname, *newname;
#endif
@@ -2710,7 +2710,7 @@
dsl_dir_phys(dd)->dd_clones, origin_head->ds_object, tx));
}
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
/* Take the spa_namespace_lock early so zvol renames don't deadlock. */
mutex_enter(&spa_namespace_lock);
@@ -2752,7 +2752,7 @@
VERIFY0(dsl_dir_hold_obj(dp, dd->dd_object,
NULL, ds, &ds->ds_dir));
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(_KERNEL)
dsl_dataset_name(ds, newname);
zfsvfs_update_fromname(oldname, newname);
zvol_rename_minors(oldname, newname);
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/dsl_dir.c Wed May 22 08:45:32 2019 +0000
@@ -1912,7 +1912,7 @@
VERIFY0(zap_add(mos, dsl_dir_phys(newparent)->dd_child_dir_zapobj,
dd->dd_myname, 8, 1, &dd->dd_object, tx));
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#ifdef _KERNEL
zfsvfs_update_fromname(ddra->ddra_oldname, ddra->ddra_newname);
zvol_rename_minors(ddra->ddra_oldname, ddra->ddra_newname);
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/spa.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/spa.c Wed May 22 08:45:32 2019 +0000
@@ -3226,7 +3226,7 @@
spa->spa_last_ubsync_txg = 0;
spa->spa_load_txg = 0;
mutex_exit(&spa_namespace_lock);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#ifdef _KERNEL
if (firstopen)
zvol_create_minors(spa->spa_name);
@@ -4508,7 +4508,7 @@
mutex_exit(&spa_namespace_lock);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#ifdef _KERNEL
zvol_create_minors(pool);
#endif
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/sys/zvol.h
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zvol.h Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zvol.h Wed May 22 08:45:32 2019 +0000
@@ -75,7 +75,7 @@
ssize_t resid, boolean_t sync);
#endif /* illumos */
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
extern int zvol_create_minors(const char *name);
extern void zvol_rename_minors(const char *oldname, const char *newname);
#endif
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c Wed May 22 08:45:32 2019 +0000
@@ -3360,10 +3360,8 @@
if (error != 0)
(void) dsl_destroy_head(fsname);
}
-#ifdef __FreeBSD__
if (error == 0 && type == DMU_OST_ZVOL)
zvol_create_minors(fsname);
-#endif
return (error);
}
@@ -3405,10 +3403,8 @@
if (error != 0)
(void) dsl_destroy_head(fsname);
}
-#ifdef __FreeBSD__
if (error == 0)
zvol_create_minors(fsname);
-#endif
return (error);
}
@@ -3681,9 +3677,7 @@
error = zfs_unmount_snap(name);
if (error != 0)
return (error);
-#if defined(__FreeBSD__)
zvol_remove_minors(name);
-#endif
}
return (dsl_destroy_snapshots_nvl(snaps, defer, outnvl));
@@ -3807,7 +3801,7 @@
else
err = dsl_destroy_head(zc->zc_name);
if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0)
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
zvol_remove_minors(zc->zc_name);
#else
(void) zvol_remove_minor(zc->zc_name);
@@ -4550,10 +4544,8 @@
}
#endif
-#ifdef __FreeBSD__
if (error == 0)
zvol_create_minors(tofs);
-#endif
/*
* On error, restore the original props.
@@ -6166,7 +6158,9 @@
static minor_t last_minor;
minor_t m;
+#ifndef __NetBSD__
ASSERT(MUTEX_HELD(&spa_namespace_lock));
+#endif
for (m = last_minor + 1; m != last_minor; m++) {
if (m > ZFSDEV_MAX_MINOR)
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c Wed May 22 08:45:32 2019 +0000
@@ -2956,7 +2956,7 @@
return (error);
}
-#ifdef __FreeBSD_kernel__
+#if defined(__FreeBSD_kernel__) || defined(__NetBSD__)
#ifdef _KERNEL
void
zfsvfs_update_fromname(const char *oldname, const char *newname)
@@ -2968,8 +2968,14 @@
oldlen = strlen(oldname);
+#ifdef __NetBSD__
+ mount_iterator_t *iter;
+ mountlist_iterator_init(&iter);
+ while ((mp = mountlist_iterator_next(iter)) != NULL) {
+#else
mtx_lock(&mountlist_mtx);
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
+#endif
fromname = mp->mnt_stat.f_mntfromname;
if (strcmp(fromname, oldname) == 0) {
(void)strlcpy(fromname, newname,
@@ -2985,7 +2991,11 @@
continue;
}
}
+#ifdef __NetBSD__
+ mountlist_iterator_destroy(iter);
+#else
mtx_unlock(&mountlist_mtx);
+#endif
}
#endif
#endif
diff -r 8435da909266 -r 856c36dc1090 external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c Wed May 22 08:44:48 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c Wed May 22 08:45:32 2019 +0000
@@ -870,7 +870,7 @@
(void) strlcpy(zv->zv_name, name, MAXPATHLEN);
zv->zv_min_bs = DEV_BSHIFT;
-#ifdef illumos
+#if defined(illumos) || defined(__NetBSD__)
zv->zv_minor = minor;
#endif
zv->zv_objset = os;
@@ -950,12 +950,17 @@
char nmbuf[20];
minor_t minor = zv->zv_minor;
- /* XXXNETBSD needs changes here */
- (void) snprintf(nmbuf, sizeof (nmbuf), "%u,raw", zv->zv_minor);
+ LIST_REMOVE(zv, zv_links);
+
+ (void) snprintf(nmbuf, sizeof (nmbuf), "%s", zv->zv_name);
ddi_remove_minor_node(zfs_dip, nmbuf);
- (void) snprintf(nmbuf, sizeof (nmbuf), "%u", zv->zv_minor);
+ (void) snprintf(nmbuf, sizeof (nmbuf), "%s", zv->zv_name);
ddi_remove_minor_node(zfs_dip, nmbuf);
+
+ disk_detach(&zv->zv_dk);
+ disk_destroy(&zv->zv_dk);
+ mutex_destroy(&zv->zv_dklock);
#endif
avl_destroy(&zv->zv_znode.z_range_avl);
@@ -983,6 +988,11 @@
mutex_exit(&zfsdev_state_lock);
return (SET_ERROR(ENXIO));
}
+#ifdef __NetBSD__
+ disk_detach(&zv->zv_dk);
+ disk_destroy(&zv->zv_dk);
+ mutex_destroy(&zv->zv_dklock);
+#endif
rc = zvol_remove_zv(zv);
mutex_exit(&zfsdev_state_lock);
return (rc);
@@ -1058,12 +1068,6 @@
dmu_objset_disown(zv->zv_objset, zvol_tag);
zv->zv_objset = NULL;
-#ifdef __NetBSD__xxx
- /* the old code has this here, but it's in the wrong place. */
- disk_detach(&zv->zv_dk);
- disk_destroy(&zv->zv_dk);
- mutex_destroy(&zv->zv_dklock);
-#endif
}
#ifdef illumos
@@ -3125,6 +3129,7 @@
}
}
}
+#endif
extern boolean_t dataset_name_hidden(const char *name);
@@ -3243,6 +3248,26 @@
return (0);
}
+#ifdef __NetBSD__
+void
+zvol_rename_minor(zvol_state_t *zv, const char *newname)
+{
+ char *nm;
+ minor_t minor = zv->zv_minor;
+
+ nm = PNBUF_GET();
+ strlcpy(nm, newname, MAXPATHLEN);
+ ddi_remove_minor_node(zfs_dip, zv->zv_name);
+ (void)ddi_create_minor_node(zfs_dip, nm, S_IFCHR, minor, DDI_PSEUDO, 0);
+ (void)ddi_create_minor_node(zfs_dip, nm, S_IFBLK, minor, DDI_PSEUDO, 0);
+ PNBUF_PUT(nm);
+
+ strlcpy(zv->zv_name, newname, sizeof(zv->zv_name));
+ /* XXX Update dk_name? */
+}
+#endif
+
+#ifdef __FreeBSD__
static void
zvol_rename_minor(zvol_state_t *zv, const char *newname)
{
@@ -3297,6 +3322,7 @@
Home |
Main Index |
Thread Index |
Old Index