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