HAMMER - Implement experimental volume removal
[dragonfly.git] / sbin / hammer / hammer.8
CommitLineData
0dfeb6c8 1.\" Copyright (c) 2007 The DragonFly Project. All rights reserved.
7bb56fa9 2.\"
0dfeb6c8
MD
3.\" This code is derived from software contributed to The DragonFly Project
4.\" by Matthew Dillon <dillon@backplane.com>
7bb56fa9 5.\"
0dfeb6c8
MD
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
7bb56fa9 9.\"
0dfeb6c8
MD
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.
7bb56fa9 19.\"
0dfeb6c8
MD
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.
7bb56fa9 32.\"
de1c0b31 33.\" $DragonFly: src/sbin/hammer/hammer.8,v 1.58 2008/11/13 02:04:27 dillon Exp $
e0331f4f 34.\"
856bc468 35.Dd December 7, 2009
0dfeb6c8
MD
36.Dt HAMMER 8
37.Os
38.Sh NAME
39.Nm hammer
40.Nd HAMMER file system utility
41.Sh SYNOPSIS
42.Nm
4567021b
TN
43.Fl h
44.Nm
45.Op Fl 2Bqrvy
48eadef9 46.Op Fl b Ar bandwidth
4567021b 47.Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
d7ae405c 48.Op Fl c Ar cyclefile
f6532f03 49.Op Fl f Ar blkdevs
6d9ab5c5 50.\" .Op Fl s Ar linkpath
48eadef9 51.Op Fl i Ar delay
6c45ca3e 52.Op Fl p Ar ssh-port
99d6191f 53.Op Fl t Ar seconds
0dfeb6c8 54.Ar command
34bb69d8 55.Op Ar argument ...
0dfeb6c8 56.Sh DESCRIPTION
6d9ab5c5 57This manual page documents the
0dfeb6c8 58.Nm
6d9ab5c5 59utility which provides miscellaneous functions related to managing a
b4448f1a
TN
60.Nm HAMMER
61file system.
62For a general introduction to the
63.Nm HAMMER
64file system, its features, and
6d9ab5c5 65examples on how to set up and maintain one, see
b4448f1a 66.Xr HAMMER 5 .
0dfeb6c8
MD
67.Pp
68The options are as follows:
69.Bl -tag -width indent
70.It Fl h
84082922 71Get help.
d4e5b69b
MD
72.It Fl 2
73Tell the mirror commands to use a 2-way protocol, which allows
2010519f
TN
74automatic negotiation of transaction id ranges.
75This option is automatically enabled by the
4567021b 76.Cm mirror-copy
d4e5b69b 77command.
4567021b
TN
78.It Fl B
79Bulk Transfer.
80.Cm Mirror-stream
81will not attempt to break-up large initial bulk transfers into smaller pieces.
82This can save time but if the link is lost in the middle of the
83initial bulk transfer you will have to start over from scratch.
48eadef9
MD
84.It Fl b Ar bandwidth
85Specify a bandwidth limit in bytes per second for mirroring streams.
86This option is typically used to prevent batch mirroring operations from
87loading down the machine.
15fa4caf 88The bandwidth may be suffixed with
4567021b 89.Cm k , m ,
15fa4caf 90or
4567021b 91.Cm g
2010519f 92to specify values in kilobytes, megabytes, and gigabytes per second.
224ac2f2 93If no suffix is specified, bytes per second is assumed.
4567021b
TN
94.It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
95Set the memory cache size for any raw
96.Tn I/O .
97The default is 16m.
98A suffix of
99.Cm k
100for kilobytes and
101.Cm m
102for megabytes is allowed,
103else the cache size is specified in bytes.
104.Pp
16265794
TN
105The read-behind/read-ahead defaults to 4
106.Nm HAMMER
107blocks.
4567021b
TN
108.Pp
109This option is typically only used with diagnostic commands
110as kernel-supported commands will use the kernel's buffer cache.
d7ae405c 111.It Fl c Ar cyclefile
84082922
TN
112When pruning and reblocking you can instruction
113.Nm
2010519f 114to start at the object id stored in the specified file.
84082922 115If the file does not exist
15fa4caf 116.Nm
84082922
TN
117will start at the beginning.
118If
15fa4caf 119.Nm
84082922 120is told to run for a
d7ae405c 121specific period of time and is unable to complete the operation it will
2010519f 122write out the current object id so the next run can pick up where it left off.
84082922
TN
123If
124.Nm
483bb69b
TN
125runs to completion it will delete
126.Ar cyclefile .
f6532f03 127.It Fl f Ar blkdevs
b4448f1a
TN
128Specify the volumes making up a
129.Nm HAMMER
130file system.
f6532f03
TN
131.Ar Blkdevs
132is a colon-separated list of devices, each specifying a
133.Nm HAMMER
134volume.
48eadef9
MD
135.It Fl i Ar delay
136When maintaining a streaming mirroring this option specifies the
137minimum delay after a batch ends before the next batch is allowed
138to start.
139The default is five seconds.
6c45ca3e
MD
140.It Fl p Ar ssh-port
141This passes the -p <port> option to ssh when using a remote
142specification for the source and/or destination.
e95314de 143.It Fl q
bb92c669 144Decrease verboseness.
2010519f 145May be specified multiple times.
bb8e52c0
TN
146.It Fl r
147Specify recursion for those commands which support it.
99d6191f 148.It Fl t Ar seconds
0006adae 149When pruning and reblocking you can tell the utility to stop after a
2010519f
TN
150certain period of time.
151This option is used along with the
483bb69b 152.Fl c Ar cyclefile
b4448f1a 153option to prune or reblock a portion of the file system incrementally.
563b4845 154.It Fl v
2010519f
TN
155Increase verboseness.
156May be specified multiple times.
07485271
MN
157.It Fl y
158Force "yes" for any interactive question.
0dfeb6c8
MD
159.El
160.Pp
161The commands are as follows:
162.Bl -tag -width indent
15fa4caf 163.\" ==== synctid ====
4567021b 164.It Cm synctid Ar filesystem Op Cm quick
367431cf 165Generates a guaranteed, formal 64 bit transaction id representing the
b4448f1a
TN
166current state of the specified
167.Nm HAMMER
2010519f
TN
168file system.
169The file system will be synced to the media.
367431cf
MD
170.Pp
171If the
4567021b 172.Cm quick
b4448f1a
TN
173keyword is specified the file system will be soft-synced, meaning that a
174crash might still undo the state of the file system as of the transaction
367431cf
MD
175id returned but any new modifications will occur after the returned
176transaction id as expected.
bf2c6489 177.Pp
16265794
TN
178This operation does not create a snapshot.
179It is meant to be used
bf2c6489 180to track temporary fine-grained changes to a subset of files and
16265794
TN
181will only remain valid for
182.Ql @@
183snapshot access purposes for the
bf2c6489 184.Cm prune-min
16265794
TN
185period configured for the PFS.
186If you desire a real snapshot then the
bf2c6489
MD
187.Cm snapq
188directive may be what you are looking for.
15fa4caf 189.\" ==== bstats ====
4567021b 190.It Cm bstats Op Ar interval
b4448f1a
TN
191Output
192.Nm HAMMER
193B-tree statistics until interrupted.
84082922
TN
194Pause
195.Ar interval
b4448f1a 196seconds between each display.
84082922 197The default interval is one second.
15fa4caf 198.\" ==== iostats ====
4567021b 199.It Cm iostats Op Ar interval
b4448f1a
TN
200Output
201.Nm HAMMER
4567021b
TN
202.Tn I/O
203statistics until interrupted.
84082922
TN
204Pause
205.Ar interval
b4448f1a 206seconds between each display.
84082922 207The default interval is one second.
15fa4caf 208.\" ==== history ====
4567021b 209.It Cm history Ar path ...
b4448f1a
TN
210Show the modification history for
211.Nm HAMMER
212file's inode and data.
b46b99bf 213.\" ==== blockmap ====
4567021b
TN
214.It Cm blockmap
215Dump the blockmap for the file system.
216The
217.Nm HAMMER
218blockmap is two-layer
219blockmap representing the maximum possible file system size of 1 Exabyte.
b46b99bf 220Needless to say the second layer is only present for blocks which exist.
4567021b
TN
221.Nm HAMMER Ns 's
222blockmap represents 8-Megabyte blocks, called big-blocks.
223Each big-block has an append
b46b99bf
MD
224point, a free byte count, and a typed zone id which allows content to be
225reverse engineered to some degree.
226.Pp
4567021b
TN
227In
228.Nm HAMMER
229allocations essentially appended to a selected big-block using
230the append offset and deducted from the free byte count.
231When space is freed the free byte count is adjusted but
232.Nm HAMMER
233does not track holes in big-blocks for reallocation.
234A big-block must be completely freed, either
235through normal file system operations or through reblocking, before
b46b99bf
MD
236it can be reused.
237.Pp
238Data blocks can be shared by deducting the space used from the free byte
4567021b
TN
239count for each shared references, though
240.Nm HAMMER
241does not yet make use of this feature.
242This means the free byte count can legally go negative.
b46b99bf
MD
243.Pp
244This command needs the
245.Fl f
246flag.
15fa4caf 247.\" ==== show ====
4567021b
TN
248.It Cm show Op Ar lo Ns Cm \&: Ns Ar objid
249Dump the B-tree.
250By default this command will validate all B-Tree
b46b99bf
MD
251linkages and CRCs, including data CRCs, and will report the most verbose
252information it can dig up.
16265794
TN
253Any errors will show up with a
254.Ql B
255in column 1 along with various
b46b99bf
MD
256other error flags.
257.Pp
f6532f03
TN
258If you specify a localization and object id field,
259.Ar lo Ns Cm \&: Ns Ar objid ,
260the dump will
e7f926a5
MD
261search for the key printing nodes as it recurses down, and then
262will iterate forwards.
263.Pp
b46b99bf
MD
264If you use
265.Fl q
266the command will report less information about the inode contents.
267.Pp
268If you use
269.Fl qq
270the command will not report the content of the inode or other typed
271data at all.
272.Pp
273If you use
274.Fl qqq
275the command will not report volume header information, big-block fill
4567021b
TN
276ratios, mirror transaction ids, or report or check data CRCs.
277B-tree CRCs and linkages are still checked.
b46b99bf 278.Pp
2010519f 279This command needs the
b4448f1a 280.Fl f
84082922 281flag.
f6532f03
TN
282.\" ==== show-undo ====
283.It Cm show-undo
284.Nm ( HAMMER
285VERSION 4+)
286Dump the UNDO map.
287.Pp
288This command needs the
289.Fl f
290flag.
84082922
TN
291.\" .It Ar blockmap
292.\" Dump the B-tree, record, large-data, and small-data blockmaps, showing
293.\" physical block assignments and free space percentages.
5e435c92 294.\" ==== namekey1 ====
4567021b 295.It Cm namekey1 Ar filename
b4448f1a
TN
296Generate a
297.Nm HAMMER
5e435c92 29864 bit directory hash for the specified file name, using
4567021b 299the original directory hash algorithm in version 1 of the file system.
cbd800c2
MD
300The low 32 bits are used as an iterator for hash collisions and will be
301output as 0.
5e435c92 302.\" ==== namekey2 ====
4567021b 303.It Cm namekey2 Ar filename
5e435c92
MD
304Generate a
305.Nm HAMMER
30664 bit directory hash for the specified file name, using
4567021b 307the new directory hash algorithm in version 2 of the file system.
5e435c92
MD
308The low 32 bits are still used as an iterator but will start out containing
309part of the hash key.
15fa4caf 310.\" ==== namekey32 ====
4567021b 311.It Cm namekey32 Ar filename
b4448f1a
TN
312Generate the top 32 bits of a
313.Nm HAMMER
2010519f 31464 bit directory hash for the specified file name.
b66b9421 315.\" ==== info ====
4567021b
TN
316.It Cm info
317Shows extended information about all the mounted
318.Nm HAMMER
319file systems.
7bb56fa9
MD
320At the moment volume identification, big-blocks information, space and
321and pseudo-filesystem (PFS) details are shown.
6a6e350f 322.\" ==== cleanup ====
4567021b
TN
323.It Cm cleanup Op Ar filesystem ...
324This is a meta-command which executes snapshot, prune, rebalance and reblock
226f3799
TN
325commands on the specified
326.Nm HAMMER
16265794 327file systems.
226f3799
TN
328If no
329.Ar filesystem
330is specified this command will clean-up all
331.Nm HAMMER
332file systems in use, including PFS's.
333To do this it will scan all
334.Nm HAMMER
335and
336.Nm null
6a6e350f
MD
337mounts, extract PFS id's, and clean-up each PFS found.
338.Pp
f85afb25 339This command will access a snapshots
16265794 340directory and a configuration file for each
226f3799
TN
341.Ar filesystem ,
342creating them if necessary.
f85afb25
TN
343.Bl -tag -width indent
344.It Nm HAMMER No version 2-
345The configuration file is
16265794
TN
346.Pa config
347in the snapshots directory which defaults to
348.Pa <pfs>/snapshots .
f85afb25 349.It Nm HAMMER No version 3+
f6532f03
TN
350The configuration file is saved in file system meta-data, see
351.Nm
352.Cm config .
16265794
TN
353The snapshots directory defaults to
354.Pa /var/hammer/<pfs>
355.Pa ( /var/hammer/root
356for root mount).
f85afb25 357.El
16265794 358.Pp
226f3799
TN
359The format of the configuration file is:
360.Bd -literal -offset indent
5e435c92 361snapshots <period> <retention-time> [any]
226f3799 362prune <period> <max-runtime>
f13fea8b 363rebalance <period> <max-runtime>
4567021b
TN
364reblock <period> <max-runtime>
365recopy <period> <max-runtime>
366.Ed
367.Pp
226f3799 368Defaults are:
4567021b
TN
369.Bd -literal -offset indent
370snapshots 1d 60d # 0d 0d for PFS /tmp, /var/tmp, /usr/obj
226f3799 371prune 1d 5m
f13fea8b 372rebalance 1d 5m
226f3799
TN
373reblock 1d 5m
374recopy 30d 10m
375.Ed
6a6e350f 376.Pp
483bb69b 377Time is given with a suffix of
226f3799
TN
378.Cm d ,
379.Cm h ,
380.Cm m
483bb69b 381or
226f3799
TN
382.Cm s
383meaning day, hour, minute and second.
5e435c92 384.Pp
4567021b
TN
385If the
386.Cm snapshots
387directive has a period of 0 and a retention time of 0
5e435c92
MD
388then snapshot generation is disabled, removal of old snapshots are
389disabled, and prunes will use
4567021b
TN
390.Cm prune-everything .
391If the
392.Cm snapshots
393directive has a period of 0 but a non-zero retention time
5e435c92
MD
394then this command will not create any new snapshots but will remove old
395snapshots it finds based on the retention time.
396.Pp
4567021b
TN
397By default only snapshots in the form
398.Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
399are processed.
5e435c92 400If the
4567021b
TN
401.Cm any
402directive is specified as a third argument on the
403.Cm snapshots
404config line then any softlink of the form
405.Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
406or
407.Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
408will be processed.
5e435c92 409.Pp
226f3799
TN
410A prune max-runtime of 0 means unlimited.
411.Pp
e0331f4f 412If period hasn't passed since the previous
4567021b 413.Cm cleanup
483bb69b
TN
414run nothing is done.
415For example a day has passed when midnight is passed (localtime).
e0331f4f
SW
416By default,
417.Dx
418is set up to run
419.Nm Ar cleanup
420nightly via
421.Xr periodic 8 .
226f3799
TN
422.Pp
423The default configuration file will create a daily snapshot, do a daily
f13fea8b 424pruning, rebalancing and reblocking run and a monthly recopy run.
226f3799
TN
425Reblocking is defragmentation with a level of 95%,
426and recopy is full defragmentation.
427.Pp
4567021b
TN
428By default prune and rebalance operations are time limited to 5 minutes,
429reblock operations to a bit over 5 minutes,
430and recopy operations to a bit over 10 minutes.
431Reblocking and recopy runs are each broken down into four separate functions:
432btree, inodes, dirs and data.
433Each function is time limited to the time given in the configuration file,
434but the btree, inodes and dirs functions usually does not take very long time,
435full defragmentation is always used for these three functions.
226f3799 436Also note that this directive will by default disable snapshots on
2010519f 437the following PFS's:
6a6e350f 438.Pa /tmp ,
226f3799 439.Pa /var/tmp
6a6e350f 440and
226f3799 441.Pa /usr/obj .
6a6e350f 442.Pp
16265794 443The defaults may be adjusted by modifying the configuration file.
6a6e350f
MD
444The pruning and reblocking commands automatically maintain a cyclefile
445for incremental operation.
4567021b
TN
446If you interrupt (^C) the program the cyclefile will be updated,
447but a sub-command
226f3799
TN
448may continue to run in the background for a few seconds until the
449.Nm HAMMER
6a6e350f 450ioctl detects the interrupt.
226f3799 451The
4567021b 452.Cm snapshots
226f3799 453PFS option can be set to use another location for the snapshots directory.
6a6e350f
MD
454.Pp
455Work on this command is still in progress.
4567021b
TN
456Expected additions:
457An ability to remove snapshots dynamically as the
226f3799 458file system becomes full.
83f2a3aa 459.\" ==== config ====
16265794
TN
460.It Cm config Op Ar filesystem Op Ar configfile
461.Nm ( HAMMER
462VERSION 3+)
463If zero or one arguments are specified this function dumps the current
464configuration file to stdout.
465Zero arguments specifies the PFS containing the current directory.
f6532f03 466This configuration file is stored in file system meta-data.
83f2a3aa
MD
467If two arguments are specified this function installs a new config file.
468.Pp
469In
470.Nm HAMMER
16265794
TN
471versions less than 3 the configuration file is by default stored in
472.Pa <pfs>/snapshots/config ,
f6532f03 473but in all later versions the configuration file is stored in file system
83f2a3aa 474meta-data.
16265794
TN
475.\" ==== viconfig ====
476.It Cm viconfig Op Ar filesystem
477.Nm ( HAMMER
478VERSION 3+)
f6532f03 479Edit the configuration file and reinstall into file system meta-data when done.
16265794 480Zero arguments specifies the PFS containing the current directory.
d121f61c
MN
481.\" ==== volume-add ====
482.It Cm volume-add Ar device Ar filesystem
ceed7673
MN
483This command will format
484.Ar device
485and add all of its space to
486.Ar filesystem .
487.Pp
4567021b
TN
488.Em NOTE!
489All existing data contained on
ceed7673 490.Ar device
4567021b
TN
491will be destroyed by this operation!
492If
ceed7673
MN
493.Ar device
494contains a valid
495.Nm HAMMER
f6532f03 496file system, formatting will be denied.
16265794 497You can overcome this sanity check
ceed7673
MN
498by using
499.Xr dd 1
500to erase the beginning sectors of the device.
501Also remember that you have to specify
502.Ar device ,
f6532f03
TN
503together with any other device that make up the file system,
504colon-separated to
505.Pa /etc/fstab
506and
ceed7673 507.Xr mount_hammer 8 .
865c9609
MN
508.\" ==== volume-del ====
509.It Cm volume-del Ar device Ar filesystem
510This command will remove volume
511.Ar device
512from
513.Ar filesystem .
514.Pp
515Remember that you have to remove
516.Ar device
517from the colon-separated list in
518.Pa /etc/fstab
519and
520.Xr mount_hammer 8 .
0e999592 521.\" ==== snapshot ====
4567021b 522.It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
16265794 523.It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
0e999592
TN
524Takes a snapshot of the file system either explicitly given by
525.Ar filesystem
526or implicitly derived from the
527.Ar snapshot-dir
528argument and creates a symlink in the directory provided by
529.Ar snapshot-dir
530pointing to the snapshot.
531If
532.Ar snapshot-dir
533is not a directory, it is assumed to be a format string passed to
534.Xr strftime 3
535with the current time as parameter.
536If
537.Ar snapshot-dir
4567021b
TN
538refers to an existing directory, a default format string of
539.Ql snap-%Y%d%m-%H%M
0e999592
TN
540is assumed and used as name for the newly created symlink.
541.Pp
542Snapshot is a per PFS operation, so a
543.Nm HAMMER
544file system and each PFS in it have to be snapshot separately.
545.Pp
546Example, assuming that
547.Pa /mysnapshots
548is on file system
549.Pa /
550and that
551.Pa /obj
16265794
TN
552and
553.Pa /usr
554are file systems on their own, the following invocations:
0e999592
TN
555.Bd -literal -offset indent
556hammer snapshot /mysnapshots
557
558hammer snapshot /mysnapshots/%Y-%m-%d
559
560hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
b5ec5ad4 561
16265794 562hammer snapshot /usr /my/snaps/usr "note"
0e999592
TN
563.Ed
564.Pp
b5ec5ad4 565Would create symlinks similar to:
0e999592
TN
566.Bd -literal -offset indent
567/mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
568
569/mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
570
571/mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
16265794
TN
572
573/my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
0e999592 574.Ed
b5ec5ad4
MD
575.Pp
576When run on a
577.Nm HAMMER
f6532f03 578version 3+ file system the snapshot is also recorded in file system meta-data
16265794
TN
579along with the optional
580.Ar note .
581See the
b5ec5ad4
MD
582.Cm snapls
583directive.
83f2a3aa 584.\" ==== snap* ====
16265794
TN
585.It Cm snap Ar path Op Ar note
586.Nm ( HAMMER
587VERSION 3+)
588Create a snapshot for the PFS containing
589.Ar path
590and create a snapshot softlink.
591If the path specified is a
83f2a3aa
MD
592directory a standard snapshot softlink will be created in the directory.
593The snapshot softlink points to the base of the mounted PFS.
16265794
TN
594.It Cm snaplo Ar path Op Ar note
595.Nm ( HAMMER
596VERSION 3+)
597Create a snapshot for the PFS containing
598.Ar path
599and create a snapshot softlink.
600If the path specified is a
83f2a3aa
MD
601directory a standard snapshot softlink will be created in the directory.
602The snapshot softlink points into the directory it is contained in.
16265794
TN
603.It Cm snapq Ar dir Op Ar note
604.Nm ( HAMMER
605VERSION 3+)
83f2a3aa 606Create a snapshot for the PFS containing the specified directory but do
16265794
TN
607not create a softlink.
608Instead output a path which can be used to access
83f2a3aa 609the directory via the snapshot.
bf2c6489 610.Pp
16265794
TN
611An absolute or relative path may be specified.
612The path will be used as-is as a prefix in the path output to stdout.
613As with the other
bf2c6489 614snap and snapshot directives the snapshot transaction id will be registered
f6532f03 615in the file system meta-data.
16265794
TN
616.It Cm snaprm Bro Ar path | transid Brc Ar ...
617.Nm ( HAMMER
618VERSION 3+)
619Remove a snapshot given its softlink or transaction id.
620If specifying a transaction id
f6532f03 621the snapshot is removed from file system meta-data but you are responsible
83f2a3aa 622for removing any related softlinks.
16265794
TN
623.It Cm snapls Op Ar path ...
624.Nm ( HAMMER
625VERSION 3+)
626Dump the snapshot meta-data for PFSs containing each
627.Ar path
628listing all available snapshots and their notes.
629If no arguments are specified snapshots for the PFS containing the
630current directory are listed.
f6532f03 631This is the definitive list of snapshots for the file system.
15fa4caf 632.\" ==== prune ====
4567021b 633.It Cm prune Ar softlink-dir
b4448f1a
TN
634Prune the file system based on previously created snapshot softlinks.
635Pruning is the act of deleting file system history.
84082922 636The
4567021b
TN
637.Cm prune
638command will delete file system history such that
b4448f1a 639the file system state is retained for the given snapshots,
4567021b
TN
640and all history after the latest snapshot.
641By setting the per PFS parameter
642.Cm prune-min ,
643history is guaranteed to be saved at least this time interval.
644All other history is deleted.
84082922 645.Pp
e8969ef0 646The target directory is expected to contain softlinks pointing to
2010519f
TN
647snapshots of the file systems you wish to retain.
648The directory is scanned non-recursively and the mount points and
649transaction ids stored in the softlinks are extracted and sorted.
b4448f1a 650The file system is then explicitly pruned according to what is found.
4567021b
TN
651Cleaning out portions of the file system is as simple as removing a
652snapshot softlink and then running the
653.Cm prune
e8969ef0
MD
654command.
655.Pp
656As a safety measure pruning only occurs if one or more softlinks are found
4567021b
TN
657containing the
658.Ql @@
659snapshot id extension.
e8969ef0 660Currently the scanned softlink directory must contain softlinks pointing
b4448f1a
TN
661to a single
662.Nm HAMMER
2010519f
TN
663mount.
664The softlinks may specify absolute or relative paths.
4567021b
TN
665Softlinks must use 20-character
666.Ql @@0x%016llx
667transaction ids, as might be returned from
668.Nm Cm synctid Ar filesystem .
e8969ef0 669.Pp
226f3799 670Pruning is a per PFS operation, so a
15fa4caf
TN
671.Nm HAMMER
672file system and each PFS in it have to be pruned separately.
673.Pp
674Note that pruning a file system may not immediately free-up space,
675though typically some space will be freed if a large number of records are
2010519f
TN
676pruned out.
677The file system must be reblocked to completely recover all available space.
15fa4caf 678.Pp
4567021b
TN
679Example, lets say your that you didn't set
680.Cm prune-min ,
681and snapshot directory contains the following links:
226f3799 682.Bd -literal -offset indent
f51a18e7
SW
683lrwxr-xr-x 1 root wheel 29 May 31 17:57 snap1 ->
684/usr/obj/@@0x10d2cd05b7270d16
685
686lrwxr-xr-x 1 root wheel 29 May 31 17:58 snap2 ->
687/usr/obj/@@0x10d2cd13f3fde98f
688
689lrwxr-xr-x 1 root wheel 29 May 31 17:59 snap3 ->
690/usr/obj/@@0x10d2cd222adee364
691.Ed
e8969ef0 692.Pp
84082922 693If you were to run the
4567021b 694.Cm prune
b4448f1a
TN
695command on this directory, then the
696.Nm HAMMER
f51a18e7
SW
697.Pa /usr/obj
698mount will be pruned to retain the above three snapshots.
2010519f
TN
699In addition, history for modifications made to the file system older than
700the oldest snapshot will be destroyed and history for potentially fine-grained
701modifications made to the file system more recently than the most recent
702snapshot will be retained.
703.Pp
704If you then delete the
705.Pa snap2
706softlink and rerun the
4567021b 707.Cm prune
84082922
TN
708command,
709history for modifications pertaining to that snapshot would be destroyed.
83f2a3aa
MD
710.Pp
711In
712.Nm HAMMER
f6532f03
TN
713file system versions 3+ this command also scans the snapshots stored
714in the file system meta-data and includes them in the prune.
15fa4caf 715.\" ==== prune-everything ====
4567021b 716.It Cm prune-everything Ar filesystem
b4448f1a 717This command will remove all historical records from the file system.
b5aaba7f 718This directive is not normally used on a production system.
83f2a3aa
MD
719.Pp
720This command does not remove snapshot softlinks but will delete all
f6532f03 721snapshots recorded in file system meta-data (for file system version 3+).
83f2a3aa 722The user is responsible for deleting any softlinks.
797a0b63 723.\" ==== rebalance ====
f6532f03 724.It Cm rebalance Ar filesystem Op Ar saturation_percentage
4567021b 725This command will rebalance the B-tree, nodes with small number of
797a0b63
MD
726elements will be combined and element counts will be smoothed out
727between nodes.
728.Pp
f6532f03
TN
729The saturation percentage is between 50% and 100%.
730The default is 75% (the
731.Sq %
732suffix is not needed).
16265794 733.\" ==== reblock* ====
4567021b
TN
734.It Cm reblock Ar filesystem Op Ar fill_percentage
735.It Cm reblock-btree Ar filesystem Op Ar fill_percentage
736.It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
737.It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
738.It Cm reblock-data Ar filesystem Op Ar fill_percentage
9e29c876 739Attempt to defragment and free space for reuse by reblocking a live
b4448f1a
TN
740.Nm HAMMER
741file system.
4567021b 742Big-blocks cannot be reused by
b4448f1a
TN
743.Nm HAMMER
744until they are completely free.
9e29c876 745This command also has the effect of reordering all elements, effectively
b4448f1a 746defragmenting the file system.
ba7b52c9 747.Pp
b4448f1a 748The default fill percentage is 100% and will cause the file system to be
2010519f
TN
749completely defragmented.
750All specified element types will be reallocated and rewritten.
751If you wish to quickly free up space instead try specifying
15fa4caf
TN
752a smaller fill percentage, such as 90% or 80% (the
753.Sq %
754suffix is not needed).
ba7b52c9 755.Pp
9e29c876 756Since this command may rewrite the entire contents of the disk it is
84082922
TN
757best to do it incrementally from a
758.Xr cron 8
759job along with the
9e29c876
MD
760.Fl c Ar cyclefile
761and
99d6191f 762.Fl t Ar seconds
9e29c876 763options to limit the run time.
b4448f1a 764The file system would thus be defragmented over long period of time.
9e29c876
MD
765.Pp
766It is recommended that separate invocations be used for each data type.
d2ee8e9f 767B-tree nodes, inodes, and directories are typically the most important
2010519f
TN
768elements needing defragmentation.
769Data can be defragmented over a longer period of time.
15fa4caf 770.Pp
226f3799 771Reblocking is a per PFS operation, so a
15fa4caf
TN
772.Nm HAMMER
773file system and each PFS in it have to be reblocked separately.
774.\" ==== pfs-status ====
4567021b 775.It Cm pfs-status Ar dirpath ...
34ebae70 776Retrieve the mirroring configuration parameters for the specified
b4448f1a 777.Nm HAMMER
2010519f 778file systems or pseudo-filesystems (PFS's).
15fa4caf 779.\" ==== pfs-master ====
4567021b 780.It Cm pfs-master Ar dirpath Op Ar options
b4448f1a
TN
781Create a pseudo-filesystem (PFS) inside a
782.Nm HAMMER
783file system.
784Up to 65535 such file systems can be created.
765c85a8 785Each PFS uses an independent inode numbering space making it suitable
d4e5b69b
MD
786for use as a replication source or target.
787.Pp
788The
4567021b 789.Cm pfs-master
d4e5b69b
MD
790directive creates a PFS that you can read, write, and use as a mirroring
791source.
bb8e52c0
TN
792.Pp
793It is recommended to use a
794.Nm null
795mount to access a PFS, for more information see
796.Xr HAMMER 5 .
15fa4caf 797.\" ==== pfs-slave ====
4567021b 798.It Cm pfs-slave Ar dirpath Op Ar options
b4448f1a
TN
799Create a pseudo-filesystem (PFS) inside a
800.Nm HAMMER
801file system.
802Up to 65535 such file systems can be created.
765c85a8 803Each PFS uses an independent inode numbering space making it suitable
d4e5b69b
MD
804for use as a replication source or target.
805.Pp
806The
4567021b 807.Cm pfs-slave
765c85a8 808directive creates a PFS that you can use as a mirroring target.
d4e5b69b
MD
809You will not be able to access a slave PFS until you have completed the
810first mirroring operation with it as the target (its root directory will
811not exist until then).
34ebae70 812.Pp
4567021b 813Access to the pfs-slave via the special softlink, as described in the
2010519f
TN
814.Sx PFS NOTES
815below, allows
b4448f1a
TN
816.Nm HAMMER
817to
84082922
TN
818dynamically modify the snapshot transaction id by returning a dynamic result
819from
820.Xr readlink 2
821calls.
d4e5b69b 822.Pp
765c85a8 823A PFS can only be truly destroyed with the
4567021b 824.Cm pfs-destroy
d4e5b69b
MD
825directive.
826Removing the softlink will not destroy the underlying PFS.
bb8e52c0
TN
827.Pp
828It is recommended to use a
829.Nm null
830mount to access a PFS, for more information see
831.Xr HAMMER 5 .
15fa4caf 832.\" ==== pfs-update ====
4567021b 833.It Cm pfs-update Ar dirpath Op Ar options
b4448f1a
TN
834Update the configuration parameters for an existing
835.Nm HAMMER
4567021b 836file system or pseudo-filesystem.
2010519f 837Options that may be specified:
34ebae70 838.Bl -tag -width indent
4567021b 839.It Cm sync-beg-tid= Ns Ar 0x16llx
2010519f
TN
840This is the automatic snapshot access starting transaction id for
841mirroring slaves.
34ebae70 842This parameter is normally updated automatically by the
4567021b 843.Cm mirror-write
34ebae70
MD
844directive.
845.Pp
846It is important to note that accessing a mirroring slave
765c85a8 847with a transaction id greater than the last fully synchronized transaction
34ebae70
MD
848id can result in an unreliable snapshot since you will be accessing
849data that is still undergoing synchronization.
850.Pp
4567021b
TN
851Manually modifying this field is dangerous and can result in a broken mirror.
852.It Cm sync-end-tid= Ns Ar 0x16llx
ddc8e722 853This is the current synchronization point for mirroring slaves.
34ebae70 854This parameter is normally updated automatically by the
4567021b 855.Cm mirror-write
34ebae70
MD
856directive.
857.Pp
2010519f 858Manually modifying this field is dangerous and can result in a broken mirror.
4567021b 859.It Cm shared-uuid= Ns Ar uuid
2010519f
TN
860Set the shared UUID for this file system.
861All mirrors must have the same shared UUID.
862For safety purposes the
4567021b 863.Cm mirror-write
2010519f 864directives will refuse to operate on a target with a different shared UUID.
34ebae70 865.Pp
84082922 866Changing the shared UUID on an existing, non-empty mirroring target,
2010519f
TN
867including an empty but not completely pruned target,
868can lead to corruption of the mirroring target.
4567021b 869.It Cm unique-uuid= Ns Ar uuid
2010519f
TN
870Set the unique UUID for this file system.
871This UUID should not be used anywhere else,
872even on exact copies of the file system.
4567021b 873.It Cm label= Ns Ar string
b4448f1a 874Set a descriptive label for this file system.
4567021b 875.It Cm snapshots= Ns Ar string
226f3799
TN
876Specify the snapshots directory which
877.Nm
4567021b 878.Cm cleanup
2010519f 879will use to manage this PFS.
f85afb25
TN
880.Bl -tag -width indent
881.It Nm HAMMER No version 2-
2010519f 882The snapshots directory does not need to be configured for
226f3799
TN
883PFS masters and will default to
884.Pa <pfs>/snapshots .
ff1c9800
MD
885.Pp
886PFS slaves are mirroring slaves so you cannot configure a snapshots
887directory on the slave itself to be managed by the slave's machine.
226f3799
TN
888In fact, the slave will likely have a
889.Pa snapshots
890sub-directory mirrored
ff1c9800 891from the master, but that directory contains the configuration the master
226f3799 892is using for its copy of the file system, not the configuration that we
ff1c9800
MD
893want to use for our slave.
894.Pp
226f3799
TN
895It is recommended that
896.Pa <fs>/var/slaves/<name>
897be configured for a PFS slave, where
898.Pa <fs>
899is the base
900.Nm HAMMER
901file system, and
902.Pa <name>
903is an appropriate label.
f85afb25
TN
904.It Nm HAMMER No version 3+
905The snapshots directory does not need to be configured for PFS masters or
906slaves.
907The snapshots directory defaults to
908.Pa /var/hammer/<pfs>
909.Pa ( /var/hammer/root
910for root mount).
911.El
912.Pp
2010519f 913You can control snapshot retention on your slave independent of the master.
4567021b
TN
914.It Cm snapshots-clear
915Zero out the
916.Cm snapshots
917directory path for this PFS.
918.It Cm prune-min= Ns Ar N Ns Cm d
f85afb25
TN
919.It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \
920Ar hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss
e7f926a5
MD
921Set the minimum fine-grained data retention period.
922.Nm HAMMER
0bd7a37c
MD
923always retains fine-grained history up to the most recent snapshot.
924You can extend the retention period further by specifying a non-zero
4567021b
TN
925pruning minimum.
926Any snapshot softlinks within the retention period are ignored
927for the purposes of pruning (the fine grained history is retained).
928Number of days, hours, minutes and seconds are given as
929.Ar N , hh , mm
930and
931.Ar ss .
0bd7a37c
MD
932.Pp
933Because the transaction id in the snapshot softlink cannot be used
934to calculate a timestamp,
935.Nm HAMMER
4567021b
TN
936uses the earlier of the
937.Fa st_ctime
938or
939.Fa st_mtime
940field of the softlink to
0bd7a37c
MD
941determine which snapshots fall within the retention period.
942Users must be sure to retain one of these two fields when manipulating
943the softlink.
34ebae70 944.El
34bb69d8 945.\" ==== pfs-upgrade ====
4567021b 946.It Cm pfs-upgrade Ar dirpath
2010519f 947Upgrade a PFS from slave to master operation.
4567021b 948The PFS will be rolled back to the current end synchronization transaction id
2010519f 949(removing any partial synchronizations), and will then become writable.
34bb69d8
TN
950.Pp
951.Em WARNING!
952.Nm HAMMER
953currently supports only single masters and using
2010519f
TN
954this command can easily result in file system corruption
955if you don't know what you are doing.
34bb69d8
TN
956.Pp
957This directive will refuse to run if any programs have open descriptors
958in the PFS, including programs chdir'd into the PFS.
959.\" ==== pfs-downgrade ====
4567021b 960.It Cm pfs-downgrade Ar dirpath
2010519f
TN
961Downgrade a master PFS from master to slave operation
962The PFS becomes read-only and access will be locked to its
4567021b 963.Cm sync-end-tid .
34bb69d8
TN
964.Pp
965This directive will refuse to run if any programs have open descriptors
966in the PFS, including programs chdir'd into the PFS.
967.\" ==== pfs-destroy ====
4567021b 968.It Cm pfs-destroy Ar dirpath
34bb69d8
TN
969This permanently destroys a PFS.
970.Pp
971This directive will refuse to run if any programs have open descriptors
972in the PFS, including programs chdir'd into the PFS.
15fa4caf 973.\" ==== mirror-read ====
4567021b 974.It Cm mirror-read Ar filesystem Op Ar begin-tid
34ebae70 975Generate a mirroring stream to stdout.
48eadef9 976The stream ends when the transaction id space has been exhausted.
15fa4caf 977.\" ==== mirror-read-stream ====
4567021b 978.It Cm mirror-read-stream Ar filesystem Op Ar begin-tid
48eadef9
MD
979Generate a mirroring stream to stdout.
980Upon completion the stream is paused until new data is synced to the
981master, then resumed.
982Operation continues until the pipe is broken.
15fa4caf 983.\" ==== mirror-write ====
4567021b 984.It Cm mirror-write Ar filesystem
34bb69d8 985Take a mirroring stream on stdin.
34ebae70
MD
986.Pp
987This command will fail if the
4567021b 988.Cm shared-uuid
b4448f1a 989configuration field for the two file systems do not match.
01a72c9f
MD
990.Pp
991If the target PFS does not exist this command will ask you whether
992you want to create a compatible PFS slave for the target or not.
15fa4caf 993.\" ==== mirror-dump ====
4567021b 994.It Cm mirror-dump
15fa4caf 995A
4567021b 996.Cm mirror-read
15fa4caf 997can be piped into a
4567021b 998.Cm mirror-dump
2010519f 999to dump an ASCII representation of the mirroring stream.
15fa4caf 1000.\" ==== mirror-copy ====
4567021b 1001.\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem
f85afb25 1002.It Cm mirror-copy \
f6532f03
TN
1003Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1004Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
84082922 1005This is a shortcut which pipes a
4567021b 1006.Cm mirror-read
84082922 1007command to a
4567021b 1008.Cm mirror-write
2010519f
TN
1009command.
1010If a remote host specification is made the program forks a
6d9ab5c5 1011.Xr ssh 1
84082922 1012and execs the
4567021b 1013.Cm mirror-read
84082922 1014and/or
4567021b 1015.Cm mirror-write
84082922 1016on the appropriate host.
9c67b4d2 1017The source may be a master or slave PFS, and the target must be a slave PFS.
d4e5b69b 1018.Pp
9c67b4d2 1019This command also established full duplex communication and turns on
2010519f
TN
1020the two-way protocol feature which automatically negotiates transaction id
1021ranges without having to use a cyclefile.
84082922 1022If the operation completes successfully the target PFS's
4567021b 1023.Cm sync-end-tid
2010519f
TN
1024will be updated.
1025Note that you must re-chdir into the target PFS to see the updated information.
1026If you do not you will still be in the previous snapshot.
01a72c9f
MD
1027.Pp
1028If the target PFS does not exist this command will ask you whether
1029you want to create a compatible PFS slave for the target or not.
15fa4caf 1030.\" ==== mirror-stream ====
4567021b 1031.\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem
f85afb25 1032.It Cm mirror-stream \
f6532f03
TN
1033Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1034Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
48eadef9 1035This command works similarly to
4567021b 1036.Cm mirror-copy
e7f926a5
MD
1037but does not exit after the initial mirroring completes.
1038The mirroring operation will resume as changes continue to be made to the
1039master.
2010519f 1040The command is commonly used with
48eadef9
MD
1041.Fl i Ar delay
1042and
1043.Fl b Ar bandwidth
1044options to keep the mirroring target in sync with the source on a continuing
1045basis.
e7f926a5
MD
1046.Pp
1047If the pipe is broken the command will automatically retry after sleeping
4567021b
TN
1048for a short while.
1049The time slept will be 15 seconds plus the time given in the
0bd7a37c
MD
1050.Fl i
1051option.
e7f926a5
MD
1052.Pp
1053This command also detects the initial-mirroring case and spends some
1054time scanning the B-Tree to find good break points, allowing the initial
1055bulk mirroring operation to be broken down into about 20 separate pieces.
1056This means that the user can kill and restart the operation and it will
1057not have to start from scratch once it has gotten past the first chunk.
0bd7a37c
MD
1058The
1059.Fl B
1060option may be used to disable this feature and perform an initial bulk
1061transfer instead.
de1c0b31 1062.\" ==== version ====
4567021b 1063.It Cm version Ar filesystem
3f2565b9
SW
1064This command returns the
1065.Nm HAMMER
4567021b
TN
1066file system version for the specified
1067.Ar filesystem
1068as well as the range of versions supported in the kernel.
de1c0b31
MD
1069The
1070.Fl q
1071option may be used to remove the summary at the end.
1072.\" ==== version-upgrade ====
4567021b 1073.It Cm version-upgrade Ar filesystem Ar version Op Cm force
3f2565b9
SW
1074This command upgrades the
1075.Nm HAMMER
4567021b
TN
1076.Ar filesystem
1077to the specified
1078.Ar version .
1079Once upgraded a file system may not be downgraded.
1080If you wish to upgrade a file system to a version greater or equal to the
de1c0b31 1081work-in-progress version number you must specify the
4567021b 1082.Cm force
de1c0b31
MD
1083directive.
1084Use of WIP versions should be relegated to testing and may require wiping
f6532f03 1085the file system as development progresses, even though the WIP version might
de1c0b31
MD
1086not change.
1087.Pp
4567021b
TN
1088.Em NOTE!
1089This command operates on the entire
3f2565b9 1090.Nm HAMMER
4567021b 1091file system and is not a per PFS operation.
3f2565b9 1092All PFS's will be affected.
de1c0b31
MD
1093.Bl -tag -width indent
1094.It 1
3f2565b9
SW
1095.Dx 2.0
1096default version, first
1097.Nm HAMMER
1098release.
de1c0b31 1099.It 2
f6532f03
TN
1100.Dx 2.3 .
1101New directory entry layout.
4567021b 1102This version is using a new directory hash key.
16265794 1103.It 3
856bc468 1104.Dx 2.5 .
f6532f03 1105New snapshot management, using file system meta-data for saving
16265794
TN
1106configuration file and snapshots (transaction ids etc.).
1107Also default snapshots directory has changed.
1108.It 4
856bc468
TN
1109.Dx 2.5
1110default version.
1111New undo/flush, giving faster sync.
de1c0b31 1112.El
0dfeb6c8 1113.El
f51a18e7 1114.\".Sh EXAMPLES
4567021b 1115.Sh PSEUDO-FILESYSTEM (PFS) NOTES
b4448f1a
TN
1116The root of a PFS is not hooked into the primary
1117.Nm HAMMER
2010519f 1118file system as a directory.
b4448f1a
TN
1119Instead,
1120.Nm HAMMER
4567021b
TN
1121creates a special softlink called
1122.Ql @@PFS%05d
1123(exactly 10 characters long) in the primary
b4448f1a
TN
1124.Nm HAMMER
1125file system.
1126.Nm HAMMER
1127then modifies the contents of the softlink as read by
9c67b4d2 1128.Xr readlink 2 ,
84082922 1129and thus what you see with an
16265794 1130.Nm ls
84082922 1131command or if you were to
16265794 1132.Nm cd
84082922 1133into the link.
9c67b4d2
MD
1134If the PFS is a master the link reflects the current state of the PFS.
1135If the PFS is a slave the link reflects the last completed snapshot, and the
1136contents of the link will change when the next snapshot is completed, and
1137so forth.
1138.Pp
2010519f 1139The
9c67b4d2 1140.Nm
2010519f 1141utility employs numerous safeties to reduce user foot-shooting.
9c67b4d2 1142The
4567021b 1143.Cm mirror-copy
9c67b4d2 1144directive requires that the target be configured as a slave and that the
4567021b 1145.Cm shared-uuid
9c67b4d2 1146field of the mirroring source and target match.
bf2c6489 1147.Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2
16265794 1148This upgrade changes the way directory entries are stored.
f6532f03 1149It is possible to upgrade a V1 file system to V2 in place, but
bf2c6489
MD
1150directories created prior to the upgrade will continue to use
1151the old layout.
1152.Pp
1153Note that the slave mirroring code in the target kernel had bugs in
1154V1 which can create an incompatible root directory on the slave.
16265794
TN
1155Do not mix a
1156.Nm HAMMER
1157master created after the upgrade with a
1158.Nm HAMMER
bf2c6489
MD
1159slave created prior to the upgrade.
1160.Pp
1161Any directories created after upgrading will use a new layout.
1162.Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3
16265794 1163This upgrade adds meta-data elements to the B-Tree.
f6532f03 1164It is possible to upgrade a V2 file system to V3 in place.
16265794
TN
1165After issuing the upgrade be sure to run a
1166.Nm
1167.Cm cleanup
1168to perform post-upgrade tasks.
bf2c6489 1169.Pp
16265794
TN
1170After making this upgrade running a
1171.Nm
1172.Cm cleanup
1173will move the
1174.Pa <pfs>/snapshots
bf2c6489 1175directory for each PFS mount into
16265794
TN
1176.Pa /var/hammer/<pfs> .
1177A
1178.Nm HAMMER
1179root mount will migrate
bf2c6489
MD
1180.Pa /snapshots
1181into
1182.Pa /var/hammer/root .
1183Migration occurs only once and only if you have not specified
16265794
TN
1184a snapshots directory in the PFS configuration.
1185If you have specified a snapshots directory in the PFS configuration no
bf2c6489
MD
1186automatic migration will occur.
1187.Pp
1188For slaves, if you desire, you can migrate your snapshots
1189config to the new location manually and then clear the
1190snapshot directory configuration in the slave PFS.
1191The new snapshots hierarchy is designed to work with
1192both master and slave PFSs equally well.
1193.Pp
f6532f03 1194In addition, the old config file will be moved to file system meta-data,
16265794
TN
1195editable via the new
1196.Nm
bf2c6489 1197.Cm viconfig
16265794
TN
1198directive.
1199The old config file will be deleted.
bf2c6489
MD
1200Migration occurs only once.
1201.Pp
f6532f03 1202The V3 file system has new
bf2c6489
MD
1203.Cm snap*
1204directives for creating snapshots.
1205All snapshot directives, including the original, will create
1206meta-data entries for the snapshots and the pruning code will
1207automatically incorporate these entries into its list and
1208expire them the same way it expires softlinks.
16265794 1209If you by accident blow away your snapshot softlinks you can use the
bf2c6489 1210.Cm snapls
f6532f03 1211directive to get a definitive list from the file system meta-data and
bf2c6489 1212regenerate them from that list.
92ed14a3 1213.Pp
16265794
TN
1214.Em WARNING!
1215If you are using
1216.Nm
f6532f03 1217to backup file systems your scripts may be using the
92ed14a3 1218.Cm synctid
16265794
TN
1219directive to generate transaction ids.
1220This directive does not create a snapshot.
1221You will have to modify your scripts to use the
92ed14a3
MD
1222.Cm snapq
1223directive to generate the linkbuf for the softlink you create, or
1224use one of the other
1225.Cm snap*
1226directives.
1227The older
1228.Cm snapshot
1229directive will continue to work as expected and in V3 it will also
f6532f03 1230record the snapshot transaction id in file system meta-data.
16265794
TN
1231You may also want to make use of the new
1232.Ar note
1233tag for the meta-data.
92ed14a3 1234.Pp
16265794
TN
1235.Em WARNING!
1236If you used to remove snapshot softlinks with
92ed14a3
MD
1237.Nm rm
1238you should probably start using the
1239.Cm snaprm
1240directive instead to also remove the related meta-data.
1241The pruning code scans the meta-data so just removing the
1242softlink is not sufficient.
856bc468
TN
1243.Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4
1244This upgrade changes undo/flush, giving faster sync.
1245It is possible to upgrade a V3 file system to V4 in place.
1246This upgrade reformats the UNDO FIFO (typically 1GB), so upgrade might take
1247a minute or two depending.
1248.Pp
1249Version 4 allows the UNDO FIFO to be flushed without also having
1250to flush the volume header, removing 2 of the 4 disk syncs typically
1251required for an fsync() and removing 1 of the 2 disk syncs typically
1252required for a flush sequence.
16265794
TN
1253.Sh EXIT STATUS
1254.Ex -std
226f3799
TN
1255.Sh FILES
1256.Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
4567021b 1257.It Pa <pfs>/snapshots
226f3799 1258default per PFS snapshots directory
16265794
TN
1259.Nm ( HAMMER
1260VERSION 2-)
1261.It Pa /var/hammer/<pfs>
1262default per PFS snapshots directory (not root)
1263.Nm ( HAMMER
1264VERSION 3+)
1265.It Pa /var/hammer/root
1266default snapshots directory for root directory
1267.Nm ( HAMMER
1268VERSION 3+)
226f3799 1269.It Pa <snapshots>/config
4567021b 1270per PFS
226f3799 1271.Nm
4567021b 1272.Cm cleanup
226f3799 1273configuration file
16265794
TN
1274.Nm ( HAMMER
1275VERSION 2-)
226f3799
TN
1276.It Pa <fs>/var/slaves/<name>
1277recommended slave PFS snapshots directory
16265794
TN
1278.Nm ( HAMMER
1279VERSION 2-)
226f3799 1280.El
0dfeb6c8 1281.Sh SEE ALSO
4567021b 1282.Xr ssh 1 ,
84082922 1283.Xr undo 1 ,
b4448f1a 1284.Xr HAMMER 5 ,
e0331f4f 1285.Xr periodic.conf 5 ,
84082922 1286.Xr mount_hammer 8 ,
bb8e52c0 1287.Xr mount_null 8 ,
0dfeb6c8
MD
1288.Xr newfs_hammer 8
1289.Sh HISTORY
1290The
1291.Nm
1292utility first appeared in
1293.Dx 1.11 .
1294.Sh AUTHORS
1295.An Matthew Dillon Aq dillon@backplane.com