aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/zcommon/zfs_prop.c9
-rw-r--r--module/zfs/zfs_ioctl.c3
-rw-r--r--module/zfs/zvol.c62
3 files changed, 71 insertions, 3 deletions
diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c
index 6aa38382b..b27e4f36f 100644
--- a/module/zcommon/zfs_prop.c
+++ b/module/zcommon/zfs_prop.c
@@ -106,6 +106,12 @@ zfs_prop_init(void)
{ NULL }
};
+ static zprop_index_t snapdev_table[] = {
+ { "hidden", ZFS_SNAPDEV_HIDDEN },
+ { "visible", ZFS_SNAPDEV_VISIBLE },
+ { NULL }
+ };
+
static zprop_index_t acl_inherit_table[] = {
{ "discard", ZFS_ACL_DISCARD },
{ "noallow", ZFS_ACL_NOALLOW },
@@ -217,6 +223,9 @@ zfs_prop_init(void)
zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
"hidden | visible", "SNAPDIR", snapdir_table);
+ zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN,
+ PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
+ "hidden | visible", "SNAPDEV", snapdev_table);
zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
"discard | noallow | restricted | passthrough | passthrough-x",
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index e804cce08..5560b2548 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -2184,6 +2184,9 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
case ZFS_PROP_VOLSIZE:
err = zvol_set_volsize(dsname, intval);
break;
+ case ZFS_PROP_SNAPDEV:
+ err = zvol_set_snapdev(dsname, intval);
+ break;
case ZFS_PROP_VERSION:
{
zfs_sb_t *zsb;
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index b0d59fe0c..b41eeb202 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -1288,7 +1288,28 @@ zvol_free(zvol_state_t *zv)
}
static int
-__zvol_create_minor(const char *name)
+__zvol_snapdev_hidden(const char *name)
+{
+ uint64_t snapdev;
+ char *parent;
+ char *atp;
+ int error = 0;
+
+ parent = kmem_alloc(MAXPATHLEN, KM_SLEEP);
+ (void) strlcpy(parent, name, MAXPATHLEN);
+
+ if ((atp = strrchr(parent, '@')) != NULL) {
+ *atp = '\0';
+ error = dsl_prop_get_integer(parent, "snapdev", &snapdev, NULL);
+ if ((error == 0) && (snapdev == ZFS_SNAPDEV_HIDDEN))
+ error = ENODEV;
+ }
+ kmem_free(parent, MAXPATHLEN);
+ return (error);
+}
+
+static int
+__zvol_create_minor(const char *name, boolean_t ignore_snapdev)
{
zvol_state_t *zv;
objset_t *os;
@@ -1305,6 +1326,12 @@ __zvol_create_minor(const char *name)
goto out;
}
+ if (ignore_snapdev == B_FALSE) {
+ error = __zvol_snapdev_hidden(name);
+ if (error)
+ goto out;
+ }
+
doi = kmem_alloc(sizeof(dmu_object_info_t), KM_SLEEP);
error = dmu_objset_own(name, DMU_OST_ZVOL, B_TRUE, zvol_tag, &os);
@@ -1386,7 +1413,7 @@ zvol_create_minor(const char *name)
int error;
mutex_enter(&zvol_state_lock);
- error = __zvol_create_minor(name);
+ error = __zvol_create_minor(name, B_FALSE);
mutex_exit(&zvol_state_lock);
return (error);
@@ -1434,7 +1461,7 @@ zvol_create_minors_cb(spa_t *spa, uint64_t dsobj,
if (strchr(dsname, '/') == NULL)
return 0;
- (void) __zvol_create_minor(dsname);
+ (void) __zvol_create_minor(dsname, B_FALSE);
return (0);
}
@@ -1502,6 +1529,35 @@ zvol_remove_minors(const char *pool)
kmem_free(str, MAXNAMELEN);
}
+static int
+snapdev_snapshot_changed_cb(const char *dsname, void *arg) {
+ uint64_t snapdev = *(uint64_t *) arg;
+
+ if (strchr(dsname, '@') == NULL)
+ return 0;
+
+ switch (snapdev) {
+ case ZFS_SNAPDEV_VISIBLE:
+ mutex_enter(&zvol_state_lock);
+ (void) __zvol_create_minor(dsname, B_TRUE);
+ mutex_exit(&zvol_state_lock);
+ break;
+ case ZFS_SNAPDEV_HIDDEN:
+ (void) zvol_remove_minor(dsname);
+ break;
+ }
+ return 0;
+}
+
+int
+zvol_set_snapdev(const char *dsname, uint64_t snapdev) {
+ (void) dmu_objset_find((char *) dsname, snapdev_snapshot_changed_cb,
+ &snapdev, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
+ /* caller should continue to modify snapdev property */
+ return (-1);
+}
+
+
int
zvol_init(void)
{