From nobody@FreeBSD.org  Tue Nov 19 18:17:54 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 308361AB
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Nov 2013 18:17:54 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 2024921E8
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Nov 2013 18:17:54 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rAJIHrRN055495
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Nov 2013 18:17:53 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rAJIHrUN055493;
	Tue, 19 Nov 2013 18:17:53 GMT
	(envelope-from nobody)
Message-Id: <201311191817.rAJIHrUN055493@oldred.freebsd.org>
Date: Tue, 19 Nov 2013 18:17:53 GMT
From: Christopher Harrison <harrison@glsan.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: zfs zvol devices are not appearing till after reimport of pool
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         184092
>Category:       kern
>Synopsis:       [zfs] zfs zvol devices are not appearing till after reimport of pool
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 19 18:20:00 UTC 2013
>Closed-Date:    Wed Apr 16 01:00:24 UTC 2014
>Last-Modified:  Wed Apr 16 01:00:24 UTC 2014
>Originator:     Christopher Harrison
>Release:        FreeBSD 9.2-RELEASE amd64
>Organization:
Great Lakes SAN
>Environment:
System: FreeBSD ws.glsan.com 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 26 22:50:31 UTC 2013 root@bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
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.
>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.
>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


>Release-Note:
>Audit-Trail:

From: Xin Li <delphij@delphij.net>
To: Christopher Harrison <harrison@glsan.com>, 
 freebsd-gnats-submit@FreeBSD.org
Cc: Andriy Gapon <avg@freebsd.org>
Subject: Re: kern/184092: zfs zvol devices are not appearing till after reimport
 of pool
Date: Tue, 19 Nov 2013 10:50:34 -0800

 -----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-----

From: Christopher Harrison <harrison@glsan.com>
To: d@delphij.net, freebsd-gnats-submit@FreeBSD.org
Cc: Andriy Gapon <avg@freebsd.org>
Subject: Re: kern/184092: zfs zvol devices are not appearing till after reimport
 of pool
Date: Mon, 27 Jan 2014 14:29:07 -0600

 This is a multi-part message in MIME format.
 --------------030209090805040302020101
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 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-----
 
 
 --------------030209090805040302020101
 Content-Type: text/x-vcard; charset=utf-8;
  name="harrison.vcf"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="harrison.vcf"
 
 begin:vcard
 fn:Christopher  Harrison
 n:Harrison;Christopher 
 org:Great Lakes SAN, LLC
 adr;dom:;;518 Holly Ave;Madison;Wi;53711
 email;internet:harrison@glsan.com
 title:CEO
 tel;work:608.347.6967
 version:2.1
 end:vcard
 
 
 --------------030209090805040302020101--

From: Andriy Gapon <avg@FreeBSD.org>
To: Christopher Harrison <harrison@glsan.com>, d@delphij.net,
        freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/184092: zfs zvol devices are not appearing till after reimport
 of pool
Date: Sun, 16 Feb 2014 18:53:53 +0200

 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

From: Andriy Gapon <avg@FreeBSD.org>
To: d@delphij.net, Christopher Harrison <harrison@glsan.com>,
        freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/184092: zfs zvol devices are not appearing till after reimport
 of pool
Date: Sun, 16 Feb 2014 18:52:20 +0200

 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

From: Aragon Gouveia <aragon@phat.za.net>
To: bug-followup@FreeBSD.org, harrison@glsan.com
Cc:  
Subject: Re: kern/184092: zfs zvol devices are not appearing till after reimport
 of pool
Date: Mon, 07 Apr 2014 10:42:10 +0200

 FYI, this is a dupe of kern/178999.
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Apr 16 00:59:45 UTC 2014 
State-Changed-Why:  
see kern/178999. 


Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Apr 16 00:59:45 UTC 2014 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=184092 
>Unformatted:
