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