HAMMER - Update hammer.8 documentation. Document the fsync modes.
[dragonfly.git] / sbin / hammer / hammer.8
1 .\" Copyright (c) 2007 The DragonFly Project.  All rights reserved.
2 .\"
3 .\" This code is derived from software contributed to The DragonFly Project
4 .\" by Matthew Dillon <dillon@backplane.com>
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\"
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
15 .\"    distribution.
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.
19 .\"
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
31 .\" SUCH DAMAGE.
32 .\"
33 .\" $DragonFly: src/sbin/hammer/hammer.8,v 1.58 2008/11/13 02:04:27 dillon Exp $
34 .\"
35 .Dd February 12, 2010
36 .Dt HAMMER 8
37 .Os
38 .Sh NAME
39 .Nm hammer
40 .Nd HAMMER file system utility
41 .Sh SYNOPSIS
42 .Nm
43 .Fl h
44 .Nm
45 .Op Fl 2BqrvXy
46 .Op Fl b Ar bandwidth
47 .Op Fl c Ar cyclefile
48 .Op Fl f Ar blkdevs
49 .\" .Op Fl s Ar linkpath
50 .Op Fl i Ar delay
51 .Op Fl p Ar ssh-port
52 .Op Fl t Ar seconds
53 .Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
54 .Op Fl S Ar splitsize
55 .Ar command
56 .Op Ar argument ...
57 .Sh DESCRIPTION
58 This manual page documents the
59 .Nm
60 utility which provides miscellaneous functions related to managing a
61 .Nm HAMMER
62 file system.
63 For a general introduction to the
64 .Nm HAMMER
65 file system, its features, and
66 examples on how to set up and maintain one, see
67 .Xr HAMMER 5 .
68 .Pp
69 The options are as follows:
70 .Bl -tag -width indent
71 .It Fl h
72 Get help.
73 .It Fl 2
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
77 .Cm mirror-copy
78 command.
79 .It Fl b Ar bandwidth
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
84 .Cm k , m ,
85 or
86 .Cm g
87 to specify values in kilobytes, megabytes, and gigabytes per second.
88 If no suffix is specified, bytes per second is assumed.
89 .It Fl c Ar cyclefile
90 When pruning and reblocking you can instruction
91 .Nm
92 to start at the object id stored in the specified file.
93 If the file does not exist
94 .Nm
95 will start at the beginning.
96 If
97 .Nm
98 is told to run for a
99 specific period of time and is unable to complete the operation it will
100 write out the current object id so the next run can pick up where it left off.
101 If
102 .Nm
103 runs to completion it will delete
104 .Ar cyclefile .
105 .It Fl f Ar blkdevs
106 Specify the volumes making up a
107 .Nm HAMMER
108 file system.
109 .Ar Blkdevs
110 is a colon-separated list of devices, each specifying a
111 .Nm HAMMER
112 volume.
113 .It Fl i Ar delay
114 When maintaining a streaming mirroring this option specifies the
115 minimum delay after a batch ends before the next batch is allowed
116 to start.
117 The default is five seconds.
118 .It Fl p Ar ssh-port
119 This passes the -p <port> option to ssh when using a remote
120 specification for the source and/or destination.
121 .It Fl q
122 Decrease verboseness.
123 May be specified multiple times.
124 .It Fl r
125 Specify recursion for those commands which support it.
126 .It Fl t Ar seconds
127 When pruning and reblocking you can tell the utility to stop after a
128 certain period of time.
129 This option is used along with the
130 .Fl c Ar cyclefile
131 option to prune or reblock a portion of the file system incrementally.
132 .It Fl v
133 Increase verboseness.
134 May be specified multiple times.
135 .It Fl y
136 Force "yes" for any interactive question.
137 .It Fl B
138 Bulk Transfer.
139 .Cm Mirror-stream
140 will not attempt to break-up large initial bulk transfers into smaller
141 pieces.
142 This can save time but if the link is lost in the middle of the
143 initial bulk transfer you will have to start over from scratch.
144 This option is not recommended.
145 For more information see the
146 .Fl S
147 option.
148 .It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
149 Set the memory cache size for any raw
150 .Tn I/O .
151 The default is 16m.
152 A suffix of
153 .Cm k
154 for kilobytes and
155 .Cm m
156 for megabytes is allowed,
157 else the cache size is specified in bytes.
158 .Pp
159 The read-behind/read-ahead defaults to 4
160 .Nm HAMMER
161 blocks.
162 .Pp
163 This option is typically only used with diagnostic commands
164 as kernel-supported commands will use the kernel's buffer cache.
165 .It Fl S Ar splitsize
166 Specify the bulk splitup size in bytes for mirroring streams.
167 When a mirror-stream is first started
168 .Nm
169 will do an initial run-through of the data to calculate good
170 transaction ids to cut up the bulk transfers, creating
171 restart points in case the stream is interrupted.
172 If we don't do this and the stream is interrupted it might
173 have to start all over again.
174 The default is a splitsize of 100m.
175 .Pp
176 At the moment the run-through is disk-bandwidth-heavy but some
177 future version will limit the run-through to just the B-Tree
178 records and not the record data.
179 .Pp
180 The splitsize may be suffixed with
181 .Cm k , m ,
182 or
183 .Cm g
184 to specify values in kilobytes, megabytes, or gigabytessecond.
185 If no suffix is specified, bytes is assumed.
186 .It Fl X
187 Enable compression for any remote ssh specifications.  Unfortunately
188 the
189 .Fl C
190 option has already been reserved for other purposes so we had to use
191 a different letter.  This option is typically used with the
192 mirroring directives.
193 .El
194 .Pp
195 The commands are as follows:
196 .Bl -tag -width indent
197 .\" ==== synctid ====
198 .It Cm synctid Ar filesystem Op Cm quick
199 Generates a guaranteed, formal 64 bit transaction id representing the
200 current state of the specified
201 .Nm HAMMER
202 file system.
203 The file system will be synced to the media.
204 .Pp
205 If the
206 .Cm quick
207 keyword is specified the file system will be soft-synced, meaning that a
208 crash might still undo the state of the file system as of the transaction
209 id returned but any new modifications will occur after the returned
210 transaction id as expected.
211 .Pp
212 This operation does not create a snapshot.
213 It is meant to be used
214 to track temporary fine-grained changes to a subset of files and
215 will only remain valid for
216 .Ql @@
217 snapshot access purposes for the
218 .Cm prune-min
219 period configured for the PFS.
220 If you desire a real snapshot then the
221 .Cm snapq
222 directive may be what you are looking for.
223 .\" ==== bstats ====
224 .It Cm bstats Op Ar interval
225 Output
226 .Nm HAMMER
227 B-tree statistics until interrupted.
228 Pause
229 .Ar interval
230 seconds between each display.
231 The default interval is one second.
232 .\" ==== iostats ====
233 .It Cm iostats Op Ar interval
234 Output
235 .Nm HAMMER
236 .Tn I/O
237 statistics until interrupted.
238 Pause
239 .Ar interval
240 seconds between each display.
241 The default interval is one second.
242 .\" ==== history ====
243 .It Cm history Ar path ...
244 Show the modification history for
245 .Nm HAMMER
246 file's inode and data.
247 .\" ==== blockmap ====
248 .It Cm blockmap
249 Dump the blockmap for the file system.
250 The
251 .Nm HAMMER
252 blockmap is two-layer
253 blockmap representing the maximum possible file system size of 1 Exabyte.
254 Needless to say the second layer is only present for blocks which exist.
255 .Nm HAMMER Ns 's
256 blockmap represents 8-Megabyte blocks, called big-blocks.
257 Each big-block has an append
258 point, a free byte count, and a typed zone id which allows content to be
259 reverse engineered to some degree.
260 .Pp
261 In
262 .Nm HAMMER
263 allocations essentially appended to a selected big-block using
264 the append offset and deducted from the free byte count.
265 When space is freed the free byte count is adjusted but
266 .Nm HAMMER
267 does not track holes in big-blocks for reallocation.
268 A big-block must be completely freed, either
269 through normal file system operations or through reblocking, before
270 it can be reused.
271 .Pp
272 Data blocks can be shared by deducting the space used from the free byte
273 count for each shared references, though
274 .Nm HAMMER
275 does not yet make use of this feature.
276 This means the free byte count can legally go negative.
277 .Pp
278 This command needs the
279 .Fl f
280 flag.
281 .\" ==== show ====
282 .It Cm show Op Ar lo Ns Cm \&: Ns Ar objid
283 Dump the B-tree.
284 By default this command will validate all B-Tree
285 linkages and CRCs, including data CRCs, and will report the most verbose
286 information it can dig up.
287 Any errors will show up with a
288 .Ql B
289 in column 1 along with various
290 other error flags.
291 .Pp
292 If you specify a localization field or a localization:obj_id field,
293 .Ar lo Ns Cm \&: Ns Ar objid ,
294 the dump will
295 search for the key printing nodes as it recurses down, and then
296 will iterate forwards.  These fields are specified in HEX.
297 Note that the pfsid is the top 16 bits of the 32 bit localization
298 field so pfs #1 would be 00010000.
299 .Pp
300 If you use
301 .Fl q
302 the command will report less information about the inode contents.
303 .Pp
304 If you use
305 .Fl qq
306 the command will not report the content of the inode or other typed
307 data at all.
308 .Pp
309 If you use
310 .Fl qqq
311 the command will not report volume header information, big-block fill
312 ratios, mirror transaction ids, or report or check data CRCs.
313 B-tree CRCs and linkages are still checked.
314 .Pp
315 This command needs the
316 .Fl f
317 flag.
318 .\" ==== show-undo ====
319 .It Cm show-undo
320 .Nm ( HAMMER
321 VERSION 4+)
322 Dump the UNDO map.
323 .Pp
324 This command needs the
325 .Fl f
326 flag.
327 .\" .It Ar blockmap
328 .\" Dump the B-tree, record, large-data, and small-data blockmaps, showing
329 .\" physical block assignments and free space percentages.
330 .\" ==== namekey1 ====
331 .It Cm namekey1 Ar filename
332 Generate a
333 .Nm HAMMER
334 64 bit directory hash for the specified file name, using
335 the original directory hash algorithm in version 1 of the file system.
336 The low 32 bits are used as an iterator for hash collisions and will be
337 output as 0.
338 .\" ==== namekey2 ====
339 .It Cm namekey2 Ar filename
340 Generate a
341 .Nm HAMMER
342 64 bit directory hash for the specified file name, using
343 the new directory hash algorithm in version 2 of the file system.
344 The low 32 bits are still used as an iterator but will start out containing
345 part of the hash key.
346 .\" ==== namekey32 ====
347 .It Cm namekey32 Ar filename
348 Generate the top 32 bits of a
349 .Nm HAMMER
350 64 bit directory hash for the specified file name.
351 .\" ==== info ====
352 .It Cm info
353 Shows extended information about all the mounted
354 .Nm HAMMER
355 file systems.
356 The information is divided into sections:
357 .Bl -tag
358 .It Volume identification
359 General information, like the label of the
360 .Nm HAMMER
361 filesystem, the number of volumes it contains, the FSID, and the
362 .Nm HAMMER
363 version being used.
364 .It Big block information
365 Big block statistics, such as total, used, reserved and free big blocks.
366 .It Space information
367 Information about space used on the filesystem.
368 Currently total size, used, reserved and free space are displayed.
369 .It PFS Information
370 Basic information about the PFSs currently present on a
371 .Nm HAMMER
372 filesystem.
373 .Pp
374 .Dq PFS ID
375 is the ID of the PFS, with 0 being the root PFS.
376 .Dq Snaps
377 is the current snapshot count on the PFS.
378 .Dq Mounted on
379 displays the mount point of the PFS is currently mounted on (if any).
380 .El
381 .\" ==== cleanup ====
382 .It Cm cleanup Op Ar filesystem ...
383 This is a meta-command which executes snapshot, prune, rebalance and reblock
384 commands on the specified
385 .Nm HAMMER
386 file systems.
387 If no
388 .Ar filesystem
389 is specified this command will clean-up all
390 .Nm HAMMER
391 file systems in use, including PFS's.
392 To do this it will scan all
393 .Nm HAMMER
394 and
395 .Nm null
396 mounts, extract PFS id's, and clean-up each PFS found.
397 .Pp
398 This command will access a snapshots
399 directory and a configuration file for each
400 .Ar filesystem ,
401 creating them if necessary.
402 .Bl -tag -width indent
403 .It Nm HAMMER No version 2-
404 The configuration file is
405 .Pa config
406 in the snapshots directory which defaults to
407 .Pa <pfs>/snapshots .
408 .It Nm HAMMER No version 3+
409 The configuration file is saved in file system meta-data, see
410 .Nm
411 .Cm config .
412 The snapshots directory defaults to
413 .Pa /var/hammer/<pfs>
414 .Pa ( /var/hammer/root
415 for root mount).
416 .El
417 .Pp
418 The format of the configuration file is:
419 .Bd -literal -offset indent
420 snapshots  <period> <retention-time> [any]
421 prune      <period> <max-runtime>
422 rebalance  <period> <max-runtime>
423 reblock    <period> <max-runtime>
424 recopy     <period> <max-runtime>
425 .Ed
426 .Pp
427 Defaults are:
428 .Bd -literal -offset indent
429 snapshots  1d 60d  # 0d 0d  for PFS /tmp, /var/tmp, /usr/obj
430 prune      1d 5m
431 rebalance  1d 5m
432 reblock    1d 5m
433 recopy     30d 10m
434 .Ed
435 .Pp
436 Time is given with a suffix of
437 .Cm d ,
438 .Cm h ,
439 .Cm m
440 or
441 .Cm s
442 meaning day, hour, minute and second.
443 .Pp
444 If the
445 .Cm snapshots
446 directive has a period of 0 and a retention time of 0
447 then snapshot generation is disabled, removal of old snapshots are
448 disabled, and prunes will use
449 .Cm prune-everything .
450 If the
451 .Cm snapshots
452 directive has a period of 0 but a non-zero retention time
453 then this command will not create any new snapshots but will remove old
454 snapshots it finds based on the retention time.
455 .Pp
456 By default only snapshots in the form
457 .Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
458 are processed.
459 If the
460 .Cm any
461 directive is specified as a third argument on the
462 .Cm snapshots
463 config line then any softlink of the form
464 .Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
465 or
466 .Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
467 will be processed.
468 .Pp
469 A prune max-runtime of 0 means unlimited.
470 .Pp
471 If period hasn't passed since the previous
472 .Cm cleanup
473 run nothing is done.
474 For example a day has passed when midnight is passed (localtime).
475 By default,
476 .Dx
477 is set up to run
478 .Nm Ar cleanup
479 nightly via
480 .Xr periodic 8 .
481 .Pp
482 The default configuration file will create a daily snapshot, do a daily
483 pruning, rebalancing and reblocking run and a monthly recopy run.
484 Reblocking is defragmentation with a level of 95%,
485 and recopy is full defragmentation.
486 .Pp
487 By default prune and rebalance operations are time limited to 5 minutes,
488 reblock operations to a bit over 5 minutes,
489 and recopy operations to a bit over 10 minutes.
490 Reblocking and recopy runs are each broken down into four separate functions:
491 btree, inodes, dirs and data.
492 Each function is time limited to the time given in the configuration file,
493 but the btree, inodes and dirs functions usually does not take very long time,
494 full defragmentation is always used for these three functions.
495 Also note that this directive will by default disable snapshots on
496 the following PFS's:
497 .Pa /tmp ,
498 .Pa /var/tmp
499 and
500 .Pa /usr/obj .
501 .Pp
502 The defaults may be adjusted by modifying the configuration file.
503 The pruning and reblocking commands automatically maintain a cyclefile
504 for incremental operation.
505 If you interrupt (^C) the program the cyclefile will be updated,
506 but a sub-command
507 may continue to run in the background for a few seconds until the
508 .Nm HAMMER
509 ioctl detects the interrupt.
510 The
511 .Cm snapshots
512 PFS option can be set to use another location for the snapshots directory.
513 .Pp
514 Work on this command is still in progress.
515 Expected additions:
516 An ability to remove snapshots dynamically as the
517 file system becomes full.
518 .\" ==== config ====
519 .It Cm config Op Ar filesystem Op Ar configfile
520 .Nm ( HAMMER
521 VERSION 3+)
522 If zero or one arguments are specified this function dumps the current
523 configuration file to stdout.
524 Zero arguments specifies the PFS containing the current directory.
525 This configuration file is stored in file system meta-data.
526 If two arguments are specified this function installs a new config file.
527 .Pp
528 In
529 .Nm HAMMER
530 versions less than 3 the configuration file is by default stored in
531 .Pa <pfs>/snapshots/config ,
532 but in all later versions the configuration file is stored in file system
533 meta-data.
534 .\" ==== viconfig ====
535 .It Cm viconfig Op Ar filesystem
536 .Nm ( HAMMER
537 VERSION 3+)
538 Edit the configuration file and reinstall into file system meta-data when done.
539 Zero arguments specifies the PFS containing the current directory.
540 .\" ==== volume-add ====
541 .It Cm volume-add Ar device Ar filesystem
542 This command will format
543 .Ar device
544 and add all of its space to
545 .Ar filesystem .
546 .Pp
547 .Em NOTE!
548 All existing data contained on
549 .Ar device
550 will be destroyed by this operation!
551 If
552 .Ar device
553 contains a valid
554 .Nm HAMMER
555 file system, formatting will be denied.
556 You can overcome this sanity check
557 by using
558 .Xr dd 1
559 to erase the beginning sectors of the device.
560 Also remember that you have to specify
561 .Ar device ,
562 together with any other device that make up the file system,
563 colon-separated to
564 .Pa /etc/fstab
565 and
566 .Xr mount_hammer 8 .
567 .\" ==== volume-del ====
568 .It Cm volume-del Ar device Ar filesystem
569 This command will remove volume
570 .Ar device
571 from
572 .Ar filesystem .
573 .Pp
574 Remember that you have to remove
575 .Ar device
576 from the colon-separated list in
577 .Pa /etc/fstab
578 and
579 .Xr mount_hammer 8 .
580 .\" ==== snapshot ====
581 .It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
582 .It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
583 Takes a snapshot of the file system either explicitly given by
584 .Ar filesystem
585 or implicitly derived from the
586 .Ar snapshot-dir
587 argument and creates a symlink in the directory provided by
588 .Ar snapshot-dir
589 pointing to the snapshot.
590 If
591 .Ar snapshot-dir
592 is not a directory, it is assumed to be a format string passed to
593 .Xr strftime 3
594 with the current time as parameter.
595 If
596 .Ar snapshot-dir
597 refers to an existing directory, a default format string of
598 .Ql snap-%Y%d%m-%H%M
599 is assumed and used as name for the newly created symlink.
600 .Pp
601 Snapshot is a per PFS operation, so a
602 .Nm HAMMER
603 file system and each PFS in it have to be snapshot separately.
604 .Pp
605 Example, assuming that
606 .Pa /mysnapshots
607 is on file system
608 .Pa /
609 and that
610 .Pa /obj
611 and
612 .Pa /usr
613 are file systems on their own, the following invocations:
614 .Bd -literal -offset indent
615 hammer snapshot /mysnapshots
616
617 hammer snapshot /mysnapshots/%Y-%m-%d
618
619 hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
620
621 hammer snapshot /usr /my/snaps/usr "note"
622 .Ed
623 .Pp
624 Would create symlinks similar to:
625 .Bd -literal -offset indent
626 /mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
627
628 /mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
629
630 /mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
631
632 /my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
633 .Ed
634 .Pp
635 When run on a
636 .Nm HAMMER
637 version 3+ file system the snapshot is also recorded in file system meta-data
638 along with the optional
639 .Ar note .
640 See the
641 .Cm snapls
642 directive.
643 .\" ==== snap* ====
644 .It Cm snap Ar path Op Ar note
645 .Nm ( HAMMER
646 VERSION 3+)
647 Create a snapshot for the PFS containing
648 .Ar path
649 and create a snapshot softlink.
650 If the path specified is a
651 directory a standard snapshot softlink will be created in the directory.
652 The snapshot softlink points to the base of the mounted PFS.
653 .It Cm snaplo Ar path Op Ar note
654 .Nm ( HAMMER
655 VERSION 3+)
656 Create a snapshot for the PFS containing
657 .Ar path
658 and create a snapshot softlink.
659 If the path specified is a
660 directory a standard snapshot softlink will be created in the directory.
661 The snapshot softlink points into the directory it is contained in.
662 .It Cm snapq Ar dir Op Ar note
663 .Nm ( HAMMER
664 VERSION 3+)
665 Create a snapshot for the PFS containing the specified directory but do
666 not create a softlink.
667 Instead output a path which can be used to access
668 the directory via the snapshot.
669 .Pp
670 An absolute or relative path may be specified.
671 The path will be used as-is as a prefix in the path output to stdout.
672 As with the other
673 snap and snapshot directives the snapshot transaction id will be registered
674 in the file system meta-data.
675 .It Cm snaprm Ar path Ar ...
676 .It Cm snaprm Ar transid Ar ...
677 .It Cm snaprm Ar filesystem Ar transid Ar ...
678 .Nm ( HAMMER
679 VERSION 3+)
680 Remove a snapshot given its softlink or transaction id.
681 If specifying a transaction id
682 the snapshot is removed from file system meta-data but you are responsible
683 for removing any related softlinks.
684 .Pp
685 If a softlink path is specified the filesystem and transaction id
686 is derived from the contents of the softlink.
687 If just a transaction id is specified it is assumed to be a snapshot
688 in the HAMMER filesystem you are currently chdir'd into.
689 You can also specify the filesystem and transaction id explicitly.
690 .It Cm snapls Op Ar path ...
691 .Nm ( HAMMER
692 VERSION 3+)
693 Dump the snapshot meta-data for PFSs containing each
694 .Ar path
695 listing all available snapshots and their notes.
696 If no arguments are specified snapshots for the PFS containing the
697 current directory are listed.
698 This is the definitive list of snapshots for the file system.
699 .\" ==== prune ====
700 .It Cm prune Ar softlink-dir
701 Prune the file system based on previously created snapshot softlinks.
702 Pruning is the act of deleting file system history.
703 The
704 .Cm prune
705 command will delete file system history such that
706 the file system state is retained for the given snapshots,
707 and all history after the latest snapshot.
708 By setting the per PFS parameter
709 .Cm prune-min ,
710 history is guaranteed to be saved at least this time interval.
711 All other history is deleted.
712 .Pp
713 The target directory is expected to contain softlinks pointing to
714 snapshots of the file systems you wish to retain.
715 The directory is scanned non-recursively and the mount points and
716 transaction ids stored in the softlinks are extracted and sorted.
717 The file system is then explicitly pruned according to what is found.
718 Cleaning out portions of the file system is as simple as removing a
719 snapshot softlink and then running the
720 .Cm prune
721 command.
722 .Pp
723 As a safety measure pruning only occurs if one or more softlinks are found
724 containing the
725 .Ql @@
726 snapshot id extension.
727 Currently the scanned softlink directory must contain softlinks pointing
728 to a single
729 .Nm HAMMER
730 mount.
731 The softlinks may specify absolute or relative paths.
732 Softlinks must use 20-character
733 .Ql @@0x%016llx
734 transaction ids, as might be returned from
735 .Nm Cm synctid Ar filesystem .
736 .Pp
737 Pruning is a per PFS operation, so a
738 .Nm HAMMER
739 file system and each PFS in it have to be pruned separately.
740 .Pp
741 Note that pruning a file system may not immediately free-up space,
742 though typically some space will be freed if a large number of records are
743 pruned out.
744 The file system must be reblocked to completely recover all available space.
745 .Pp
746 Example, lets say your that you didn't set
747 .Cm prune-min ,
748 and snapshot directory contains the following links:
749 .Bd -literal -offset indent
750 lrwxr-xr-x  1 root  wheel  29 May 31 17:57 snap1 ->
751 /usr/obj/@@0x10d2cd05b7270d16
752
753 lrwxr-xr-x  1 root  wheel  29 May 31 17:58 snap2 ->
754 /usr/obj/@@0x10d2cd13f3fde98f
755
756 lrwxr-xr-x  1 root  wheel  29 May 31 17:59 snap3 ->
757 /usr/obj/@@0x10d2cd222adee364
758 .Ed
759 .Pp
760 If you were to run the
761 .Cm prune
762 command on this directory, then the
763 .Nm HAMMER
764 .Pa /usr/obj
765 mount will be pruned to retain the above three snapshots.
766 In addition, history for modifications made to the file system older than
767 the oldest snapshot will be destroyed and history for potentially fine-grained
768 modifications made to the file system more recently than the most recent
769 snapshot will be retained.
770 .Pp
771 If you then delete the
772 .Pa snap2
773 softlink and rerun the
774 .Cm prune
775 command,
776 history for modifications pertaining to that snapshot would be destroyed.
777 .Pp
778 In
779 .Nm HAMMER
780 file system versions 3+ this command also scans the snapshots stored
781 in the file system meta-data and includes them in the prune.
782 .\" ==== prune-everything ====
783 .It Cm prune-everything Ar filesystem
784 This command will remove all historical records from the file system.
785 This directive is not normally used on a production system.
786 .Pp
787 This command does not remove snapshot softlinks but will delete all
788 snapshots recorded in file system meta-data (for file system version 3+).
789 The user is responsible for deleting any softlinks.
790 .\" ==== rebalance ====
791 .It Cm rebalance Ar filesystem Op Ar saturation_percentage
792 This command will rebalance the B-tree, nodes with small number of
793 elements will be combined and element counts will be smoothed out
794 between nodes.
795 .Pp
796 The saturation percentage is between 50% and 100%.
797 The default is 75% (the
798 .Sq %
799 suffix is not needed).
800 .\" ==== reblock* ====
801 .It Cm reblock Ar filesystem Op Ar fill_percentage
802 .It Cm reblock-btree Ar filesystem Op Ar fill_percentage
803 .It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
804 .It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
805 .It Cm reblock-data Ar filesystem Op Ar fill_percentage
806 Attempt to defragment and free space for reuse by reblocking a live
807 .Nm HAMMER
808 file system.
809 Big-blocks cannot be reused by
810 .Nm HAMMER
811 until they are completely free.
812 This command also has the effect of reordering all elements, effectively
813 defragmenting the file system.
814 .Pp
815 The default fill percentage is 100% and will cause the file system to be
816 completely defragmented.
817 All specified element types will be reallocated and rewritten.
818 If you wish to quickly free up space instead try specifying
819 a smaller fill percentage, such as 90% or 80% (the
820 .Sq %
821 suffix is not needed).
822 .Pp
823 Since this command may rewrite the entire contents of the disk it is
824 best to do it incrementally from a
825 .Xr cron 8
826 job along with the
827 .Fl c Ar cyclefile
828 and
829 .Fl t Ar seconds
830 options to limit the run time.
831 The file system would thus be defragmented over long period of time.
832 .Pp
833 It is recommended that separate invocations be used for each data type.
834 B-tree nodes, inodes, and directories are typically the most important
835 elements needing defragmentation.
836 Data can be defragmented over a longer period of time.
837 .Pp
838 Reblocking is a per PFS operation, so a
839 .Nm HAMMER
840 file system and each PFS in it have to be reblocked separately.
841 .\" ==== pfs-status ====
842 .It Cm pfs-status Ar dirpath ...
843 Retrieve the mirroring configuration parameters for the specified
844 .Nm HAMMER
845 file systems or pseudo-filesystems (PFS's).
846 .\" ==== pfs-master ====
847 .It Cm pfs-master Ar dirpath Op Ar options
848 Create a pseudo-filesystem (PFS) inside a
849 .Nm HAMMER
850 file system.
851 Up to 65535 such file systems can be created.
852 Each PFS uses an independent inode numbering space making it suitable
853 for use as a replication source or target.
854 .Pp
855 The
856 .Cm pfs-master
857 directive creates a PFS that you can read, write, and use as a mirroring
858 source.
859 .Pp
860 It is recommended to use a
861 .Nm null
862 mount to access a PFS, for more information see
863 .Xr HAMMER 5 .
864 .\" ==== pfs-slave ====
865 .It Cm pfs-slave Ar dirpath Op Ar options
866 Create a pseudo-filesystem (PFS) inside a
867 .Nm HAMMER
868 file system.
869 Up to 65535 such file systems can be created.
870 Each PFS uses an independent inode numbering space making it suitable
871 for use as a replication source or target.
872 .Pp
873 The
874 .Cm pfs-slave
875 directive creates a PFS that you can use as a mirroring target.
876 You will not be able to access a slave PFS until you have completed the
877 first mirroring operation with it as the target (its root directory will
878 not exist until then).
879 .Pp
880 Access to the pfs-slave via the special softlink, as described in the
881 .Sx PFS NOTES
882 below, allows
883 .Nm HAMMER
884 to
885 dynamically modify the snapshot transaction id by returning a dynamic result
886 from
887 .Xr readlink 2
888 calls.
889 .Pp
890 A PFS can only be truly destroyed with the
891 .Cm pfs-destroy
892 directive.
893 Removing the softlink will not destroy the underlying PFS.
894 .Pp
895 It is recommended to use a
896 .Nm null
897 mount to access a PFS, for more information see
898 .Xr HAMMER 5 .
899 .\" ==== pfs-update ====
900 .It Cm pfs-update Ar dirpath Op Ar options
901 Update the configuration parameters for an existing
902 .Nm HAMMER
903 file system or pseudo-filesystem.
904 Options that may be specified:
905 .Bl -tag -width indent
906 .It Cm sync-beg-tid= Ns Ar 0x16llx
907 This is the automatic snapshot access starting transaction id for
908 mirroring slaves.
909 This parameter is normally updated automatically by the
910 .Cm mirror-write
911 directive.
912 .Pp
913 It is important to note that accessing a mirroring slave
914 with a transaction id greater than the last fully synchronized transaction
915 id can result in an unreliable snapshot since you will be accessing
916 data that is still undergoing synchronization.
917 .Pp
918 Manually modifying this field is dangerous and can result in a broken mirror.
919 .It Cm sync-end-tid= Ns Ar 0x16llx
920 This is the current synchronization point for mirroring slaves.
921 This parameter is normally updated automatically by the
922 .Cm mirror-write
923 directive.
924 .Pp
925 Manually modifying this field is dangerous and can result in a broken mirror.
926 .It Cm shared-uuid= Ns Ar uuid
927 Set the shared UUID for this file system.
928 All mirrors must have the same shared UUID.
929 For safety purposes the
930 .Cm mirror-write
931 directives will refuse to operate on a target with a different shared UUID.
932 .Pp
933 Changing the shared UUID on an existing, non-empty mirroring target,
934 including an empty but not completely pruned target,
935 can lead to corruption of the mirroring target.
936 .It Cm unique-uuid= Ns Ar uuid
937 Set the unique UUID for this file system.
938 This UUID should not be used anywhere else,
939 even on exact copies of the file system.
940 .It Cm label= Ns Ar string
941 Set a descriptive label for this file system.
942 .It Cm snapshots= Ns Ar string
943 Specify the snapshots directory which
944 .Nm
945 .Cm cleanup
946 will use to manage this PFS.
947 .Bl -tag -width indent
948 .It Nm HAMMER No version 2-
949 The snapshots directory does not need to be configured for
950 PFS masters and will default to
951 .Pa <pfs>/snapshots .
952 .Pp
953 PFS slaves are mirroring slaves so you cannot configure a snapshots
954 directory on the slave itself to be managed by the slave's machine.
955 In fact, the slave will likely have a
956 .Pa snapshots
957 sub-directory mirrored
958 from the master, but that directory contains the configuration the master
959 is using for its copy of the file system, not the configuration that we
960 want to use for our slave.
961 .Pp
962 It is recommended that
963 .Pa <fs>/var/slaves/<name>
964 be configured for a PFS slave, where
965 .Pa <fs>
966 is the base
967 .Nm HAMMER
968 file system, and
969 .Pa <name>
970 is an appropriate label.
971 .It Nm HAMMER No version 3+
972 The snapshots directory does not need to be configured for PFS masters or
973 slaves.
974 The snapshots directory defaults to
975 .Pa /var/hammer/<pfs>
976 .Pa ( /var/hammer/root
977 for root mount).
978 .El
979 .Pp
980 You can control snapshot retention on your slave independent of the master.
981 .It Cm snapshots-clear
982 Zero out the
983 .Cm snapshots
984 directory path for this PFS.
985 .It Cm prune-min= Ns Ar N Ns Cm d
986 .It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \
987 Ar hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss
988 Set the minimum fine-grained data retention period.
989 .Nm HAMMER
990 always retains fine-grained history up to the most recent snapshot.
991 You can extend the retention period further by specifying a non-zero
992 pruning minimum.
993 Any snapshot softlinks within the retention period are ignored
994 for the purposes of pruning (the fine grained history is retained).
995 Number of days, hours, minutes and seconds are given as
996 .Ar N , hh , mm
997 and
998 .Ar ss .
999 .Pp
1000 Because the transaction id in the snapshot softlink cannot be used
1001 to calculate a timestamp,
1002 .Nm HAMMER
1003 uses the earlier of the
1004 .Fa st_ctime
1005 or
1006 .Fa st_mtime
1007 field of the softlink to
1008 determine which snapshots fall within the retention period.
1009 Users must be sure to retain one of these two fields when manipulating
1010 the softlink.
1011 .El
1012 .\" ==== pfs-upgrade ====
1013 .It Cm pfs-upgrade Ar dirpath
1014 Upgrade a PFS from slave to master operation.
1015 The PFS will be rolled back to the current end synchronization transaction id
1016 (removing any partial synchronizations), and will then become writable.
1017 .Pp
1018 .Em WARNING!
1019 .Nm HAMMER
1020 currently supports only single masters and using
1021 this command can easily result in file system corruption
1022 if you don't know what you are doing.
1023 .Pp
1024 This directive will refuse to run if any programs have open descriptors
1025 in the PFS, including programs chdir'd into the PFS.
1026 .\" ==== pfs-downgrade ====
1027 .It Cm pfs-downgrade Ar dirpath
1028 Downgrade a master PFS from master to slave operation
1029 The PFS becomes read-only and access will be locked to its
1030 .Cm sync-end-tid .
1031 .Pp
1032 This directive will refuse to run if any programs have open descriptors
1033 in the PFS, including programs chdir'd into the PFS.
1034 .\" ==== pfs-destroy ====
1035 .It Cm pfs-destroy Ar dirpath
1036 This permanently destroys a PFS.
1037 .Pp
1038 This directive will refuse to run if any programs have open descriptors
1039 in the PFS, including programs chdir'd into the PFS.
1040 .\" ==== mirror-read ====
1041 .It Cm mirror-read Ar filesystem Op Ar begin-tid
1042 Generate a mirroring stream to stdout.
1043 The stream ends when the transaction id space has been exhausted.
1044 .\" ==== mirror-read-stream ====
1045 .It Cm mirror-read-stream Ar filesystem Op Ar begin-tid
1046 Generate a mirroring stream to stdout.
1047 Upon completion the stream is paused until new data is synced to the
1048 master, then resumed.
1049 Operation continues until the pipe is broken.
1050 .\" ==== mirror-write ====
1051 .It Cm mirror-write Ar filesystem
1052 Take a mirroring stream on stdin.
1053 .Pp
1054 This command will fail if the
1055 .Cm shared-uuid
1056 configuration field for the two file systems do not match.
1057 .Pp
1058 If the target PFS does not exist this command will ask you whether
1059 you want to create a compatible PFS slave for the target or not.
1060 .\" ==== mirror-dump ====
1061 .It Cm mirror-dump
1062 A
1063 .Cm mirror-read
1064 can be piped into a
1065 .Cm mirror-dump
1066 to dump an ASCII representation of the mirroring stream.
1067 .\" ==== mirror-copy ====
1068 .\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem
1069 .It Cm mirror-copy \
1070 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1071 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1072 This is a shortcut which pipes a
1073 .Cm mirror-read
1074 command to a
1075 .Cm mirror-write
1076 command.
1077 If a remote host specification is made the program forks a
1078 .Xr ssh 1
1079 and execs the
1080 .Cm mirror-read
1081 and/or
1082 .Cm mirror-write
1083 on the appropriate host.
1084 The source may be a master or slave PFS, and the target must be a slave PFS.
1085 .Pp
1086 This command also established full duplex communication and turns on
1087 the two-way protocol feature which automatically negotiates transaction id
1088 ranges without having to use a cyclefile.
1089 If the operation completes successfully the target PFS's
1090 .Cm sync-end-tid
1091 will be updated.
1092 Note that you must re-chdir into the target PFS to see the updated information.
1093 If you do not you will still be in the previous snapshot.
1094 .Pp
1095 If the target PFS does not exist this command will ask you whether
1096 you want to create a compatible PFS slave for the target or not.
1097 .\" ==== mirror-stream ====
1098 .\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem
1099 .It Cm mirror-stream \
1100 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1101 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1102 This command works similarly to
1103 .Cm mirror-copy
1104 but does not exit after the initial mirroring completes.
1105 The mirroring operation will resume as changes continue to be made to the
1106 master.
1107 The command is commonly used with
1108 .Fl i Ar delay
1109 and
1110 .Fl b Ar bandwidth
1111 options to keep the mirroring target in sync with the source on a continuing
1112 basis.
1113 .Pp
1114 If the pipe is broken the command will automatically retry after sleeping
1115 for a short while.
1116 The time slept will be 15 seconds plus the time given in the
1117 .Fl i
1118 option.
1119 .Pp
1120 This command also detects the initial-mirroring case and spends some
1121 time scanning the B-Tree to find good break points, allowing the initial
1122 bulk mirroring operation to be broken down into about 20 separate pieces.
1123 This means that the user can kill and restart the operation and it will
1124 not have to start from scratch once it has gotten past the first chunk.
1125 The
1126 .Fl B
1127 option may be used to disable this feature and perform an initial bulk
1128 transfer instead.
1129 .\" ==== version ====
1130 .It Cm version Ar filesystem
1131 This command returns the
1132 .Nm HAMMER
1133 file system version for the specified
1134 .Ar filesystem
1135 as well as the range of versions supported in the kernel.
1136 The
1137 .Fl q
1138 option may be used to remove the summary at the end.
1139 .\" ==== version-upgrade ====
1140 .It Cm version-upgrade Ar filesystem Ar version Op Cm force
1141 This command upgrades the
1142 .Nm HAMMER
1143 .Ar filesystem
1144 to the specified
1145 .Ar version .
1146 Once upgraded a file system may not be downgraded.
1147 If you wish to upgrade a file system to a version greater or equal to the
1148 work-in-progress version number you must specify the
1149 .Cm force
1150 directive.
1151 Use of WIP versions should be relegated to testing and may require wiping
1152 the file system as development progresses, even though the WIP version might
1153 not change.
1154 .Pp
1155 .Em NOTE!
1156 This command operates on the entire
1157 .Nm HAMMER
1158 file system and is not a per PFS operation.
1159 All PFS's will be affected.
1160 .Bl -tag -width indent
1161 .It 1
1162 .Dx 2.0
1163 default version, first
1164 .Nm HAMMER
1165 release.
1166 .It 2
1167 .Dx 2.3 .
1168 New directory entry layout.
1169 This version is using a new directory hash key.
1170 .It 3
1171 .Dx 2.5 .
1172 New snapshot management, using file system meta-data for saving
1173 configuration file and snapshots (transaction ids etc.).
1174 Also default snapshots directory has changed.
1175 .It 4
1176 .Dx 2.5
1177 default version.
1178 New undo/flush, giving faster sync.
1179 .El
1180 .El
1181 .\".Sh EXAMPLES
1182 .Sh ENVIRONMENT
1183 If the following environment variables exist, they will be used by
1184 .Nm :
1185 .Bl -tag -width ".Ev EDITOR"
1186 .It Ev EDITOR
1187 The editor program specified in the variable
1188 .Ev EDITOR
1189 will be invoked instead of the default editor, which is
1190 .Xr vi 1
1191 .It Ev VISUAL
1192 Same effect as
1193 .Ev EDITOR
1194 variable.
1195 .El
1196 .Sh PSEUDO-FILESYSTEM (PFS) NOTES
1197 The root of a PFS is not hooked into the primary
1198 .Nm HAMMER
1199 file system as a directory.
1200 Instead,
1201 .Nm HAMMER
1202 creates a special softlink called
1203 .Ql @@PFS%05d
1204 (exactly 10 characters long) in the primary
1205 .Nm HAMMER
1206 file system.
1207 .Nm HAMMER
1208 then modifies the contents of the softlink as read by
1209 .Xr readlink 2 ,
1210 and thus what you see with an
1211 .Nm ls
1212 command or if you were to
1213 .Nm cd
1214 into the link.
1215 If the PFS is a master the link reflects the current state of the PFS.
1216 If the PFS is a slave the link reflects the last completed snapshot, and the
1217 contents of the link will change when the next snapshot is completed, and
1218 so forth.
1219 .Pp
1220 The
1221 .Nm
1222 utility employs numerous safeties to reduce user foot-shooting.
1223 The
1224 .Cm mirror-copy
1225 directive requires that the target be configured as a slave and that the
1226 .Cm shared-uuid
1227 field of the mirroring source and target match.
1228 .Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2
1229 This upgrade changes the way directory entries are stored.
1230 It is possible to upgrade a V1 file system to V2 in place, but
1231 directories created prior to the upgrade will continue to use
1232 the old layout.
1233 .Pp
1234 Note that the slave mirroring code in the target kernel had bugs in
1235 V1 which can create an incompatible root directory on the slave.
1236 Do not mix a
1237 .Nm HAMMER
1238 master created after the upgrade with a
1239 .Nm HAMMER
1240 slave created prior to the upgrade.
1241 .Pp
1242 Any directories created after upgrading will use a new layout.
1243 .Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3
1244 This upgrade adds meta-data elements to the B-Tree.
1245 It is possible to upgrade a V2 file system to V3 in place.
1246 After issuing the upgrade be sure to run a
1247 .Nm
1248 .Cm cleanup
1249 to perform post-upgrade tasks.
1250 .Pp
1251 After making this upgrade running a
1252 .Nm
1253 .Cm cleanup
1254 will move the
1255 .Pa <pfs>/snapshots
1256 directory for each PFS mount into
1257 .Pa /var/hammer/<pfs> .
1258 A
1259 .Nm HAMMER
1260 root mount will migrate
1261 .Pa /snapshots
1262 into
1263 .Pa /var/hammer/root .
1264 Migration occurs only once and only if you have not specified
1265 a snapshots directory in the PFS configuration.
1266 If you have specified a snapshots directory in the PFS configuration no
1267 automatic migration will occur.
1268 .Pp
1269 For slaves, if you desire, you can migrate your snapshots
1270 config to the new location manually and then clear the
1271 snapshot directory configuration in the slave PFS.
1272 The new snapshots hierarchy is designed to work with
1273 both master and slave PFSs equally well.
1274 .Pp
1275 In addition, the old config file will be moved to file system meta-data,
1276 editable via the new
1277 .Nm
1278 .Cm viconfig
1279 directive.
1280 The old config file will be deleted.
1281 Migration occurs only once.
1282 .Pp
1283 The V3 file system has new
1284 .Cm snap*
1285 directives for creating snapshots.
1286 All snapshot directives, including the original, will create
1287 meta-data entries for the snapshots and the pruning code will
1288 automatically incorporate these entries into its list and
1289 expire them the same way it expires softlinks.
1290 If you by accident blow away your snapshot softlinks you can use the
1291 .Cm snapls
1292 directive to get a definitive list from the file system meta-data and
1293 regenerate them from that list.
1294 .Pp
1295 .Em WARNING!
1296 If you are using
1297 .Nm
1298 to backup file systems your scripts may be using the
1299 .Cm synctid
1300 directive to generate transaction ids.
1301 This directive does not create a snapshot.
1302 You will have to modify your scripts to use the
1303 .Cm snapq
1304 directive to generate the linkbuf for the softlink you create, or
1305 use one of the other
1306 .Cm snap*
1307 directives.
1308 The older
1309 .Cm snapshot
1310 directive will continue to work as expected and in V3 it will also
1311 record the snapshot transaction id in file system meta-data.
1312 You may also want to make use of the new
1313 .Ar note
1314 tag for the meta-data.
1315 .Pp
1316 .Em WARNING!
1317 If you used to remove snapshot softlinks with
1318 .Nm rm
1319 you should probably start using the
1320 .Cm snaprm
1321 directive instead to also remove the related meta-data.
1322 The pruning code scans the meta-data so just removing the
1323 softlink is not sufficient.
1324 .Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4
1325 This upgrade changes undo/flush, giving faster sync.
1326 It is possible to upgrade a V3 file system to V4 in place.
1327 This upgrade reformats the UNDO FIFO (typically 1GB), so upgrade might take
1328 a minute or two depending.
1329 .Pp
1330 Version 4 allows the UNDO FIFO to be flushed without also having
1331 to flush the volume header, removing 2 of the 4 disk syncs typically
1332 required for an fsync() and removing 1 of the 2 disk syncs typically
1333 required for a flush sequence.
1334 .Sh FSYNC FLUSH MODES
1335 Hammer implements five different fsync flush modes via the
1336 .Li vfs.hammer.fsync_mode
1337 sysctl.
1338 .Pp
1339 .Bl -tag -width indent
1340 .It mode 0
1341 Full synchronous fsync semantics without REDO.
1342 .Pp
1343 Hammer will not generate REDOs.  A fsync() will completely sync
1344 the data and meta-data and double-flush the FIFO, including
1345 issuing two disk synchronization commands.  The data is guaranteed
1346 to be on the media as of when fsync() returns.
1347 Needless to say, this is slow.
1348 .Pp
1349 Even though all modes are available in that release the REDO
1350 semantics are not well tested yet and not enabled by default.
1351 .It mode 1
1352 Relaxed asynchronous fsync semantics without REDO.
1353 .Pp
1354 This mode works the same as mode 0 except the last disk synchronization
1355 command is not issued.  It is faster than mode 0 but not even remotely
1356 close to the speed you get with mode 2 or mode 3.
1357 .Pp
1358 Note that there is no chance of meta-data corruption when using this
1359 mode, it simply means that the data you wrote and then fsync()'d might
1360 not have made it to the media if the storage system crashes at a bad
1361 time.
1362 .Pp
1363 .It mode 2
1364 Full synchronous fsync semantics using REDO.
1365 .Pp
1366 Hammer will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1367 If this is sufficient to satisfy the fsync() operation the blocks
1368 will be written out and hammer will wait for the I/Os to complete,
1369 and then followup with a disk sync command to guarantee the data
1370 is on the media before returning.
1371 This is slower than mode 3 and can result in significant disk or
1372 SSDs overheads, though not as bad as mode 0 or mode 1.
1373 .Pp
1374 .It mode 3
1375 Relaxed asynchronous fsync semantics using REDO.
1376 .Pp
1377 Hammer will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1378 If this is sufficient to satisfy the fsync() operation the blocks
1379 will be written out and hammer will wait for the I/Os to complete,
1380 but will
1381 .Em NOT
1382 issue a disk synchronization command.
1383 .Pp
1384 Note that there is no chance of meta-data corruption when using this
1385 mode, it simply means that the data you wrote and then fsync()'d might
1386 not have made it to the media if the storage system crashes at a bad
1387 time.
1388 .Pp
1389 This mode is the fastest production fsyncing mode available.
1390 This mode is equivalent to how the UFS fsync in the BSDs operates.
1391 .Pp
1392 .It mode 4
1393 fsync is ignored.
1394 .Pp
1395 Calls to fsync() will be ignored.  This mode is primarily designed
1396 for testing and should not be used on a production system.
1397 .El
1398 .Sh EXIT STATUS
1399 .Ex -std
1400 .Sh FILES
1401 .Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
1402 .It Pa <pfs>/snapshots
1403 default per PFS snapshots directory
1404 .Nm ( HAMMER
1405 VERSION 2-)
1406 .It Pa /var/hammer/<pfs>
1407 default per PFS snapshots directory (not root)
1408 .Nm ( HAMMER
1409 VERSION 3+)
1410 .It Pa /var/hammer/root
1411 default snapshots directory for root directory
1412 .Nm ( HAMMER
1413 VERSION 3+)
1414 .It Pa <snapshots>/config
1415 per PFS
1416 .Nm
1417 .Cm cleanup
1418 configuration file
1419 .Nm ( HAMMER
1420 VERSION 2-)
1421 .It Pa <fs>/var/slaves/<name>
1422 recommended slave PFS snapshots directory
1423 .Nm ( HAMMER
1424 VERSION 2-)
1425 .El
1426 .Sh SEE ALSO
1427 .Xr ssh 1 ,
1428 .Xr undo 1 ,
1429 .Xr HAMMER 5 ,
1430 .Xr periodic.conf 5 ,
1431 .Xr mount_hammer 8 ,
1432 .Xr mount_null 8 ,
1433 .Xr newfs_hammer 8
1434 .Sh HISTORY
1435 The
1436 .Nm
1437 utility first appeared in
1438 .Dx 1.11 .
1439 .Sh AUTHORS
1440 .An Matthew Dillon Aq dillon@backplane.com