{"action":"created","issue":{"url":"https://api.github.com/repos/openzfsonosx/zfs/issues/481","repository_url":"https://api.github.com/repos/openzfsonosx/zfs","labels_url":"https://api.github.com/repos/openzfsonosx/zfs/issues/481/labels{/name}","comments_url":"https://api.github.com/repos/openzfsonosx/zfs/issues/481/comments","events_url":"https://api.github.com/repos/openzfsonosx/zfs/issues/481/events","html_url":"https://github.com/openzfsonosx/zfs/pull/481","id":150934124,"number":481,"title":"zvols cloned with readonly=on are initially read-write","user":{"login":"evansus","id":2881843,"avatar_url":"https://avatars.githubusercontent.com/u/2881843?v=3","gravatar_id":"","url":"https://api.github.com/users/evansus","html_url":"https://github.com/evansus","followers_url":"https://api.github.com/users/evansus/followers","following_url":"https://api.github.com/users/evansus/following{/other_user}","gists_url":"https://api.github.com/users/evansus/gists{/gist_id}","starred_url":"https://api.github.com/users/evansus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evansus/subscriptions","organizations_url":"https://api.github.com/users/evansus/orgs","repos_url":"https://api.github.com/users/evansus/repos","events_url":"https://api.github.com/users/evansus/events{/privacy}","received_events_url":"https://api.github.com/users/evansus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-25T17:40:52Z","updated_at":"2016-04-26T19:52:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/openzfsonosx/zfs/pulls/481","html_url":"https://github.com/openzfsonosx/zfs/pull/481","diff_url":"https://github.com/openzfsonosx/zfs/pull/481.diff","patch_url":"https://github.com/openzfsonosx/zfs/pull/481.patch"},"body":"`zfs create -V <size> -o readonly=on <dataset>`\r\nor\r\n`zfs clone -o readonly=on <src> <dest>`\r\n\r\nwould create a read-write zvol device that could (incorrectly) be written to.\r\n\r\nThis is due to the create and clone ioctl setting local properties after creating a new dmu_objset, where dmu_objset_create and _clone calls zvol_create_minors on completion.\r\n\r\nzfs receive and zpool import were correctly handling readonly zvols, since the property is already set on the dataset by the time zvol_create_minors is called.\r\n\r\nWorkarounds: export and import pool, use send and receive to a new zvol\r\n\r\nFixed by disabling zvol_create_minors calls from dmu_objset_create_sync and dmu_objset_clone_sync, and instead calling after local properties have been set from zfs_ioc_create and zfs_ioc_clone."},"comment":{"url":"https://api.github.com/repos/openzfsonosx/zfs/issues/comments/214866322","html_url":"https://github.com/openzfsonosx/zfs/pull/481#issuecomment-214866322","issue_url":"https://api.github.com/repos/openzfsonosx/zfs/issues/481","id":214866322,"user":{"login":"evansus","id":2881843,"avatar_url":"https://avatars.githubusercontent.com/u/2881843?v=3","gravatar_id":"","url":"https://api.github.com/users/evansus","html_url":"https://github.com/evansus","followers_url":"https://api.github.com/users/evansus/followers","following_url":"https://api.github.com/users/evansus/following{/other_user}","gists_url":"https://api.github.com/users/evansus/gists{/gist_id}","starred_url":"https://api.github.com/users/evansus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evansus/subscriptions","organizations_url":"https://api.github.com/users/evansus/orgs","repos_url":"https://api.github.com/users/evansus/repos","events_url":"https://api.github.com/users/evansus/events{/privacy}","received_events_url":"https://api.github.com/users/evansus/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T19:52:43Z","updated_at":"2016-04-26T19:52:43Z","body":"In my opinion that commit is a big improvement, unless there are other regressions that can't be resolved easily. We still have some quirks/bugs, but they existed prior. Most obvious are zfs rename, rollback, and zfs set for readonly and volsize.\r\nSnapdev is working correctly, and we now have the zvol_inhibit_devs sysctl which is useful too.\r\n\r\nAgain, I think `zfs clone -o readonly` is likely to be used, and this is an easy fix. It continues to use the same async zvol operation, just changes when it is invoked in two specific cases."}}