Project

General

Profile

Feature #1647

"zfs destroy" should determine space reclaimed by destroying multiple snapshots

Added by Matthew Ahrens almost 8 years ago. Updated almost 8 years ago.

Status:
Resolved
Priority:
Normal
Category:
zfs - Zettabyte File System
Start date:
2011-10-14
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

"zfs destroy" should be able to destroy multiple snapshots of the same filesystem with one command, and also determine how much space would be reclaimed when destroying multiple snapshots. This solves the problem of determining how much space is shared between several contiguous snapshots.

manpage changes:

zfs destroy [-fnpRrv] filesystem|volume
...
-n

Do a dry-run ("No-op") deletion. No data will be
deleted. This is useful in conjunction with the -v
or -p flags to determine what data would be deleted.

-p

Print machine-parsable verbose information about the
deleted data.

-v

Print verbose information about the deleted data.

zfs destroy [-dnpRrv] filesystem|volume@snap[:snap][,...]
...
An inclusive range of snapshots may be specified by
separating the first and last snapshots with a colon.

The first and/or last snapshots may be left blank, in
which case the filesystem's oldest or newest snapshot
will be implied.

Multiple snapshots (or ranges of snapshots) of the same
filesystem or volume may be specified in a comma-
separated list of snapshots. Only the snapshot's short
name (the part after the @) should be specified when
using a range or comma-separated list to identify multi-
ple snapshots.
...
-n

Do a dry-run ("No-op") deletion. No data will be
deleted. This is useful in conjunction with the -v
or -p flags to determine what data would be deleted.

-p

Print machine-parsable verbose information about the
deleted data.

-v

Print verbose information about the deleted data.

examples:


$ zfs list -r -t all ws/delphix-gate-old
NAME                             USED  AVAIL  REFER  MOUNTPOINT
ws/delphix-gate-old             4.64G  4.79G  1.29G  /ws/delphix-gate-old
ws/delphix-gate-old@2011-03-08  24.3M      -  1.48G  -
ws/delphix-gate-old@1           16.4M      -  1.72G  -
ws/delphix-gate-old@b           30.6M      -  1.54G  -
ws/delphix-gate-old@with-cache   230M      -  1.54G  -
ws/delphix-gate-old@c            337M      -  1.49G  -
ws/delphix-gate-old@foobar       492M      -  1.80G  -

$ zfs destroy -nv ws/delphix-gate-old@b:c,2011-03-08
would destroy ws/delphix-gate-old@2011-03-08
would destroy ws/delphix-gate-old@b
would destroy ws/delphix-gate-old@with-cache
would destroy ws/delphix-gate-old@c
would reclaim 917M

$ zfs destroy -nvp ws/delphix-gate-old@:
destroy ws/delphix-gate-old@2011-03-08
destroy ws/delphix-gate-old@1
destroy ws/delphix-gate-old@b
destroy ws/delphix-gate-old@with-cache
destroy ws/delphix-gate-old@c
destroy ws/delphix-gate-old@foobar
reclaim 3598630912

$ zfs get -p usedbysnapshots ws/delphix-gate-old
NAME                 PROPERTY         VALUE     SOURCE
ws/delphix-gate-old  usedbysnapshots  3598630912  -

History

#1

Updated by Matthew Ahrens almost 8 years ago

In the manpage quote, there are 2 places where it says "... -n". There should be a newline before "..." and again before "-n".

#2

Updated by Matthew Ahrens almost 8 years ago

The colon (:) character is actually allowed in dataset names, so we can't use it to delimit a range of snapshots. Instead, we will use the percent (%) character.

#3

Updated by Eric Schrock almost 8 years ago

  • Status changed from New to Resolved

changeset: 13509:04570f5cbeca
tag: tip
user: Matthew Ahrens <>
date: Sat Nov 05 17:34:13 2011 -0700

description:
1644 add ZFS "clones" property
1645 add ZFS "written" and "written@..." properties
1646 "zfs send" should estimate size of stream
1647 "zfs destroy" should determine space reclaimed by destroying multiple snapshots
1708 adjust size of zpool history data
Reviewed by: Richard Lowe <>
Reviewed by: George Wilson <>
Approved by: Gordon Ross <>

modified:
usr/src/cmd/truss/codes.c
usr/src/cmd/zfs/zfs_main.c
usr/src/cmd/zoneadmd/Makefile
usr/src/common/zfs/zfs_prop.c
usr/src/lib/libzfs/Makefile.com
usr/src/lib/libzfs/common/libzfs.h
usr/src/lib/libzfs/common/libzfs_dataset.c
usr/src/lib/libzfs/common/libzfs_impl.h
usr/src/lib/libzfs/common/libzfs_sendrecv.c
usr/src/lib/libzfs/common/libzfs_util.c
usr/src/lib/libzfs/common/mapfile-vers
usr/src/man/man1m/zfs.1m
usr/src/uts/Makefile.uts
usr/src/uts/common/fs/zfs/bpobj.c
usr/src/uts/common/fs/zfs/dmu_send.c
usr/src/uts/common/fs/zfs/dsl_dataset.c
usr/src/uts/common/fs/zfs/dsl_deadlist.c
usr/src/uts/common/fs/zfs/dsl_deleg.c
usr/src/uts/common/fs/zfs/dsl_pool.c
usr/src/uts/common/fs/zfs/spa_history.c
usr/src/uts/common/fs/zfs/sys/dmu.h
usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
usr/src/uts/common/fs/zfs/zap_micro.c
usr/src/uts/common/fs/zfs/zfs_ioctl.c
usr/src/uts/common/sys/fs/zfs.h
added:
usr/src/lib/libzfs/common/libzfs_iter.c
removed:
usr/src/lib/libzfs/common/libzfs_graph.c

#4

Updated by Rich Lowe almost 8 years ago

  • Status changed from Resolved to In Progress

Backed out by r13511 commit:4bd28e91c699

Broke snapshots, BEs, possibly other things.

#5

Updated by Eric Schrock almost 8 years ago

  • Status changed from In Progress to Resolved

changeset: 13524:f0e12b33f77c
tag: tip
user: Matthew Ahrens <>
date: Thu Nov 17 10:14:36 2011 -0800

description:
1644 add ZFS "clones" property
1645 add ZFS "written" and "written@..." properties
1646 "zfs send" should estimate size of stream
1647 "zfs destroy" should determine space reclaimed by destroying multiple snapshots
1708 adjust size of zpool history data
Reviewed by: Richard Lowe <>
Reviewed by: George Wilson <>
Reviewed by: Albert Lee <>
Approved by: Garrett D'Amore <>

modified:
usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
usr/src/cmd/truss/codes.c
usr/src/cmd/zfs/zfs_main.c
usr/src/common/zfs/zfs_prop.c
usr/src/lib/libbe/common/be_create.c
usr/src/lib/libzfs/Makefile.com
usr/src/lib/libzfs/common/libzfs.h
usr/src/lib/libzfs/common/libzfs_dataset.c
usr/src/lib/libzfs/common/libzfs_impl.h
usr/src/lib/libzfs/common/libzfs_sendrecv.c
usr/src/lib/libzfs/common/libzfs_util.c
usr/src/lib/libzfs/common/mapfile-vers
usr/src/man/man1m/zfs.1m
usr/src/uts/Makefile.uts
usr/src/uts/common/fs/zfs/bpobj.c
usr/src/uts/common/fs/zfs/dmu_send.c
usr/src/uts/common/fs/zfs/dsl_dataset.c
usr/src/uts/common/fs/zfs/dsl_deadlist.c
usr/src/uts/common/fs/zfs/dsl_deleg.c
usr/src/uts/common/fs/zfs/dsl_pool.c
usr/src/uts/common/fs/zfs/spa_history.c
usr/src/uts/common/fs/zfs/sys/dmu.h
usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
usr/src/uts/common/fs/zfs/zap_micro.c
usr/src/uts/common/fs/zfs/zfs_ioctl.c
usr/src/uts/common/sys/fs/zfs.h
added:
usr/src/lib/libzfs/common/libzfs_iter.c
removed:
usr/src/lib/libzfs/common/libzfs_graph.c

Also available in: Atom PDF