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