HAMMER Util - Add new features, fix history retention bug in prune
[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 October 22, 2008
36 .Dt HAMMER 8
37 .Os
38 .Sh NAME
39 .Nm hammer
40 .Nd HAMMER file system utility
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl h2qrv
44 .Op Fl b Ar bandwidth
45 .Op Fl c Ar cyclefile
46 .Op Fl f Ar blkdev[:blkdev]*
47 .\" .Op Fl s Ar linkpath
48 .Op Fl i Ar delay
49 .Op Fl t Ar seconds
50 .Op Fl C Ar cachesize[:readahead]
51 .Ar command
52 .Op Ar argument ...
53 .Sh DESCRIPTION
54 This manual page documents the
55 .Nm
56 utility which provides miscellaneous functions related to managing a
57 .Nm HAMMER
58 file system.
59 For a general introduction to the
60 .Nm HAMMER
61 file system, its features, and
62 examples on how to set up and maintain one, see
63 .Xr HAMMER 5 .
64 .Pp
65 The options are as follows:
66 .Bl -tag -width indent
67 .It Fl h
68 Get help.
69 .It Fl 2
70 Tell the mirror commands to use a 2-way protocol, which allows
71 automatic negotiation of transaction id ranges.
72 This option is automatically enabled by the
73 .Ar mirror-copy
74 command.
75 .It Fl b Ar bandwidth
76 Specify a bandwidth limit in bytes per second for mirroring streams.
77 This option is typically used to prevent batch mirroring operations from
78 loading down the machine.
79 The bandwidth may be suffixed with
80 .Sq k ,
81 .Sq m ,
82 or
83 .Sq g
84 to specify values in kilobytes, megabytes, and gigabytes per second.
85 If no suffix is specified, bytes per second is assumed.
86 .It Fl c Ar cyclefile
87 When pruning and reblocking you can instruction
88 .Nm
89 to start at the object id stored in the specified file.
90 If the file does not exist
91 .Nm
92 will start at the beginning.
93 If
94 .Nm
95 is told to run for a
96 specific period of time and is unable to complete the operation it will
97 write out the current object id so the next run can pick up where it left off.
98 If
99 .Nm
100 runs to completion it will delete
101 .Ar cyclefile .
102 .It Fl f Ar blkdev[:blkdev]*
103 Specify the volumes making up a
104 .Nm HAMMER
105 file system.
106 .It Fl i Ar delay
107 When maintaining a streaming mirroring this option specifies the
108 minimum delay after a batch ends before the next batch is allowed
109 to start.
110 The default is five seconds.
111 .It Fl q
112 Decrease verboseness.
113 May be specified multiple times.
114 .It Fl r
115 Specify recursion for those commands which support it.
116 .It Fl t Ar seconds
117 When pruning and reblocking you can tell the utility to stop after a
118 certain period of time.
119 This option is used along with the
120 .Fl c Ar cyclefile
121 option to prune or reblock a portion of the file system incrementally.
122 .It Fl v
123 Increase verboseness.
124 May be specified multiple times.
125 .It Fl y
126 Force "yes" for any interactive question.
127 .It Fl C Ar cachesize[:readahead]
128 Set the memory cache size for any raw I/O.  The default is 16m.
129 A suffix of 'k' for kilobytes and 'm' for megabytes is allowed,
130 else the cache size is specified in bytes.
131 .Pp
132 The read-behind/read-ahead defaults to 4 hammer blocks.
133 .Pp
134 This option is typically only used with diagnostic commands
135 as kernel-supported commands will use the kernel's buffer cache.
136 .El
137 .Pp
138 The commands are as follows:
139 .Bl -tag -width indent
140 .\" ==== synctid ====
141 .It Ar synctid Ar filesystem Op quick
142 Generates a guaranteed, formal 64 bit transaction id representing the
143 current state of the specified
144 .Nm HAMMER
145 file system.
146 The file system will be synced to the media.
147 .Pp
148 If the
149 .Ar quick
150 keyword is specified the file system will be soft-synced, meaning that a
151 crash might still undo the state of the file system as of the transaction
152 id returned but any new modifications will occur after the returned
153 transaction id as expected.
154 .\" ==== bstats ====
155 .It Ar bstats Op interval
156 Output
157 .Nm HAMMER
158 B-tree statistics until interrupted.
159 Pause
160 .Ar interval
161 seconds between each display.
162 The default interval is one second.
163 .\" ==== iostats ====
164 .It Ar iostats Op interval
165 Output
166 .Nm HAMMER
167 I/O statistics until interrupted.
168 Pause
169 .Ar interval
170 seconds between each display.
171 The default interval is one second.
172 .\" ==== history ====
173 .It Ar history Ar path ...
174 Show the modification history for
175 .Nm HAMMER
176 file's inode and data.
177 .\" ==== blockmap ====
178 .It Ar blockmap
179 Dump the blockmap for the filesystem.  The HAMMER blockmap is two-layer
180 blockmap representing the maximum possible filesystem size of 1 Exabyte.
181 Needless to say the second layer is only present for blocks which exist.
182 HAMMER's blockmap represents 8-Megabyte blocks.  Each block has an append
183 point, a free byte count, and a typed zone id which allows content to be
184 reverse engineered to some degree.
185 .Pp
186 In HAMMER allocations essentially appended to a selected big-block using
187 the append offset and deducted from the free byte count.  When space is
188 freed the free byte count is adjusted but HAMMER does not track holes in
189 big-blocks for reallocation.  A big-block must be completely freed, either
190 through normal filesystem operations or through reblocking, before
191 it can be reused.
192 .Pp
193 Data blocks can be shared by deducting the space used from the free byte
194 count for each shared references, though HAMMER does not yet make use of
195 this feature.  This means the free byte count can legally go negative.
196 .Pp
197 This command needs the
198 .Fl f
199 flag.
200 .\" ==== show ====
201 .It Ar show Op Ar lo:objid
202 Dump the B-tree.  By default this command will validate all B-Tree
203 linkages and CRCs, including data CRCs, and will report the most verbose
204 information it can dig up.
205 Any errors will show up with a 'B' in column 1 along with various
206 other error flags.
207 .Pp
208 If you specify a localization and object id field the dump will
209 search for the key printing nodes as it recurses down, and then
210 will iterate forwards.
211 .Pp
212 If you use
213 .Fl q
214 the command will report less information about the inode contents.
215 .Pp
216 If you use
217 .Fl qq
218 the command will not report the content of the inode or other typed
219 data at all.
220 .Pp
221 If you use
222 .Fl qqq
223 the command will not report volume header information, big-block fill
224 ratios, mirror TIDs, or report or check data CRCs.  B-Tree CRCs and
225 linkages are still checked.
226 .Pp
227 This command needs the
228 .Fl f
229 flag.
230 .\" .It Ar blockmap
231 .\" Dump the B-tree, record, large-data, and small-data blockmaps, showing
232 .\" physical block assignments and free space percentages.
233 .\" ==== namekey1 ====
234 .It Ar namekey1 Ar filename
235 Generate a
236 .Nm HAMMER
237 64 bit directory hash for the specified file name, using
238 the original directory hash algorithm in version 1 of the filesystem.
239 The low 32 bits are used as an iterator for hash collisions and will be
240 output as 0.
241 .\" ==== namekey2 ====
242 .It Ar namekey2 Ar filename
243 Generate a
244 .Nm HAMMER
245 64 bit directory hash for the specified file name, using
246 the new directory hash algorithm in version 2 of the filesystem.
247 The low 32 bits are still used as an iterator but will start out containing
248 part of the hash key.
249 .\" ==== namekey32 ====
250 .It Ar namekey32 Ar filename
251 Generate the top 32 bits of a
252 .Nm HAMMER
253 64 bit directory hash for the specified file name.
254 .\" ==== info ====
255 .It Ar info
256 Shows extended information about all the mounted HAMMER filesystems.
257 At the moment volume identification, big blocks information and space details are shown.
258 .\" ==== cleanup ====
259 .It Ar cleanup Op Ar filesystem ...
260 This is a meta-command which executes snapshot, pruning, and reblocking
261 commands on the specified
262 .Nm HAMMER
263 file system.
264 If no
265 .Ar filesystem
266 is specified this command will clean-up all
267 .Nm HAMMER
268 file systems in use, including PFS's.
269 To do this it will scan all
270 .Nm HAMMER
271 and
272 .Nm null
273 mounts, extract PFS id's, and clean-up each PFS found.
274 .Pp
275 This command will by default access a
276 .Pa snapshots
277 subdirectory and a
278 .Pa snapshots/config
279 file for each
280 .Ar filesystem ,
281 creating them if necessary.
282 The format of the configuration file is:
283 .Bd -literal -offset indent
284 snapshots  <period> <retention-time> [any]
285 prune      <period> <max-runtime>
286 .\"rebalance  <period> <max-runtime>
287 reblock    <period> <1/3 max-runtime>
288 recopy     <period> <1/3 max-runtime>
289
290 Defaults are:
291 snapshots  1d 60d  # 0d 60d  for PFS /tmp, /var/tmp, /usr/obj
292 prune      1d 5m
293 .\"rebalance  1d 5m
294 reblock    1d 5m
295 recopy     30d 10m
296 .Ed
297 .Pp
298 Time is given with a suffix of
299 .Cm d ,
300 .Cm h ,
301 .Cm m
302 or
303 .Cm s
304 meaning day, hour, minute and second.
305 .Pp
306 If the snapshots directive has a period of 0 and a retention time of 0
307 then snapshot generation is disabled, removal of old snapshots are
308 disabled, and prunes will use
309 .Ar prune-everything .
310 If the snapshots directive has a period of 0 but a non-zero retention time
311 then this command will not create any new snapshots but will remove old
312 snapshots it finds based on the retention time.
313 .Pp
314 By default only snapshots in the form:  snap-yyyymmdd[-hhmm] are processed.
315 If the
316 .Ar any
317 directive is specified as a third argument on the snapshots config line
318 then any softlink of the form *[- or .]yyyymmdd[-hhmm] will be processed.
319 .Pp
320 A prune max-runtime of 0 means unlimited.
321 .Pp
322 If period hasn't passed since the previous
323 .Ar cleanup
324 run nothing is done.
325 For example a day has passed when midnight is passed (localtime).
326 By default,
327 .Dx
328 is set up to run
329 .Nm Ar cleanup
330 nightly via
331 .Xr periodic 8 .
332 .Pp
333 The default configuration file will create a daily snapshot, do a daily
334 pruning and reblocking run and a monthly recopy run.
335 Reblocking is defragmentation with a level of 95%,
336 and recopy is full defragmentation.
337 .Pp
338 By default prune and reblock operations are limited to 5 minutes per function,
339 and recopy operations are limited to 10 minutes per function.
340 Reblocking and recopy runs are each broken down into three separate functions
341 (btree, inodes and data)
342 and are thus by default limited to 15 and 30 minutes respectively.
343 Also note that this directive will by default disable snapshots on
344 the following PFS's:
345 .Pa /tmp ,
346 .Pa /var/tmp
347 and
348 .Pa /usr/obj .
349 .Pp
350 The defaults may be adjusted by modifying the
351 .Pa config
352 file.
353 The pruning and reblocking commands automatically maintain a cyclefile
354 for incremental operation.
355 If you interrupt (^C) the program the cyclefile will be updated, but a sub-command
356 may continue to run in the background for a few seconds until the
357 .Nm HAMMER
358 ioctl detects the interrupt.
359 The
360 .Ar snapshots
361 PFS option can be set to use another location for the snapshots directory.
362 .Pp
363 Work on this command is still in progress.
364 Expected additions:  An ability to remove snapshots dynamically as the
365 file system becomes full.
366 .\" ==== expand ====
367 .It Ar expand Ar filesystem Ar device
368 This command will format
369 .Ar device
370 and add all of its space to
371 .Ar filesystem .
372 .Pp
373 NOTE! All existing data contained on
374 .Ar device
375 will be destroyed by this operation! If
376 .Ar device
377 contains a valid
378 .Nm HAMMER
379 filesystem, formatting will be denied. You can overcome this sanity check
380 by using
381 .Xr dd 1
382 to erase the beginning sectors of the device.
383 Also remember that you have to specify
384 .Ar device ,
385 together with any other device that make the filesystem, colon-separated to
386 .Xr mount_hammer 8 .
387 .\" ==== snapshot ====
388 .It Ar snapshot Oo Ar filesystem Oc Ar snapshot-dir
389 Takes a snapshot of the file system either explicitly given by
390 .Ar filesystem
391 or implicitly derived from the
392 .Ar snapshot-dir
393 argument and creates a symlink in the directory provided by
394 .Ar snapshot-dir
395 pointing to the snapshot.
396 If
397 .Ar snapshot-dir
398 is not a directory, it is assumed to be a format string passed to
399 .Xr strftime 3
400 with the current time as parameter.
401 If
402 .Ar snapshot-dir
403 refers to an existing directory, a default format string of "snap-%Y%d%m-%H%M"
404 is assumed and used as name for the newly created symlink.
405 .Pp
406 Snapshot is a per PFS operation, so a
407 .Nm HAMMER
408 file system and each PFS in it have to be snapshot separately.
409 .Pp
410 Example, assuming that
411 .Pa /mysnapshots
412 is on file system
413 .Pa /
414 and that
415 .Pa /obj
416 is a file system on its own, the following invocations:
417 .Bd -literal -offset indent
418 hammer snapshot /mysnapshots
419
420 hammer snapshot /mysnapshots/%Y-%m-%d
421
422 hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
423 .Ed
424 .Pp
425 would create symlinks similar to:
426 .Bd -literal -offset indent
427 /mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
428
429 /mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
430
431 /mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
432 .Ed
433 .\" ==== prune ====
434 .It Ar prune Ar softlink-dir
435 Prune the file system based on previously created snapshot softlinks.
436 Pruning is the act of deleting file system history.
437 The
438 .Ar prune
439 command
440 will delete file system history such that
441 the file system state is retained for the given snapshots,
442 and all history after the latest snapshot,
443 but all other history is deleted.
444 .Pp
445 The target directory is expected to contain softlinks pointing to
446 snapshots of the file systems you wish to retain.
447 The directory is scanned non-recursively and the mount points and
448 transaction ids stored in the softlinks are extracted and sorted.
449 The file system is then explicitly pruned according to what is found.
450 Cleaning out portions of the file system is as simple as removing a softlink
451 and then running the
452 .Ar prune
453 command.
454 .Pp
455 As a safety measure pruning only occurs if one or more softlinks are found
456 containing the @@ snapshot id extension.
457 Currently the scanned softlink directory must contain softlinks pointing
458 to a single
459 .Nm HAMMER
460 mount.
461 The softlinks may specify absolute or relative paths.
462 Softlinks must use 20-character (@@0x%016llx) transaction ids,
463 as might be returned from
464 .Dq Nm Ar synctid filesystem .
465 .Pp
466 Pruning is a per PFS operation, so a
467 .Nm HAMMER
468 file system and each PFS in it have to be pruned separately.
469 .Pp
470 Note that pruning a file system may not immediately free-up space,
471 though typically some space will be freed if a large number of records are
472 pruned out.
473 The file system must be reblocked to completely recover all available space.
474 .Pp
475 Example, lets say your snapshot directory contains the following links:
476 .Bd -literal -offset indent
477 lrwxr-xr-x  1 root  wheel  29 May 31 17:57 snap1 ->
478 /usr/obj/@@0x10d2cd05b7270d16
479
480 lrwxr-xr-x  1 root  wheel  29 May 31 17:58 snap2 ->
481 /usr/obj/@@0x10d2cd13f3fde98f
482
483 lrwxr-xr-x  1 root  wheel  29 May 31 17:59 snap3 ->
484 /usr/obj/@@0x10d2cd222adee364
485 .Ed
486 .Pp
487 If you were to run the
488 .Ar prune
489 command on this directory, then the
490 .Nm HAMMER
491 .Pa /usr/obj
492 mount will be pruned to retain the above three snapshots.
493 In addition, history for modifications made to the file system older than
494 the oldest snapshot will be destroyed and history for potentially fine-grained
495 modifications made to the file system more recently than the most recent
496 snapshot will be retained.
497 .Pp
498 If you then delete the
499 .Pa snap2
500 softlink and rerun the
501 .Ar prune
502 command,
503 history for modifications pertaining to that snapshot would be destroyed.
504 .\" ==== prune-everything ====
505 .It Ar prune-everything Ar filesystem
506 This command will remove all historical records from the file system.
507 This directive is not normally used on a production system.
508 .\" ==== rebalance ====
509 .It Ar rebalance Ar filesystem Op Ar saturation_level
510 This command will rebalance the B-Tree, nodes with small numbers of
511 elements will be combined and element counts will be smoothed out
512 between nodes.
513 .Pp
514 The saturation level is a percentage between 50 and 100.  The default
515 is 75 percent.
516 .\" ==== reblock ====
517 .It Ar reblock Ar filesystem Op Ar fill_percentage
518 .It Ar reblock-btree Ar filesystem Op Ar fill_percentage
519 .It Ar reblock-inodes Ar filesystem Op Ar fill_percentage
520 .It Ar reblock-dirs Ar filesystem Op Ar fill_percentage
521 .It Ar reblock-data Ar filesystem Op Ar fill_percentage
522 Attempt to defragment and free space for reuse by reblocking a live
523 .Nm HAMMER
524 file system.
525 Big blocks cannot be reused by
526 .Nm HAMMER
527 until they are completely free.
528 This command also has the effect of reordering all elements, effectively
529 defragmenting the file system.
530 .Pp
531 The default fill percentage is 100% and will cause the file system to be
532 completely defragmented.
533 All specified element types will be reallocated and rewritten.
534 If you wish to quickly free up space instead try specifying
535 a smaller fill percentage, such as 90% or 80% (the
536 .Sq %
537 suffix is not needed).
538 .Pp
539 Since this command may rewrite the entire contents of the disk it is
540 best to do it incrementally from a
541 .Xr cron 8
542 job along with the
543 .Fl c Ar cyclefile
544 and
545 .Fl t Ar seconds
546 options to limit the run time.
547 The file system would thus be defragmented over long period of time.
548 .Pp
549 It is recommended that separate invocations be used for each data type.
550 B-tree nodes, inodes, and directories are typically the most important
551 elements needing defragmentation.
552 Data can be defragmented over a longer period of time.
553 .Pp
554 Reblocking is a per PFS operation, so a
555 .Nm HAMMER
556 file system and each PFS in it have to be reblocked separately.
557 .\" ==== pfs-status ====
558 .It Ar pfs-status Ar dirpath ...
559 Retrieve the mirroring configuration parameters for the specified
560 .Nm HAMMER
561 file systems or pseudo-filesystems (PFS's).
562 .\" ==== pfs-master ====
563 .It Ar pfs-master Ar dirpath Op options
564 Create a pseudo-filesystem (PFS) inside a
565 .Nm HAMMER
566 file system.
567 Up to 65535 such file systems can be created.
568 Each PFS uses an independent inode numbering space making it suitable
569 for use as a replication source or target.
570 .Pp
571 The
572 .Ar pfs-master
573 directive creates a PFS that you can read, write, and use as a mirroring
574 source.
575 .Pp
576 It is recommended to use a
577 .Nm null
578 mount to access a PFS, for more information see
579 .Xr HAMMER 5 .
580 .\" ==== pfs-slave ====
581 .It Ar pfs-slave Ar dirpath Op options
582 Create a pseudo-filesystem (PFS) inside a
583 .Nm HAMMER
584 file system.
585 Up to 65535 such file systems can be created.
586 Each PFS uses an independent inode numbering space making it suitable
587 for use as a replication source or target.
588 .Pp
589 The
590 .Ar pfs-slave
591 directive creates a PFS that you can use as a mirroring target.
592 You will not be able to access a slave PFS until you have completed the
593 first mirroring operation with it as the target (its root directory will
594 not exist until then).
595 .Pp
596 Access to the pfs-slave via the special softlink,
597 as described in the
598 .Sx PFS NOTES
599 below, allows
600 .Nm HAMMER
601 to
602 dynamically modify the snapshot transaction id by returning a dynamic result
603 from
604 .Xr readlink 2
605 calls.
606 .Pp
607 A PFS can only be truly destroyed with the
608 .Ar pfs-destroy
609 directive.
610 Removing the softlink will not destroy the underlying PFS.
611 .Pp
612 It is recommended to use a
613 .Nm null
614 mount to access a PFS, for more information see
615 .Xr HAMMER 5 .
616 .\" ==== pfs-update ====
617 .It Ar pfs-update Ar dirpath Op options
618 Update the configuration parameters for an existing
619 .Nm HAMMER
620 file system
621 or pseudo-filesystem.
622 Options that may be specified:
623 .Bl -tag -width indent
624 .It sync-beg-tid=0x16llx
625 This is the automatic snapshot access starting transaction id for
626 mirroring slaves.
627 This parameter is normally updated automatically by the
628 .Ar mirror-write
629 directive.
630 .Pp
631 It is important to note that accessing a mirroring slave
632 with a transaction id greater than the last fully synchronized transaction
633 id can result in an unreliable snapshot since you will be accessing
634 data that is still undergoing synchronization.
635 .Pp
636 Manually modifying this field is dangerous and can result in a broken
637 mirror.
638 .It sync-end-tid=0x16llx
639 This is the current synchronization point for mirroring slaves.
640 This parameter is normally updated automatically by the
641 .Ar mirror-write
642 directive.
643 .Pp
644 Manually modifying this field is dangerous and can result in a broken mirror.
645 .It shared-uuid=<uuid>
646 Set the shared UUID for this file system.
647 All mirrors must have the same shared UUID.
648 For safety purposes the
649 .Ar mirror-write
650 directives will refuse to operate on a target with a different shared UUID.
651 .Pp
652 Changing the shared UUID on an existing, non-empty mirroring target,
653 including an empty but not completely pruned target,
654 can lead to corruption of the mirroring target.
655 .It unique-uuid=<uuid>
656 Set the unique UUID for this file system.
657 This UUID should not be used anywhere else,
658 even on exact copies of the file system.
659 .It label=<string>
660 Set a descriptive label for this file system.
661 .It snapshots=<string>
662 Specify the snapshots directory which
663 .Nm
664 .Ar cleanup
665 will use to manage this PFS.
666 The snapshots directory does not need to be configured for
667 PFS masters and will default to
668 .Pa <pfs>/snapshots .
669 .Pp
670 PFS slaves are mirroring slaves so you cannot configure a snapshots
671 directory on the slave itself to be managed by the slave's machine.
672 In fact, the slave will likely have a
673 .Pa snapshots
674 sub-directory mirrored
675 from the master, but that directory contains the configuration the master
676 is using for its copy of the file system, not the configuration that we
677 want to use for our slave.
678 .Pp
679 It is recommended that
680 .Pa <fs>/var/slaves/<name>
681 be configured for a PFS slave, where
682 .Pa <fs>
683 is the base
684 .Nm HAMMER
685 file system, and
686 .Pa <name>
687 is an appropriate label.
688 You can control snapshot retention on your slave independent of the master.
689 .It snapshots-clear
690 Zero out the snapshots directory path for this PFS.
691 .It prune-min=Nd
692 .It prune-min=Nd/hh[:mm[:ss]]
693 .It prune-min=hh[:mm[:ss]]
694 Set the minimum fine-grained data retention period.
695 .Nm HAMMER
696 always retains fine-grained history up to the first snapshot.
697 You can extend the retention period beyond the first snapshot by
698 specifying it with this option.
699 .El
700 .\" ==== pfs-upgrade ====
701 .It Ar pfs-upgrade Ar dirpath
702 Upgrade a PFS from slave to master operation.
703 The PFS will be rolled back to the current end synchronization tid
704 (removing any partial synchronizations), and will then become writable.
705 .Pp
706 .Em WARNING!
707 .Nm HAMMER
708 currently supports only single masters and using
709 this command can easily result in file system corruption
710 if you don't know what you are doing.
711 .Pp
712 This directive will refuse to run if any programs have open descriptors
713 in the PFS, including programs chdir'd into the PFS.
714 .\" ==== pfs-downgrade ====
715 .It Ar pfs-downgrade Ar dirpath
716 Downgrade a master PFS from master to slave operation
717 The PFS becomes read-only and access will be locked to its
718 .Ar sync-end-tid .
719 .Pp
720 This directive will refuse to run if any programs have open descriptors
721 in the PFS, including programs chdir'd into the PFS.
722 .\" ==== pfs-destroy ====
723 .It Ar pfs-destroy Ar dirpath
724 This permanently destroys a PFS.
725 .Pp
726 This directive will refuse to run if any programs have open descriptors
727 in the PFS, including programs chdir'd into the PFS.
728 .\" ==== mirror-read ====
729 .It Ar mirror-read Ar filesystem Op Ar <begin-tid>
730 Generate a mirroring stream to stdout.
731 The stream ends when the transaction id space has been exhausted.
732 .\" ==== mirror-read-stream ====
733 .It Ar mirror-read-stream Ar filesystem Op Ar <begin-tid>
734 Generate a mirroring stream to stdout.
735 Upon completion the stream is paused until new data is synced to the
736 master, then resumed.
737 Operation continues until the pipe is broken.
738 .\" ==== mirror-write ====
739 .It Ar mirror-write Ar filesystem
740 Take a mirroring stream on stdin.
741 .Pp
742 This command will fail if the
743 .Ar shared-uuid
744 configuration field for the two file systems do not match.
745 .Pp
746 If the target PFS does not exist this command will ask you whether
747 you want to create a compatible PFS slave for the target or not.
748 .\" ==== mirror-dump ====
749 .It Ar mirror-dump
750 A
751 .Ar mirror-read
752 can be piped into a
753 .Ar mirror-dump
754 to dump an ASCII representation of the mirroring stream.
755 .\" ==== mirror-copy ====
756 .It Ar mirror-copy Ar [[user@]host:]filesystem Ar [[user@]host:]filesystem
757 This is a shortcut which pipes a
758 .Ar mirror-read
759 command to a
760 .Ar mirror-write
761 command.
762 If a remote host specification is made the program forks a
763 .Xr ssh 1
764 and execs the
765 .Ar mirror-read
766 and/or
767 .Ar mirror-write
768 on the appropriate host.
769 The source may be a master or slave PFS, and the target must be a slave PFS.
770 .Pp
771 This command also established full duplex communication and turns on
772 the two-way protocol feature which automatically negotiates transaction id
773 ranges without having to use a cyclefile.
774 If the operation completes successfully the target PFS's
775 .Ar sync-end-tid
776 will be updated.
777 Note that you must re-chdir into the target PFS to see the updated information.
778 If you do not you will still be in the previous snapshot.
779 .Pp
780 If the target PFS does not exist this command will ask you whether
781 you want to create a compatible PFS slave for the target or not.
782 .\" ==== mirror-stream ====
783 .It Ar mirror-stream Ar [[user@]host:]filesystem Ar [[user@]host:]filesystem
784 This command works similarly to
785 .Ar mirror-copy
786 but does not exit after the initial mirroring completes.
787 The mirroring operation will resume as changes continue to be made to the
788 master.
789 The command is commonly used with
790 .Fl i Ar delay
791 and
792 .Fl b Ar bandwidth
793 options to keep the mirroring target in sync with the source on a continuing
794 basis.
795 .Pp
796 If the pipe is broken the command will automatically retry after sleeping
797 for a short while.
798 .Pp
799 This command also detects the initial-mirroring case and spends some
800 time scanning the B-Tree to find good break points, allowing the initial
801 bulk mirroring operation to be broken down into about 20 separate pieces.
802 This means that the user can kill and restart the operation and it will
803 not have to start from scratch once it has gotten past the first chunk.
804 .\" ==== version ====
805 .It Ar version Ar filesystem
806 This command returns the
807 .Nm HAMMER
808 filesystem version for the specified
809 filesystem as well as the range of versions supported in the kernel.
810 The
811 .Fl q
812 option may be used to remove the summary at the end.
813 .\" ==== version-upgrade ====
814 .It Ar version-upgrade Ar filesystem Ar version Op Ar force
815 This command upgrades the
816 .Nm HAMMER
817 filesystem to the specified version.
818 Once upgraded a filesystem may not be downgraded.
819 If you wish to upgrade a filesystem to a version greater or equal to the
820 work-in-progress version number you must specify the
821 .Ar force
822 directive.
823 Use of WIP versions should be relegated to testing and may require wiping
824 the filesystem as development progresses, even though the WIP version might
825 not change.
826 .Pp
827 NOTE!  This command operates on the entire
828 .Nm HAMMER
829 filesystem and is not a per-PFS operation.
830 All PFS's will be affected.
831 .Bl -tag -width indent
832 .It 1
833 .Dx 2.0
834 default version, first
835 .Nm HAMMER
836 release.
837 .It 2
838 Work-in-progress version.
839 This version is developing a new directory hash key.
840 .El
841 .El
842 .\".Sh EXAMPLES
843 .Sh PSEUDO FILESYSTEM (PFS) NOTES
844 The root of a PFS is not hooked into the primary
845 .Nm HAMMER
846 file system as a directory.
847 Instead,
848 .Nm HAMMER
849 creates a special softlink called "@@PFS%05d" (exactly 10 characters long)
850 in the primary
851 .Nm HAMMER
852 file system.
853 .Nm HAMMER
854 then modifies the contents of the softlink as read by
855 .Xr readlink 2 ,
856 and thus what you see with an
857 .Xr ls 1
858 command or if you were to
859 .Xr cd 1
860 into the link.
861 If the PFS is a master the link reflects the current state of the PFS.
862 If the PFS is a slave the link reflects the last completed snapshot, and the
863 contents of the link will change when the next snapshot is completed, and
864 so forth.
865 .Pp
866 PFS support is currently very new and experimental.
867 The
868 .Nm
869 utility employs numerous safeties to reduce user foot-shooting.
870 The
871 .Ar mirror-copy
872 directive requires that the target be configured as a slave and that the
873 .Ar shared-uuid
874 field of the mirroring source and target match.
875 .Sh FILES
876 .Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
877 .It Pa snapshots
878 default per PFS snapshots directory
879 .It Pa <snapshots>/config
880 .Nm
881 .Ar cleanup
882 configuration file
883 .It Pa <fs>/var/slaves/<name>
884 recommended slave PFS snapshots directory
885 .El
886 .Sh EXIT STATUS
887 .Ex -std
888 .Sh SEE ALSO
889 .Xr undo 1 ,
890 .Xr HAMMER 5 ,
891 .Xr periodic.conf 5 ,
892 .Xr mount_hammer 8 ,
893 .Xr mount_null 8 ,
894 .Xr newfs_hammer 8
895 .Sh HISTORY
896 The
897 .Nm
898 utility first appeared in
899 .Dx 1.11 .
900 .Sh AUTHORS
901 .An Matthew Dillon Aq dillon@backplane.com