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