extern int zvol_set_volsize(const char *, uint64_t);
extern int zvol_set_volthreading(const char *, boolean_t);
extern int zvol_set_common(const char *, zfs_prop_t, zprop_source_t, uint64_t);
+extern int zvol_set_ro(const char *, boolean_t);
extern zvol_state_handle_t *zvol_suspend(const char *);
extern int zvol_resume(zvol_state_handle_t *);
extern void *zvol_tag(zvol_state_handle_t *);
case ZFS_PROP_VOLMODE:
err = zvol_set_common(dsname, prop, source, intval);
break;
+ case ZFS_PROP_READONLY:
+ err = zvol_set_ro(dsname, intval);
+ /*
+ * Set err to -1 to force the zfs_set_prop_nvlist code down the
+ * default path to set the value in the nvlist.
+ */
+ if (err == 0)
+ err = -1;
+ break;
case ZFS_PROP_VERSION:
{
zfsvfs_t *zfsvfs;
return (0);
}
+/*
+ * Update zvol ro property.
+ */
+int
+zvol_set_ro(const char *name, boolean_t value)
+{
+ zvol_state_t *zv = zvol_find_by_name(name, RW_NONE);
+ if (zv == NULL)
+ return (-1);
+ if (value) {
+ zvol_os_set_disk_ro(zv, 1);
+ zv->zv_flags |= ZVOL_RDONLY;
+ } else {
+ zvol_os_set_disk_ro(zv, 0);
+ zv->zv_flags &= ~ZVOL_RDONLY;
+ }
+ mutex_exit(&zv->zv_state_lock);
+ return (0);
+}
+
/*
* Sanity check volume block size.
*/