/
hammer.8
1524 lines (1516 loc) · 45.5 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
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.\" 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 February 12, 2010
.Dt HAMMER 8
.Os
.Sh NAME
.Nm hammer
.Nd HAMMER file system utility
.Sh SYNOPSIS
.Nm
.Fl h
.Nm
.Op Fl 2BqrvXy
.Op Fl b Ar bandwidth
.Op Fl c Ar cyclefile
.Op Fl f Ar blkdevs
.\" .Op Fl s Ar linkpath
.Op Fl i Ar delay
.Op Fl p Ar ssh-port
.Op Fl t Ar seconds
.Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
.Op Fl S Ar splitsize
.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
.Cm 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
.Cm k , m ,
or
.Cm g
to specify values in kilobytes, megabytes, and gigabytes per second.
If no suffix is specified, bytes per second is assumed.
.Pp
Unfortunately this is only applicable to the pre-compression bandwidth
when compression is used, so a better solution would probably be to
use a
.Xr ipfw 8
pipe or a
.Xr pf 4
queue.
.It Fl c Ar cyclefile
When pruning, rebalancing or reblocking you can tell the utility
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 blkdevs
Specify the volumes making up a
.Nm HAMMER
file system.
.Ar Blkdevs
is a colon-separated list of devices, each specifying a
.Nm HAMMER
volume.
.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 p Ar ssh-port
This passes the
.Fl p Ar ssh-port
option to
.Xr ssh 1
when using a remote
specification for the source and/or destination.
.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, rebalancing or 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, rebalance or reblock incrementally.
.It Fl v
Increase verboseness.
May be specified multiple times.
.It Fl y
Force "yes" for any interactive question.
.It Fl B
Bulk transfer.
.Cm Mirror-stream
will not attempt to break-up large initial bulk transfers into smaller
pieces.
This can save time but if the link is lost in the middle of the
initial bulk transfer you will have to start over from scratch.
This option is not recommended.
For more information see the
.Fl S
option.
.It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
Set the memory cache size for any raw
.Tn I/O .
The default is 16MB.
A suffix of
.Cm k
for kilobytes and
.Cm m
for megabytes is allowed,
else the cache size is specified in bytes.
.Pp
The read-behind/read-ahead defaults to 4
.Nm HAMMER
blocks.
.Pp
This option is typically only used with diagnostic commands
as kernel-supported commands will use the kernel's buffer cache.
.It Fl S Ar splitsize
Specify the bulk splitup size in bytes for mirroring streams.
When a
.Cm mirror-stream
is first started
.Nm
will do an initial run-through of the data to calculate good
transaction ids to cut up the bulk transfers, creating
restart points in case the stream is interrupted.
If we don't do this and the stream is interrupted it might
have to start all over again.
The default is a splitsize of 4G.
.Pp
At the moment the run-through is disk-bandwidth-heavy but some
future version will limit the run-through to just the B-Tree
records and not the record data.
.Pp
The splitsize may be suffixed with
.Cm k , m ,
or
.Cm g
to specify values in kilobytes, megabytes, or gigabytes.
If no suffix is specified, bytes is assumed.
.Pp
When mirroring very large filesystems the minimum recommended
split side is 4G.
A small split size may wind up generating a great deal of overhead
but very little actual incremental data and is not recommended.
.It Fl X
Enable compression for any remote ssh specifications.
Unfortunately the
.Fl C
option has already been reserved for other purposes so we had to use
a different letter.
This option is typically used with the mirroring directives.
.It Fl y
Force "yes" for any interactive question.
.El
.Pp
The commands are as follows:
.Bl -tag -width indent
.\" ==== synctid ====
.It Cm synctid Ar filesystem Op Cm 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
.Cm 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.
.Pp
This operation does not create a snapshot.
It is meant to be used
to track temporary fine-grained changes to a subset of files and
will only remain valid for
.Ql @@
snapshot access purposes for the
.Cm prune-min
period configured for the PFS.
If you desire a real snapshot then the
.Cm snapq
directive may be what you are looking for.
.\" ==== bstats ====
.It Cm bstats Op Ar interval
Output
.Nm HAMMER
B-Tree statistics until interrupted.
Pause
.Ar interval
seconds between each display.
The default interval is one second.
.\" ==== iostats ====
.It Cm iostats Op Ar interval
Output
.Nm HAMMER
.Tn I/O
statistics until interrupted.
Pause
.Ar interval
seconds between each display.
The default interval is one second.
.\" ==== history ====
.It Cm history Ar path ...
Show the modification history for
.Nm HAMMER
file's inode and data.
.\" ==== blockmap ====
.It Cm blockmap
Dump the blockmap for the file system.
The
.Nm HAMMER
blockmap is two-layer
blockmap representing the maximum possible file system size of 1 Exabyte.
Needless to say the second layer is only present for blocks which exist.
.Nm HAMMER Ns 's
blockmap represents 8-Megabyte blocks, called big-blocks.
Each big-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
.Nm HAMMER
allocations are 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
.Nm HAMMER
does not track holes in big-blocks for reallocation.
A big-block must be completely freed, either
through normal file system 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
.Nm 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 Cm show Op Ar lo Ns Cm \&: Ns Ar objid
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
.Ql B
in column 1 along with various
other error flags.
.Pp
If you specify a localization field or a localization:obj_id field,
.Ar lo Ns Cm \&: Ns Ar objid ,
the dump will
search for the key printing nodes as it recurses down, and then
will iterate forwards.
These fields are specified in HEX.
Note that the pfsid is the top 16 bits of the 32 bit localization
field so PFS #1 would be 00010000.
.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 transaction ids, or report or check data CRCs.
B-Tree CRCs and linkages are still checked.
.Pp
This command needs the
.Fl f
flag.
.\" ==== show-undo ====
.It Cm show-undo
.Nm ( HAMMER
VERSION 4+)
Dump the UNDO map.
.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 Cm 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 file system.
The low 32 bits are used as an iterator for hash collisions and will be
output as 0.
.\" ==== namekey2 ====
.It Cm 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 file system.
The low 32 bits are still used as an iterator but will start out containing
part of the hash key.
.\" ==== namekey32 ====
.It Cm namekey32 Ar filename
Generate the top 32 bits of a
.Nm HAMMER
64 bit directory hash for the specified file name.
.\" ==== info ====
.It Cm info
Shows extended information about all the mounted
.Nm HAMMER
file systems.
The information is divided into sections:
.Bl -tag -width indent
.It Volume identification
General information, like the label of the
.Nm HAMMER
filesystem, the number of volumes it contains, the FSID, and the
.Nm HAMMER
version being used.
.It Big block information
Big block statistics, such as total, used, reserved and free big blocks.
.It Space information
Information about space used on the filesystem.
Currently total size, used, reserved and free space are displayed.
.It PFS information
Basic information about the PFSs currently present on a
.Nm HAMMER
filesystem.
.Pp
.Dq PFS ID
is the ID of the PFS, with 0 being the root PFS.
.Dq Snaps
is the current snapshot count on the PFS.
.Dq Mounted on
displays the mount point of the PFS is currently mounted on (if any).
.El
.\" ==== cleanup ====
.It Cm cleanup Op Ar filesystem ...
This is a meta-command which executes snapshot, prune, rebalance and reblock
commands on the specified
.Nm HAMMER
file systems.
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 access a snapshots
directory and a configuration file for each
.Ar filesystem ,
creating them if necessary.
.Bl -tag -width indent
.It Nm HAMMER No version 2-
The configuration file is
.Pa config
in the snapshots directory which defaults to
.Pa <pfs>/snapshots .
.It Nm HAMMER No version 3+
The configuration file is saved in file system meta-data, see
.Nm
.Cm config .
The snapshots directory defaults to
.Pa /var/hammer/<pfs>
.Pa ( /var/hammer/root
for root mount).
.El
.Pp
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> <max-runtime>
recopy <period> <max-runtime>
.Ed
.Pp
Defaults are:
.Bd -literal -offset indent
snapshots 1d 60d # 0d 0d 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
.Cm 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
.Cm prune-everything .
If the
.Cm 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
.Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
are processed.
If the
.Cm any
directive is specified as a third argument on the
.Cm snapshots
config line then any softlink of the form
.Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
or
.Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
will be processed.
.Pp
A prune max-runtime of 0 means unlimited.
.Pp
If period hasn't passed since the previous
.Cm 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, rebalancing 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 rebalance operations are time limited to 5 minutes,
reblock operations to a bit over 5 minutes,
and recopy operations to a bit over 10 minutes.
Reblocking and recopy runs are each broken down into four separate functions:
btree, inodes, dirs and data.
Each function is time limited to the time given in the configuration file,
but the btree, inodes and dirs functions usually does not take very long time,
full defragmentation is always used for these three functions.
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 configuration 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
.Cm 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.
.\" ==== config ====
.It Cm config Op Ar filesystem Op Ar configfile
.Nm ( HAMMER
VERSION 3+)
Show or change configuration for
.Ar filesystem .
If zero or one arguments are specified this function dumps the current
configuration file to stdout.
Zero arguments specifies the PFS containing the current directory.
This configuration file is stored in file system meta-data.
If two arguments are specified this function installs a new config file.
.Pp
In
.Nm HAMMER
versions less than 3 the configuration file is by default stored in
.Pa <pfs>/snapshots/config ,
but in all later versions the configuration file is stored in file system
meta-data.
.\" ==== viconfig ====
.It Cm viconfig Op Ar filesystem
.Nm ( HAMMER
VERSION 3+)
Edit the configuration file and reinstall into file system meta-data when done.
Zero arguments specifies the PFS containing the current directory.
.\" ==== volume-add ====
.It Cm volume-add Ar device Ar filesystem
This command will format
.Ar device
and add all of its space to
.Ar filesystem .
.Pp
.Em NOTE!
All existing data contained on
.Ar device
will be destroyed by this operation!
If
.Ar device
contains a valid
.Nm HAMMER
file system, formatting will be denied.
You can overcome this sanity check
by using
.Xr dd 1
to erase the beginning sectors of the device.
Also remember that you have to specify
.Ar device ,
together with any other device that make up the file system,
colon-separated to
.Pa /etc/fstab
and
.Xr mount_hammer 8 .
.\" ==== volume-del ====
.It Cm volume-del Ar device Ar filesystem
This command will remove volume
.Ar device
from
.Ar filesystem .
.Pp
Remember that you have to remove
.Ar device
from the colon-separated list in
.Pa /etc/fstab
and
.Xr mount_hammer 8 .
.\" ==== snapshot ====
.It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
.It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
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
.Ql 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
and
.Pa /usr
are file systems on their 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
hammer snapshot /usr /my/snaps/usr "note"
.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
/my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
.Ed
.Pp
When run on a
.Nm HAMMER
version 3+ file system the snapshot is also recorded in file system meta-data
along with the optional
.Ar note .
See the
.Cm snapls
directive.
.\" ==== snap* ====
.It Cm snap Ar path Op Ar note
.Nm ( HAMMER
VERSION 3+)
Create a snapshot for the PFS containing
.Ar path
and create a snapshot softlink.
If the path specified is a
directory a standard snapshot softlink will be created in the directory.
The snapshot softlink points to the base of the mounted PFS.
.It Cm snaplo Ar path Op Ar note
.Nm ( HAMMER
VERSION 3+)
Create a snapshot for the PFS containing
.Ar path
and create a snapshot softlink.
If the path specified is a
directory a standard snapshot softlink will be created in the directory.
The snapshot softlink points into the directory it is contained in.
.It Cm snapq Ar dir Op Ar note
.Nm ( HAMMER
VERSION 3+)
Create a snapshot for the PFS containing the specified directory but do
not create a softlink.
Instead output a path which can be used to access
the directory via the snapshot.
.Pp
An absolute or relative path may be specified.
The path will be used as-is as a prefix in the path output to stdout.
As with the other
snap and snapshot directives the snapshot transaction id will be registered
in the file system meta-data.
.It Cm snaprm Ar path Ar ...
.It Cm snaprm Ar transid Ar ...
.It Cm snaprm Ar filesystem Ar transid Ar ...
.Nm ( HAMMER
VERSION 3+)
Remove a snapshot given its softlink or transaction id.
If specifying a transaction id
the snapshot is removed from file system meta-data but you are responsible
for removing any related softlinks.
.Pp
If a softlink path is specified the filesystem and transaction id
is derived from the contents of the softlink.
If just a transaction id is specified it is assumed to be a snapshot
in the HAMMER filesystem you are currently chdir'd into.
You can also specify the filesystem and transaction id explicitly.
.It Cm snapls Op Ar path ...
.Nm ( HAMMER
VERSION 3+)
Dump the snapshot meta-data for PFSs containing each
.Ar path
listing all available snapshots and their notes.
If no arguments are specified snapshots for the PFS containing the
current directory are listed.
This is the definitive list of snapshots for the file system.
.\" ==== prune ====
.It Cm prune Ar softlink-dir
Prune the file system based on previously created snapshot softlinks.
Pruning is the act of deleting file system history.
The
.Cm 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.
By setting the per PFS parameter
.Cm prune-min ,
history is guaranteed to be saved at least this time interval.
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
snapshot softlink and then running the
.Cm prune
command.
.Pp
As a safety measure pruning only occurs if one or more softlinks are found
containing the
.Ql @@
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
.Ql @@0x%016llx
transaction ids, as might be returned from
.Nm Cm synctid Ar 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 that you didn't set
.Cm prune-min ,
and 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
.Cm 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
.Cm prune
command,
history for modifications pertaining to that snapshot would be destroyed.
.Pp
In
.Nm HAMMER
file system versions 3+ this command also scans the snapshots stored
in the file system meta-data and includes them in the prune.
.\" ==== prune-everything ====
.It Cm 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.
.Pp
This command does not remove snapshot softlinks but will delete all
snapshots recorded in file system meta-data (for file system version 3+).
The user is responsible for deleting any softlinks.
.Pp
Pruning is a per PFS operation, so a
.Nm HAMMER
file system and each PFS in it have to be pruned separately.
.\" ==== rebalance ====
.It Cm rebalance Ar filesystem Op Ar saturation_percentage
This command will rebalance the B-Tree, nodes with small number of
elements will be combined and element counts will be smoothed out
between nodes.
.Pp
The saturation percentage is between 50% and 100%.
The default is 75% (the
.Sq %
suffix is not needed).
.Pp
Rebalancing is a per PFS operation, so a
.Nm HAMMER
file system and each PFS in it have to be rebalanced separately.
.\" ==== reblock* ====
.It Cm reblock Ar filesystem Op Ar fill_percentage
.It Cm reblock-btree Ar filesystem Op Ar fill_percentage
.It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
.It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
.It Cm 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 Cm pfs-status Ar dirpath ...
Retrieve the mirroring configuration parameters for the specified
.Nm HAMMER
file systems or pseudo-filesystems (PFS's).
.\" ==== pfs-master ====
.It Cm pfs-master Ar dirpath Op Ar 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
.Cm 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 Cm pfs-slave Ar dirpath Op Ar 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
.Cm 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
.Cm 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 Cm pfs-update Ar dirpath Op Ar 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 Cm sync-beg-tid= Ns Ar 0x16llx
This is the automatic snapshot access starting transaction id for
mirroring slaves.
This parameter is normally updated automatically by the
.Cm 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 Cm sync-end-tid= Ns Ar 0x16llx
This is the current synchronization point for mirroring slaves.
This parameter is normally updated automatically by the
.Cm mirror-write
directive.
.Pp
Manually modifying this field is dangerous and can result in a broken mirror.
.It Cm shared-uuid= Ns Ar uuid
Set the shared UUID for this file system.
All mirrors must have the same shared UUID.
For safety purposes the
.Cm 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 Cm unique-uuid= Ns Ar 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 Cm label= Ns Ar string
Set a descriptive label for this file system.
.It Cm snapshots= Ns Ar string
Specify the snapshots directory which
.Nm
.Cm cleanup
will use to manage this PFS.
.Bl -tag -width indent
.It Nm HAMMER No version 2-
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>