Bug 184092 - [zfs] zfs zvol devices are not appearing till after reimport of pool
Summary: [zfs] zfs zvol devices are not appearing till after reimport of pool
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-19 18:20 UTC by harrison
Modified: 2014-04-16 02:00 UTC (History)
0 users

See Also:


Attachments
harrison.vcf (215 bytes, text/x-vcard; charset=utf-8)
2014-01-27 20:29 UTC, harrison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description harrison 2013-11-19 18:20:00 UTC
cloned zvol's from snapshots do not appear in dev tree.

When creating a zfs volume and snapshoting this volume the volume and snapshot appear just fine in the /dev tree (under /dev/zvol/...).   However, when creating a clone of a snapshot, the dev tree is not updated with the new clone zvol.   The only way I have been able to have the cloned zvol appear in the dev tree is to completely export the zpool and reimport it.   Once the zpool has been reimported the /dev/zvol clone device appears.

It might be related but deleted zvol snapshots also remain and continue to appear in the zvol dev tree after the zvol snapshot has been deleted.

Fix: 

Pure speculation at this point:   
        

update the zfs clone code to check if the cloned dataset is a volume and create a new zvol device if the clone is a volume from the snapshot.

clean/reindex the zvol dev tree when zvol snapshots are destroyed or cloned
How-To-Repeat: create zfs zvol volume
snapshot the zvol volume
create a clone from the zvol volume snapshot
try to access the zvol device from the zvol device tree under /dev/zvol/<poolname>/<zvol>
No device exists
Export the zpool (zpool export <poolname>)
import the zpool (zpool import <poolname>)
The zvol device now appears under the device tree in the proper /dev/zvol area.
Comment 1 Xin LI 2013-11-19 18:50:34 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I think Andriy (cc'ed) have fixed a similar issue.  A quick glance at
the code suggests maybe we can use something like this:


Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
===================================================================
- --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
(revision 258350)
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
(working copy)
@@ -3298,6 +3298,10 @@ zfs_ioc_clone(const char *fsname, nvlist_t *innvl,
                if (error != 0)
                        (void) dsl_destroy_head(fsname);
        }
+#ifdef __FreeBSD__
+       if (error == 0)
+               zvol_create_minors(fsname);
+#endif
        return (error);
 }

Can you confirm if this helps?

(I think we should use a better way to trigger zvol_create_minor,
maybe via a devfs lookup hook?)

Cheers,
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJSi7L6AAoJEJW2GBstM+nsU7IQAKJhuls5BEXXsvp8SsoJDZ1x
7SK4BP27cIF++hqzf4DVyP5OJEXFivFBgmbbdcS2q91X4ZR7kwdp/c7PWLArrtLO
uQkQaeFpr5xvZsro6n58zVqjFc6ItaEZ0RWsv82Rqx9lVX8INb3Z/AneM2HXVXkX
GDPTCf17bsxcgsxeCXgirpYYO4bOnUlTCNNmBSR62BNvQRNHwrTO+wVRVLGkZ4JK
/y0GtiE2P1xhGq24XNswGqlmZPwBZHvqrvMXM1BjAdW2/kKuzWQ2HA9nflSGFK5k
V502qe+fZXK4p227/9To1XfNIDC2GnONfvYOjqJigwjvd+2zENVxyLphHowfQpkw
qWOgQ7b8nHc5GzjkWRJIJVm1JJHSHfAyH3VRwHBkEOGv0qs/ScM3x9mjaeqSb5Uu
cIAF2vMt9gDfvgsV1fL0y33qOGFMFqPW7E0oOPGHrDMRQPUsGAeItUWCppbxmnVD
HkCbPxYiH3EoFXULT8kX5gthRpbl1IveEluGGFITPxYsj1XmUvmQPBSkJPauoTvZ
0Aoe306mfuad8gmCBxpSCqTs9cvQrzeOvfc3bMKSLmSCbZ7SfnwG1EVGUMiX1DI9
1ugyRXHPlCZ/59HsEDym+Jlz/cqijo+dFykgjllwiwQtgzQSAhlaiyXjVZIxhfKL
EgIpjuU+stDV10DsEwow
=jwi6
-----END PGP SIGNATURE-----
Comment 2 harrison 2014-01-27 20:29:07 UTC
I was not able to get the code patch to apply cleanly.   I do support 
the idea of a devfs hook.   I think the devfs hook is a lot cleaner and 
reduces the need to make sure the devnode is created/destroyed after 
every update to the zvols.

     -C

On 11/19/13 12:50, Xin Li wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> I think Andriy (cc'ed) have fixed a similar issue.  A quick glance at
> the code suggests maybe we can use something like this:
>
>
> Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
> ===================================================================
> - --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
> (revision 258350)
> +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
> (working copy)
> @@ -3298,6 +3298,10 @@ zfs_ioc_clone(const char *fsname, nvlist_t *innvl,
>                  if (error != 0)
>                          (void) dsl_destroy_head(fsname);
>          }
> +#ifdef __FreeBSD__
> +       if (error == 0)
> +               zvol_create_minors(fsname);
> +#endif
>          return (error);
>   }
>
> Can you confirm if this helps?
>
> (I think we should use a better way to trigger zvol_create_minor,
> maybe via a devfs lookup hook?)
>
> Cheers,
> -----BEGIN PGP SIGNATURE-----
>
> iQIcBAEBCgAGBQJSi7L6AAoJEJW2GBstM+nsU7IQAKJhuls5BEXXsvp8SsoJDZ1x
> 7SK4BP27cIF++hqzf4DVyP5OJEXFivFBgmbbdcS2q91X4ZR7kwdp/c7PWLArrtLO
> uQkQaeFpr5xvZsro6n58zVqjFc6ItaEZ0RWsv82Rqx9lVX8INb3Z/AneM2HXVXkX
> GDPTCf17bsxcgsxeCXgirpYYO4bOnUlTCNNmBSR62BNvQRNHwrTO+wVRVLGkZ4JK
> /y0GtiE2P1xhGq24XNswGqlmZPwBZHvqrvMXM1BjAdW2/kKuzWQ2HA9nflSGFK5k
> V502qe+fZXK4p227/9To1XfNIDC2GnONfvYOjqJigwjvd+2zENVxyLphHowfQpkw
> qWOgQ7b8nHc5GzjkWRJIJVm1JJHSHfAyH3VRwHBkEOGv0qs/ScM3x9mjaeqSb5Uu
> cIAF2vMt9gDfvgsV1fL0y33qOGFMFqPW7E0oOPGHrDMRQPUsGAeItUWCppbxmnVD
> HkCbPxYiH3EoFXULT8kX5gthRpbl1IveEluGGFITPxYsj1XmUvmQPBSkJPauoTvZ
> 0Aoe306mfuad8gmCBxpSCqTs9cvQrzeOvfc3bMKSLmSCbZ7SfnwG1EVGUMiX1DI9
> 1ugyRXHPlCZ/59HsEDym+Jlz/cqijo+dFykgjllwiwQtgzQSAhlaiyXjVZIxhfKL
> EgIpjuU+stDV10DsEwow
> =jwi6
> -----END PGP SIGNATURE-----
Comment 3 Andriy Gapon freebsd_committer freebsd_triage 2014-02-16 16:52:20 UTC
on 19/11/2013 20:50 Xin Li said the following:
> I think Andriy (cc'ed) have fixed a similar issue.  A quick glance at the
> code suggests maybe we can use something like this:

I am not sure if I have ever fixed this -- if you have a reference then please
share with :-)  But the change looks good to me and I also think that Steve
Hartland proposed this change as well.
Thanks!  And sorry for the delay with my reply.

> Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c 
> =================================================================== ---
> sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c (revision
> 258350) +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c 
> (working copy) @@ -3298,6 +3298,10 @@ zfs_ioc_clone(const char *fsname,
> nvlist_t *innvl, if (error != 0) (void) dsl_destroy_head(fsname); } +#ifdef
> __FreeBSD__ +       if (error == 0) +
> zvol_create_minors(fsname); +#endif return (error); }
> 
> Can you confirm if this helps?
> 
> (I think we should use a better way to trigger zvol_create_minor, maybe via
> a devfs lookup hook?)
> 
> Cheers,
> 

-- 
Andriy Gapon
Comment 4 Andriy Gapon freebsd_committer freebsd_triage 2014-02-16 16:53:53 UTC
on 27/01/2014 22:29 Christopher Harrison said the following:
> I was not able to get the code patch to apply cleanly.   I do support the idea
> of a devfs hook.   I think the devfs hook is a lot cleaner and reduces the need
> to make sure the devnode is created/destroyed after every update to the zvols.

Sorry, but having said "*the* devfs hook" could you please provide any reference
or context?  I am not aware of any zvol related devfs hook.

-- 
Andriy Gapon
Comment 5 Aragon Gouveia 2014-04-07 09:42:10 UTC
FYI, this is a dupe of kern/178999.
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2014-04-16 01:59:45 UTC
State Changed
From-To: open->closed

see kern/178999. 


Comment 7 Mark Linimon freebsd_committer freebsd_triage 2014-04-16 01:59:45 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs