1 .\" Copyright (c) 2007 The DragonFly Project. All rights reserved.
3 .\" This code is derived from software contributed to The DragonFly Project
4 .\" by Matthew Dillon <dillon@backplane.com>
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in
14 .\" the documentation and/or other materials provided with the
16 .\" 3. Neither the name of The DragonFly Project nor the names of its
17 .\" contributors may be used to endorse or promote products derived
18 .\" from this software without specific, prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" $DragonFly: src/sbin/hammer/hammer.8,v 1.58 2008/11/13 02:04:27 dillon Exp $
40 .Nd HAMMER file system utility
49 .\" .Op Fl s Ar linkpath
53 .Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
58 This manual page documents the
60 utility which provides miscellaneous functions related to managing a
63 For a general introduction to the
65 file system, its features, and
66 examples on how to set up and maintain one, see
69 The options are as follows:
70 .Bl -tag -width indent
74 Tell the mirror commands to use a 2-way protocol, which allows
75 automatic negotiation of transaction id ranges.
76 This option is automatically enabled by the
80 Specify a bandwidth limit in bytes per second for mirroring streams.
81 This option is typically used to prevent batch mirroring operations from
82 loading down the machine.
83 The bandwidth may be suffixed with
87 to specify values in kilobytes, megabytes, and gigabytes per second.
88 If no suffix is specified, bytes per second is assumed.
90 Unfortunately this is only applicable to the pre-compression bandwidth
91 when compression is used, so a better solution would probably be to
98 When pruning, rebalancing or reblocking you can tell the utility
99 to start at the object id stored in the specified file.
100 If the file does not exist
102 will start at the beginning.
106 specific period of time and is unable to complete the operation it will
107 write out the current object id so the next run can pick up where it left off.
110 runs to completion it will delete
113 Specify the volumes making up a
117 is a colon-separated list of devices, each specifying a
121 When maintaining a streaming mirroring this option specifies the
122 minimum delay after a batch ends before the next batch is allowed
124 The default is five seconds.
131 specification for the source and/or destination.
133 Decrease verboseness.
134 May be specified multiple times.
136 Specify recursion for those commands which support it.
138 When pruning, rebalancing or reblocking you can tell the utility to stop
139 after a certain period of time.
140 This option is used along with the
142 option to prune, rebalance or reblock incrementally.
144 Increase verboseness.
145 May be specified multiple times.
147 Force "yes" for any interactive question.
151 will not attempt to break-up large initial bulk transfers into smaller
153 This can save time but if the link is lost in the middle of the
154 initial bulk transfer you will have to start over from scratch.
155 This option is not recommended.
156 For more information see the
159 .It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
160 Set the memory cache size for any raw
167 for megabytes is allowed,
168 else the cache size is specified in bytes.
170 The read-behind/read-ahead defaults to 4
174 This option is typically only used with diagnostic commands
175 as kernel-supported commands will use the kernel's buffer cache.
176 .It Fl S Ar splitsize
177 Specify the bulk splitup size in bytes for mirroring streams.
182 will do an initial run-through of the data to calculate good
183 transaction ids to cut up the bulk transfers, creating
184 restart points in case the stream is interrupted.
185 If we don't do this and the stream is interrupted it might
186 have to start all over again.
187 The default is a splitsize of 4G.
189 At the moment the run-through is disk-bandwidth-heavy but some
190 future version will limit the run-through to just the B-Tree
191 records and not the record data.
193 The splitsize may be suffixed with
197 to specify values in kilobytes, megabytes, or gigabytes.
198 If no suffix is specified, bytes is assumed.
200 When mirroring very large filesystems the minimum recommended
202 A small split size may wind up generating a great deal of overhead
203 but very little actual incremental data and is not recommended.
205 Enable compression for any remote ssh specifications.
208 option has already been reserved for other purposes so we had to use
210 This option is typically used with the mirroring directives.
212 Force "yes" for any interactive question.
215 The commands are as follows:
216 .Bl -tag -width indent
217 .\" ==== synctid ====
218 .It Cm synctid Ar filesystem Op Cm quick
219 Generates a guaranteed, formal 64 bit transaction id representing the
220 current state of the specified
223 The file system will be synced to the media.
227 keyword is specified the file system will be soft-synced, meaning that a
228 crash might still undo the state of the file system as of the transaction
229 id returned but any new modifications will occur after the returned
230 transaction id as expected.
232 This operation does not create a snapshot.
233 It is meant to be used
234 to track temporary fine-grained changes to a subset of files and
235 will only remain valid for
237 snapshot access purposes for the
239 period configured for the PFS.
240 If you desire a real snapshot then the
242 directive may be what you are looking for.
244 .It Cm bstats Op Ar interval
247 B-Tree statistics until interrupted.
250 seconds between each display.
251 The default interval is one second.
252 .\" ==== iostats ====
253 .It Cm iostats Op Ar interval
257 statistics until interrupted.
260 seconds between each display.
261 The default interval is one second.
262 .\" ==== history ====
263 .It Cm history Ar path ...
264 Show the modification history for
266 file's inode and data.
267 .\" ==== blockmap ====
269 Dump the blockmap for the file system.
272 blockmap is two-layer
273 blockmap representing the maximum possible file system size of 1 Exabyte.
274 Needless to say the second layer is only present for blocks which exist.
276 blockmap represents 8-Megabyte blocks, called big-blocks.
277 Each big-block has an append
278 point, a free byte count, and a typed zone id which allows content to be
279 reverse engineered to some degree.
283 allocations are essentially appended to a selected big-block using
284 the append offset and deducted from the free byte count.
285 When space is freed the free byte count is adjusted but
287 does not track holes in big-blocks for reallocation.
288 A big-block must be completely freed, either
289 through normal file system operations or through reblocking, before
292 Data blocks can be shared by deducting the space used from the free byte
293 count for each shared references, though
295 does not yet make use of this feature.
296 This means the free byte count can legally go negative.
298 This command needs the
301 .\" ==== checkmap ====
303 Check the blockmap allocation count.
305 will scan the B-Tree, collect allocation information, and
306 construct a blockmap in-memory. It will then check that blockmap
307 against the on-disk blockmap.
309 This command needs the
313 .It Cm show Op Ar lo Ns Cm \&: Ns Ar objid
315 By default this command will validate all B-Tree
316 linkages and CRCs, including data CRCs, and will report the most verbose
317 information it can dig up.
318 Any errors will show up with a
320 in column 1 along with various
323 If you specify a localization field or a localization:obj_id field,
324 .Ar lo Ns Cm \&: Ns Ar objid ,
326 search for the key printing nodes as it recurses down, and then
327 will iterate forwards.
328 These fields are specified in HEX.
329 Note that the pfsid is the top 16 bits of the 32 bit localization
330 field so PFS #1 would be 00010000.
334 the command will report less information about the inode contents.
338 the command will not report the content of the inode or other typed
343 the command will not report volume header information, big-block fill
344 ratios, mirror transaction ids, or report or check data CRCs.
345 B-Tree CRCs and linkages are still checked.
347 This command needs the
350 .\" ==== show-undo ====
356 This command needs the
360 .\" Dump the B-Tree, record, large-data, and small-data blockmaps, showing
361 .\" physical block assignments and free space percentages.
362 .\" ==== recover ====
363 .It Cm recover Ar targetdir
364 This is a low level command which operates on the filesystem image and
365 attempts to locate and recover files from a corrupted filesystem. The
366 entire image is scanned linearly looking for B-Tree nodes. Any node
367 found which passes its crc test is scanned for file, inode, and directory
368 fragments and the target directory is populated with the resulting data.
369 files and directories in the target directory are initially named after
370 the object id and are renamed as fragmentory information is processed.
372 This command keeps track of filename/objid translations and may eat a
373 considerably amount of memory while operating.
375 This command is literally the last line of defense when it comes to
376 recovering data from a dead filesystem.
377 .\" ==== namekey1 ====
378 .It Cm namekey1 Ar filename
381 64 bit directory hash for the specified file name, using
382 the original directory hash algorithm in version 1 of the file system.
383 The low 32 bits are used as an iterator for hash collisions and will be
385 .\" ==== namekey2 ====
386 .It Cm namekey2 Ar filename
389 64 bit directory hash for the specified file name, using
390 the new directory hash algorithm in version 2 of the file system.
391 The low 32 bits are still used as an iterator but will start out containing
392 part of the hash key.
393 .\" ==== namekey32 ====
394 .It Cm namekey32 Ar filename
395 Generate the top 32 bits of a
397 64 bit directory hash for the specified file name.
400 Shows extended information about all the mounted
403 The information is divided into sections:
404 .Bl -tag -width indent
405 .It Volume identification
406 General information, like the label of the
408 filesystem, the number of volumes it contains, the FSID, and the
411 .It Big block information
412 Big block statistics, such as total, used, reserved and free big blocks.
413 .It Space information
414 Information about space used on the filesystem.
415 Currently total size, used, reserved and free space are displayed.
417 Basic information about the PFSs currently present on a
422 is the ID of the PFS, with 0 being the root PFS.
424 is the current snapshot count on the PFS.
426 displays the mount point of the PFS is currently mounted on (if any).
428 .\" ==== cleanup ====
429 .It Cm cleanup Op Ar filesystem ...
430 This is a meta-command which executes snapshot, prune, rebalance and reblock
431 commands on the specified
436 is specified this command will clean-up all
438 file systems in use, including PFS's.
439 To do this it will scan all
443 mounts, extract PFS id's, and clean-up each PFS found.
445 This command will access a snapshots
446 directory and a configuration file for each
448 creating them if necessary.
449 .Bl -tag -width indent
450 .It Nm HAMMER No version 2-
451 The configuration file is
453 in the snapshots directory which defaults to
454 .Pa <pfs>/snapshots .
455 .It Nm HAMMER No version 3+
456 The configuration file is saved in file system meta-data, see
459 The snapshots directory defaults to
460 .Pa /var/hammer/<pfs>
461 .Pa ( /var/hammer/root
465 The format of the configuration file is:
466 .Bd -literal -offset indent
467 snapshots <period> <retention-time> [any]
468 prune <period> <max-runtime>
469 rebalance <period> <max-runtime>
470 reblock <period> <max-runtime>
471 recopy <period> <max-runtime>
475 .Bd -literal -offset indent
476 snapshots 1d 60d # 0d 0d for PFS /tmp, /var/tmp, /usr/obj
483 Time is given with a suffix of
489 meaning day, hour, minute and second.
493 directive has a period of 0 and a retention time of 0
494 then snapshot generation is disabled, removal of old snapshots are
495 disabled, and prunes will use
496 .Cm prune-everything .
499 directive has a period of 0 but a non-zero retention time
500 then this command will not create any new snapshots but will remove old
501 snapshots it finds based on the retention time.
503 By default only snapshots in the form
504 .Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
508 directive is specified as a third argument on the
510 config line then any softlink of the form
511 .Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
513 .Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
516 A prune max-runtime of 0 means unlimited.
518 If period hasn't passed since the previous
521 For example a day has passed when midnight is passed (localtime).
529 The default configuration file will create a daily snapshot, do a daily
530 pruning, rebalancing and reblocking run and a monthly recopy run.
531 Reblocking is defragmentation with a level of 95%,
532 and recopy is full defragmentation.
534 By default prune and rebalance operations are time limited to 5 minutes,
535 reblock operations to a bit over 5 minutes,
536 and recopy operations to a bit over 10 minutes.
537 Reblocking and recopy runs are each broken down into four separate functions:
538 btree, inodes, dirs and data.
539 Each function is time limited to the time given in the configuration file,
540 but the btree, inodes and dirs functions usually does not take very long time,
541 full defragmentation is always used for these three functions.
542 Also note that this directive will by default disable snapshots on
549 The defaults may be adjusted by modifying the configuration file.
550 The pruning and reblocking commands automatically maintain a cyclefile
551 for incremental operation.
552 If you interrupt (^C) the program the cyclefile will be updated,
554 may continue to run in the background for a few seconds until the
556 ioctl detects the interrupt.
559 PFS option can be set to use another location for the snapshots directory.
561 Work on this command is still in progress.
563 An ability to remove snapshots dynamically as the
564 file system becomes full.
566 .It Cm config Op Ar filesystem Op Ar configfile
569 Show or change configuration for
571 If zero or one arguments are specified this function dumps the current
572 configuration file to stdout.
573 Zero arguments specifies the PFS containing the current directory.
574 This configuration file is stored in file system meta-data.
575 If two arguments are specified this function installs a new config file.
579 versions less than 3 the configuration file is by default stored in
580 .Pa <pfs>/snapshots/config ,
581 but in all later versions the configuration file is stored in file system
583 .\" ==== viconfig ====
584 .It Cm viconfig Op Ar filesystem
587 Edit the configuration file and reinstall into file system meta-data when done.
588 Zero arguments specifies the PFS containing the current directory.
589 .\" ==== volume-add ====
590 .It Cm volume-add Ar device Ar filesystem
591 This command will format
593 and add all of its space to
597 All existing data contained on
599 will be destroyed by this operation!
604 file system, formatting will be denied.
605 You can overcome this sanity check
608 to erase the beginning sectors of the device.
609 Also remember that you have to specify
611 together with any other device that make up the file system,
616 .\" ==== volume-del ====
617 .It Cm volume-del Ar device Ar filesystem
618 This command will remove volume
623 Remember that you have to remove
625 from the colon-separated list in
629 .\" ==== snapshot ====
630 .It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
631 .It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
632 Takes a snapshot of the file system either explicitly given by
634 or implicitly derived from the
636 argument and creates a symlink in the directory provided by
638 pointing to the snapshot.
641 is not a directory, it is assumed to be a format string passed to
643 with the current time as parameter.
646 refers to an existing directory, a default format string of
648 is assumed and used as name for the newly created symlink.
650 Snapshot is a per PFS operation, so a
652 file system and each PFS in it have to be snapshot separately.
654 Example, assuming that
662 are file systems on their own, the following invocations:
663 .Bd -literal -offset indent
664 hammer snapshot /mysnapshots
666 hammer snapshot /mysnapshots/%Y-%m-%d
668 hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
670 hammer snapshot /usr /my/snaps/usr "note"
673 Would create symlinks similar to:
674 .Bd -literal -offset indent
675 /mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
677 /mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
679 /mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
681 /my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
686 version 3+ file system the snapshot is also recorded in file system meta-data
687 along with the optional
693 .It Cm snap Ar path Op Ar note
696 Create a snapshot for the PFS containing
698 and create a snapshot softlink.
699 If the path specified is a
700 directory a standard snapshot softlink will be created in the directory.
701 The snapshot softlink points to the base of the mounted PFS.
702 .It Cm snaplo Ar path Op Ar note
705 Create a snapshot for the PFS containing
707 and create a snapshot softlink.
708 If the path specified is a
709 directory a standard snapshot softlink will be created in the directory.
710 The snapshot softlink points into the directory it is contained in.
711 .It Cm snapq Ar dir Op Ar note
714 Create a snapshot for the PFS containing the specified directory but do
715 not create a softlink.
716 Instead output a path which can be used to access
717 the directory via the snapshot.
719 An absolute or relative path may be specified.
720 The path will be used as-is as a prefix in the path output to stdout.
722 snap and snapshot directives the snapshot transaction id will be registered
723 in the file system meta-data.
724 .It Cm snaprm Ar path Ar ...
725 .It Cm snaprm Ar transid Ar ...
726 .It Cm snaprm Ar filesystem Ar transid Ar ...
729 Remove a snapshot given its softlink or transaction id.
730 If specifying a transaction id
731 the snapshot is removed from file system meta-data but you are responsible
732 for removing any related softlinks.
734 If a softlink path is specified the filesystem and transaction id
735 is derived from the contents of the softlink.
736 If just a transaction id is specified it is assumed to be a snapshot
737 in the HAMMER filesystem you are currently chdir'd into.
738 You can also specify the filesystem and transaction id explicitly.
739 .It Cm snapls Op Ar path ...
742 Dump the snapshot meta-data for PFSs containing each
744 listing all available snapshots and their notes.
745 If no arguments are specified snapshots for the PFS containing the
746 current directory are listed.
747 This is the definitive list of snapshots for the file system.
749 .It Cm prune Ar softlink-dir
750 Prune the file system based on previously created snapshot softlinks.
751 Pruning is the act of deleting file system history.
754 command will delete file system history such that
755 the file system state is retained for the given snapshots,
756 and all history after the latest snapshot.
757 By setting the per PFS parameter
759 history is guaranteed to be saved at least this time interval.
760 All other history is deleted.
762 The target directory is expected to contain softlinks pointing to
763 snapshots of the file systems you wish to retain.
764 The directory is scanned non-recursively and the mount points and
765 transaction ids stored in the softlinks are extracted and sorted.
766 The file system is then explicitly pruned according to what is found.
767 Cleaning out portions of the file system is as simple as removing a
768 snapshot softlink and then running the
772 As a safety measure pruning only occurs if one or more softlinks are found
775 snapshot id extension.
776 Currently the scanned softlink directory must contain softlinks pointing
780 The softlinks may specify absolute or relative paths.
781 Softlinks must use 20-character
783 transaction ids, as might be returned from
784 .Nm Cm synctid Ar filesystem .
786 Pruning is a per PFS operation, so a
788 file system and each PFS in it have to be pruned separately.
790 Note that pruning a file system may not immediately free-up space,
791 though typically some space will be freed if a large number of records are
793 The file system must be reblocked to completely recover all available space.
795 Example, lets say your that you didn't set
797 and snapshot directory contains the following links:
798 .Bd -literal -offset indent
799 lrwxr-xr-x 1 root wheel 29 May 31 17:57 snap1 ->
800 /usr/obj/@@0x10d2cd05b7270d16
802 lrwxr-xr-x 1 root wheel 29 May 31 17:58 snap2 ->
803 /usr/obj/@@0x10d2cd13f3fde98f
805 lrwxr-xr-x 1 root wheel 29 May 31 17:59 snap3 ->
806 /usr/obj/@@0x10d2cd222adee364
809 If you were to run the
811 command on this directory, then the
814 mount will be pruned to retain the above three snapshots.
815 In addition, history for modifications made to the file system older than
816 the oldest snapshot will be destroyed and history for potentially fine-grained
817 modifications made to the file system more recently than the most recent
818 snapshot will be retained.
820 If you then delete the
822 softlink and rerun the
825 history for modifications pertaining to that snapshot would be destroyed.
829 file system versions 3+ this command also scans the snapshots stored
830 in the file system meta-data and includes them in the prune.
831 .\" ==== prune-everything ====
832 .It Cm prune-everything Ar filesystem
833 This command will remove all historical records from the file system.
834 This directive is not normally used on a production system.
836 This command does not remove snapshot softlinks but will delete all
837 snapshots recorded in file system meta-data (for file system version 3+).
838 The user is responsible for deleting any softlinks.
840 Pruning is a per PFS operation, so a
842 file system and each PFS in it have to be pruned separately.
843 .\" ==== rebalance ====
844 .It Cm rebalance Ar filesystem Op Ar saturation_percentage
845 This command will rebalance the B-Tree, nodes with small number of
846 elements will be combined and element counts will be smoothed out
849 The saturation percentage is between 50% and 100%.
850 The default is 75% (the
852 suffix is not needed).
854 Rebalancing is a per PFS operation, so a
856 file system and each PFS in it have to be rebalanced separately.
857 .\" ==== reblock* ====
858 .It Cm reblock Ar filesystem Op Ar fill_percentage
859 .It Cm reblock-btree Ar filesystem Op Ar fill_percentage
860 .It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
861 .It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
862 .It Cm reblock-data Ar filesystem Op Ar fill_percentage
863 Attempt to defragment and free space for reuse by reblocking a live
866 Big-blocks cannot be reused by
868 until they are completely free.
869 This command also has the effect of reordering all elements, effectively
870 defragmenting the file system.
872 The default fill percentage is 100% and will cause the file system to be
873 completely defragmented.
874 All specified element types will be reallocated and rewritten.
875 If you wish to quickly free up space instead try specifying
876 a smaller fill percentage, such as 90% or 80% (the
878 suffix is not needed).
880 Since this command may rewrite the entire contents of the disk it is
881 best to do it incrementally from a
887 options to limit the run time.
888 The file system would thus be defragmented over long period of time.
890 It is recommended that separate invocations be used for each data type.
891 B-Tree nodes, inodes, and directories are typically the most important
892 elements needing defragmentation.
893 Data can be defragmented over a longer period of time.
895 Reblocking is a per PFS operation, so a
897 file system and each PFS in it have to be reblocked separately.
898 .\" ==== pfs-status ====
899 .It Cm pfs-status Ar dirpath ...
900 Retrieve the mirroring configuration parameters for the specified
902 file systems or pseudo-filesystems (PFS's).
903 .\" ==== pfs-master ====
904 .It Cm pfs-master Ar dirpath Op Ar options
905 Create a pseudo-filesystem (PFS) inside a
908 Up to 65535 such file systems can be created.
909 Each PFS uses an independent inode numbering space making it suitable
910 for use as a replication source or target.
914 directive creates a PFS that you can read, write, and use as a mirroring
917 It is recommended to use a
919 mount to access a PFS, for more information see
921 .\" ==== pfs-slave ====
922 .It Cm pfs-slave Ar dirpath Op Ar options
923 Create a pseudo-filesystem (PFS) inside a
926 Up to 65535 such file systems can be created.
927 Each PFS uses an independent inode numbering space making it suitable
928 for use as a replication source or target.
932 directive creates a PFS that you can use as a mirroring target.
933 You will not be able to access a slave PFS until you have completed the
934 first mirroring operation with it as the target (its root directory will
935 not exist until then).
937 Access to the pfs-slave via the special softlink, as described in the
942 dynamically modify the snapshot transaction id by returning a dynamic result
947 A PFS can only be truly destroyed with the
950 Removing the softlink will not destroy the underlying PFS.
952 It is recommended to use a
954 mount to access a PFS, for more information see
956 .\" ==== pfs-update ====
957 .It Cm pfs-update Ar dirpath Op Ar options
958 Update the configuration parameters for an existing
960 file system or pseudo-filesystem.
961 Options that may be specified:
962 .Bl -tag -width indent
963 .It Cm sync-beg-tid= Ns Ar 0x16llx
964 This is the automatic snapshot access starting transaction id for
966 This parameter is normally updated automatically by the
970 It is important to note that accessing a mirroring slave
971 with a transaction id greater than the last fully synchronized transaction
972 id can result in an unreliable snapshot since you will be accessing
973 data that is still undergoing synchronization.
975 Manually modifying this field is dangerous and can result in a broken mirror.
976 .It Cm sync-end-tid= Ns Ar 0x16llx
977 This is the current synchronization point for mirroring slaves.
978 This parameter is normally updated automatically by the
982 Manually modifying this field is dangerous and can result in a broken mirror.
983 .It Cm shared-uuid= Ns Ar uuid
984 Set the shared UUID for this file system.
985 All mirrors must have the same shared UUID.
986 For safety purposes the
988 directives will refuse to operate on a target with a different shared UUID.
990 Changing the shared UUID on an existing, non-empty mirroring target,
991 including an empty but not completely pruned target,
992 can lead to corruption of the mirroring target.
993 .It Cm unique-uuid= Ns Ar uuid
994 Set the unique UUID for this file system.
995 This UUID should not be used anywhere else,
996 even on exact copies of the file system.
997 .It Cm label= Ns Ar string
998 Set a descriptive label for this file system.
999 .It Cm snapshots= Ns Ar string
1000 Specify the snapshots directory which
1003 will use to manage this PFS.
1004 .Bl -tag -width indent
1005 .It Nm HAMMER No version 2-
1006 The snapshots directory does not need to be configured for
1007 PFS masters and will default to
1008 .Pa <pfs>/snapshots .
1010 PFS slaves are mirroring slaves so you cannot configure a snapshots
1011 directory on the slave itself to be managed by the slave's machine.
1012 In fact, the slave will likely have a
1014 sub-directory mirrored
1015 from the master, but that directory contains the configuration the master
1016 is using for its copy of the file system, not the configuration that we
1017 want to use for our slave.
1019 It is recommended that
1020 .Pa <fs>/var/slaves/<name>
1021 be configured for a PFS slave, where
1027 is an appropriate label.
1028 .It Nm HAMMER No version 3+
1029 The snapshots directory does not need to be configured for PFS masters or
1031 The snapshots directory defaults to
1032 .Pa /var/hammer/<pfs>
1033 .Pa ( /var/hammer/root
1037 You can control snapshot retention on your slave independent of the master.
1038 .It Cm snapshots-clear
1041 directory path for this PFS.
1042 .It Cm prune-min= Ns Ar N Ns Cm d
1043 .It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \
1044 Ar hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss
1045 Set the minimum fine-grained data retention period.
1047 always retains fine-grained history up to the most recent snapshot.
1048 You can extend the retention period further by specifying a non-zero
1050 Any snapshot softlinks within the retention period are ignored
1051 for the purposes of pruning (the fine grained history is retained).
1052 Number of days, hours, minutes and seconds are given as
1057 Because the transaction id in the snapshot softlink cannot be used
1058 to calculate a timestamp,
1060 uses the earlier of the
1064 field of the softlink to
1065 determine which snapshots fall within the retention period.
1066 Users must be sure to retain one of these two fields when manipulating
1069 .\" ==== pfs-upgrade ====
1070 .It Cm pfs-upgrade Ar dirpath
1071 Upgrade a PFS from slave to master operation.
1072 The PFS will be rolled back to the current end synchronization transaction id
1073 (removing any partial synchronizations), and will then become writable.
1077 currently supports only single masters and using
1078 this command can easily result in file system corruption
1079 if you don't know what you are doing.
1081 This directive will refuse to run if any programs have open descriptors
1082 in the PFS, including programs chdir'd into the PFS.
1083 .\" ==== pfs-downgrade ====
1084 .It Cm pfs-downgrade Ar dirpath
1085 Downgrade a master PFS from master to slave operation.
1086 The PFS becomes read-only and access will be locked to its
1089 This directive will refuse to run if any programs have open descriptors
1090 in the PFS, including programs chdir'd into the PFS.
1091 .\" ==== pfs-destroy ====
1092 .It Cm pfs-destroy Ar dirpath
1093 This permanently destroys a PFS.
1095 This directive will refuse to run if any programs have open descriptors
1096 in the PFS, including programs chdir'd into the PFS.
1097 .\" ==== mirror-read ====
1098 .It Cm mirror-read Ar filesystem Op Ar begin-tid
1099 Generate a mirroring stream to stdout.
1100 The stream ends when the transaction id space has been exhausted.
1101 .\" ==== mirror-read-stream ====
1102 .It Cm mirror-read-stream Ar filesystem Op Ar begin-tid
1103 Generate a mirroring stream to stdout.
1104 Upon completion the stream is paused until new data is synced to the
1107 Operation continues until the pipe is broken.
1110 command for more details.
1111 .\" ==== mirror-write ====
1112 .It Cm mirror-write Ar filesystem
1113 Take a mirroring stream on stdin.
1115 This command will fail if the
1117 configuration field for the two file systems do not match.
1120 command for more details.
1122 If the target PFS does not exist this command will ask you whether
1123 you want to create a compatible PFS slave for the target or not.
1124 .\" ==== mirror-dump ====
1130 to dump an ASCII representation of the mirroring stream.
1131 .\" ==== mirror-copy ====
1132 .\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem
1133 .It Cm mirror-copy \
1134 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1135 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1136 This is a shortcut which pipes a
1141 If a remote host specification is made the program forks a
1147 on the appropriate host.
1148 The source may be a master or slave PFS, and the target must be a slave PFS.
1150 This command also establishes full duplex communication and turns on
1151 the 2-way protocol feature
1153 which automatically negotiates transaction id
1154 ranges without having to use a cyclefile.
1155 If the operation completes successfully the target PFS's
1158 Note that you must re-chdir into the target PFS to see the updated information.
1159 If you do not you will still be in the previous snapshot.
1161 If the target PFS does not exist this command will ask you whether
1162 you want to create a compatible PFS slave for the target or not.
1163 .\" ==== mirror-stream ====
1164 .\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem
1165 .It Cm mirror-stream \
1166 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1167 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1168 This is a shortcut which pipes a
1169 .Cm mirror-read-stream
1173 This command works similarly to
1175 but does not exit after the initial mirroring completes.
1176 The mirroring operation will resume as changes continue to be made to the
1178 The command is commonly used with
1182 options to keep the mirroring target in sync with the source on a continuing
1185 If the pipe is broken the command will automatically retry after sleeping
1187 The time slept will be 15 seconds plus the time given in the
1191 This command also detects the initial-mirroring case and spends some
1192 time scanning the B-Tree to find good break points, allowing the initial
1193 bulk mirroring operation to be broken down into 100MB pieces.
1194 This means that the user can kill and restart the operation and it will
1195 not have to start from scratch once it has gotten past the first chunk.
1198 option may be used to change the size of pieces and the
1200 option may be used to disable this feature and perform an initial bulk
1202 .\" ==== version ====
1203 .It Cm version Ar filesystem
1204 This command returns the
1206 file system version for the specified
1208 as well as the range of versions supported in the kernel.
1211 option may be used to remove the summary at the end.
1212 .\" ==== version-upgrade ====
1213 .It Cm version-upgrade Ar filesystem Ar version Op Cm force
1214 This command upgrades the
1219 Once upgraded a file system may not be downgraded.
1220 If you wish to upgrade a file system to a version greater or equal to the
1221 work-in-progress version number you must specify the
1224 Use of WIP versions should be relegated to testing and may require wiping
1225 the file system as development progresses, even though the WIP version might
1229 This command operates on the entire
1231 file system and is not a per PFS operation.
1232 All PFS's will be affected.
1233 .Bl -tag -width indent
1236 default version, first
1241 New directory entry layout.
1242 This version is using a new directory hash key.
1245 New snapshot management, using file system meta-data for saving
1246 configuration file and snapshots (transaction ids etc.).
1247 Also default snapshots directory has changed.
1251 New undo/redo/flush, giving HAMMER a much faster sync and fsync.
1254 .Sh PSEUDO-FILESYSTEM (PFS) NOTES
1255 The root of a PFS is not hooked into the primary
1257 file system as a directory.
1260 creates a special softlink called
1262 (exactly 10 characters long) in the primary
1266 then modifies the contents of the softlink as read by
1268 and thus what you see with an
1270 command or if you were to
1273 If the PFS is a master the link reflects the current state of the PFS.
1274 If the PFS is a slave the link reflects the last completed snapshot, and the
1275 contents of the link will change when the next snapshot is completed, and
1280 utility employs numerous safeties to reduce user foot-shooting.
1283 directive requires that the target be configured as a slave and that the
1285 field of the mirroring source and target match.
1286 .Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2
1287 This upgrade changes the way directory entries are stored.
1288 It is possible to upgrade a V1 file system to V2 in place, but
1289 directories created prior to the upgrade will continue to use
1292 Note that the slave mirroring code in the target kernel had bugs in
1293 V1 which can create an incompatible root directory on the slave.
1296 master created after the upgrade with a
1298 slave created prior to the upgrade.
1300 Any directories created after upgrading will use a new layout.
1301 .Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3
1302 This upgrade adds meta-data elements to the B-Tree.
1303 It is possible to upgrade a V2 file system to V3 in place.
1304 After issuing the upgrade be sure to run a
1307 to perform post-upgrade tasks.
1309 After making this upgrade running a
1314 directory for each PFS mount into
1315 .Pa /var/hammer/<pfs> .
1318 root mount will migrate
1321 .Pa /var/hammer/root .
1322 Migration occurs only once and only if you have not specified
1323 a snapshots directory in the PFS configuration.
1324 If you have specified a snapshots directory in the PFS configuration no
1325 automatic migration will occur.
1327 For slaves, if you desire, you can migrate your snapshots
1328 config to the new location manually and then clear the
1329 snapshot directory configuration in the slave PFS.
1330 The new snapshots hierarchy is designed to work with
1331 both master and slave PFSs equally well.
1333 In addition, the old config file will be moved to file system meta-data,
1334 editable via the new
1338 The old config file will be deleted.
1339 Migration occurs only once.
1341 The V3 file system has new
1343 directives for creating snapshots.
1344 All snapshot directives, including the original, will create
1345 meta-data entries for the snapshots and the pruning code will
1346 automatically incorporate these entries into its list and
1347 expire them the same way it expires softlinks.
1348 If you by accident blow away your snapshot softlinks you can use the
1350 directive to get a definitive list from the file system meta-data and
1351 regenerate them from that list.
1356 to backup file systems your scripts may be using the
1358 directive to generate transaction ids.
1359 This directive does not create a snapshot.
1360 You will have to modify your scripts to use the
1362 directive to generate the linkbuf for the softlink you create, or
1363 use one of the other
1368 directive will continue to work as expected and in V3 it will also
1369 record the snapshot transaction id in file system meta-data.
1370 You may also want to make use of the new
1372 tag for the meta-data.
1375 If you used to remove snapshot softlinks with
1377 you should probably start using the
1379 directive instead to also remove the related meta-data.
1380 The pruning code scans the meta-data so just removing the
1381 softlink is not sufficient.
1382 .Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4
1383 This upgrade changes undo/flush, giving faster sync.
1384 It is possible to upgrade a V3 file system to V4 in place.
1385 This upgrade reformats the UNDO FIFO (typically 1GB), so upgrade might take
1386 a minute or two depending.
1388 Version 4 allows the UNDO FIFO to be flushed without also having
1389 to flush the volume header, removing 2 of the 4 disk syncs typically
1392 and removing 1 of the 2 disk syncs typically
1393 required for a flush sequence.
1394 Version 4 also implements the REDO log (see below) which is capable
1395 of fsync()ing with either one disk flush or zero disk flushes.
1396 .Sh FSYNC FLUSH MODES
1398 implements five different fsync flush modes via the
1399 .Va vfs.hammer.fsync_mode
1402 version 4+ file systems.
1406 fsync mode 3 is set by default.
1407 REDO operation and recovery is enabled by default.
1408 .Bl -tag -width indent
1410 Full synchronous fsync semantics without REDO.
1413 will not generate REDOs.
1416 will completely sync
1417 the data and meta-data and double-flush the FIFO, including
1418 issuing two disk synchronization commands.
1419 The data is guaranteed
1420 to be on the media as of when
1423 Needless to say, this is slow.
1425 Relaxed asynchronous fsync semantics without REDO.
1427 This mode works the same as mode 0 except the last disk synchronization
1428 command is not issued.
1429 It is faster than mode 0 but not even remotely
1430 close to the speed you get with mode 2 or mode 3.
1432 Note that there is no chance of meta-data corruption when using this
1433 mode, it simply means that the data you wrote and then
1435 might not have made it to the media if the storage system crashes at a bad
1439 Full synchronous fsync semantics using REDO.
1440 NOTE: If not running
1441 a HAMMER version 4 filesystem or later mode 0 is silently used.
1444 will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1445 If this is sufficient to satisfy the
1447 operation the blocks
1448 will be written out and
1450 will wait for the I/Os to complete,
1451 and then followup with a disk sync command to guarantee the data
1452 is on the media before returning.
1453 This is slower than mode 3 and can result in significant disk or
1454 SSDs overheads, though not as bad as mode 0 or mode 1.
1457 Relaxed asynchronous fsync semantics using REDO.
1458 NOTE: If not running
1459 a HAMMER version 4 filesystem or later mode 1 is silently used.
1462 will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1463 If this is sufficient to satisfy the
1465 operation the blocks
1466 will be written out and
1468 will wait for the I/Os to complete,
1471 issue a disk synchronization command.
1473 Note that there is no chance of meta-data corruption when using this
1474 mode, it simply means that the data you wrote and then
1477 not have made it to the media if the storage system crashes at a bad
1480 This mode is the fastest production fsyncing mode available.
1481 This mode is equivalent to how the UFS fsync in the
1491 This mode is primarily designed
1492 for testing and should not be used on a production system.
1494 .Sh RESTORING FROM A SNAPSHOT BACKUP
1495 You restore a snapshot by copying it over to live, but there is a caveat.
1496 The mtime and atime fields for files accessed via a snapshot is locked
1497 to the ctime in order to keep the snapshot consistent, because neither
1498 mtime nor atime changes roll any history.
1500 In order to avoid unnecessary copying it is recommended that you use
1504 when doing the copyback. Also make sure you traverse the snapshot softlink
1505 by appending a ".", as in "<snapshotpath>/.", and you match up the directory
1510 If the following environment variables exist, they will be used by:
1511 .Bl -tag -width ".Ev EDITOR"
1513 The editor program specified in the variable
1515 will be invoked instead of the default editor, which is
1523 .Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
1524 .It Pa <pfs>/snapshots
1525 default per PFS snapshots directory
1528 .It Pa /var/hammer/<pfs>
1529 default per PFS snapshots directory (not root)
1532 .It Pa /var/hammer/root
1533 default snapshots directory for root directory
1536 .It Pa <snapshots>/config
1543 .It Pa <fs>/var/slaves/<name>
1544 recommended slave PFS snapshots directory
1553 .Xr periodic.conf 5 ,
1554 .Xr mount_hammer 8 ,
1560 utility first appeared in
1563 .An Matthew Dillon Aq dillon@backplane.com