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
38 .Nd HAMMER file system utility
47 .\" .Op Fl s Ar linkpath
51 .Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
56 This manual page documents the
58 utility which provides miscellaneous functions related to managing a
61 For a general introduction to the
63 file system, its features, and
64 examples on how to set up and maintain one, see
67 The options are as follows:
68 .Bl -tag -width indent
72 Tell the mirror commands to use a 2-way protocol, which allows
73 automatic negotiation of transaction id ranges.
74 This option is automatically enabled by the
78 Specify a bandwidth limit in bytes per second for mirroring streams.
79 This option is typically used to prevent batch mirroring operations from
80 loading down the machine.
81 The bandwidth may be suffixed with
85 to specify values in kilobytes, megabytes, and gigabytes per second.
86 If no suffix is specified, bytes per second is assumed.
88 Unfortunately this is only applicable to the pre-compression bandwidth
89 when compression is used, so a better solution would probably be to
96 When pruning, rebalancing or reblocking you can tell the utility
97 to start at the object id stored in the specified file.
98 If the file does not exist
100 will start at the beginning.
104 specific period of time and is unable to complete the operation it will
105 write out the current object id so the next run can pick up where it left off.
108 runs to completion it will delete
111 Specify the volumes making up a
115 is a colon-separated list of devices, each specifying a
119 When maintaining a streaming mirroring this option specifies the
120 minimum delay after a batch ends before the next batch is allowed
122 The default is five seconds.
129 specification for the source and/or destination.
131 Decrease verboseness.
132 May be specified multiple times.
134 Specify recursion for those commands which support it.
136 When pruning, rebalancing or reblocking you can tell the utility to stop
137 after a certain period of time.
138 This option is used along with the
140 option to prune, rebalance or reblock incrementally.
142 Increase verboseness.
143 May be specified multiple times.
145 Force "yes" for any interactive question.
149 will not attempt to break-up large initial bulk transfers into smaller
151 This can save time but if the link is lost in the middle of the
152 initial bulk transfer you will have to start over from scratch.
153 This option is not recommended.
154 For more information see the
157 .It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
158 Set the memory cache size for any raw
165 for megabytes is allowed,
166 else the cache size is specified in bytes.
168 The read-behind/read-ahead defaults to 4
172 This option is typically only used with diagnostic commands
173 as kernel-supported commands will use the kernel's buffer cache.
174 .It Fl S Ar splitsize
175 Specify the bulk splitup size in bytes for mirroring streams.
180 will do an initial run-through of the data to calculate good
181 transaction ids to cut up the bulk transfers, creating
182 restart points in case the stream is interrupted.
183 If we don't do this and the stream is interrupted it might
184 have to start all over again.
185 The default is a splitsize of 4G.
187 At the moment the run-through is disk-bandwidth-heavy but some
188 future version will limit the run-through to just the B-Tree
189 records and not the record data.
191 The splitsize may be suffixed with
195 to specify values in kilobytes, megabytes, or gigabytes.
196 If no suffix is specified, bytes is assumed.
198 When mirroring very large filesystems the minimum recommended
200 A small split size may wind up generating a great deal of overhead
201 but very little actual incremental data and is not recommended.
203 Enable compression for any remote ssh specifications.
206 option has already been reserved for other purposes so we had to use
208 This option is typically used with the mirroring directives.
210 Force "yes" for any interactive question.
213 The commands are as follows:
214 .Bl -tag -width indent
215 .\" ==== synctid ====
216 .It Cm synctid Ar filesystem Op Cm quick
217 Generates a guaranteed, formal 64 bit transaction id representing the
218 current state of the specified
221 The file system will be synced to the media.
225 keyword is specified the file system will be soft-synced, meaning that a
226 crash might still undo the state of the file system as of the transaction
227 id returned but any new modifications will occur after the returned
228 transaction id as expected.
230 This operation does not create a snapshot.
231 It is meant to be used
232 to track temporary fine-grained changes to a subset of files and
233 will only remain valid for
235 snapshot access purposes for the
237 period configured for the PFS.
238 If you desire a real snapshot then the
240 directive may be what you are looking for.
242 .It Cm bstats Op Ar interval
245 B-Tree statistics until interrupted.
248 seconds between each display.
249 The default interval is one second.
250 .\" ==== iostats ====
251 .It Cm iostats Op Ar interval
255 statistics until interrupted.
258 seconds between each display.
259 The default interval is one second.
260 .\" ==== history ====
261 .It Cm history Ar path ...
262 Show the modification history for
264 file's inode and data.
265 .\" ==== blockmap ====
267 Dump the blockmap for the file system.
270 blockmap is two-layer
271 blockmap representing the maximum possible file system size of 1 Exabyte.
272 Needless to say the second layer is only present for blocks which exist.
274 blockmap represents 8-Megabyte blocks, called big-blocks.
275 Each big-block has an append
276 point, a free byte count, and a typed zone id which allows content to be
277 reverse engineered to some degree.
281 allocations are essentially appended to a selected big-block using
282 the append offset and deducted from the free byte count.
283 When space is freed the free byte count is adjusted but
285 does not track holes in big-blocks for reallocation.
286 A big-block must be completely freed, either
287 through normal file system operations or through reblocking, before
290 Data blocks can be shared by deducting the space used from the free byte
291 count for each shared references.
292 This means the free byte count can legally go negative.
294 This command needs the
297 .\" ==== checkmap ====
299 Check the blockmap allocation count.
301 will scan the B-Tree, collect allocation information, and
302 construct a blockmap in-memory. It will then check that blockmap
303 against the on-disk blockmap.
305 This command needs the
309 .It Cm show Op Ar lo Ns Cm \&: Ns Ar objid
311 By default this command will validate all B-Tree
312 linkages and CRCs, including data CRCs, and will report the most verbose
313 information it can dig up.
314 Any errors will show up with a
316 in column 1 along with various
319 If you specify a localization field or a localization:obj_id field,
320 .Ar lo Ns Cm \&: Ns Ar objid ,
322 search for the key printing nodes as it recurses down, and then
323 will iterate forwards.
324 These fields are specified in HEX.
325 Note that the pfsid is the top 16 bits of the 32 bit localization
326 field so PFS #1 would be 00010000.
330 the command will report less information about the inode contents.
334 the command will not report the content of the inode or other typed
339 the command will not report volume header information, big-block fill
340 ratios, mirror transaction ids, or report or check data CRCs.
341 B-Tree CRCs and linkages are still checked.
343 This command needs the
346 .\" ==== show-undo ====
352 This command needs the
356 .\" Dump the B-Tree, record, large-data, and small-data blockmaps, showing
357 .\" physical block assignments and free space percentages.
358 .\" ==== recover ====
359 .It Cm recover Ar targetdir
360 This is a low level command which operates on the filesystem image and
361 attempts to locate and recover files from a corrupted filesystem. The
362 entire image is scanned linearly looking for B-Tree nodes. Any node
363 found which passes its crc test is scanned for file, inode, and directory
364 fragments and the target directory is populated with the resulting data.
365 files and directories in the target directory are initially named after
366 the object id and are renamed as fragmentory information is processed.
368 This command keeps track of filename/objid translations and may eat a
369 considerably amount of memory while operating.
371 This command is literally the last line of defense when it comes to
372 recovering data from a dead filesystem.
373 .\" ==== namekey1 ====
374 .It Cm namekey1 Ar filename
377 64 bit directory hash for the specified file name, using
378 the original directory hash algorithm in version 1 of the file system.
379 The low 32 bits are used as an iterator for hash collisions and will be
381 .\" ==== namekey2 ====
382 .It Cm namekey2 Ar filename
385 64 bit directory hash for the specified file name, using
386 the new directory hash algorithm in version 2 of the file system.
387 The low 32 bits are still used as an iterator but will start out containing
388 part of the hash key.
389 .\" ==== namekey32 ====
390 .It Cm namekey32 Ar filename
391 Generate the top 32 bits of a
393 64 bit directory hash for the specified file name.
396 Shows extended information about all the mounted
399 The information is divided into sections:
400 .Bl -tag -width indent
401 .It Volume identification
402 General information, like the label of the
404 filesystem, the number of volumes it contains, the FSID, and the
407 .It Big block information
408 Big block statistics, such as total, used, reserved and free big blocks.
409 .It Space information
410 Information about space used on the filesystem.
411 Currently total size, used, reserved and free space are displayed.
413 Basic information about the PFSs currently present on a
418 is the ID of the PFS, with 0 being the root PFS.
420 is the current snapshot count on the PFS.
422 displays the mount point of the PFS is currently mounted on (if any).
424 .\" ==== cleanup ====
425 .It Cm cleanup Op Ar filesystem ...
426 This is a meta-command which executes snapshot, prune, rebalance, dedup
427 and reblock commands on the specified
432 is specified this command will clean-up all
434 file systems in use, including PFS's.
435 To do this it will scan all
439 mounts, extract PFS id's, and clean-up each PFS found.
441 This command will access a snapshots
442 directory and a configuration file for each
444 creating them if necessary.
445 .Bl -tag -width indent
446 .It Nm HAMMER No version 2-
447 The configuration file is
449 in the snapshots directory which defaults to
450 .Pa <pfs>/snapshots .
451 .It Nm HAMMER No version 3+
452 The configuration file is saved in file system meta-data, see
455 The snapshots directory defaults to
456 .Pa /var/hammer/<pfs>
457 .Pa ( /var/hammer/root
461 The format of the configuration file is:
462 .Bd -literal -offset indent
463 snapshots <period> <retention-time> [any]
464 prune <period> <max-runtime>
465 rebalance <period> <max-runtime>
466 dedup <period> <max-runtime>
467 reblock <period> <max-runtime>
468 recopy <period> <max-runtime>
472 .Bd -literal -offset indent
473 snapshots 1d 60d # 0d 0d for PFS /tmp, /var/tmp, /usr/obj
481 Time is given with a suffix of
487 meaning day, hour, minute and second.
491 directive has a period of 0 and a retention time of 0
492 then snapshot generation is disabled, removal of old snapshots are
493 disabled, and prunes will use
494 .Cm prune-everything .
498 directive has a period of 0 but a non-zero retention time
499 then this command will not create any new snapshots but will remove old
500 snapshots it finds based on the retention time. This form should be
501 used on PFS masters where you are generating your own snapshot softlinks
502 manually and on PFS slaves when all you wish to do is prune away existing
503 snapshots inherited via the mirroring stream.
505 By default only snapshots in the form
506 .Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
510 directive is specified as a third argument on the
512 config line then any softlink of the form
513 .Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
515 .Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
518 A prune max-runtime of 0 means unlimited.
520 If period hasn't passed since the previous
523 For example a day has passed when midnight is passed (localtime).
531 The default configuration file will create a daily snapshot, do a daily
532 pruning, rebalancing, deduping and reblocking run and a monthly recopy run.
533 Reblocking is defragmentation with a level of 95%,
534 and recopy is full defragmentation.
536 By default prune and rebalance operations are time limited to 5 minutes,
537 dedup and reblock operations to a bit over 5 minutes,
538 and recopy operations to a bit over 10 minutes.
539 Reblocking and recopy runs are each broken down into four separate functions:
540 btree, inodes, dirs and data.
541 Each function is time limited to the time given in the configuration file,
542 but the btree, inodes and dirs functions usually does not take very long time,
543 full defragmentation is always used for these three functions.
544 Also note that this directive will by default disable snapshots on
551 The defaults may be adjusted by modifying the configuration file.
552 The pruning and reblocking commands automatically maintain a cyclefile
553 for incremental operation.
554 If you interrupt (^C) the program the cyclefile will be updated,
556 may continue to run in the background for a few seconds until the
558 ioctl detects the interrupt.
561 PFS option can be set to use another location for the snapshots directory.
563 Work on this command is still in progress.
565 An ability to remove snapshots dynamically as the
566 file system becomes full.
568 .It Cm config Op Ar filesystem Op Ar configfile
571 Show or change configuration for
573 If zero or one arguments are specified this function dumps the current
574 configuration file to stdout.
575 Zero arguments specifies the PFS containing the current directory.
576 This configuration file is stored in file system meta-data.
577 If two arguments are specified this function installs a new config file.
581 versions less than 3 the configuration file is by default stored in
582 .Pa <pfs>/snapshots/config ,
583 but in all later versions the configuration file is stored in file system
585 .\" ==== viconfig ====
586 .It Cm viconfig Op Ar filesystem
589 Edit the configuration file and reinstall into file system meta-data when done.
590 Zero arguments specifies the PFS containing the current directory.
591 .\" ==== volume-add ====
592 .It Cm volume-add Ar device Ar filesystem
593 This command will format
595 and add all of its space to
599 All existing data contained on
601 will be destroyed by this operation!
606 file system, formatting will be denied.
607 You can overcome this sanity check
610 to erase the beginning sectors of the device.
611 Also remember that you have to specify
613 together with any other device that make up the file system,
618 .\" ==== volume-del ====
619 .It Cm volume-del Ar device Ar filesystem
620 This command will remove volume
625 Remember that you have to remove
627 from the colon-separated list in
631 .\" ==== snapshot ====
632 .It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
633 .It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
634 Takes a snapshot of the file system either explicitly given by
636 or implicitly derived from the
638 argument and creates a symlink in the directory provided by
640 pointing to the snapshot.
643 is not a directory, it is assumed to be a format string passed to
645 with the current time as parameter.
648 refers to an existing directory, a default format string of
650 is assumed and used as name for the newly created symlink.
652 Snapshot is a per PFS operation, so a
654 file system and each PFS in it have to be snapshot separately.
656 Example, assuming that
664 are file systems on their own, the following invocations:
665 .Bd -literal -offset indent
666 hammer snapshot /mysnapshots
668 hammer snapshot /mysnapshots/%Y-%m-%d
670 hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
672 hammer snapshot /usr /my/snaps/usr "note"
675 Would create symlinks similar to:
676 .Bd -literal -offset indent
677 /mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
679 /mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
681 /mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
683 /my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
688 version 3+ file system the snapshot is also recorded in file system meta-data
689 along with the optional
695 .It Cm snap Ar path Op Ar note
698 Create a snapshot for the PFS containing
700 and create a snapshot softlink.
701 If the path specified is a
702 directory a standard snapshot softlink will be created in the directory.
703 The snapshot softlink points to the base of the mounted PFS.
704 .It Cm snaplo Ar path Op Ar note
707 Create a snapshot for the PFS containing
709 and create a snapshot softlink.
710 If the path specified is a
711 directory a standard snapshot softlink will be created in the directory.
712 The snapshot softlink points into the directory it is contained in.
713 .It Cm snapq Ar dir Op Ar note
716 Create a snapshot for the PFS containing the specified directory but do
717 not create a softlink.
718 Instead output a path which can be used to access
719 the directory via the snapshot.
721 An absolute or relative path may be specified.
722 The path will be used as-is as a prefix in the path output to stdout.
724 snap and snapshot directives the snapshot transaction id will be registered
725 in the file system meta-data.
726 .It Cm snaprm Ar path Ar ...
727 .It Cm snaprm Ar transid Ar ...
728 .It Cm snaprm Ar filesystem Ar transid Ar ...
731 Remove a snapshot given its softlink or transaction id.
732 If specifying a transaction id
733 the snapshot is removed from file system meta-data but you are responsible
734 for removing any related softlinks.
736 If a softlink path is specified the filesystem and transaction id
737 is derived from the contents of the softlink.
738 If just a transaction id is specified it is assumed to be a snapshot
739 in the HAMMER filesystem you are currently chdir'd into.
740 You can also specify the filesystem and transaction id explicitly.
741 .It Cm snapls Op Ar path ...
744 Dump the snapshot meta-data for PFSs containing each
746 listing all available snapshots and their notes.
747 If no arguments are specified snapshots for the PFS containing the
748 current directory are listed.
749 This is the definitive list of snapshots for the file system.
751 .It Cm prune Ar softlink-dir
752 Prune the file system based on previously created snapshot softlinks.
753 Pruning is the act of deleting file system history.
756 command will delete file system history such that
757 the file system state is retained for the given snapshots,
758 and all history after the latest snapshot.
759 By setting the per PFS parameter
761 history is guaranteed to be saved at least this time interval.
762 All other history is deleted.
764 The target directory is expected to contain softlinks pointing to
765 snapshots of the file systems you wish to retain.
766 The directory is scanned non-recursively and the mount points and
767 transaction ids stored in the softlinks are extracted and sorted.
768 The file system is then explicitly pruned according to what is found.
769 Cleaning out portions of the file system is as simple as removing a
770 snapshot softlink and then running the
774 As a safety measure pruning only occurs if one or more softlinks are found
777 snapshot id extension.
778 Currently the scanned softlink directory must contain softlinks pointing
782 The softlinks may specify absolute or relative paths.
783 Softlinks must use 20-character
785 transaction ids, as might be returned from
786 .Nm Cm synctid Ar filesystem .
788 Pruning is a per PFS operation, so a
790 file system and each PFS in it have to be pruned separately.
792 Note that pruning a file system may not immediately free-up space,
793 though typically some space will be freed if a large number of records are
795 The file system must be reblocked to completely recover all available space.
797 Example, lets say your that you didn't set
799 and snapshot directory contains the following links:
800 .Bd -literal -offset indent
801 lrwxr-xr-x 1 root wheel 29 May 31 17:57 snap1 ->
802 /usr/obj/@@0x10d2cd05b7270d16
804 lrwxr-xr-x 1 root wheel 29 May 31 17:58 snap2 ->
805 /usr/obj/@@0x10d2cd13f3fde98f
807 lrwxr-xr-x 1 root wheel 29 May 31 17:59 snap3 ->
808 /usr/obj/@@0x10d2cd222adee364
811 If you were to run the
813 command on this directory, then the
816 mount will be pruned to retain the above three snapshots.
817 In addition, history for modifications made to the file system older than
818 the oldest snapshot will be destroyed and history for potentially fine-grained
819 modifications made to the file system more recently than the most recent
820 snapshot will be retained.
822 If you then delete the
824 softlink and rerun the
827 history for modifications pertaining to that snapshot would be destroyed.
831 file system versions 3+ this command also scans the snapshots stored
832 in the file system meta-data and includes them in the prune.
833 .\" ==== prune-everything ====
834 .It Cm prune-everything Ar filesystem
835 This command will remove all historical records from the file system.
836 This directive is not normally used on a production system.
838 This command does not remove snapshot softlinks but will delete all
839 snapshots recorded in file system meta-data (for file system version 3+).
840 The user is responsible for deleting any softlinks.
842 Pruning is a per PFS operation, so a
844 file system and each PFS in it have to be pruned separately.
845 .\" ==== rebalance ====
846 .It Cm rebalance Ar filesystem Op Ar saturation_percentage
847 This command will rebalance the B-Tree, nodes with small number of
848 elements will be combined and element counts will be smoothed out
851 The saturation percentage is between 50% and 100%.
852 The default is 75% (the
854 suffix is not needed).
856 Rebalancing is a per PFS operation, so a
858 file system and each PFS in it have to be rebalanced separately.
860 .It Cm dedup Ar filesystem
863 Perform offline (post-process) deduplication. Deduplication occurs at
864 the block level, currently only data blocks of the same size can be
865 deduped, metadata blocks can not. The hash function used for comparing
866 data blocks is CRC-32 (CRCs are computed anyways as part of
868 data integrity features, so there's no additional overhead). Since CRC
869 is a weak hash function a byte-by-byte comparison is done before actual
870 deduping. In case of a CRC collision (two data blocks have the same CRC
871 but different contents) the checksum is upgraded to SHA-256.
875 reblocker may partially blow up (re-expand) dedup (reblocker's normal
876 operation is to reallocate every record, so it's possible for deduped
877 blocks to be re-expanded back).
879 Deduplication is a per PFS operation, so a
881 file system and each PFS in it have to be deduped separately. This also
882 means that if you have duplicated data in two different PFSs that data
883 won't be deduped, however the addition of such feature is planned.
884 .\" ==== dedup-simulate ====
885 .It Cm dedup-simulate Ar filesystem
888 Shows potential space savings (simulated dedup ratio) one can get after
891 command. If the estimated dedup ratio is greater than 1.00 you will see
892 dedup space savings. Remember that this is an estimated number, in
893 practice real dedup ratio will be slightly smaller because of
895 bigblock underflows, B-Tree locking issues and other factors.
896 .\" ==== reblock* ====
897 .It Cm reblock Ar filesystem Op Ar fill_percentage
898 .It Cm reblock-btree Ar filesystem Op Ar fill_percentage
899 .It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
900 .It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
901 .It Cm reblock-data Ar filesystem Op Ar fill_percentage
902 Attempt to defragment and free space for reuse by reblocking a live
905 Big-blocks cannot be reused by
907 until they are completely free.
908 This command also has the effect of reordering all elements, effectively
909 defragmenting the file system.
911 The default fill percentage is 100% and will cause the file system to be
912 completely defragmented.
913 All specified element types will be reallocated and rewritten.
914 If you wish to quickly free up space instead try specifying
915 a smaller fill percentage, such as 90% or 80% (the
917 suffix is not needed).
919 Since this command may rewrite the entire contents of the disk it is
920 best to do it incrementally from a
926 options to limit the run time.
927 The file system would thus be defragmented over long period of time.
929 It is recommended that separate invocations be used for each data type.
930 B-Tree nodes, inodes, and directories are typically the most important
931 elements needing defragmentation.
932 Data can be defragmented over a longer period of time.
934 Reblocking is a per PFS operation, so a
936 file system and each PFS in it have to be reblocked separately.
937 .\" ==== pfs-status ====
938 .It Cm pfs-status Ar dirpath ...
939 Retrieve the mirroring configuration parameters for the specified
941 file systems or pseudo-filesystems (PFS's).
942 .\" ==== pfs-master ====
943 .It Cm pfs-master Ar dirpath Op Ar options
944 Create a pseudo-filesystem (PFS) inside a
947 Up to 65535 such file systems can be created.
948 Each PFS uses an independent inode numbering space making it suitable
949 for use as a replication source or target.
953 directive creates a PFS that you can read, write, and use as a mirroring
956 It is recommended to use a
958 mount to access a PFS, for more information see
960 .\" ==== pfs-slave ====
961 .It Cm pfs-slave Ar dirpath Op Ar options
962 Create a pseudo-filesystem (PFS) inside a
965 Up to 65535 such file systems can be created.
966 Each PFS uses an independent inode numbering space making it suitable
967 for use as a replication source or target.
971 directive creates a PFS that you can use as a mirroring target.
972 You will not be able to access a slave PFS until you have completed the
973 first mirroring operation with it as the target (its root directory will
974 not exist until then).
976 Access to the pfs-slave via the special softlink, as described in the
981 dynamically modify the snapshot transaction id by returning a dynamic result
986 A PFS can only be truly destroyed with the
989 Removing the softlink will not destroy the underlying PFS.
991 It is recommended to use a
993 mount to access a PFS, for more information see
995 .\" ==== pfs-update ====
996 .It Cm pfs-update Ar dirpath Op Ar options
997 Update the configuration parameters for an existing
999 file system or pseudo-filesystem.
1000 Options that may be specified:
1001 .Bl -tag -width indent
1002 .It Cm sync-beg-tid= Ns Ar 0x16llx
1003 This is the automatic snapshot access starting transaction id for
1005 This parameter is normally updated automatically by the
1009 It is important to note that accessing a mirroring slave
1010 with a transaction id greater than the last fully synchronized transaction
1011 id can result in an unreliable snapshot since you will be accessing
1012 data that is still undergoing synchronization.
1014 Manually modifying this field is dangerous and can result in a broken mirror.
1015 .It Cm sync-end-tid= Ns Ar 0x16llx
1016 This is the current synchronization point for mirroring slaves.
1017 This parameter is normally updated automatically by the
1021 Manually modifying this field is dangerous and can result in a broken mirror.
1022 .It Cm shared-uuid= Ns Ar uuid
1023 Set the shared UUID for this file system.
1024 All mirrors must have the same shared UUID.
1025 For safety purposes the
1027 directives will refuse to operate on a target with a different shared UUID.
1029 Changing the shared UUID on an existing, non-empty mirroring target,
1030 including an empty but not completely pruned target,
1031 can lead to corruption of the mirroring target.
1032 .It Cm unique-uuid= Ns Ar uuid
1033 Set the unique UUID for this file system.
1034 This UUID should not be used anywhere else,
1035 even on exact copies of the file system.
1036 .It Cm label= Ns Ar string
1037 Set a descriptive label for this file system.
1038 .It Cm snapshots= Ns Ar string
1039 Specify the snapshots directory which
1042 will use to manage this PFS.
1043 .Bl -tag -width indent
1044 .It Nm HAMMER No version 2-
1045 The snapshots directory does not need to be configured for
1046 PFS masters and will default to
1047 .Pa <pfs>/snapshots .
1049 PFS slaves are mirroring slaves so you cannot configure a snapshots
1050 directory on the slave itself to be managed by the slave's machine.
1051 In fact, the slave will likely have a
1053 sub-directory mirrored
1054 from the master, but that directory contains the configuration the master
1055 is using for its copy of the file system, not the configuration that we
1056 want to use for our slave.
1058 It is recommended that
1059 .Pa <fs>/var/slaves/<name>
1060 be configured for a PFS slave, where
1066 is an appropriate label.
1067 .It Nm HAMMER No version 3+
1068 The snapshots directory does not need to be configured for PFS masters or
1070 The snapshots directory defaults to
1071 .Pa /var/hammer/<pfs>
1072 .Pa ( /var/hammer/root
1076 You can control snapshot retention on your slave independent of the master.
1077 .It Cm snapshots-clear
1080 directory path for this PFS.
1081 .It Cm prune-min= Ns Ar N Ns Cm d
1082 .It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \
1083 Ar hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss
1084 Set the minimum fine-grained data retention period.
1086 always retains fine-grained history up to the most recent snapshot.
1087 You can extend the retention period further by specifying a non-zero
1089 Any snapshot softlinks within the retention period are ignored
1090 for the purposes of pruning (the fine grained history is retained).
1091 Number of days, hours, minutes and seconds are given as
1096 Because the transaction id in the snapshot softlink cannot be used
1097 to calculate a timestamp,
1099 uses the earlier of the
1103 field of the softlink to
1104 determine which snapshots fall within the retention period.
1105 Users must be sure to retain one of these two fields when manipulating
1108 .\" ==== pfs-upgrade ====
1109 .It Cm pfs-upgrade Ar dirpath
1110 Upgrade a PFS from slave to master operation.
1111 The PFS will be rolled back to the current end synchronization transaction id
1112 (removing any partial synchronizations), and will then become writable.
1116 currently supports only single masters and using
1117 this command can easily result in file system corruption
1118 if you don't know what you are doing.
1120 This directive will refuse to run if any programs have open descriptors
1121 in the PFS, including programs chdir'd into the PFS.
1122 .\" ==== pfs-downgrade ====
1123 .It Cm pfs-downgrade Ar dirpath
1124 Downgrade a master PFS from master to slave operation.
1125 The PFS becomes read-only and access will be locked to its
1128 This directive will refuse to run if any programs have open descriptors
1129 in the PFS, including programs chdir'd into the PFS.
1130 .\" ==== pfs-destroy ====
1131 .It Cm pfs-destroy Ar dirpath
1132 This permanently destroys a PFS.
1134 This directive will refuse to run if any programs have open descriptors
1135 in the PFS, including programs chdir'd into the PFS.
1136 .\" ==== mirror-read ====
1137 .It Cm mirror-read Ar filesystem Op Ar begin-tid
1138 Generate a mirroring stream to stdout.
1139 The stream ends when the transaction id space has been exhausted.
1140 .\" ==== mirror-read-stream ====
1141 .It Cm mirror-read-stream Ar filesystem Op Ar begin-tid
1142 Generate a mirroring stream to stdout.
1143 Upon completion the stream is paused until new data is synced to the
1146 Operation continues until the pipe is broken.
1149 command for more details.
1150 .\" ==== mirror-write ====
1151 .It Cm mirror-write Ar filesystem
1152 Take a mirroring stream on stdin.
1154 This command will fail if the
1156 configuration field for the two file systems do not match.
1159 command for more details.
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-dump ====
1169 to dump an ASCII representation of the mirroring stream.
1170 .\" ==== mirror-copy ====
1171 .\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem
1172 .It Cm mirror-copy \
1173 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1174 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1175 This is a shortcut which pipes a
1180 If a remote host specification is made the program forks a
1186 on the appropriate host.
1187 The source may be a master or slave PFS, and the target must be a slave PFS.
1189 This command also establishes full duplex communication and turns on
1190 the 2-way protocol feature
1192 which automatically negotiates transaction id
1193 ranges without having to use a cyclefile.
1194 If the operation completes successfully the target PFS's
1197 Note that you must re-chdir into the target PFS to see the updated information.
1198 If you do not you will still be in the previous snapshot.
1200 If the target PFS does not exist this command will ask you whether
1201 you want to create a compatible PFS slave for the target or not.
1202 .\" ==== mirror-stream ====
1203 .\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem
1204 .It Cm mirror-stream \
1205 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1206 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1207 This is a shortcut which pipes a
1208 .Cm mirror-read-stream
1212 This command works similarly to
1214 but does not exit after the initial mirroring completes.
1215 The mirroring operation will resume as changes continue to be made to the
1217 The command is commonly used with
1221 options to keep the mirroring target in sync with the source on a continuing
1224 If the pipe is broken the command will automatically retry after sleeping
1226 The time slept will be 15 seconds plus the time given in the
1230 This command also detects the initial-mirroring case and spends some
1231 time scanning the B-Tree to find good break points, allowing the initial
1232 bulk mirroring operation to be broken down into 100MB pieces.
1233 This means that the user can kill and restart the operation and it will
1234 not have to start from scratch once it has gotten past the first chunk.
1237 option may be used to change the size of pieces and the
1239 option may be used to disable this feature and perform an initial bulk
1241 .\" ==== version ====
1242 .It Cm version Ar filesystem
1243 This command returns the
1245 file system version for the specified
1247 as well as the range of versions supported in the kernel.
1250 option may be used to remove the summary at the end.
1251 .\" ==== version-upgrade ====
1252 .It Cm version-upgrade Ar filesystem Ar version Op Cm force
1253 This command upgrades the
1258 Once upgraded a file system may not be downgraded.
1259 If you wish to upgrade a file system to a version greater or equal to the
1260 work-in-progress version number you must specify the
1263 Use of WIP versions should be relegated to testing and may require wiping
1264 the file system as development progresses, even though the WIP version might
1268 This command operates on the entire
1270 file system and is not a per PFS operation.
1271 All PFS's will be affected.
1272 .Bl -tag -width indent
1275 default version, first
1280 New directory entry layout.
1281 This version is using a new directory hash key.
1284 New snapshot management, using file system meta-data for saving
1285 configuration file and snapshots (transaction ids etc.).
1286 Also default snapshots directory has changed.
1290 New undo/redo/flush, giving HAMMER a much faster sync and fsync.
1293 Offline deduplication support.
1296 .Sh PSEUDO-FILESYSTEM (PFS) NOTES
1297 The root of a PFS is not hooked into the primary
1299 file system as a directory.
1302 creates a special softlink called
1304 (exactly 10 characters long) in the primary
1308 then modifies the contents of the softlink as read by
1310 and thus what you see with an
1312 command or if you were to
1315 If the PFS is a master the link reflects the current state of the PFS.
1316 If the PFS is a slave the link reflects the last completed snapshot, and the
1317 contents of the link will change when the next snapshot is completed, and
1322 utility employs numerous safeties to reduce user foot-shooting.
1325 directive requires that the target be configured as a slave and that the
1327 field of the mirroring source and target match.
1328 .Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2
1329 This upgrade changes the way directory entries are stored.
1330 It is possible to upgrade a V1 file system to V2 in place, but
1331 directories created prior to the upgrade will continue to use
1334 Note that the slave mirroring code in the target kernel had bugs in
1335 V1 which can create an incompatible root directory on the slave.
1338 master created after the upgrade with a
1340 slave created prior to the upgrade.
1342 Any directories created after upgrading will use a new layout.
1343 .Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3
1344 This upgrade adds meta-data elements to the B-Tree.
1345 It is possible to upgrade a V2 file system to V3 in place.
1346 After issuing the upgrade be sure to run a
1349 to perform post-upgrade tasks.
1351 After making this upgrade running a
1356 directory for each PFS mount into
1357 .Pa /var/hammer/<pfs> .
1360 root mount will migrate
1363 .Pa /var/hammer/root .
1364 Migration occurs only once and only if you have not specified
1365 a snapshots directory in the PFS configuration.
1366 If you have specified a snapshots directory in the PFS configuration no
1367 automatic migration will occur.
1369 For slaves, if you desire, you can migrate your snapshots
1370 config to the new location manually and then clear the
1371 snapshot directory configuration in the slave PFS.
1372 The new snapshots hierarchy is designed to work with
1373 both master and slave PFSs equally well.
1375 In addition, the old config file will be moved to file system meta-data,
1376 editable via the new
1380 The old config file will be deleted.
1381 Migration occurs only once.
1383 The V3 file system has new
1385 directives for creating snapshots.
1386 All snapshot directives, including the original, will create
1387 meta-data entries for the snapshots and the pruning code will
1388 automatically incorporate these entries into its list and
1389 expire them the same way it expires softlinks.
1390 If you by accident blow away your snapshot softlinks you can use the
1392 directive to get a definitive list from the file system meta-data and
1393 regenerate them from that list.
1398 to backup file systems your scripts may be using the
1400 directive to generate transaction ids.
1401 This directive does not create a snapshot.
1402 You will have to modify your scripts to use the
1404 directive to generate the linkbuf for the softlink you create, or
1405 use one of the other
1410 directive will continue to work as expected and in V3 it will also
1411 record the snapshot transaction id in file system meta-data.
1412 You may also want to make use of the new
1414 tag for the meta-data.
1417 If you used to remove snapshot softlinks with
1419 you should probably start using the
1421 directive instead to also remove the related meta-data.
1422 The pruning code scans the meta-data so just removing the
1423 softlink is not sufficient.
1424 .Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4
1425 This upgrade changes undo/flush, giving faster sync.
1426 It is possible to upgrade a V3 file system to V4 in place.
1427 This upgrade reformats the UNDO FIFO (typically 1GB), so upgrade might take
1428 a minute or two depending.
1430 Version 4 allows the UNDO FIFO to be flushed without also having
1431 to flush the volume header, removing 2 of the 4 disk syncs typically
1434 and removing 1 of the 2 disk syncs typically
1435 required for a flush sequence.
1436 Version 4 also implements the REDO log (see below) which is capable
1437 of fsync()ing with either one disk flush or zero disk flushes.
1438 .Sh UPGRADE INSTRUCTIONS HAMMER V4 TO V5
1439 This upgrade brings in offline deduplication support. It is possible to
1440 upgrade a V4 file system to V5 in place. Technically it makes the
1443 field a signed value instead of unsigned, allowing it
1444 to go negative. A version 5 filesystem is required for dedup operation.
1445 .Sh FSYNC FLUSH MODES
1447 implements five different fsync flush modes via the
1448 .Va vfs.hammer.fsync_mode
1451 version 4+ file systems.
1455 fsync mode 3 is set by default.
1456 REDO operation and recovery is enabled by default.
1457 .Bl -tag -width indent
1459 Full synchronous fsync semantics without REDO.
1462 will not generate REDOs.
1465 will completely sync
1466 the data and meta-data and double-flush the FIFO, including
1467 issuing two disk synchronization commands.
1468 The data is guaranteed
1469 to be on the media as of when
1472 Needless to say, this is slow.
1474 Relaxed asynchronous fsync semantics without REDO.
1476 This mode works the same as mode 0 except the last disk synchronization
1477 command is not issued.
1478 It is faster than mode 0 but not even remotely
1479 close to the speed you get with mode 2 or mode 3.
1481 Note that there is no chance of meta-data corruption when using this
1482 mode, it simply means that the data you wrote and then
1484 might not have made it to the media if the storage system crashes at a bad
1488 Full synchronous fsync semantics using REDO.
1489 NOTE: If not running
1490 a HAMMER version 4 filesystem or later mode 0 is silently used.
1493 will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1494 If this is sufficient to satisfy the
1496 operation the blocks
1497 will be written out and
1499 will wait for the I/Os to complete,
1500 and then followup with a disk sync command to guarantee the data
1501 is on the media before returning.
1502 This is slower than mode 3 and can result in significant disk or
1503 SSDs overheads, though not as bad as mode 0 or mode 1.
1506 Relaxed asynchronous fsync semantics using REDO.
1507 NOTE: If not running
1508 a HAMMER version 4 filesystem or later mode 1 is silently used.
1511 will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1512 If this is sufficient to satisfy the
1514 operation the blocks
1515 will be written out and
1517 will wait for the I/Os to complete,
1520 issue a disk synchronization command.
1522 Note that there is no chance of meta-data corruption when using this
1523 mode, it simply means that the data you wrote and then
1526 not have made it to the media if the storage system crashes at a bad
1529 This mode is the fastest production fsyncing mode available.
1530 This mode is equivalent to how the UFS fsync in the
1540 This mode is primarily designed
1541 for testing and should not be used on a production system.
1543 .Sh RESTORING FROM A SNAPSHOT BACKUP
1544 You restore a snapshot by copying it over to live, but there is a caveat.
1545 The mtime and atime fields for files accessed via a snapshot is locked
1546 to the ctime in order to keep the snapshot consistent, because neither
1547 mtime nor atime changes roll any history.
1549 In order to avoid unnecessary copying it is recommended that you use
1553 when doing the copyback. Also make sure you traverse the snapshot softlink
1554 by appending a ".", as in "<snapshotpath>/.", and you match up the directory
1559 If the following environment variables exist, they will be used by:
1560 .Bl -tag -width ".Ev EDITOR"
1562 The editor program specified in the variable
1564 will be invoked instead of the default editor, which is
1572 .Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
1573 .It Pa <pfs>/snapshots
1574 default per PFS snapshots directory
1577 .It Pa /var/hammer/<pfs>
1578 default per PFS snapshots directory (not root)
1581 .It Pa /var/hammer/root
1582 default snapshots directory for root directory
1585 .It Pa <snapshots>/config
1592 .It Pa <fs>/var/slaves/<name>
1593 recommended slave PFS snapshots directory
1602 .Xr periodic.conf 5 ,
1603 .Xr mount_hammer 8 ,
1609 utility first appeared in
1612 .An Matthew Dillon Aq dillon@backplane.com