Henu
2010-Jun-11 08:47 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
In another thread recursive snapshot creation was found atomic so that it is done quickly, and more important, all at once or nothing at all. Do you know if recursive destroying and renaming of snapshots are atomic too? Regards Henrik Heino
Darren J Moffat
2010-Jun-11 08:52 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
On 11/06/2010 09:47, Henu wrote:> In another thread recursive snapshot creation was found atomic so that > it is done quickly, and more important, all at once or nothing at all. > > Do you know if recursive destroying and renaming of snapshots are atomic > too?I don''t believe they are guaranteed to be atomic, but neither is the creation. It is one call from userland to kernel but that doesn''t make it atomic from a ZFS transaction view point. -- Darren J Moffat
Henu
2010-Jun-11 09:59 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
Quoting Darren J Moffat <darrenm at opensolaris.org>:> On 11/06/2010 09:47, Henu wrote: >> In another thread recursive snapshot creation was found atomic so that >> it is done quickly, and more important, all at once or nothing at all. >> >> Do you know if recursive destroying and renaming of snapshots are atomic >> too? > > I don''t believe they are guaranteed to be atomic, but neither is the > creation. It is one call from userland to kernel but that doesn''t > make it atomic from a ZFS transaction view point. > > -- > Darren J Moffat >But the following document says "Recursive ZFS snapshots are created quickly as one atomic operation. The snapshots are created together (all at once) or not created at all." http://docs.sun.com/app/docs/doc/819-5461/gdfdt?a=view
Darren J Moffat
2010-Jun-11 10:30 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
On 11/06/2010 10:59, Henu wrote:> Quoting Darren J Moffat <darrenm at opensolaris.org>: > >> On 11/06/2010 09:47, Henu wrote: >>> In another thread recursive snapshot creation was found atomic so that >>> it is done quickly, and more important, all at once or nothing at all. >>> >>> Do you know if recursive destroying and renaming of snapshots are atomic >>> too? >> >> I don''t believe they are guaranteed to be atomic, but neither is the >> creation. It is one call from userland to kernel but that doesn''t make >> it atomic from a ZFS transaction view point. >> >> -- >> Darren J Moffat >> > > But the following document says "Recursive ZFS snapshots are created > quickly as one atomic operation. The snapshots are created together (all > at once) or not created at all." > http://docs.sun.com/app/docs/doc/819-5461/gdfdt?a=viewI''ve looked at the code again - I miss read part of it - it does appear to be an "all or nothing" both for the create and destroy. -- Darren J Moffat
Arne Jansen
2010-Jun-11 10:42 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
Darren J Moffat wrote:>> But the following document says "Recursive ZFS snapshots are created >> quickly as one atomic operation. The snapshots are created together (all >> at once) or not created at all." >> http://docs.sun.com/app/docs/doc/819-5461/gdfdt?a=view > > I''ve looked at the code again - I miss read part of it - it does appear > to be an "all or nothing" both for the create and destroy. >I read the code differently, zfs destroy does the iteration in the zfs utility, not even in libzfs. The ioctl doesn''t even have a recurse flag. --Arne
Henu
2010-Jun-11 10:47 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
Quoting Darren J Moffat <darrenm at opensolaris.org>:> On 11/06/2010 10:59, Henu wrote: >> Quoting Darren J Moffat <darrenm at opensolaris.org>: >> >>> On 11/06/2010 09:47, Henu wrote: >>>> In another thread recursive snapshot creation was found atomic so that >>>> it is done quickly, and more important, all at once or nothing at all. >>>> >>>> Do you know if recursive destroying and renaming of snapshots are atomic >>>> too? >>> >>> I don''t believe they are guaranteed to be atomic, but neither is the >>> creation. It is one call from userland to kernel but that doesn''t make >>> it atomic from a ZFS transaction view point. >>> >>> -- >>> Darren J Moffat >>> >> >> But the following document says "Recursive ZFS snapshots are created >> quickly as one atomic operation. The snapshots are created together (all >> at once) or not created at all." >> http://docs.sun.com/app/docs/doc/819-5461/gdfdt?a=view > > I''ve looked at the code again - I miss read part of it - it does > appear to be an "all or nothing" both for the create and destroy. > > -- > Darren J Moffat >Excellent! I''m sorry I keep bothering you, but did you checked what the code says about recursive rename? Is it atomic too?
Darren J Moffat
2010-Jun-11 10:57 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
On 11/06/2010 11:42, Arne Jansen wrote:> Darren J Moffat wrote: >>> But the following document says "Recursive ZFS snapshots are created >>> quickly as one atomic operation. The snapshots are created together (all >>> at once) or not created at all." >>> http://docs.sun.com/app/docs/doc/819-5461/gdfdt?a=view >> >> I''ve looked at the code again - I miss read part of it - it does appear >> to be an "all or nothing" both for the create and destroy. >> > > I read the code differently, zfs destroy does the iteration in the > zfs utility, not even in libzfs. The ioctl doesn''t even have a recurse > flag.You are correct that the ZFS_IOC_DESTROY ioctl doesn''t have a resurse flag but the code path is different for recursive snapshot destroy and single snapshot or non snapshot destroy. For the snapshot case start in zfs_main.c: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/zfs/zfs_main.c#zfs_do_destroy In particular line 1041 in the current version of the source: if (cb.cb_recurse && (cp = strchr(argv[0], ''@''))) { ... } In zfs_do_destroy() if recurse is set we call zfs_destroy_snaps() http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libzfs/common/libzfs_dataset.c#zfs_destroy_snaps Which makes a single ioctl call ZFS_IOC_DESTROY_SNAPS Which ends up in the kernel in zfs_ioctl.c here: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/zfs/zfs_ioctl.c#zfs_ioc_destroy_snaps Which then goes to the DMU layer here: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/zfs/dsl_dataset.c#dmu_snapshots_destroy -- Darren J Moffat
Darren J Moffat
2010-Jun-11 11:00 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
On 11/06/2010 11:47, Henu wrote:> I''m sorry I keep bothering you, but did you checked what the code says > about recursive rename? Is it atomic too?Recursive snapshot rename uses the same style of code as create and destroy so yes. -- Darren J Moffat
Henu
2010-Jun-11 11:03 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
Quoting Darren J Moffat <darrenm at opensolaris.org>:> On 11/06/2010 11:47, Henu wrote: >> I''m sorry I keep bothering you, but did you checked what the code says >> about recursive rename? Is it atomic too? > > Recursive snapshot rename uses the same style of code as create and > destroy so yes. > > -- > Darren J Moffat >Okay, good thing then. And thanks for all the help! :) BR, Henrik Heino
Arne Jansen
2010-Jun-11 11:11 UTC
[zfs-discuss] Are recursive snapshot destroy and rename atomic too?
Darren J Moffat wrote:> On 11/06/2010 11:42, Arne Jansen wrote: >> Darren J Moffat wrote: >>>> But the following document says "Recursive ZFS snapshots are created >>>> quickly as one atomic operation. The snapshots are created together >>>> (all >>>> at once) or not created at all." >>>> http://docs.sun.com/app/docs/doc/819-5461/gdfdt?a=view >>> >>> I''ve looked at the code again - I miss read part of it - it does appear >>> to be an "all or nothing" both for the create and destroy. >>> >> >> I read the code differently, zfs destroy does the iteration in the >> zfs utility, not even in libzfs. The ioctl doesn''t even have a recurse >> flag. > > In zfs_do_destroy() if recurse is set we call zfs_destroy_snaps() > > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libzfs/common/libzfs_dataset.c#zfs_destroy_snaps > > > Which makes a single ioctl call ZFS_IOC_DESTROY_SNAPS >Ah! There''s an extra ioctl for a recursive snapshot delete, I missed that part. Many thanks! This will also help me with my multi-snapshot- destroy-module. I should at least have checked with a simple truss... You made my day :) --Arne