6da7e234d4d8ec54ab44cdb29da8351986afce80
[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
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 use
209 .Fl q
210 the command will report less information about the inode contents.
211 .Pp
212 If you use
213 .Fl qq
214 the command will not report the content of the inode or other typed
215 data at all.
216 .Pp
217 If you use
218 .Fl qqq
219 the command will not report volume header information, big-block fill
220 ratios, mirror TIDs, or report or check data CRCs.  B-Tree CRCs and
221 linkages are still checked.
222 .Pp
223 This command needs the
224 .Fl f
225 flag.
226 .\" .It Ar blockmap
227 .\" Dump the B-tree, record, large-data, and small-data blockmaps, showing
228 .\" physical block assignments and free space percentages.
229 .\" ==== namekey1 ====
230 .It Ar namekey1 Ar filename
231 Generate a
232 .Nm HAMMER
233 64 bit directory hash for the specified file name, using
234 the original directory hash algorithm in version 1 of the filesystem.
235 The low 32 bits are used as an iterator for hash collisions and will be
236 output as 0.
237 .\" ==== namekey2 ====
238 .It Ar namekey2 Ar filename
239 Generate a
240 .Nm HAMMER
241 64 bit directory hash for the specified file name, using
242 the new directory hash algorithm in version 2 of the filesystem.
243 The low 32 bits are still used as an iterator but will start out containing
244 part of the hash key.
245 .\" ==== namekey32 ====
246 .It Ar namekey32 Ar filename
247 Generate the top 32 bits of a
248 .Nm HAMMER
249 64 bit directory hash for the specified file name.
250 .\" ==== cleanup ====
251 .It Ar cleanup Op Ar filesystem ...
252 This is a meta-command which executes snapshot, pruning, and reblocking
253 commands on the specified
254 .Nm HAMMER
255 file system.
256 If no
257 .Ar filesystem
258 is specified this command will clean-up all
259 .Nm HAMMER
260 file systems in use, including PFS's.
261 To do this it will scan all
262 .Nm HAMMER
263 and
264 .Nm null
265 mounts, extract PFS id's, and clean-up each PFS found.
266 .Pp
267 This command will by default access a
268 .Pa snapshots
269 subdirectory and a
270 .Pa snapshots/config
271 file for each
272 .Ar filesystem ,
273 creating them if necessary.
274 The format of the configuration file is:
275 .Bd -literal -offset indent
276 snapshots  <period> <retention-time> [any]
277 prune      <period> <max-runtime>
278 rebalance  <period> <max-runtime>
279 reblock    <period> <1/3 max-runtime>
280 recopy     <period> <1/3 max-runtime>
281
282 Defaults are:
283 snapshots  1d 60d  # 0d 60d  for PFS /tmp, /var/tmp, /usr/obj
284 prune      1d 5m
285 rebalance  1d 5m
286 reblock    1d 5m
287 recopy     30d 10m
288 .Ed
289 .Pp
290 Time is given with a suffix of
291 .Cm d ,
292 .Cm h ,
293 .Cm m
294 or
295 .Cm s
296 meaning day, hour, minute and second.
297 .Pp
298 If the snapshots directive has a period of 0 and a retention time of 0
299 then snapshot generation is disabled, removal of old snapshots are
300 disabled, and prunes will use
301 .Ar prune-everything .
302 If the snapshots directive has a period of 0 but a non-zero retention time
303 then this command will not create any new snapshots but will remove old
304 snapshots it finds based on the retention time.
305 .Pp
306 By default only snapshots in the form:  snap-yyyymmdd[-hhmm] are processed.
307 If the
308 .Ar any
309 directive is specified as a third argument on the snapshots config line
310 then any softlink of the form *[- or .]yyyymmdd[-hhmm] will be processed.
311 .Pp
312 A prune max-runtime of 0 means unlimited.
313 .Pp
314 If period hasn't passed since the previous
315 .Ar cleanup
316 run nothing is done.
317 For example a day has passed when midnight is passed (localtime).
318 By default,
319 .Dx
320 is set up to run
321 .Nm Ar cleanup
322 nightly via
323 .Xr periodic 8 .
324 .Pp
325 The default configuration file will create a daily snapshot, do a daily
326 pruning and reblocking run and a monthly recopy run.
327 Reblocking is defragmentation with a level of 95%,
328 and recopy is full defragmentation.
329 .Pp
330 By default prune and reblock operations are limited to 5 minutes per function,
331 and recopy operations are limited to 10 minutes per function.
332 Reblocking and recopy runs are each broken down into three separate functions
333 (btree, inodes and data)
334 and are thus by default limited to 15 and 30 minutes respectively.
335 Also note that this directive will by default disable snapshots on
336 the following PFS's:
337 .Pa /tmp ,
338 .Pa /var/tmp
339 and
340 .Pa /usr/obj .
341 .Pp
342 The defaults may be adjusted by modifying the
343 .Pa config
344 file.
345 The pruning and reblocking commands automatically maintain a cyclefile
346 for incremental operation.
347 If you interrupt (^C) the program the cyclefile will be updated, but a sub-command
348 may continue to run in the background for a few seconds until the
349 .Nm HAMMER
350 ioctl detects the interrupt.
351 The
352 .Ar snapshots
353 PFS option can be set to use another location for the snapshots directory.
354 .Pp
355 Work on this command is still in progress.
356 Expected additions:  An ability to remove snapshots dynamically as the
357 file system becomes full.
358 .\" ==== snapshot ====
359 .It Ar snapshot Oo Ar filesystem Oc Ar snapshot-dir
360 Takes a snapshot of the file system either explicitly given by
361 .Ar filesystem
362 or implicitly derived from the
363 .Ar snapshot-dir
364 argument and creates a symlink in the directory provided by
365 .Ar snapshot-dir
366 pointing to the snapshot.
367 If
368 .Ar snapshot-dir
369 is not a directory, it is assumed to be a format string passed to
370 .Xr strftime 3
371 with the current time as parameter.
372 If
373 .Ar snapshot-dir
374 refers to an existing directory, a default format string of "snap-%Y%d%m-%H%M"
375 is assumed and used as name for the newly created symlink.
376 .Pp
377 Snapshot is a per PFS operation, so a
378 .Nm HAMMER
379 file system and each PFS in it have to be snapshot separately.
380 .Pp
381 Example, assuming that
382 .Pa /mysnapshots
383 is on file system
384 .Pa /
385 and that
386 .Pa /obj
387 is a file system on its own, the following invocations:
388 .Bd -literal -offset indent
389 hammer snapshot /mysnapshots
390
391 hammer snapshot /mysnapshots/%Y-%m-%d
392
393 hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
394 .Ed
395 .Pp
396 would create symlinks similar to:
397 .Bd -literal -offset indent
398 /mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
399
400 /mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
401
402 /mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
403 .Ed
404 .\" ==== prune ====
405 .It Ar prune Ar softlink-dir
406 Prune the file system based on previously created snapshot softlinks.
407 Pruning is the act of deleting file system history.
408 The
409 .Ar prune
410 command
411 will delete file system history such that
412 the file system state is retained for the given snapshots,
413 and all history after the latest snapshot,
414 but all other history is deleted.
415 .Pp
416 The target directory is expected to contain softlinks pointing to
417 snapshots of the file systems you wish to retain.
418 The directory is scanned non-recursively and the mount points and
419 transaction ids stored in the softlinks are extracted and sorted.
420 The file system is then explicitly pruned according to what is found.
421 Cleaning out portions of the file system is as simple as removing a softlink
422 and then running the
423 .Ar prune
424 command.
425 .Pp
426 As a safety measure pruning only occurs if one or more softlinks are found
427 containing the @@ snapshot id extension.
428 Currently the scanned softlink directory must contain softlinks pointing
429 to a single
430 .Nm HAMMER
431 mount.
432 The softlinks may specify absolute or relative paths.
433 Softlinks must use 20-character (@@0x%016llx) transaction ids,
434 as might be returned from
435 .Dq Nm Ar synctid filesystem .
436 .Pp
437 Pruning is a per PFS operation, so a
438 .Nm HAMMER
439 file system and each PFS in it have to be pruned separately.
440 .Pp
441 Note that pruning a file system may not immediately free-up space,
442 though typically some space will be freed if a large number of records are
443 pruned out.
444 The file system must be reblocked to completely recover all available space.
445 .Pp
446 Example, lets say your snapshot directory contains the following links:
447 .Bd -literal -offset indent
448 lrwxr-xr-x  1 root  wheel  29 May 31 17:57 snap1 ->
449 /usr/obj/@@0x10d2cd05b7270d16
450
451 lrwxr-xr-x  1 root  wheel  29 May 31 17:58 snap2 ->
452 /usr/obj/@@0x10d2cd13f3fde98f
453
454 lrwxr-xr-x  1 root  wheel  29 May 31 17:59 snap3 ->
455 /usr/obj/@@0x10d2cd222adee364
456 .Ed
457 .Pp
458 If you were to run the
459 .Ar prune
460 command on this directory, then the
461 .Nm HAMMER
462 .Pa /usr/obj
463 mount will be pruned to retain the above three snapshots.
464 In addition, history for modifications made to the file system older than
465 the oldest snapshot will be destroyed and history for potentially fine-grained
466 modifications made to the file system more recently than the most recent
467 snapshot will be retained.
468 .Pp
469 If you then delete the
470 .Pa snap2
471 softlink and rerun the
472 .Ar prune
473 command,
474 history for modifications pertaining to that snapshot would be destroyed.
475 .\" ==== prune-everything ====
476 .It Ar prune-everything Ar filesystem
477 This command will remove all historical records from the file system.
478 This directive is not normally used on a production system.
479 .\" ==== rebalance ====
480 .It Ar rebalance Ar filesystem Op Ar saturation_level
481 This command will rebalance the B-Tree, nodes with small numbers of
482 elements will be combined and element counts will be smoothed out
483 between nodes.
484 .Pp
485 The saturation level is a percentage between 50 and 100.  The default
486 is 75 percent.
487 .\" ==== reblock ====
488 .It Ar reblock Ar filesystem Op Ar fill_percentage
489 .It Ar reblock-btree Ar filesystem Op Ar fill_percentage
490 .It Ar reblock-inodes Ar filesystem Op Ar fill_percentage
491 .It Ar reblock-dirs Ar filesystem Op Ar fill_percentage
492 .It Ar reblock-data Ar filesystem Op Ar fill_percentage
493 Attempt to defragment and free space for reuse by reblocking a live
494 .Nm HAMMER
495 file system.
496 Big blocks cannot be reused by
497 .Nm HAMMER
498 until they are completely free.
499 This command also has the effect of reordering all elements, effectively
500 defragmenting the file system.
501 .Pp
502 The default fill percentage is 100% and will cause the file system to be
503 completely defragmented.
504 All specified element types will be reallocated and rewritten.
505 If you wish to quickly free up space instead try specifying
506 a smaller fill percentage, such as 90% or 80% (the
507 .Sq %
508 suffix is not needed).
509 .Pp
510 Since this command may rewrite the entire contents of the disk it is
511 best to do it incrementally from a
512 .Xr cron 8
513 job along with the
514 .Fl c Ar cyclefile
515 and
516 .Fl t Ar seconds
517 options to limit the run time.
518 The file system would thus be defragmented over long period of time.
519 .Pp
520 It is recommended that separate invocations be used for each data type.
521 B-tree nodes, inodes, and directories are typically the most important
522 elements needing defragmentation.
523 Data can be defragmented over a longer period of time.
524 .Pp
525 Reblocking is a per PFS operation, so a
526 .Nm HAMMER
527 file system and each PFS in it have to be reblocked separately.
528 .\" ==== pfs-status ====
529 .It Ar pfs-status Ar dirpath ...
530 Retrieve the mirroring configuration parameters for the specified
531 .Nm HAMMER
532 file systems or pseudo-filesystems (PFS's).
533 .\" ==== pfs-master ====
534 .It Ar pfs-master Ar dirpath Op options
535 Create a pseudo-filesystem (PFS) inside a
536 .Nm HAMMER
537 file system.
538 Up to 65535 such file systems can be created.
539 Each PFS uses an independent inode numbering space making it suitable
540 for use as a replication source or target.
541 .Pp
542 The
543 .Ar pfs-master
544 directive creates a PFS that you can read, write, and use as a mirroring
545 source.
546 .Pp
547 It is recommended to use a
548 .Nm null
549 mount to access a PFS, for more information see
550 .Xr HAMMER 5 .
551 .\" ==== pfs-slave ====
552 .It Ar pfs-slave Ar dirpath Op options
553 Create a pseudo-filesystem (PFS) inside a
554 .Nm HAMMER
555 file system.
556 Up to 65535 such file systems can be created.
557 Each PFS uses an independent inode numbering space making it suitable
558 for use as a replication source or target.
559 .Pp
560 The
561 .Ar pfs-slave
562 directive creates a PFS that you can use as a mirroring target.
563 You will not be able to access a slave PFS until you have completed the
564 first mirroring operation with it as the target (its root directory will
565 not exist until then).
566 .Pp
567 Access to the pfs-slave via the special softlink,
568 as described in the
569 .Sx PFS NOTES
570 below, allows
571 .Nm HAMMER
572 to
573 dynamically modify the snapshot transaction id by returning a dynamic result
574 from
575 .Xr readlink 2
576 calls.
577 .Pp
578 A PFS can only be truly destroyed with the
579 .Ar pfs-destroy
580 directive.
581 Removing the softlink will not destroy the underlying PFS.
582 .Pp
583 It is recommended to use a
584 .Nm null
585 mount to access a PFS, for more information see
586 .Xr HAMMER 5 .
587 .\" ==== pfs-update ====
588 .It Ar pfs-update Ar dirpath Op options
589 Update the configuration parameters for an existing
590 .Nm HAMMER
591 file system
592 or pseudo-filesystem.
593 Options that may be specified:
594 .Bl -tag -width indent
595 .It sync-beg-tid=0x16llx
596 This is the automatic snapshot access starting transaction id for
597 mirroring slaves.
598 This parameter is normally updated automatically by the
599 .Ar mirror-write
600 directive.
601 .Pp
602 It is important to note that accessing a mirroring slave
603 with a transaction id greater than the last fully synchronized transaction
604 id can result in an unreliable snapshot since you will be accessing
605 data that is still undergoing synchronization.
606 .Pp
607 Manually modifying this field is dangerous and can result in a broken
608 mirror.
609 .It sync-end-tid=0x16llx
610 This is the current synchronization point for mirroring slaves.
611 This parameter is normally updated automatically by the
612 .Ar mirror-write
613 directive.
614 .Pp
615 Manually modifying this field is dangerous and can result in a broken mirror.
616 .It shared-uuid=<uuid>
617 Set the shared UUID for this file system.
618 All mirrors must have the same shared UUID.
619 For safety purposes the
620 .Ar mirror-write
621 directives will refuse to operate on a target with a different shared UUID.
622 .Pp
623 Changing the shared UUID on an existing, non-empty mirroring target,
624 including an empty but not completely pruned target,
625 can lead to corruption of the mirroring target.
626 .It unique-uuid=<uuid>
627 Set the unique UUID for this file system.
628 This UUID should not be used anywhere else,
629 even on exact copies of the file system.
630 .It label=<string>
631 Set a descriptive label for this file system.
632 .It snapshots=<string>
633 Specify the snapshots directory which
634 .Nm
635 .Ar cleanup
636 will use to manage this PFS.
637 The snapshots directory does not need to be configured for
638 PFS masters and will default to
639 .Pa <pfs>/snapshots .
640 .Pp
641 PFS slaves are mirroring slaves so you cannot configure a snapshots
642 directory on the slave itself to be managed by the slave's machine.
643 In fact, the slave will likely have a
644 .Pa snapshots
645 sub-directory mirrored
646 from the master, but that directory contains the configuration the master
647 is using for its copy of the file system, not the configuration that we
648 want to use for our slave.
649 .Pp
650 It is recommended that
651 .Pa <fs>/var/slaves/<name>
652 be configured for a PFS slave, where
653 .Pa <fs>
654 is the base
655 .Nm HAMMER
656 file system, and
657 .Pa <name>
658 is an appropriate label.
659 You can control snapshot retention on your slave independent of the master.
660 .It snapshots-clear
661 Zero out the snapshots directory path for this PFS.
662 .El
663 .\" ==== pfs-upgrade ====
664 .It Ar pfs-upgrade Ar dirpath
665 Upgrade a PFS from slave to master operation.
666 The PFS will be rolled back to the current end synchronization tid
667 (removing any partial synchronizations), and will then become writable.
668 .Pp
669 .Em WARNING!
670 .Nm HAMMER
671 currently supports only single masters and using
672 this command can easily result in file system corruption
673 if you don't know what you are doing.
674 .Pp
675 This directive will refuse to run if any programs have open descriptors
676 in the PFS, including programs chdir'd into the PFS.
677 .\" ==== pfs-downgrade ====
678 .It Ar pfs-downgrade Ar dirpath
679 Downgrade a master PFS from master to slave operation
680 The PFS becomes read-only and access will be locked to its
681 .Ar sync-end-tid .
682 .Pp
683 This directive will refuse to run if any programs have open descriptors
684 in the PFS, including programs chdir'd into the PFS.
685 .\" ==== pfs-destroy ====
686 .It Ar pfs-destroy Ar dirpath
687 This permanently destroys a PFS.
688 .Pp
689 This directive will refuse to run if any programs have open descriptors
690 in the PFS, including programs chdir'd into the PFS.
691 .\" ==== mirror-read ====
692 .It Ar mirror-read Ar filesystem Op Ar <begin-tid>
693 Generate a mirroring stream to stdout.
694 The stream ends when the transaction id space has been exhausted.
695 .\" ==== mirror-read-stream ====
696 .It Ar mirror-read-stream Ar filesystem Op Ar <begin-tid>
697 Generate a mirroring stream to stdout.
698 Upon completion the stream is paused until new data is synced to the
699 master, then resumed.
700 Operation continues until the pipe is broken.
701 .\" ==== mirror-write ====
702 .It Ar mirror-write Ar filesystem
703 Take a mirroring stream on stdin.
704 .Pp
705 This command will fail if the
706 .Ar shared-uuid
707 configuration field for the two file systems do not match.
708 .Pp
709 If the target PFS does not exist this command will ask you whether
710 you want to create a compatible PFS slave for the target or not.
711 .\" ==== mirror-dump ====
712 .It Ar mirror-dump
713 A
714 .Ar mirror-read
715 can be piped into a
716 .Ar mirror-dump
717 to dump an ASCII representation of the mirroring stream.
718 .\" ==== mirror-copy ====
719 .It Ar mirror-copy Ar [[user@]host:]filesystem Ar [[user@]host:]filesystem
720 This is a shortcut which pipes a
721 .Ar mirror-read
722 command to a
723 .Ar mirror-write
724 command.
725 If a remote host specification is made the program forks a
726 .Xr ssh 1
727 and execs the
728 .Ar mirror-read
729 and/or
730 .Ar mirror-write
731 on the appropriate host.
732 The source may be a master or slave PFS, and the target must be a slave PFS.
733 .Pp
734 This command also established full duplex communication and turns on
735 the two-way protocol feature which automatically negotiates transaction id
736 ranges without having to use a cyclefile.
737 If the operation completes successfully the target PFS's
738 .Ar sync-end-tid
739 will be updated.
740 Note that you must re-chdir into the target PFS to see the updated information.
741 If you do not you will still be in the previous snapshot.
742 .Pp
743 If the target PFS does not exist this command will ask you whether
744 you want to create a compatible PFS slave for the target or not.
745 .\" ==== mirror-stream ====
746 .It Ar mirror-stream Ar [[user@]host:]filesystem Ar [[user@]host:]filesystem
747 This command works similarly to
748 .Ar mirror-copy
749 but does not exit unless the pipe is broken.
750 This command will resume the mirroring operation whenever the master is synced.
751 The command is commonly used with
752 .Fl i Ar delay
753 and
754 .Fl b Ar bandwidth
755 options to keep the mirroring target in sync with the source on a continuing
756 basis.
757 .\" ==== version ====
758 .It Ar version Ar filesystem
759 This command returns the
760 .Nm HAMMER
761 filesystem version for the specified
762 filesystem as well as the range of versions supported in the kernel.
763 The
764 .Fl q
765 option may be used to remove the summary at the end.
766 .\" ==== version-upgrade ====
767 .It Ar version-upgrade Ar filesystem Ar version Op Ar force
768 This command upgrades the
769 .Nm HAMMER
770 filesystem to the specified version.
771 Once upgraded a filesystem may not be downgraded.
772 If you wish to upgrade a filesystem to a version greater or equal to the
773 work-in-progress version number you must specify the
774 .Ar force
775 directive.
776 Use of WIP versions should be relegated to testing and may require wiping
777 the filesystem as development progresses, even though the WIP version might
778 not change.
779 .Pp
780 NOTE!  This command operates on the entire
781 .Nm HAMMER
782 filesystem and is not a per-PFS operation.
783 All PFS's will be affected.
784 .Bl -tag -width indent
785 .It 1
786 .Dx 2.0
787 default version, first
788 .Nm HAMMER
789 release.
790 .It 2
791 Work-in-progress version.
792 This version is developing a new directory hash key.
793 .El
794 .El
795 .\".Sh EXAMPLES
796 .Sh PSEUDO FILESYSTEM (PFS) NOTES
797 The root of a PFS is not hooked into the primary
798 .Nm HAMMER
799 file system as a directory.
800 Instead,
801 .Nm HAMMER
802 creates a special softlink called "@@PFS%05d" (exactly 10 characters long)
803 in the primary
804 .Nm HAMMER
805 file system.
806 .Nm HAMMER
807 then modifies the contents of the softlink as read by
808 .Xr readlink 2 ,
809 and thus what you see with an
810 .Xr ls 1
811 command or if you were to
812 .Xr cd 1
813 into the link.
814 If the PFS is a master the link reflects the current state of the PFS.
815 If the PFS is a slave the link reflects the last completed snapshot, and the
816 contents of the link will change when the next snapshot is completed, and
817 so forth.
818 .Pp
819 PFS support is currently very new and experimental.
820 The
821 .Nm
822 utility employs numerous safeties to reduce user foot-shooting.
823 The
824 .Ar mirror-copy
825 directive requires that the target be configured as a slave and that the
826 .Ar shared-uuid
827 field of the mirroring source and target match.
828 .Sh FILES
829 .Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
830 .It Pa snapshots
831 default per PFS snapshots directory
832 .It Pa <snapshots>/config
833 .Nm
834 .Ar cleanup
835 configuration file
836 .It Pa <fs>/var/slaves/<name>
837 recommended slave PFS snapshots directory
838 .El
839 .Sh EXIT STATUS
840 .Ex -std
841 .Sh SEE ALSO
842 .Xr undo 1 ,
843 .Xr HAMMER 5 ,
844 .Xr periodic.conf 5 ,
845 .Xr mount_hammer 8 ,
846 .Xr mount_null 8 ,
847 .Xr newfs_hammer 8
848 .Sh HISTORY
849 The
850 .Nm
851 utility first appeared in
852 .Dx 1.11 .
853 .Sh AUTHORS
854 .An Matthew Dillon Aq dillon@backplane.com