Geoff Nordli
2010-Sep-27 17:14 UTC
[zfs-discuss] way to find out of a dataset has children
Is there a way to find out if a dataset has children or not using zfs properties or other scriptable method? I am looking for a more efficient way to delete datasets after they are finished being used. Right now I use custom property to set delete=1 on a dataset, and then I have a script that runs async to clean them up. If there are children then the delete will fail. This method works, but I would rather filter it again so it only tries to delete a dataset which can actually be deleted. I have looked at the usedbychildren and usedbysnapshots, but they are just showing "0" in the columns. Thanks, Geoff
Darren J Moffat
2010-Sep-27 18:03 UTC
[zfs-discuss] way to find out of a dataset has children
On 27/09/2010 18:14, Geoff Nordli wrote:> Is there a way to find out if a dataset has children or not using zfs > properties or other scriptable method? > > I am looking for a more efficient way to delete datasets after they are > finished being used. Right now I use custom property to set delete=1 on a > dataset, and then I have a script that runs async to clean them up. If > there are children then the delete will fail. > > This method works, but I would rather filter it again so it only tries to > delete a dataset which can actually be deleted.This sounds very like what ''zfs hold'' and ''zfs destroy -d'' were designed for. When using ''zfs send'' holds will automatically be taken out for pool versions 18 and higher. -- Darren J Moffat
Geoff Nordli
2010-Sep-27 18:54 UTC
[zfs-discuss] way to find out of a dataset has children
>From: Darren J Moffat >Sent: Monday, September 27, 2010 11:03 AM > > >On 27/09/2010 18:14, Geoff Nordli wrote: >> Is there a way to find out if a dataset has children or not using zfs >> properties or other scriptable method? >> >> I am looking for a more efficient way to delete datasets after they >> are finished being used. Right now I use custom property to set >> delete=1 on a dataset, and then I have a script that runs async to >> clean them up. If there are children then the delete will fail. >> >> This method works, but I would rather filter it again so it only tries >> to delete a dataset which can actually be deleted. > >This sounds very like what ''zfs hold'' and ''zfs destroy -d'' were designedfor. When>using ''zfs send'' holds will automatically be taken out for pool versions 18and>higher. >Darren, thanks for this tip. It this looks like it will work well for snapshots, but I can''t apply the property to a clone. Are there any properties I can set on the clone side? I could definitely do a zfs list, and look for same name as the clone which I am trying to delete, but I am looking for a better way. Geoff
Richard Elling
2010-Sep-27 20:01 UTC
[zfs-discuss] way to find out of a dataset has children
On Sep 27, 2010, at 11:54 AM, Geoff Nordli wrote:> > Are there any properties I can set on the clone side?Each clone records its origin snapshot in the "origin" property. $ zfs get origin syspool/rootfs-nmu-001 NAME PROPERTY VALUE SOURCE syspool/rootfs-nmu-001 origin syspool/rootfs-nmu-000 at nmu-001 - Enjoy -- richard -- OpenStorage Summit, October 25-27, Palo Alto, CA http://nexenta-summit2010.eventbrite.com Richard Elling richard at nexenta.com +1-760-896-4422 Enterprise class storage for everyone www.nexenta.com
Geoff Nordli
2010-Sep-27 20:23 UTC
[zfs-discuss] way to find out of a dataset has children
>From: Richard Elling >Sent: Monday, September 27, 2010 1:01 PM > >On Sep 27, 2010, at 11:54 AM, Geoff Nordli wrote: >> >> Are there any properties I can set on the clone side? > >Each clone records its origin snapshot in the "origin" property. > >$ zfs get origin syspool/rootfs-nmu-001 >NAME PROPERTY VALUE SOURCE >syspool/rootfs-nmu-001 origin syspool/rootfs-nmu-000 at nmu-001 - > >Enjoy > -- richardHi Richard. Yes, we can use the origin, but that tells me where it came from, not how many snapshots are built from it. Before I can delete it, the clone can''t have any snapshots under it. This isn''t hard to solve, I can just do a regex on the clone name looking for snapshots name, but I was hoping there was a simple zfs property I can query. Thanks, Geoff