Permalink
Browse files

Merge pull request #17 from noprobs/autosnap-clonedelete

Use native zfs functionality for protecting snaps with clones (mark
snapshots for deletion if they can not be deleted right now).
  • Loading branch information...
2 parents 81f421b + be57041 commit 15da659dc99baf996c5370f732cbef0c119585cb @delphij delphij committed Jun 29, 2013
Showing with 1 addition and 11 deletions.
  1. +1 −11 gui/tools/autosnap.py
View
@@ -192,16 +192,6 @@ def exit_if_running(pid):
else:
snapshots[(fs, snap_ret_policy)] = snap_infodict
-# Exclude snapshots that have clones associated from being deleted
-if len(snapshots_pending_delete) > 0:
- snapshots_cloned = set()
- zfsproc = pipeopen("/sbin/zfs list -H -t filesystem,volume -o origin", debug, logger=log)
- lines = zfsproc.communicate()[0].split('\n')
- for snapshot_name in lines:
- if snapshot_name != '-':
- snapshots_cloned.add(snapshot_name)
- snapshots_pending_delete = snapshots_pending_delete.difference(snapshots_cloned)
-
list_mp = mp_to_task_map.keys()
for mpkey in list_mp:
@@ -253,7 +243,7 @@ def exit_if_running(pid):
if output != '':
fsname, attrname, value, source = output.split('\n')[0].split('\t')
if value == '-':
- snapcmd = '/sbin/zfs destroy -r %s' % (snapshot)
+ snapcmd = '/sbin/zfs destroy -r -d %s' % (snapshot) #snapshots with clones will have destruction deferred
proc = pipeopen(snapcmd, logger=log)
err = proc.communicate()[1]
if proc.returncode != 0:

0 comments on commit 15da659

Please sign in to comment.