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