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