xref: /dflybsd-src/sbin/hammer/hammer.8 (revision d4155bf40214a508c4a41d2a26d0b12e900bd828)
10dfeb6c8SMatthew Dillon.\" Copyright (c) 2007 The DragonFly Project.  All rights reserved.
20dfeb6c8SMatthew Dillon.\"
30dfeb6c8SMatthew Dillon.\" This code is derived from software contributed to The DragonFly Project
40dfeb6c8SMatthew Dillon.\" by Matthew Dillon <dillon@backplane.com>
50dfeb6c8SMatthew Dillon.\"
60dfeb6c8SMatthew Dillon.\" Redistribution and use in source and binary forms, with or without
70dfeb6c8SMatthew Dillon.\" modification, are permitted provided that the following conditions
80dfeb6c8SMatthew Dillon.\" are met:
90dfeb6c8SMatthew Dillon.\"
100dfeb6c8SMatthew Dillon.\" 1. Redistributions of source code must retain the above copyright
110dfeb6c8SMatthew Dillon.\"    notice, this list of conditions and the following disclaimer.
120dfeb6c8SMatthew Dillon.\" 2. Redistributions in binary form must reproduce the above copyright
130dfeb6c8SMatthew Dillon.\"    notice, this list of conditions and the following disclaimer in
140dfeb6c8SMatthew Dillon.\"    the documentation and/or other materials provided with the
150dfeb6c8SMatthew Dillon.\"    distribution.
160dfeb6c8SMatthew Dillon.\" 3. Neither the name of The DragonFly Project nor the names of its
170dfeb6c8SMatthew Dillon.\"    contributors may be used to endorse or promote products derived
180dfeb6c8SMatthew Dillon.\"    from this software without specific, prior written permission.
190dfeb6c8SMatthew Dillon.\"
200dfeb6c8SMatthew Dillon.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
210dfeb6c8SMatthew Dillon.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
220dfeb6c8SMatthew Dillon.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
230dfeb6c8SMatthew Dillon.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
240dfeb6c8SMatthew Dillon.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
250dfeb6c8SMatthew Dillon.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
260dfeb6c8SMatthew Dillon.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
270dfeb6c8SMatthew Dillon.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
280dfeb6c8SMatthew Dillon.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
290dfeb6c8SMatthew Dillon.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
300dfeb6c8SMatthew Dillon.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
310dfeb6c8SMatthew Dillon.\" SUCH DAMAGE.
320dfeb6c8SMatthew Dillon.\"
332458c6f4SSascha Wildner.Dd December 31, 2017
340dfeb6c8SMatthew Dillon.Dt HAMMER 8
350dfeb6c8SMatthew Dillon.Os
360dfeb6c8SMatthew Dillon.Sh NAME
370dfeb6c8SMatthew Dillon.Nm hammer
380dfeb6c8SMatthew Dillon.Nd HAMMER file system utility
390dfeb6c8SMatthew Dillon.Sh SYNOPSIS
400dfeb6c8SMatthew Dillon.Nm
414567021bSThomas Nikolajsen.Fl h
424567021bSThomas Nikolajsen.Nm
435e1e1454STomohiro Kusumi.Op Fl 2ABFqrvXy
4448eadef9SMatthew Dillon.Op Fl b Ar bandwidth
455f22d366SThomas Nikolajsen.Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
4669f5a58cSMatthew Dillon.Op Fl R Ar restrictcmd
4769f5a58cSMatthew Dillon.Op Fl T Ar restrictpath
48d7ae405cSMatthew Dillon.Op Fl c Ar cyclefile
49269cdd19SMatthew Dillon.Op Fl e Ar scoreboardfile
50f6532f03SThomas Nikolajsen.Op Fl f Ar blkdevs
516d9ab5c5SSascha Wildner.\" .Op Fl s Ar linkpath
5248eadef9SMatthew Dillon.Op Fl i Ar delay
536c45ca3eSMatthew Dillon.Op Fl p Ar ssh-port
543d7b2393SMatthew Dillon.Op Fl S Ar splitsize
555f22d366SThomas Nikolajsen.Op Fl t Ar seconds
56fbe1c665SMatthew Dillon.Op Fl m Ar memlimit
570dfeb6c8SMatthew Dillon.Ar command
5834bb69d8SThomas Nikolajsen.Op Ar argument ...
590dfeb6c8SMatthew Dillon.Sh DESCRIPTION
606d9ab5c5SSascha WildnerThis manual page documents the
610dfeb6c8SMatthew Dillon.Nm
626d9ab5c5SSascha Wildnerutility which provides miscellaneous functions related to managing a
63b4448f1aSThomas Nikolajsen.Nm HAMMER
64b4448f1aSThomas Nikolajsenfile system.
65b4448f1aSThomas NikolajsenFor a general introduction to the
66b4448f1aSThomas Nikolajsen.Nm HAMMER
67b4448f1aSThomas Nikolajsenfile system, its features, and
686d9ab5c5SSascha Wildnerexamples on how to set up and maintain one, see
69b4448f1aSThomas Nikolajsen.Xr HAMMER 5 .
700dfeb6c8SMatthew Dillon.Pp
710dfeb6c8SMatthew DillonThe options are as follows:
720dfeb6c8SMatthew Dillon.Bl -tag -width indent
73d4e5b69bSMatthew Dillon.It Fl 2
74d4e5b69bSMatthew DillonTell the mirror commands to use a 2-way protocol, which allows
752010519fSThomas Nikolajsenautomatic negotiation of transaction id ranges.
762010519fSThomas NikolajsenThis option is automatically enabled by the
774567021bSThomas Nikolajsen.Cm mirror-copy
78d4e5b69bSMatthew Dilloncommand.
795e1e1454STomohiro Kusumi.It Fl A
805e1e1454STomohiro KusumiMake per PFS commands perform on all PFSs if possible.
815e1e1454STomohiro KusumiIf the command supports this option, it targets all PFSs of the
825e1e1454STomohiro Kusumi.Nm HAMMER
835e1e1454STomohiro Kusumifilesystem that the
845e1e1454STomohiro Kusumi.Ar filesystem
855e1e1454STomohiro Kusumiargument (of that command) belongs to.
865e1e1454STomohiro KusumiCurrently
875e1e1454STomohiro Kusumi.Cm rebalance ,
885e1e1454STomohiro Kusumi.Cm reblock ,
895e1e1454STomohiro Kusumi.Cm reblock-btree ,
905e1e1454STomohiro Kusumi.Cm reblock-inodes ,
915e1e1454STomohiro Kusumi.Cm reblock-dirs
925e1e1454STomohiro Kusumiand
935e1e1454STomohiro Kusumi.Cm reblock-data
945e1e1454STomohiro Kusumicommands support this option.
955e1e1454STomohiro KusumiIf the command does not support this option, it does nothing.
965f22d366SThomas Nikolajsen.It Fl B
975f22d366SThomas NikolajsenBulk transfer.
985f22d366SThomas Nikolajsen.Cm Mirror-stream
995f22d366SThomas Nikolajsenwill not attempt to break-up large initial bulk transfers into smaller
1005f22d366SThomas Nikolajsenpieces.
1015f22d366SThomas NikolajsenThis can save time but if the link is lost in the middle of the
1025f22d366SThomas Nikolajseninitial bulk transfer you will have to start over from scratch.
1035f22d366SThomas NikolajsenFor more information see the
1045f22d366SThomas Nikolajsen.Fl S
1055f22d366SThomas Nikolajsenoption.
10648eadef9SMatthew Dillon.It Fl b Ar bandwidth
10748eadef9SMatthew DillonSpecify a bandwidth limit in bytes per second for mirroring streams.
10848eadef9SMatthew DillonThis option is typically used to prevent batch mirroring operations from
10948eadef9SMatthew Dillonloading down the machine.
11015fa4cafSThomas NikolajsenThe bandwidth may be suffixed with
1114567021bSThomas Nikolajsen.Cm k , m ,
11215fa4cafSThomas Nikolajsenor
1134567021bSThomas Nikolajsen.Cm g
1142010519fSThomas Nikolajsento specify values in kilobytes, megabytes, and gigabytes per second.
115224ac2f2SMatthew DillonIf no suffix is specified, bytes per second is assumed.
116527a7bdbSMatthew Dillon.Pp
117527a7bdbSMatthew DillonUnfortunately this is only applicable to the pre-compression bandwidth
118527a7bdbSMatthew Dillonwhen compression is used, so a better solution would probably be to
119527a7bdbSMatthew Dillonuse a
120527a7bdbSMatthew Dillon.Xr ipfw 8
121527a7bdbSMatthew Dillonpipe or a
122527a7bdbSMatthew Dillon.Xr pf 4
123527a7bdbSMatthew Dillonqueue.
1243d7b2393SMatthew Dillon.It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
1253d7b2393SMatthew DillonSet the memory cache size for any raw
1263d7b2393SMatthew Dillon.Tn I/O .
127aaf93065SThomas NikolajsenThe default is 16MB.
1283d7b2393SMatthew DillonA suffix of
1293d7b2393SMatthew Dillon.Cm k
1303d7b2393SMatthew Dillonfor kilobytes and
1313d7b2393SMatthew Dillon.Cm m
1323d7b2393SMatthew Dillonfor megabytes is allowed,
1333d7b2393SMatthew Dillonelse the cache size is specified in bytes.
1343d7b2393SMatthew Dillon.Pp
1353d7b2393SMatthew DillonThe read-behind/read-ahead defaults to 4
1363d7b2393SMatthew Dillon.Nm HAMMER
1373d7b2393SMatthew Dillonblocks.
1383d7b2393SMatthew Dillon.Pp
1393d7b2393SMatthew DillonThis option is typically only used with diagnostic commands
1403d7b2393SMatthew Dillonas kernel-supported commands will use the kernel's buffer cache.
14169f5a58cSMatthew Dillon.It Fl R Ar restrictcmd
14269f5a58cSMatthew DillonThis option is used by hammer ssh-remote to restrict the command later
143*d4155bf4SSascha Wildneron in the argument list.
144*d4155bf4SSascha WildnerMultiple commands may be specified, separated by a comma (all one argument).
14569f5a58cSMatthew Dillon.It Fl T Ar restrictpath
14669f5a58cSMatthew DillonThis option is used by hammer ssh-remote to restrict the filesystem path
14769f5a58cSMatthew Dillonspecified later on in the argument list.
1485f22d366SThomas Nikolajsen.It Fl c Ar cyclefile
1495f22d366SThomas NikolajsenWhen pruning, rebalancing or reblocking you can tell the utility
1505f22d366SThomas Nikolajsento start at the object id stored in the specified file.
1515f22d366SThomas NikolajsenIf the file does not exist
1525f22d366SThomas Nikolajsen.Nm
1535f22d366SThomas Nikolajsenwill start at the beginning.
1545f22d366SThomas NikolajsenIf
1555f22d366SThomas Nikolajsen.Nm
1565f22d366SThomas Nikolajsenis told to run for a specific period of time
1575f22d366SThomas Nikolajsen.Pq Fl t
1585f22d366SThomas Nikolajsenand is unable to complete the operation it will write out
1595f22d366SThomas Nikolajsenthe current object id so the next run can pick up where it left off.
1605f22d366SThomas NikolajsenIf
1615f22d366SThomas Nikolajsen.Nm
1625f22d366SThomas Nikolajsenruns to completion it will delete
1635f22d366SThomas Nikolajsen.Ar cyclefile .
164269cdd19SMatthew Dillon.It Fl e Ar scoreboardfile
165269cdd19SMatthew DillonUpdate scoreboard file with progress, primarily used by mirror-stream.
1665f22d366SThomas Nikolajsen.It Fl F
1675f22d366SThomas NikolajsenForce operation.
1685f22d366SThomas NikolajsenE.g.\&
1695f22d366SThomas Nikolajsen.Cm cleanup
1705f22d366SThomas Nikolajsenwill not check that time period has elapsed if this option is given.
1715f22d366SThomas Nikolajsen.It Fl f Ar blkdevs
1725f22d366SThomas NikolajsenSpecify the volumes making up a
1735f22d366SThomas Nikolajsen.Nm HAMMER
1745f22d366SThomas Nikolajsenfile system.
1755f22d366SThomas Nikolajsen.Ar Blkdevs
1765f22d366SThomas Nikolajsenis a colon-separated list of devices, each specifying a
1775f22d366SThomas Nikolajsen.Nm HAMMER
1785f22d366SThomas Nikolajsenvolume.
1795f22d366SThomas Nikolajsen.It Fl h
1805f22d366SThomas NikolajsenShow usage.
1815f22d366SThomas Nikolajsen.It Fl i Ar delay
1825f22d366SThomas NikolajsenSpecify delay in seconds for
1835f22d366SThomas Nikolajsen.Cm mirror-read-stream .
1845f22d366SThomas NikolajsenWhen maintaining a streaming mirroring this option specifies the
1855f22d366SThomas Nikolajsenminimum delay after a batch ends before the next batch is allowed
1865f22d366SThomas Nikolajsento start.
1875f22d366SThomas NikolajsenThe default is five seconds.
188fbe1c665SMatthew Dillon.It Fl m Ar memlimit
189fbe1c665SMatthew DillonSpecify the maximum amount of memory
190fbe1c665SMatthew Dillon.Nm
191fbe1c665SMatthew Dillonwill allocate during a dedup pass.
1920362ff63SSascha WildnerSpecify a suffix 'm', 'g', or 't' for megabytes, gigabytes, or terabytes.
193fbe1c665SMatthew DillonBy default
194fbe1c665SMatthew Dillon.Nm
195fbe1c665SMatthew Dillonwill allocate up to 1G of ram to hold CRC/SHA tables while running dedup.
196fbe1c665SMatthew DillonWhen the limit is reached the dedup code restricts the range of CRCs to
197fbe1c665SMatthew Dillonkeep memory use within bounds and runs multiple passes as necessary until
198fbe1c665SMatthew Dillonthe entire filesystem has been deduped.
1995f22d366SThomas Nikolajsen.It Fl p Ar ssh-port
2005f22d366SThomas NikolajsenPass the
2015f22d366SThomas Nikolajsen.Fl p Ar ssh-port
2025f22d366SThomas Nikolajsenoption to
2035f22d366SThomas Nikolajsen.Xr ssh 1
2045f22d366SThomas Nikolajsenwhen using a remote
2055f22d366SThomas Nikolajsenspecification for the source and/or destination.
2065f22d366SThomas Nikolajsen.It Fl q
2075f22d366SThomas NikolajsenDecrease verboseness.
2085f22d366SThomas NikolajsenMay be specified multiple times.
2095f22d366SThomas Nikolajsen.It Fl r
2105f22d366SThomas NikolajsenSpecify recursion for those commands which support it.
2113d7b2393SMatthew Dillon.It Fl S Ar splitsize
2123d7b2393SMatthew DillonSpecify the bulk splitup size in bytes for mirroring streams.
213aaf93065SThomas NikolajsenWhen a
214aaf93065SThomas Nikolajsen.Cm mirror-stream
215aaf93065SThomas Nikolajsenis first started
2163d7b2393SMatthew Dillon.Nm
2173d7b2393SMatthew Dillonwill do an initial run-through of the data to calculate good
21827eff55eSMatthew Dillontransaction ids to cut up the bulk transfers, creating
2193d7b2393SMatthew Dillonrestart points in case the stream is interrupted.
2203d7b2393SMatthew DillonIf we don't do this and the stream is interrupted it might
2213d7b2393SMatthew Dillonhave to start all over again.
2225f22d366SThomas NikolajsenThe default is a
2235f22d366SThomas Nikolajsen.Ar splitsize
2245f22d366SThomas Nikolajsenof 4GB.
2253d7b2393SMatthew Dillon.Pp
2263d7b2393SMatthew DillonAt the moment the run-through is disk-bandwidth-heavy but some
2273d7b2393SMatthew Dillonfuture version will limit the run-through to just the B-Tree
2283d7b2393SMatthew Dillonrecords and not the record data.
2293d7b2393SMatthew Dillon.Pp
2303d7b2393SMatthew DillonThe splitsize may be suffixed with
2313d7b2393SMatthew Dillon.Cm k , m ,
2323d7b2393SMatthew Dillonor
2333d7b2393SMatthew Dillon.Cm g
234aaf93065SThomas Nikolajsento specify values in kilobytes, megabytes, or gigabytes.
2353d7b2393SMatthew DillonIf no suffix is specified, bytes is assumed.
236527a7bdbSMatthew Dillon.Pp
237527a7bdbSMatthew DillonWhen mirroring very large filesystems the minimum recommended
2385f22d366SThomas Nikolajsensplit size is 4GB.
239527a7bdbSMatthew DillonA small split size may wind up generating a great deal of overhead
240527a7bdbSMatthew Dillonbut very little actual incremental data and is not recommended.
2415f22d366SThomas Nikolajsen.It Fl t Ar seconds
2425f22d366SThomas NikolajsenSpecify timeout in seconds.
2435f22d366SThomas NikolajsenWhen pruning, rebalancing, reblocking or mirror-reading
2445f22d366SThomas Nikolajsenyou can tell the utility to stop after a certain period of time.
2455f22d366SThomas NikolajsenA value of 0 means unlimited.
2465f22d366SThomas NikolajsenThis option is used along with the
2475f22d366SThomas Nikolajsen.Fl c Ar cyclefile
2485f22d366SThomas Nikolajsenoption to prune, rebalance or reblock incrementally.
2495f22d366SThomas Nikolajsen.It Fl v
2505f22d366SThomas NikolajsenIncrease verboseness.
2515f22d366SThomas NikolajsenMay be specified multiple times.
2523a998207SMatthew Dillon.It Fl X
253aaf93065SThomas NikolajsenEnable compression for any remote ssh specifications.
254aaf93065SThomas NikolajsenThis option is typically used with the mirroring directives.
255aaf93065SThomas Nikolajsen.It Fl y
2565f22d366SThomas NikolajsenForce
2575f22d366SThomas Nikolajsen.Dq yes
2585f22d366SThomas Nikolajsenfor interactive questions.
2590dfeb6c8SMatthew Dillon.El
2600dfeb6c8SMatthew Dillon.Pp
2610dfeb6c8SMatthew DillonThe commands are as follows:
2620dfeb6c8SMatthew Dillon.Bl -tag -width indent
26315fa4cafSThomas Nikolajsen.\" ==== synctid ====
2644567021bSThomas Nikolajsen.It Cm synctid Ar filesystem Op Cm quick
2655f22d366SThomas NikolajsenGenerate a guaranteed, formal 64-bit transaction id representing the
266b4448f1aSThomas Nikolajsencurrent state of the specified
267b4448f1aSThomas Nikolajsen.Nm HAMMER
2682010519fSThomas Nikolajsenfile system.
2692010519fSThomas NikolajsenThe file system will be synced to the media.
270367431cfSMatthew Dillon.Pp
271367431cfSMatthew DillonIf the
2724567021bSThomas Nikolajsen.Cm quick
273367431cfSMatthew Dillonkeyword is specified the file system will be soft-synced, meaning that a
274367431cfSMatthew Dilloncrash might still undo the state of the file system as of the transaction
275367431cfSMatthew Dillonid returned but any new modifications will occur after the returned
276367431cfSMatthew Dillontransaction id as expected.
277bf2c6489SMatthew Dillon.Pp
27816265794SThomas NikolajsenThis operation does not create a snapshot.
27916265794SThomas NikolajsenIt is meant to be used
280bf2c6489SMatthew Dillonto track temporary fine-grained changes to a subset of files and
28116265794SThomas Nikolajsenwill only remain valid for
28216265794SThomas Nikolajsen.Ql @@
2835f22d366SThomas Nikolajsenaccess purposes for the
284bf2c6489SMatthew Dillon.Cm prune-min
28516265794SThomas Nikolajsenperiod configured for the PFS.
28616265794SThomas NikolajsenIf you desire a real snapshot then the
287bf2c6489SMatthew Dillon.Cm snapq
288bf2c6489SMatthew Dillondirective may be what you are looking for.
28915fa4cafSThomas Nikolajsen.\" ==== bstats ====
2904567021bSThomas Nikolajsen.It Cm bstats Op Ar interval
291b4448f1aSThomas NikolajsenOutput
292b4448f1aSThomas Nikolajsen.Nm HAMMER
293aaf93065SThomas NikolajsenB-Tree statistics until interrupted.
29484082922SThomas NikolajsenPause
29584082922SThomas Nikolajsen.Ar interval
296b4448f1aSThomas Nikolajsenseconds between each display.
29784082922SThomas NikolajsenThe default interval is one second.
29815fa4cafSThomas Nikolajsen.\" ==== iostats ====
2994567021bSThomas Nikolajsen.It Cm iostats Op Ar interval
300b4448f1aSThomas NikolajsenOutput
301b4448f1aSThomas Nikolajsen.Nm HAMMER
3024567021bSThomas Nikolajsen.Tn I/O
3034567021bSThomas Nikolajsenstatistics until interrupted.
30484082922SThomas NikolajsenPause
30584082922SThomas Nikolajsen.Ar interval
306b4448f1aSThomas Nikolajsenseconds between each display.
30784082922SThomas NikolajsenThe default interval is one second.
3083f760d89STomohiro Kusumi.\" ==== stats ====
3093f760d89STomohiro Kusumi.It Cm stats Op Ar interval
3103f760d89STomohiro KusumiOutput
3113f760d89STomohiro Kusumi.Nm HAMMER
3123f760d89STomohiro KusumiB-Tree and
3133f760d89STomohiro Kusumi.Tn I/O
3143f760d89STomohiro Kusumistatistics until interrupted.
3153f760d89STomohiro KusumiPause
3163f760d89STomohiro Kusumi.Ar interval
3173f760d89STomohiro Kusumiseconds between each display.
3183f760d89STomohiro KusumiThe default interval is one second.
31915fa4cafSThomas Nikolajsen.\" ==== history ====
3208907a51bSTomohiro Kusumi.It Cm history Ns Oo Cm @ Ns Ar offset Ns Oo Cm \&, Ns Ar length Oc Oc Ar path Ns Oo Cm @ Ns Ar offset Ns Oo Cm \&, Ns Ar length Oc Oc Ar ...
3215f22d366SThomas NikolajsenShow the modification history for inode and data of
322b4448f1aSThomas Nikolajsen.Nm HAMMER
3235f22d366SThomas Nikolajsenfiles.
3245f22d366SThomas NikolajsenIf
3255f22d366SThomas Nikolajsen.Ar offset
3265f22d366SThomas Nikolajsenis given history is shown for data block at given offset,
3275f22d366SThomas Nikolajsenotherwise history is shown for inode.
3285f22d366SThomas NikolajsenIf
3295f22d366SThomas Nikolajsen.Fl v
3305f22d366SThomas Nikolajsenis specified
3315f22d366SThomas Nikolajsen.Ar length
3325f22d366SThomas Nikolajsendata bytes at given offset are dumped for each version,
3335f22d366SThomas Nikolajsendefault is 32.
3345f22d366SThomas Nikolajsen.Pp
3355f22d366SThomas NikolajsenFor each
3365f22d366SThomas Nikolajsen.Ar path
3375f22d366SThomas Nikolajsenthis directive shows object id and sync status,
3385f22d366SThomas Nikolajsenand for each object version it shows transaction id and time stamp.
3395f22d366SThomas NikolajsenFiles has to exist for this directive to be applicable,
3405f22d366SThomas Nikolajsento track inodes which has been deleted or renamed see
3415f22d366SThomas Nikolajsen.Xr undo 1 .
3428907a51bSTomohiro Kusumi.Pp
3438907a51bSTomohiro KusumiDifferent
3448907a51bSTomohiro Kusumi.Ar offset
3458907a51bSTomohiro Kusumiand
3468907a51bSTomohiro Kusumi.Ar length
3478907a51bSTomohiro Kusumican be used for each
3488907a51bSTomohiro Kusumi.Ar path
3498907a51bSTomohiro Kusumiby specifying
3508907a51bSTomohiro Kusumi.Ar offset
3518907a51bSTomohiro Kusumiand
3528907a51bSTomohiro Kusumi.Ar length
3538907a51bSTomohiro Kusumifor each
3548907a51bSTomohiro Kusumi.Ar path .
355b46b99bfSMatthew Dillon.\" ==== blockmap ====
3564567021bSThomas Nikolajsen.It Cm blockmap
3574567021bSThomas NikolajsenDump the blockmap for the file system.
3584567021bSThomas NikolajsenThe
3594567021bSThomas Nikolajsen.Nm HAMMER
3604567021bSThomas Nikolajsenblockmap is two-layer
361b46b99bfSMatthew Dillonblockmap representing the maximum possible file system size of 1 Exabyte.
362b46b99bfSMatthew DillonNeedless to say the second layer is only present for blocks which exist.
3634567021bSThomas Nikolajsen.Nm HAMMER Ns 's
3644567021bSThomas Nikolajsenblockmap represents 8-Megabyte blocks, called big-blocks.
3654567021bSThomas NikolajsenEach big-block has an append
366b46b99bfSMatthew Dillonpoint, a free byte count, and a typed zone id which allows content to be
367b46b99bfSMatthew Dillonreverse engineered to some degree.
368b46b99bfSMatthew Dillon.Pp
3694567021bSThomas NikolajsenIn
3704567021bSThomas Nikolajsen.Nm HAMMER
371aaf93065SThomas Nikolajsenallocations are essentially appended to a selected big-block using
3724567021bSThomas Nikolajsenthe append offset and deducted from the free byte count.
3734567021bSThomas NikolajsenWhen space is freed the free byte count is adjusted but
3744567021bSThomas Nikolajsen.Nm HAMMER
3754567021bSThomas Nikolajsendoes not track holes in big-blocks for reallocation.
3764567021bSThomas NikolajsenA big-block must be completely freed, either
377b46b99bfSMatthew Dillonthrough normal file system operations or through reblocking, before
378b46b99bfSMatthew Dillonit can be reused.
379b46b99bfSMatthew Dillon.Pp
380b46b99bfSMatthew DillonData blocks can be shared by deducting the space used from the free byte
381bb29b5d8SMatthew Dilloncount for each shared references.
3824567021bSThomas NikolajsenThis means the free byte count can legally go negative.
383b46b99bfSMatthew Dillon.Pp
384b46b99bfSMatthew DillonThis command needs the
3855f22d366SThomas Nikolajsen.Fl f Ar blkdevs
3865f22d366SThomas Nikolajsenoption.
3876ed4c886SMatthew Dillon.\" ==== checkmap ====
3886ed4c886SMatthew Dillon.It Cm checkmap
3896ed4c886SMatthew DillonCheck the blockmap allocation count.
3906ed4c886SMatthew Dillon.Nm
39150d83294STomohiro Kusumiwill scan the freemap, B-Tree, UNDO/REDO FIFO, then collect allocation information,
392f8589256STomohiro Kusumiand construct a blockmap in-memory.
3935f22d366SThomas NikolajsenIt will then check that blockmap against the on-disk blockmap.
394c71cab34SMatthew Dillon.Pp
395c71cab34SMatthew DillonThis command needs the
3965f22d366SThomas Nikolajsen.Fl f Ar blkdevs
3975f22d366SThomas Nikolajsenoption.
39815fa4cafSThomas Nikolajsen.\" ==== show ====
39934909d8eSTomohiro Kusumi.It Cm show Op Ar localization Ns Op Cm \&: Ns Ar object_id Ns Op Cm \&: Ns Ar rec_type Ns Op Cm \&: Ns Ar key Ns Op Cm \&: Ns Ar create_tid
400aaf93065SThomas NikolajsenDump the B-Tree.
4014567021bSThomas NikolajsenBy default this command will validate all B-Tree
402b46b99bfSMatthew Dillonlinkages and CRCs, including data CRCs, and will report the most verbose
403b46b99bfSMatthew Dilloninformation it can dig up.
40416265794SThomas NikolajsenAny errors will show up with a
40516265794SThomas Nikolajsen.Ql B
40616265794SThomas Nikolajsenin column 1 along with various
407b46b99bfSMatthew Dillonother error flags.
408b46b99bfSMatthew Dillon.Pp
4095f22d366SThomas NikolajsenIf you specify
4105f22d366SThomas Nikolajsen.Ar localization
4115f22d366SThomas Nikolajsenor
4125f22d366SThomas Nikolajsen.Ar localization Ns Cm \&: Ns Ar object_id
41334909d8eSTomohiro Kusumior
41434909d8eSTomohiro Kusumi.Ar localization Ns Cm \&: Ns Ar object_id Ns Cm \&: Ns Ar rec_type
41534909d8eSTomohiro Kusumior
41634909d8eSTomohiro Kusumi.Ar localization Ns Cm \&: Ns Ar object_id Ns Cm \&: Ns Ar rec_type Ns Cm \&: Ns Ar key
41734909d8eSTomohiro Kusumior
41834909d8eSTomohiro Kusumi.Ar localization Ns Cm \&: Ns Ar object_id Ns Cm \&: Ns Ar rec_type Ns Cm \&: Ns Ar key Ns Cm \&: Ns Ar create_tid
419f6532f03SThomas Nikolajsenthe dump will
420e7f926a5SMatthew Dillonsearch for the key printing nodes as it recurses down, and then
421aaf93065SThomas Nikolajsenwill iterate forwards.
422aaf93065SThomas NikolajsenThese fields are specified in HEX.
4238add7974STomohiro KusumiNote that the PFS id is the top 16 bits of the 32-bit localization
424aaf93065SThomas Nikolajsenfield so PFS#1 would be 00010000.
425e7f926a5SMatthew Dillon.Pp
426b46b99bfSMatthew DillonIf you use
427b46b99bfSMatthew Dillon.Fl q
428b46b99bfSMatthew Dillonthe command will report less information about the inode contents.
429b46b99bfSMatthew Dillon.Pp
430b46b99bfSMatthew DillonIf you use
431b46b99bfSMatthew Dillon.Fl qq
432b46b99bfSMatthew Dillonthe command will not report the content of the inode or other typed
433b46b99bfSMatthew Dillondata at all.
434b46b99bfSMatthew Dillon.Pp
435b46b99bfSMatthew DillonIf you use
436b46b99bfSMatthew Dillon.Fl qqq
437b46b99bfSMatthew Dillonthe command will not report volume header information, big-block fill
4384567021bSThomas Nikolajsenratios, mirror transaction ids, or report or check data CRCs.
439aaf93065SThomas NikolajsenB-Tree CRCs and linkages are still checked.
440b46b99bfSMatthew Dillon.Pp
4412010519fSThomas NikolajsenThis command needs the
4425f22d366SThomas Nikolajsen.Fl f Ar blkdevs
4435f22d366SThomas Nikolajsenoption.
444f6532f03SThomas Nikolajsen.\" ==== show-undo ====
445f6532f03SThomas Nikolajsen.It Cm show-undo
446f6532f03SThomas Nikolajsen.Nm ( HAMMER
447f6532f03SThomas NikolajsenVERSION 4+)
4485f22d366SThomas NikolajsenDump the UNDO/REDO map.
449f6532f03SThomas Nikolajsen.Pp
450f6532f03SThomas NikolajsenThis command needs the
4515f22d366SThomas Nikolajsen.Fl f Ar blkdevs
4525f22d366SThomas Nikolajsenoption.
45384082922SThomas Nikolajsen.\" .It Ar blockmap
454aaf93065SThomas Nikolajsen.\" Dump the B-Tree, record, large-data, and small-data blockmaps, showing
45584082922SThomas Nikolajsen.\" physical block assignments and free space percentages.
45669f5a58cSMatthew Dillon.\" ==== ssh-remote ====
45769f5a58cSMatthew Dillon.It Cm ssh-remote Ar command Ar targetdir
45869f5a58cSMatthew DillonUsed in a ssh authorized_keys line such as
45969f5a58cSMatthew Dilloncommand="/sbin/hammer ssh-remote mirror-read /fubarmount" ... to allow
46069f5a58cSMatthew Dillonmirror-read or mirror-write access to a particular subdirectory tree.
46169f5a58cSMatthew DillonThis way you do not have to give shell access to the remote box.
46269f5a58cSMatthew Dillon.Nm
46369f5a58cSMatthew Dillonwill obtain the original command line from the SSH_ORIGINAL_COMMAND
46469f5a58cSMatthew Dillonenvironment variable, validate it against the restriction, and then
46569f5a58cSMatthew Dillonre-exec hammer with the validated arguments.
46669f5a58cSMatthew Dillon.Pp
46769f5a58cSMatthew DillonThe remote hammer command does not allow the
46869f5a58cSMatthew Dillon.Fl c
46969f5a58cSMatthew Dillonor
47069f5a58cSMatthew Dillon.Fl f
47169f5a58cSMatthew Dillonoptions to be passed in.
472b9107f58SMatthew Dillon.\" ==== recover ====
4733d900665STomohiro Kusumi.It Cm recover Ar targetdir Op Cm full|quick
4745f22d366SThomas NikolajsenRecover data from a corrupted
4755f22d366SThomas Nikolajsen.Nm HAMMER
4765f22d366SThomas Nikolajsenfilesystem.
477b9107f58SMatthew DillonThis is a low level command which operates on the filesystem image and
4785f22d366SThomas Nikolajsenattempts to locate and recover files from a corrupted filesystem.
4795f22d366SThomas NikolajsenThe entire image is scanned linearly looking for B-Tree nodes.
4805f22d366SThomas NikolajsenAny node
4815f22d366SThomas Nikolajsenfound which passes its CRC test is scanned for file, inode, and directory
482b9107f58SMatthew Dillonfragments and the target directory is populated with the resulting data.
483b9107f58SMatthew Dillonfiles and directories in the target directory are initially named after
4842e27fe5dSSascha Wildnerthe object id and are renamed as fragmentary information is processed.
485b9107f58SMatthew Dillon.Pp
4865f22d366SThomas NikolajsenThis command keeps track of filename/object_id translations and may eat a
487b9107f58SMatthew Dillonconsiderably amount of memory while operating.
488b9107f58SMatthew Dillon.Pp
489b9107f58SMatthew DillonThis command is literally the last line of defense when it comes to
490b9107f58SMatthew Dillonrecovering data from a dead filesystem.
4914bb3dee9SSascha Wildner.Pp
492e819b271STomohiro KusumiIf the
4933d900665STomohiro Kusumi.Cm full
4943d900665STomohiro Kusumikeyword is specified, this command scans all the big-blocks within the
4953d900665STomohiro Kusumientire image, regardless of whether big-blocks contain active data or meta-data.
4963d900665STomohiro KusumiBy default, it linearly scans only up to the last big-block that contains
4973d900665STomohiro Kusumiactive data or meta-data, if such big-block is detectable.
4983d900665STomohiro Kusumi.Pp
4993d900665STomohiro KusumiIf the
500e819b271STomohiro Kusumi.Cm quick
501e819b271STomohiro Kusumikeyword is specified, this command only scans big-blocks that contain
502e819b271STomohiro KusumiB-Tree nodes and associated records, without linearly scanning the entire image.
503e819b271STomohiro KusumiThis may speed up the recovery process provided that big-blocks for
504e819b271STomohiro KusumiB-Tree nodes are not corrupted.
505e819b271STomohiro Kusumi.Pp
5064bb3dee9SSascha WildnerThis command needs the
5075f22d366SThomas Nikolajsen.Fl f Ar blkdevs
5085f22d366SThomas Nikolajsenoption.
5092eccaef5STomohiro Kusumi.\" ==== strip ====
5102eccaef5STomohiro Kusumi.It Cm strip
5112eccaef5STomohiro KusumiStrip
5122eccaef5STomohiro Kusumi.Nm HAMMER
5132eccaef5STomohiro Kusumifilesystem volume header and other meta-data by overwriting them with irrelevant data.
5142eccaef5STomohiro Kusumi.Nm HAMMER
5152eccaef5STomohiro Kusumivolumes need to be unmounted.
5162eccaef5STomohiro Kusumi.Pp
5172eccaef5STomohiro KusumiThis is a fast way to make
5182eccaef5STomohiro Kusumi.Nm HAMMER
5192eccaef5STomohiro Kusumifilesystem unmountable and unrecoverable.
5202eccaef5STomohiro KusumiAfter running this command,
5212eccaef5STomohiro Kusumi.Nm HAMMER
5222eccaef5STomohiro Kusumifilesystem data is no longer recoverable using
5232eccaef5STomohiro Kusumi.Cm recover
5249b21f734STomohiro Kusumicommand, although the data still exists within the volumes.
5252eccaef5STomohiro KusumiAs safety measure the
5262eccaef5STomohiro Kusumi.Fl y
5272eccaef5STomohiro Kusumiflag have no effect on this directive.
5282eccaef5STomohiro Kusumi.Pp
5292eccaef5STomohiro KusumiThis command needs the
5302eccaef5STomohiro Kusumi.Fl f Ar blkdevs
5312eccaef5STomohiro Kusumioption.
5325e435c92SMatthew Dillon.\" ==== namekey1 ====
5334567021bSThomas Nikolajsen.It Cm namekey1 Ar filename
534b4448f1aSThomas NikolajsenGenerate a
535b4448f1aSThomas Nikolajsen.Nm HAMMER
5365f22d366SThomas Nikolajsen64-bit directory hash for the specified file name, using
5375e435c92SMatthew Dillonthe original directory hash algorithm in version 1 of the file system.
538cbd800c2SMatthew DillonThe low 32 bits are used as an iterator for hash collisions and will be
539cbd800c2SMatthew Dillonoutput as 0.
5405e435c92SMatthew Dillon.\" ==== namekey2 ====
5414567021bSThomas Nikolajsen.It Cm namekey2 Ar filename
5425e435c92SMatthew DillonGenerate a
5435e435c92SMatthew Dillon.Nm HAMMER
5445f22d366SThomas Nikolajsen64-bit directory hash for the specified file name, using
5455e435c92SMatthew Dillonthe new directory hash algorithm in version 2 of the file system.
5465e435c92SMatthew DillonThe low 32 bits are still used as an iterator but will start out containing
5475e435c92SMatthew Dillonpart of the hash key.
54815fa4cafSThomas Nikolajsen.\" ==== namekey32 ====
5494567021bSThomas Nikolajsen.It Cm namekey32 Ar filename
550b4448f1aSThomas NikolajsenGenerate the top 32 bits of a
551b4448f1aSThomas Nikolajsen.Nm HAMMER
5522010519fSThomas Nikolajsen64 bit directory hash for the specified file name.
553b66b9421SAntonio Huete.\" ==== info ====
5548a03ae8aSAntonio Huete Jimenez.It Cm info Ar dirpath ...
555d428efb7SAntonio Huete JimenezShow extended information about all
5564567021bSThomas Nikolajsen.Nm HAMMER
557d428efb7SAntonio Huete Jimenezfile systems mounted in the system or the one mounted in
558d428efb7SAntonio Huete Jimenez.Ar dirpath
559d428efb7SAntonio Huete Jimenezwhen this argument is specified.
560d428efb7SAntonio Huete Jimenez.Pp
56132f05ed4SAntonio Huete JimenezThe information is divided into sections:
562aaf93065SThomas Nikolajsen.Bl -tag -width indent
56332f05ed4SAntonio Huete Jimenez.It Volume identification
56432f05ed4SAntonio Huete JimenezGeneral information, like the label of the
56532f05ed4SAntonio Huete Jimenez.Nm HAMMER
56632f05ed4SAntonio Huete Jimenezfilesystem, the number of volumes it contains, the FSID, and the
56732f05ed4SAntonio Huete Jimenez.Nm HAMMER
56832f05ed4SAntonio Huete Jimenezversion being used.
569d165c90aSTomohiro Kusumi.It Big-block information
570d165c90aSTomohiro KusumiBig-block statistics, such as total, used, reserved and free big-blocks.
57132f05ed4SAntonio Huete Jimenez.It Space information
57232f05ed4SAntonio Huete JimenezInformation about space used on the filesystem.
57332f05ed4SAntonio Huete JimenezCurrently total size, used, reserved and free space are displayed.
574aaf93065SThomas Nikolajsen.It PFS information
57532f05ed4SAntonio Huete JimenezBasic information about the PFSs currently present on a
57632f05ed4SAntonio Huete Jimenez.Nm HAMMER
57732f05ed4SAntonio Huete Jimenezfilesystem.
57832f05ed4SAntonio Huete Jimenez.Pp
57932f05ed4SAntonio Huete Jimenez.Dq PFS ID
58032f05ed4SAntonio Huete Jimenezis the ID of the PFS, with 0 being the root PFS.
58132f05ed4SAntonio Huete Jimenez.Dq Snaps
58232f05ed4SAntonio Huete Jimenezis the current snapshot count on the PFS.
58332f05ed4SAntonio Huete Jimenez.Dq Mounted on
58432f05ed4SAntonio Huete Jimenezdisplays the mount point of the PFS is currently mounted on (if any).
58532f05ed4SAntonio Huete Jimenez.El
5866a6e350fSMatthew Dillon.\" ==== cleanup ====
5874567021bSThomas Nikolajsen.It Cm cleanup Op Ar filesystem ...
588bb29b5d8SMatthew DillonThis is a meta-command which executes snapshot, prune, rebalance, dedup
589bb29b5d8SMatthew Dillonand reblock commands on the specified
590226f3799SThomas Nikolajsen.Nm HAMMER
59116265794SThomas Nikolajsenfile systems.
592226f3799SThomas NikolajsenIf no
593226f3799SThomas Nikolajsen.Ar filesystem
594226f3799SThomas Nikolajsenis specified this command will clean-up all
595226f3799SThomas Nikolajsen.Nm HAMMER
596226f3799SThomas Nikolajsenfile systems in use, including PFS's.
597226f3799SThomas NikolajsenTo do this it will scan all
598226f3799SThomas Nikolajsen.Nm HAMMER
599226f3799SThomas Nikolajsenand
600226f3799SThomas Nikolajsen.Nm null
6016a6e350fSMatthew Dillonmounts, extract PFS id's, and clean-up each PFS found.
6026a6e350fSMatthew Dillon.Pp
603f85afb25SThomas NikolajsenThis command will access a snapshots
60416265794SThomas Nikolajsendirectory and a configuration file for each
605226f3799SThomas Nikolajsen.Ar filesystem ,
606226f3799SThomas Nikolajsencreating them if necessary.
607f85afb25SThomas Nikolajsen.Bl -tag -width indent
608f85afb25SThomas Nikolajsen.It Nm HAMMER No version 2-
609f85afb25SThomas NikolajsenThe configuration file is
61016265794SThomas Nikolajsen.Pa config
61116265794SThomas Nikolajsenin the snapshots directory which defaults to
61216265794SThomas Nikolajsen.Pa <pfs>/snapshots .
613f85afb25SThomas Nikolajsen.It Nm HAMMER No version 3+
614f6532f03SThomas NikolajsenThe configuration file is saved in file system meta-data, see
615f6532f03SThomas Nikolajsen.Nm
616f6532f03SThomas Nikolajsen.Cm config .
61716265794SThomas NikolajsenThe snapshots directory defaults to
61816265794SThomas Nikolajsen.Pa /var/hammer/<pfs>
61916265794SThomas Nikolajsen.Pa ( /var/hammer/root
62016265794SThomas Nikolajsenfor root mount).
621f85afb25SThomas Nikolajsen.El
62216265794SThomas Nikolajsen.Pp
623226f3799SThomas NikolajsenThe format of the configuration file is:
624226f3799SThomas Nikolajsen.Bd -literal -offset indent
6255e435c92SMatthew Dillonsnapshots  <period> <retention-time> [any]
626226f3799SThomas Nikolajsenprune      <period> <max-runtime>
627f13fea8bSSascha Wildnerrebalance  <period> <max-runtime>
628bb29b5d8SMatthew Dillondedup      <period> <max-runtime>
6294567021bSThomas Nikolajsenreblock    <period> <max-runtime>
6304567021bSThomas Nikolajsenrecopy     <period> <max-runtime>
6314567021bSThomas Nikolajsen.Ed
6324567021bSThomas Nikolajsen.Pp
633226f3799SThomas NikolajsenDefaults are:
6344567021bSThomas Nikolajsen.Bd -literal -offset indent
6354567021bSThomas Nikolajsensnapshots  1d 60d  # 0d 0d  for PFS /tmp, /var/tmp, /usr/obj
636226f3799SThomas Nikolajsenprune      1d 5m
637f13fea8bSSascha Wildnerrebalance  1d 5m
6388b4063feSTomohiro Kusumi#dedup      1d 5m  # not enabled by default
639226f3799SThomas Nikolajsenreblock    1d 5m
640226f3799SThomas Nikolajsenrecopy     30d 10m
641226f3799SThomas Nikolajsen.Ed
6426a6e350fSMatthew Dillon.Pp
643483bb69bSThomas NikolajsenTime is given with a suffix of
644226f3799SThomas Nikolajsen.Cm d ,
645226f3799SThomas Nikolajsen.Cm h ,
646226f3799SThomas Nikolajsen.Cm m
647483bb69bSThomas Nikolajsenor
648226f3799SThomas Nikolajsen.Cm s
649226f3799SThomas Nikolajsenmeaning day, hour, minute and second.
6505e435c92SMatthew Dillon.Pp
6514567021bSThomas NikolajsenIf the
6524567021bSThomas Nikolajsen.Cm snapshots
6534567021bSThomas Nikolajsendirective has a period of 0 and a retention time of 0
6545e435c92SMatthew Dillonthen snapshot generation is disabled, removal of old snapshots are
6555e435c92SMatthew Dillondisabled, and prunes will use
6564567021bSThomas Nikolajsen.Cm prune-everything .
6570551025bSMatthew Dillon.Pp
6584567021bSThomas NikolajsenIf the
6594567021bSThomas Nikolajsen.Cm snapshots
6604567021bSThomas Nikolajsendirective has a period of 0 but a non-zero retention time
6615e435c92SMatthew Dillonthen this command will not create any new snapshots but will remove old
6625f22d366SThomas Nikolajsensnapshots it finds based on the retention time.
6635f22d366SThomas NikolajsenThis form should be
6640551025bSMatthew Dillonused on PFS masters where you are generating your own snapshot softlinks
6650551025bSMatthew Dillonmanually and on PFS slaves when all you wish to do is prune away existing
6660551025bSMatthew Dillonsnapshots inherited via the mirroring stream.
6675e435c92SMatthew Dillon.Pp
6684567021bSThomas NikolajsenBy default only snapshots in the form
6694567021bSThomas Nikolajsen.Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
6704567021bSThomas Nikolajsenare processed.
6715e435c92SMatthew DillonIf the
6724567021bSThomas Nikolajsen.Cm any
6734567021bSThomas Nikolajsendirective is specified as a third argument on the
6744567021bSThomas Nikolajsen.Cm snapshots
6754567021bSThomas Nikolajsenconfig line then any softlink of the form
6764567021bSThomas Nikolajsen.Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
6774567021bSThomas Nikolajsenor
6784567021bSThomas Nikolajsen.Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
6794567021bSThomas Nikolajsenwill be processed.
6805e435c92SMatthew Dillon.Pp
681d106bba4SMax HerrgardA period of 0 for prune, rebalance, dedup, reblock or recopy disables the directive.
6825f22d366SThomas NikolajsenA max-runtime of 0 means unlimited.
6836a6e350fSMatthew Dillon.Pp
684e0331f4fSSascha WildnerIf period hasn't passed since the previous
6854567021bSThomas Nikolajsen.Cm cleanup
686483bb69bSThomas Nikolajsenrun nothing is done.
687483bb69bSThomas NikolajsenFor example a day has passed when midnight is passed (localtime).
6885f22d366SThomas NikolajsenIf the
6895f22d366SThomas Nikolajsen.Fl F
6905f22d366SThomas Nikolajsenflag is given the period is ignored.
691e0331f4fSSascha WildnerBy default,
692e0331f4fSSascha Wildner.Dx
693e0331f4fSSascha Wildneris set up to run
6945f22d366SThomas Nikolajsen.Nm Cm cleanup
695e0331f4fSSascha Wildnernightly via
696e0331f4fSSascha Wildner.Xr periodic 8 .
697226f3799SThomas Nikolajsen.Pp
698226f3799SThomas NikolajsenThe default configuration file will create a daily snapshot, do a daily
699bb29b5d8SMatthew Dillonpruning, rebalancing, deduping and reblocking run and a monthly recopy run.
700226f3799SThomas NikolajsenReblocking is defragmentation with a level of 95%,
701226f3799SThomas Nikolajsenand recopy is full defragmentation.
702226f3799SThomas Nikolajsen.Pp
7035f22d366SThomas NikolajsenBy default prune, dedup and rebalance operations are time limited to 5 minutes,
7045f22d366SThomas Nikolajsenand reblock operations to a bit over 5 minutes,
7054567021bSThomas Nikolajsenand recopy operations to a bit over 10 minutes.
7064567021bSThomas NikolajsenReblocking and recopy runs are each broken down into four separate functions:
70778c4be83STomohiro KusumiB-Tree, inodes, dirs and data.
7084567021bSThomas NikolajsenEach function is time limited to the time given in the configuration file,
70978c4be83STomohiro Kusumibut the B-Tree, inodes and dirs functions usually does not take very long time,
7104567021bSThomas Nikolajsenfull defragmentation is always used for these three functions.
711226f3799SThomas NikolajsenAlso note that this directive will by default disable snapshots on
7122010519fSThomas Nikolajsenthe following PFS's:
713226f3799SThomas Nikolajsen.Pa /tmp ,
714226f3799SThomas Nikolajsen.Pa /var/tmp
715226f3799SThomas Nikolajsenand
716226f3799SThomas Nikolajsen.Pa /usr/obj .
717226f3799SThomas Nikolajsen.Pp
71816265794SThomas NikolajsenThe defaults may be adjusted by modifying the configuration file.
7196a6e350fSMatthew DillonThe pruning and reblocking commands automatically maintain a cyclefile
7206a6e350fSMatthew Dillonfor incremental operation.
7214567021bSThomas NikolajsenIf you interrupt (^C) the program the cyclefile will be updated,
7224567021bSThomas Nikolajsenbut a sub-command
723226f3799SThomas Nikolajsenmay continue to run in the background for a few seconds until the
724226f3799SThomas Nikolajsen.Nm HAMMER
7256a6e350fSMatthew Dillonioctl detects the interrupt.
726226f3799SThomas NikolajsenThe
7274567021bSThomas Nikolajsen.Cm snapshots
728226f3799SThomas NikolajsenPFS option can be set to use another location for the snapshots directory.
7296a6e350fSMatthew Dillon.Pp
7306a6e350fSMatthew DillonWork on this command is still in progress.
7314567021bSThomas NikolajsenExpected additions:
7324567021bSThomas NikolajsenAn ability to remove snapshots dynamically as the
733ff1c9800SMatthew Dillonfile system becomes full.
734a360fddeSJohn Marino.\" ==== abort-cleanup ====
735a360fddeSJohn Marino.It Cm abort-cleanup
736a360fddeSJohn MarinoThis command will terminate all active
737a360fddeSJohn Marino.Cm cleanup
738a360fddeSJohn Marinoprocesses.
73983f2a3aaSMatthew Dillon.\" ==== config ====
74016265794SThomas Nikolajsen.It Cm config Op Ar filesystem Op Ar configfile
74116265794SThomas Nikolajsen.Nm ( HAMMER
74216265794SThomas NikolajsenVERSION 3+)
743aaf93065SThomas NikolajsenShow or change configuration for
744aaf93065SThomas Nikolajsen.Ar filesystem .
74516265794SThomas NikolajsenIf zero or one arguments are specified this function dumps the current
74616265794SThomas Nikolajsenconfiguration file to stdout.
74716265794SThomas NikolajsenZero arguments specifies the PFS containing the current directory.
74816265794SThomas NikolajsenThis configuration file is stored in file system meta-data.
749efc166b1STomohiro KusumiIf two arguments are specified this function installs a new configuration file
750efc166b1STomohiro Kusumi.Ar configfile .
75183f2a3aaSMatthew Dillon.Pp
75283f2a3aaSMatthew DillonIn
75383f2a3aaSMatthew Dillon.Nm HAMMER
75416265794SThomas Nikolajsenversions less than 3 the configuration file is by default stored in
75516265794SThomas Nikolajsen.Pa <pfs>/snapshots/config ,
75683f2a3aaSMatthew Dillonbut in all later versions the configuration file is stored in file system
75783f2a3aaSMatthew Dillonmeta-data.
75816265794SThomas Nikolajsen.\" ==== viconfig ====
75916265794SThomas Nikolajsen.It Cm viconfig Op Ar filesystem
76016265794SThomas Nikolajsen.Nm ( HAMMER
76116265794SThomas NikolajsenVERSION 3+)
76216265794SThomas NikolajsenEdit the configuration file and reinstall into file system meta-data when done.
76316265794SThomas NikolajsenZero arguments specifies the PFS containing the current directory.
764d121f61cSMichael Neumann.\" ==== volume-add ====
765d121f61cSMichael Neumann.It Cm volume-add Ar device Ar filesystem
7665f22d366SThomas NikolajsenAdd volume
7675f22d366SThomas Nikolajsen.Ar device
7685f22d366SThomas Nikolajsento
7695f22d366SThomas Nikolajsen.Ar filesystem .
7705f22d366SThomas NikolajsenThis will format
771ceed7673SMichael Neumann.Ar device
772ceed7673SMichael Neumannand add all of its space to
773ceed7673SMichael Neumann.Ar filesystem .
7745f22d366SThomas NikolajsenA
7755f22d366SThomas Nikolajsen.Nm HAMMER
7765f22d366SThomas Nikolajsenfile system can use up to 256 volumes.
777ceed7673SMichael Neumann.Pp
7784567021bSThomas Nikolajsen.Em NOTE!
7794567021bSThomas NikolajsenAll existing data contained on
780ceed7673SMichael Neumann.Ar device
7814567021bSThomas Nikolajsenwill be destroyed by this operation!
7824567021bSThomas NikolajsenIf
783ceed7673SMichael Neumann.Ar device
784ceed7673SMichael Neumanncontains a valid
785ceed7673SMichael Neumann.Nm HAMMER
78616265794SThomas Nikolajsenfile system, formatting will be denied.
7875f22d366SThomas NikolajsenYou can overcome this sanity check by using
788ceed7673SMichael Neumann.Xr dd 1
789ceed7673SMichael Neumannto erase the beginning sectors of the device.
7905f22d366SThomas Nikolajsen.Pp
7915f22d366SThomas NikolajsenRemember that you have to specify
792ceed7673SMichael Neumann.Ar device ,
793f6532f03SThomas Nikolajsentogether with any other device that make up the file system,
794f6532f03SThomas Nikolajsencolon-separated to
795f6532f03SThomas Nikolajsen.Pa /etc/fstab
796f6532f03SThomas Nikolajsenand
797ceed7673SMichael Neumann.Xr mount_hammer 8 .
7985f22d366SThomas NikolajsenIf
7995f22d366SThomas Nikolajsen.Ar filesystem
8005f22d366SThomas Nikolajsenis root file system, also remember to add
8015f22d366SThomas Nikolajsen.Ar device
8025f22d366SThomas Nikolajsento
8035f22d366SThomas Nikolajsen.Va vfs.root.mountfrom
8045f22d366SThomas Nikolajsenin
8055f22d366SThomas Nikolajsen.Pa /boot/loader.conf ,
8065f22d366SThomas Nikolajsensee
8075f22d366SThomas Nikolajsen.Xr loader 8 .
808865c9609SMichael Neumann.\" ==== volume-del ====
809865c9609SMichael Neumann.It Cm volume-del Ar device Ar filesystem
8105f22d366SThomas NikolajsenRemove volume
811865c9609SMichael Neumann.Ar device
812865c9609SMichael Neumannfrom
813865c9609SMichael Neumann.Ar filesystem .
814865c9609SMichael Neumann.Pp
815865c9609SMichael NeumannRemember that you have to remove
816865c9609SMichael Neumann.Ar device
817865c9609SMichael Neumannfrom the colon-separated list in
818865c9609SMichael Neumann.Pa /etc/fstab
819865c9609SMichael Neumannand
820865c9609SMichael Neumann.Xr mount_hammer 8 .
8215f22d366SThomas NikolajsenIf
8225f22d366SThomas Nikolajsen.Ar filesystem
8235f22d366SThomas Nikolajsenis root file system, also remember to remove
8245f22d366SThomas Nikolajsen.Ar device
8255f22d366SThomas Nikolajsenfrom
8265f22d366SThomas Nikolajsen.Va vfs.root.mountfrom
8275f22d366SThomas Nikolajsenin
8285f22d366SThomas Nikolajsen.Pa /boot/loader.conf ,
8295f22d366SThomas Nikolajsensee
8305f22d366SThomas Nikolajsen.Xr loader 8 .
8311e94cea6STomohiro Kusumi.Pp
832dae8f186STomohiro KusumiIt is not possible to remove the
833dae8f186STomohiro Kusumi.Ar root-volume
834dae8f186STomohiro Kusumias it contains
835dae8f186STomohiro Kusumi.Ar filesystem
836dae8f186STomohiro Kusumimeta data such as
837dae8f186STomohiro Kusumi.Nm HAMMER Ns 's
83850d83294STomohiro Kusumilayer1 blockmap and UNDO/REDO FIFO.
839dae8f186STomohiro Kusumi.Pp
8401e94cea6STomohiro KusumiThis command may
8411e94cea6STomohiro Kusumi.Cm reblock
8427c5aac38SSascha Wildnerfilesystem before it attempts to remove the volume if the volume is not empty.
843e914c91dSStathis Kamperis.\" ==== volume-list ====
844e914c91dSStathis Kamperis.It Cm volume-list Ar filesystem
8455f22d366SThomas NikolajsenList the volumes that make up
846e914c91dSStathis Kamperis.Ar filesystem .
84756c2f4d6STomohiro KusumiIf -v is specified the command shows volume number for each volume as well as
84856c2f4d6STomohiro Kusumi.Ar root-volume
84956c2f4d6STomohiro Kusumiinformation.
850b45632fbSTomohiro Kusumi.\" ==== volume-blkdevs ====
851b45632fbSTomohiro Kusumi.It Cm volume-blkdevs Ar filesystem
852b45632fbSTomohiro KusumiList the volumes that make up
853b45632fbSTomohiro Kusumi.Ar filesystem
854b45632fbSTomohiro Kusumiin
855b45632fbSTomohiro Kusumi.Ar blkdevs
856b45632fbSTomohiro Kusumiformat.
8570e999592SThomas Nikolajsen.\" ==== snapshot ====
8584567021bSThomas Nikolajsen.It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
85916265794SThomas Nikolajsen.It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
8605f22d366SThomas NikolajsenTake a snapshot of the file system either explicitly given by
8610e999592SThomas Nikolajsen.Ar filesystem
8620e999592SThomas Nikolajsenor implicitly derived from the
8630e999592SThomas Nikolajsen.Ar snapshot-dir
8640e999592SThomas Nikolajsenargument and creates a symlink in the directory provided by
8650e999592SThomas Nikolajsen.Ar snapshot-dir
8660e999592SThomas Nikolajsenpointing to the snapshot.
8670e999592SThomas NikolajsenIf
8680e999592SThomas Nikolajsen.Ar snapshot-dir
8690e999592SThomas Nikolajsenis not a directory, it is assumed to be a format string passed to
8700e999592SThomas Nikolajsen.Xr strftime 3
8710e999592SThomas Nikolajsenwith the current time as parameter.
8720e999592SThomas NikolajsenIf
8730e999592SThomas Nikolajsen.Ar snapshot-dir
8744567021bSThomas Nikolajsenrefers to an existing directory, a default format string of
8755f22d366SThomas Nikolajsen.Ql snap-%Y%m%d-%H%M
8760e999592SThomas Nikolajsenis assumed and used as name for the newly created symlink.
8770e999592SThomas Nikolajsen.Pp
8785f22d366SThomas NikolajsenSnapshot is a per PFS operation, so each PFS in a
8790e999592SThomas Nikolajsen.Nm HAMMER
8805f22d366SThomas Nikolajsenfile system have to be snapshot separately.
8810e999592SThomas Nikolajsen.Pp
8820e999592SThomas NikolajsenExample, assuming that
8830e999592SThomas Nikolajsen.Pa /mysnapshots
8840e999592SThomas Nikolajsenis on file system
8850e999592SThomas Nikolajsen.Pa /
8860e999592SThomas Nikolajsenand that
8870e999592SThomas Nikolajsen.Pa /obj
88816265794SThomas Nikolajsenand
88916265794SThomas Nikolajsen.Pa /usr
89016265794SThomas Nikolajsenare file systems on their own, the following invocations:
8910e999592SThomas Nikolajsen.Bd -literal -offset indent
8920e999592SThomas Nikolajsenhammer snapshot /mysnapshots
8930e999592SThomas Nikolajsen
8940e999592SThomas Nikolajsenhammer snapshot /mysnapshots/%Y-%m-%d
8950e999592SThomas Nikolajsen
8960e999592SThomas Nikolajsenhammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
897b5ec5ad4SMatthew Dillon
89816265794SThomas Nikolajsenhammer snapshot /usr /my/snaps/usr "note"
8990e999592SThomas Nikolajsen.Ed
9000e999592SThomas Nikolajsen.Pp
901b5ec5ad4SMatthew DillonWould create symlinks similar to:
9020e999592SThomas Nikolajsen.Bd -literal -offset indent
9030e999592SThomas Nikolajsen/mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
9040e999592SThomas Nikolajsen
9050e999592SThomas Nikolajsen/mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
9060e999592SThomas Nikolajsen
9070e999592SThomas Nikolajsen/mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
90816265794SThomas Nikolajsen
90916265794SThomas Nikolajsen/my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
9100e999592SThomas Nikolajsen.Ed
911b5ec5ad4SMatthew Dillon.Pp
912b5ec5ad4SMatthew DillonWhen run on a
913b5ec5ad4SMatthew Dillon.Nm HAMMER
914f6532f03SThomas Nikolajsenversion 3+ file system the snapshot is also recorded in file system meta-data
91516265794SThomas Nikolajsenalong with the optional
91616265794SThomas Nikolajsen.Ar note .
91716265794SThomas NikolajsenSee the
918b5ec5ad4SMatthew Dillon.Cm snapls
919b5ec5ad4SMatthew Dillondirective.
92083f2a3aaSMatthew Dillon.\" ==== snap* ====
92116265794SThomas Nikolajsen.It Cm snap Ar path Op Ar note
92216265794SThomas Nikolajsen.Nm ( HAMMER
92316265794SThomas NikolajsenVERSION 3+)
92416265794SThomas NikolajsenCreate a snapshot for the PFS containing
92516265794SThomas Nikolajsen.Ar path
92616265794SThomas Nikolajsenand create a snapshot softlink.
92716265794SThomas NikolajsenIf the path specified is a
92883f2a3aaSMatthew Dillondirectory a standard snapshot softlink will be created in the directory.
92983f2a3aaSMatthew DillonThe snapshot softlink points to the base of the mounted PFS.
93016265794SThomas Nikolajsen.It Cm snaplo Ar path Op Ar note
93116265794SThomas Nikolajsen.Nm ( HAMMER
93216265794SThomas NikolajsenVERSION 3+)
93316265794SThomas NikolajsenCreate a snapshot for the PFS containing
93416265794SThomas Nikolajsen.Ar path
93516265794SThomas Nikolajsenand create a snapshot softlink.
93616265794SThomas NikolajsenIf the path specified is a
93783f2a3aaSMatthew Dillondirectory a standard snapshot softlink will be created in the directory.
93883f2a3aaSMatthew DillonThe snapshot softlink points into the directory it is contained in.
93916265794SThomas Nikolajsen.It Cm snapq Ar dir Op Ar note
94016265794SThomas Nikolajsen.Nm ( HAMMER
94116265794SThomas NikolajsenVERSION 3+)
94283f2a3aaSMatthew DillonCreate a snapshot for the PFS containing the specified directory but do
94316265794SThomas Nikolajsennot create a softlink.
94416265794SThomas NikolajsenInstead output a path which can be used to access
94583f2a3aaSMatthew Dillonthe directory via the snapshot.
946bf2c6489SMatthew Dillon.Pp
94716265794SThomas NikolajsenAn absolute or relative path may be specified.
94816265794SThomas NikolajsenThe path will be used as-is as a prefix in the path output to stdout.
94916265794SThomas NikolajsenAs with the other
950bf2c6489SMatthew Dillonsnap and snapshot directives the snapshot transaction id will be registered
951bf2c6489SMatthew Dillonin the file system meta-data.
952ef872b8dSMatthew Dillon.It Cm snaprm Ar path Ar ...
9535f22d366SThomas Nikolajsen.It Cm snaprm Ar transaction_id Ar ...
9545f22d366SThomas Nikolajsen.It Cm snaprm Ar filesystem Ar transaction_id Ar ...
95516265794SThomas Nikolajsen.Nm ( HAMMER
95616265794SThomas NikolajsenVERSION 3+)
95716265794SThomas NikolajsenRemove a snapshot given its softlink or transaction id.
95816265794SThomas NikolajsenIf specifying a transaction id
95983f2a3aaSMatthew Dillonthe snapshot is removed from file system meta-data but you are responsible
96083f2a3aaSMatthew Dillonfor removing any related softlinks.
961ef872b8dSMatthew Dillon.Pp
962ef872b8dSMatthew DillonIf a softlink path is specified the filesystem and transaction id
963ef872b8dSMatthew Dillonis derived from the contents of the softlink.
9645f22d366SThomas NikolajsenIf just a transaction id is specified it is assumed to be a snapshot in the
9655f22d366SThomas Nikolajsen.Nm HAMMER
9665f22d366SThomas Nikolajsenfilesystem you are currently chdir'd into.
967ef872b8dSMatthew DillonYou can also specify the filesystem and transaction id explicitly.
96816265794SThomas Nikolajsen.It Cm snapls Op Ar path ...
96916265794SThomas Nikolajsen.Nm ( HAMMER
97016265794SThomas NikolajsenVERSION 3+)
97116265794SThomas NikolajsenDump the snapshot meta-data for PFSs containing each
97216265794SThomas Nikolajsen.Ar path
97316265794SThomas Nikolajsenlisting all available snapshots and their notes.
97416265794SThomas NikolajsenIf no arguments are specified snapshots for the PFS containing the
97516265794SThomas Nikolajsencurrent directory are listed.
97616265794SThomas NikolajsenThis is the definitive list of snapshots for the file system.
97715fa4cafSThomas Nikolajsen.\" ==== prune ====
9784567021bSThomas Nikolajsen.It Cm prune Ar softlink-dir
979b5aaba7fSMatthew DillonPrune the file system based on previously created snapshot softlinks.
98084082922SThomas NikolajsenPruning is the act of deleting file system history.
98184082922SThomas NikolajsenThe
9824567021bSThomas Nikolajsen.Cm prune
9834567021bSThomas Nikolajsencommand will delete file system history such that
98484082922SThomas Nikolajsenthe file system state is retained for the given snapshots,
9854567021bSThomas Nikolajsenand all history after the latest snapshot.
9864567021bSThomas NikolajsenBy setting the per PFS parameter
9874567021bSThomas Nikolajsen.Cm prune-min ,
9884567021bSThomas Nikolajsenhistory is guaranteed to be saved at least this time interval.
9894567021bSThomas NikolajsenAll other history is deleted.
99084082922SThomas Nikolajsen.Pp
991e8969ef0SMatthew DillonThe target directory is expected to contain softlinks pointing to
9922010519fSThomas Nikolajsensnapshots of the file systems you wish to retain.
9932010519fSThomas NikolajsenThe directory is scanned non-recursively and the mount points and
9942010519fSThomas Nikolajsentransaction ids stored in the softlinks are extracted and sorted.
995e8969ef0SMatthew DillonThe file system is then explicitly pruned according to what is found.
9964567021bSThomas NikolajsenCleaning out portions of the file system is as simple as removing a
9974567021bSThomas Nikolajsensnapshot softlink and then running the
9984567021bSThomas Nikolajsen.Cm prune
999e8969ef0SMatthew Dilloncommand.
1000e8969ef0SMatthew Dillon.Pp
1001e8969ef0SMatthew DillonAs a safety measure pruning only occurs if one or more softlinks are found
10024567021bSThomas Nikolajsencontaining the
10034567021bSThomas Nikolajsen.Ql @@
10044567021bSThomas Nikolajsensnapshot id extension.
1005e8969ef0SMatthew DillonCurrently the scanned softlink directory must contain softlinks pointing
1006b4448f1aSThomas Nikolajsento a single
1007b4448f1aSThomas Nikolajsen.Nm HAMMER
10082010519fSThomas Nikolajsenmount.
10092010519fSThomas NikolajsenThe softlinks may specify absolute or relative paths.
10104567021bSThomas NikolajsenSoftlinks must use 20-character
10114567021bSThomas Nikolajsen.Ql @@0x%016llx
10124567021bSThomas Nikolajsentransaction ids, as might be returned from
10134567021bSThomas Nikolajsen.Nm Cm synctid Ar filesystem .
1014e8969ef0SMatthew Dillon.Pp
10155f22d366SThomas NikolajsenPruning is a per PFS operation, so each PFS in a
101615fa4cafSThomas Nikolajsen.Nm HAMMER
10175f22d366SThomas Nikolajsenfile system have to be pruned separately.
101815fa4cafSThomas Nikolajsen.Pp
101915fa4cafSThomas NikolajsenNote that pruning a file system may not immediately free-up space,
102015fa4cafSThomas Nikolajsenthough typically some space will be freed if a large number of records are
10212010519fSThomas Nikolajsenpruned out.
10222010519fSThomas NikolajsenThe file system must be reblocked to completely recover all available space.
102315fa4cafSThomas Nikolajsen.Pp
10244567021bSThomas NikolajsenExample, lets say your that you didn't set
10254567021bSThomas Nikolajsen.Cm prune-min ,
10264567021bSThomas Nikolajsenand snapshot directory contains the following links:
1027226f3799SThomas Nikolajsen.Bd -literal -offset indent
1028f51a18e7SSascha Wildnerlrwxr-xr-x  1 root  wheel  29 May 31 17:57 snap1 ->
1029f51a18e7SSascha Wildner/usr/obj/@@0x10d2cd05b7270d16
1030f51a18e7SSascha Wildner
1031f51a18e7SSascha Wildnerlrwxr-xr-x  1 root  wheel  29 May 31 17:58 snap2 ->
1032f51a18e7SSascha Wildner/usr/obj/@@0x10d2cd13f3fde98f
1033f51a18e7SSascha Wildner
1034f51a18e7SSascha Wildnerlrwxr-xr-x  1 root  wheel  29 May 31 17:59 snap3 ->
1035f51a18e7SSascha Wildner/usr/obj/@@0x10d2cd222adee364
1036f51a18e7SSascha Wildner.Ed
1037e8969ef0SMatthew Dillon.Pp
103884082922SThomas NikolajsenIf you were to run the
10394567021bSThomas Nikolajsen.Cm prune
1040b4448f1aSThomas Nikolajsencommand on this directory, then the
1041b4448f1aSThomas Nikolajsen.Nm HAMMER
1042f51a18e7SSascha Wildner.Pa /usr/obj
1043f51a18e7SSascha Wildnermount will be pruned to retain the above three snapshots.
10442010519fSThomas NikolajsenIn addition, history for modifications made to the file system older than
10452010519fSThomas Nikolajsenthe oldest snapshot will be destroyed and history for potentially fine-grained
10462010519fSThomas Nikolajsenmodifications made to the file system more recently than the most recent
10472010519fSThomas Nikolajsensnapshot will be retained.
1048e8969ef0SMatthew Dillon.Pp
10492010519fSThomas NikolajsenIf you then delete the
10502010519fSThomas Nikolajsen.Pa snap2
10512010519fSThomas Nikolajsensoftlink and rerun the
10524567021bSThomas Nikolajsen.Cm prune
105384082922SThomas Nikolajsencommand,
105484082922SThomas Nikolajsenhistory for modifications pertaining to that snapshot would be destroyed.
105583f2a3aaSMatthew Dillon.Pp
105683f2a3aaSMatthew DillonIn
105783f2a3aaSMatthew Dillon.Nm HAMMER
105883f2a3aaSMatthew Dillonfile system versions 3+ this command also scans the snapshots stored
105983f2a3aaSMatthew Dillonin the file system meta-data and includes them in the prune.
106015fa4cafSThomas Nikolajsen.\" ==== prune-everything ====
10614567021bSThomas Nikolajsen.It Cm prune-everything Ar filesystem
10625f22d366SThomas NikolajsenRemove all historical records from
10635f22d366SThomas Nikolajsen.Ar filesystem .
10645f22d366SThomas NikolajsenUse this directive with caution on PFSs where you intend to use history.
106583f2a3aaSMatthew Dillon.Pp
106683f2a3aaSMatthew DillonThis command does not remove snapshot softlinks but will delete all
106783f2a3aaSMatthew Dillonsnapshots recorded in file system meta-data (for file system version 3+).
106883f2a3aaSMatthew DillonThe user is responsible for deleting any softlinks.
1069aaf93065SThomas Nikolajsen.Pp
10705f22d366SThomas NikolajsenPruning is a per PFS operation, so each PFS in a
1071aaf93065SThomas Nikolajsen.Nm HAMMER
10725f22d366SThomas Nikolajsenfile system have to be pruned separately.
1073797a0b63SMatthew Dillon.\" ==== rebalance ====
1074f6532f03SThomas Nikolajsen.It Cm rebalance Ar filesystem Op Ar saturation_percentage
10755f22d366SThomas NikolajsenRebalance the B-Tree, nodes with small number of
1076797a0b63SMatthew Dillonelements will be combined and element counts will be smoothed out
1077797a0b63SMatthew Dillonbetween nodes.
1078797a0b63SMatthew Dillon.Pp
1079f6532f03SThomas NikolajsenThe saturation percentage is between 50% and 100%.
1080953bfaa2SAntonio Huete JimenezThe default is 85% (the
1081f6532f03SThomas Nikolajsen.Sq %
1082f6532f03SThomas Nikolajsensuffix is not needed).
1083aaf93065SThomas Nikolajsen.Pp
10845f22d366SThomas NikolajsenRebalancing is a per PFS operation, so each PFS in a
1085aaf93065SThomas Nikolajsen.Nm HAMMER
10865f22d366SThomas Nikolajsenfile system have to be rebalanced separately.
1087bb29b5d8SMatthew Dillon.\" ==== dedup ====
1088bb29b5d8SMatthew Dillon.It Cm dedup Ar filesystem
1089bb29b5d8SMatthew Dillon.Nm ( HAMMER
1090bb29b5d8SMatthew DillonVERSION 5+)
10915f22d366SThomas NikolajsenPerform offline (post-process) deduplication.
10925f22d366SThomas NikolajsenDeduplication occurs at
1093bb29b5d8SMatthew Dillonthe block level, currently only data blocks of the same size can be
10945f22d366SThomas Nikolajsendeduped, metadata blocks can not.
10955f22d366SThomas NikolajsenThe hash function used for comparing
1096bb29b5d8SMatthew Dillondata blocks is CRC-32 (CRCs are computed anyways as part of
1097bb29b5d8SMatthew Dillon.Nm HAMMER
10985f22d366SThomas Nikolajsendata integrity features, so there's no additional overhead).
10995f22d366SThomas NikolajsenSince CRC is a weak hash function a byte-by-byte comparison is done
11005f22d366SThomas Nikolajsenbefore actual deduping.
11015f22d366SThomas NikolajsenIn case of a CRC collision (two data blocks have the same CRC
1102bb29b5d8SMatthew Dillonbut different contents) the checksum is upgraded to SHA-256.
1103bb29b5d8SMatthew Dillon.Pp
1104bb29b5d8SMatthew DillonCurrently
1105bb29b5d8SMatthew Dillon.Nm HAMMER
1106bb29b5d8SMatthew Dillonreblocker may partially blow up (re-expand) dedup (reblocker's normal
1107bb29b5d8SMatthew Dillonoperation is to reallocate every record, so it's possible for deduped
1108bb29b5d8SMatthew Dillonblocks to be re-expanded back).
1109bb29b5d8SMatthew Dillon.Pp
11105f22d366SThomas NikolajsenDeduplication is a per PFS operation, so each PFS in a
1111bb29b5d8SMatthew Dillon.Nm HAMMER
11125f22d366SThomas Nikolajsenfile system have to be deduped separately.
11135f22d366SThomas NikolajsenThis also
1114bb29b5d8SMatthew Dillonmeans that if you have duplicated data in two different PFSs that data
1115bb29b5d8SMatthew Dillonwon't be deduped, however the addition of such feature is planned.
1116fbe1c665SMatthew Dillon.Pp
1117fbe1c665SMatthew DillonThe
1118fbe1c665SMatthew Dillon.Fl m Ar memlimit
1119fbe1c665SMatthew Dillonoption should be used to limit memory use during the dedup run if the
1120fbe1c665SMatthew Dillondefault 1G limit is too much for the machine.
1121bb29b5d8SMatthew Dillon.\" ==== dedup-simulate ====
1122bb29b5d8SMatthew Dillon.It Cm dedup-simulate Ar filesystem
1123bb29b5d8SMatthew DillonShows potential space savings (simulated dedup ratio) one can get after
1124bb29b5d8SMatthew Dillonrunning
1125bb29b5d8SMatthew Dillon.Cm dedup
11265f22d366SThomas Nikolajsencommand.
11275f22d366SThomas NikolajsenIf the estimated dedup ratio is greater than 1.00 you will see
11285f22d366SThomas Nikolajsendedup space savings.
11295f22d366SThomas NikolajsenRemember that this is an estimated number, in
1130bb29b5d8SMatthew Dillonpractice real dedup ratio will be slightly smaller because of
1131bb29b5d8SMatthew Dillon.Nm HAMMER
1132a981af19STomohiro Kusumibig-block underflows, B-Tree locking issues and other factors.
1133eae1bb35SIlya Dryomov.Pp
1134eae1bb35SIlya DryomovNote that deduplication currently works only on bulk data so if you
1135eae1bb35SIlya Dryomovtry to run
1136eae1bb35SIlya Dryomov.Cm dedup-simulate
1137eae1bb35SIlya Dryomovor
1138eae1bb35SIlya Dryomov.Cm dedup
1139eae1bb35SIlya Dryomovcommands on a PFS that contains metadata only (directory entries,
1140eae1bb35SIlya Dryomovsoftlinks) you will get a 0.00 dedup ratio.
1141fbe1c665SMatthew Dillon.Pp
1142fbe1c665SMatthew DillonThe
1143fbe1c665SMatthew Dillon.Fl m Ar memlimit
1144fbe1c665SMatthew Dillonoption should be used to limit memory use during the dedup run if the
1145fbe1c665SMatthew Dillondefault 1G limit is too much for the machine.
114616265794SThomas Nikolajsen.\" ==== reblock* ====
11474567021bSThomas Nikolajsen.It Cm reblock Ar filesystem Op Ar fill_percentage
11484567021bSThomas Nikolajsen.It Cm reblock-btree Ar filesystem Op Ar fill_percentage
11494567021bSThomas Nikolajsen.It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
11504567021bSThomas Nikolajsen.It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
11514567021bSThomas Nikolajsen.It Cm reblock-data Ar filesystem Op Ar fill_percentage
11529e29c876SMatthew DillonAttempt to defragment and free space for reuse by reblocking a live
1153b4448f1aSThomas Nikolajsen.Nm HAMMER
1154b4448f1aSThomas Nikolajsenfile system.
11554567021bSThomas NikolajsenBig-blocks cannot be reused by
1156b4448f1aSThomas Nikolajsen.Nm HAMMER
1157b4448f1aSThomas Nikolajsenuntil they are completely free.
11589e29c876SMatthew DillonThis command also has the effect of reordering all elements, effectively
11599e29c876SMatthew Dillondefragmenting the file system.
1160ba7b52c9SMatthew Dillon.Pp
11619e29c876SMatthew DillonThe default fill percentage is 100% and will cause the file system to be
11622010519fSThomas Nikolajsencompletely defragmented.
11632010519fSThomas NikolajsenAll specified element types will be reallocated and rewritten.
11642010519fSThomas NikolajsenIf you wish to quickly free up space instead try specifying
116515fa4cafSThomas Nikolajsena smaller fill percentage, such as 90% or 80% (the
116615fa4cafSThomas Nikolajsen.Sq %
116715fa4cafSThomas Nikolajsensuffix is not needed).
1168ba7b52c9SMatthew Dillon.Pp
11699e29c876SMatthew DillonSince this command may rewrite the entire contents of the disk it is
117084082922SThomas Nikolajsenbest to do it incrementally from a
117184082922SThomas Nikolajsen.Xr cron 8
117284082922SThomas Nikolajsenjob along with the
11739e29c876SMatthew Dillon.Fl c Ar cyclefile
11749e29c876SMatthew Dillonand
117599d6191fSSascha Wildner.Fl t Ar seconds
11769e29c876SMatthew Dillonoptions to limit the run time.
11779e29c876SMatthew DillonThe file system would thus be defragmented over long period of time.
11789e29c876SMatthew Dillon.Pp
11799e29c876SMatthew DillonIt is recommended that separate invocations be used for each data type.
1180aaf93065SThomas NikolajsenB-Tree nodes, inodes, and directories are typically the most important
11812010519fSThomas Nikolajsenelements needing defragmentation.
11822010519fSThomas NikolajsenData can be defragmented over a longer period of time.
118315fa4cafSThomas Nikolajsen.Pp
11845f22d366SThomas NikolajsenReblocking is a per PFS operation, so each PFS in a
118515fa4cafSThomas Nikolajsen.Nm HAMMER
11865f22d366SThomas Nikolajsenfile system have to be reblocked separately.
118715fa4cafSThomas Nikolajsen.\" ==== pfs-status ====
11884567021bSThomas Nikolajsen.It Cm pfs-status Ar dirpath ...
118934ebae70SMatthew DillonRetrieve the mirroring configuration parameters for the specified
1190b4448f1aSThomas Nikolajsen.Nm HAMMER
11912010519fSThomas Nikolajsenfile systems or pseudo-filesystems (PFS's).
119215fa4cafSThomas Nikolajsen.\" ==== pfs-master ====
11934567021bSThomas Nikolajsen.It Cm pfs-master Ar dirpath Op Ar options
1194b4448f1aSThomas NikolajsenCreate a pseudo-filesystem (PFS) inside a
1195b4448f1aSThomas Nikolajsen.Nm HAMMER
1196b4448f1aSThomas Nikolajsenfile system.
11975f22d366SThomas NikolajsenUp to 65536 PFSs can be created.
1198765c85a8SSascha WildnerEach PFS uses an independent inode numbering space making it suitable
11995f22d366SThomas Nikolajsenfor replication.
120034ebae70SMatthew Dillon.Pp
1201d4e5b69bSMatthew DillonThe
12024567021bSThomas Nikolajsen.Cm pfs-master
1203d4e5b69bSMatthew Dillondirective creates a PFS that you can read, write, and use as a mirroring
1204d4e5b69bSMatthew Dillonsource.
1205bb8e52c0SThomas Nikolajsen.Pp
12065f22d366SThomas NikolajsenA PFS can only be truly destroyed with the
12075f22d366SThomas Nikolajsen.Cm pfs-destroy
12085f22d366SThomas Nikolajsendirective.
12095f22d366SThomas NikolajsenRemoving the softlink will not destroy the underlying PFS.
12105f22d366SThomas Nikolajsen.Pp
1211a5ff7917STomohiro KusumiA PFS can only be created in the root PFS,
12125f22d366SThomas Nikolajsennot in a PFS created by
12135f22d366SThomas Nikolajsen.Cm pfs-master
12145f22d366SThomas Nikolajsenor
1215a5ff7917STomohiro Kusumi.Cm pfs-slave .
12165f22d366SThomas Nikolajsen.Pp
12175f22d366SThomas NikolajsenIt is recommended that
12185f22d366SThomas Nikolajsen.Ar dirpath
12195f22d366SThomas Nikolajsenis of the form
12205f22d366SThomas Nikolajsen.Pa <fs>/pfs/<name>
12215f22d366SThomas Nikolajsen(i.e.\& located in
12228add7974STomohiro Kusumi.Pa PFS
12235f22d366SThomas Nikolajsendirectory at root of
12245f22d366SThomas Nikolajsen.Nm HAMMER
12255f22d366SThomas Nikolajsenfile system).
12265f22d366SThomas Nikolajsen.Pp
1227bb8e52c0SThomas NikolajsenIt is recommended to use a
1228bb8e52c0SThomas Nikolajsen.Nm null
12295f22d366SThomas Nikolajsenmount to access a PFS, except for root PFS, for more information see
1230bb8e52c0SThomas Nikolajsen.Xr HAMMER 5 .
123115fa4cafSThomas Nikolajsen.\" ==== pfs-slave ====
12324567021bSThomas Nikolajsen.It Cm pfs-slave Ar dirpath Op Ar options
1233b4448f1aSThomas NikolajsenCreate a pseudo-filesystem (PFS) inside a
1234b4448f1aSThomas Nikolajsen.Nm HAMMER
1235b4448f1aSThomas Nikolajsenfile system.
12365f22d366SThomas NikolajsenUp to 65536 PFSs can be created.
1237765c85a8SSascha WildnerEach PFS uses an independent inode numbering space making it suitable
12385f22d366SThomas Nikolajsenfor replication.
1239d4e5b69bSMatthew Dillon.Pp
1240d4e5b69bSMatthew DillonThe
12414567021bSThomas Nikolajsen.Cm pfs-slave
12425f22d366SThomas Nikolajsendirective creates a PFS that you can use as a mirroring source or target.
1243d4e5b69bSMatthew DillonYou will not be able to access a slave PFS until you have completed the
1244d4e5b69bSMatthew Dillonfirst mirroring operation with it as the target (its root directory will
1245d4e5b69bSMatthew Dillonnot exist until then).
1246d4e5b69bSMatthew Dillon.Pp
12474567021bSThomas NikolajsenAccess to the pfs-slave via the special softlink, as described in the
1248006a05b7SSascha Wildner.Sx PSEUDO-FILESYSTEM (PFS) NOTES
12492010519fSThomas Nikolajsenbelow, allows
1250b4448f1aSThomas Nikolajsen.Nm HAMMER
1251b4448f1aSThomas Nikolajsento
125284082922SThomas Nikolajsendynamically modify the snapshot transaction id by returning a dynamic result
125384082922SThomas Nikolajsenfrom
125484082922SThomas Nikolajsen.Xr readlink 2
125584082922SThomas Nikolajsencalls.
1256d4e5b69bSMatthew Dillon.Pp
1257765c85a8SSascha WildnerA PFS can only be truly destroyed with the
12584567021bSThomas Nikolajsen.Cm pfs-destroy
1259d4e5b69bSMatthew Dillondirective.
1260d4e5b69bSMatthew DillonRemoving the softlink will not destroy the underlying PFS.
1261bb8e52c0SThomas Nikolajsen.Pp
1262a5ff7917STomohiro KusumiA PFS can only be created in the root PFS,
12635f22d366SThomas Nikolajsennot in a PFS created by
12645f22d366SThomas Nikolajsen.Cm pfs-master
12655f22d366SThomas Nikolajsenor
1266a5ff7917STomohiro Kusumi.Cm pfs-slave .
12675f22d366SThomas Nikolajsen.Pp
12685f22d366SThomas NikolajsenIt is recommended that
12695f22d366SThomas Nikolajsen.Ar dirpath
12705f22d366SThomas Nikolajsenis of the form
12715f22d366SThomas Nikolajsen.Pa <fs>/pfs/<name>
12725f22d366SThomas Nikolajsen(i.e.\& located in
12738add7974STomohiro Kusumi.Pa PFS
12745f22d366SThomas Nikolajsendirectory at root of
12755f22d366SThomas Nikolajsen.Nm HAMMER
12765f22d366SThomas Nikolajsenfile system).
12775f22d366SThomas Nikolajsen.Pp
1278bb8e52c0SThomas NikolajsenIt is recommended to use a
1279bb8e52c0SThomas Nikolajsen.Nm null
12805f22d366SThomas Nikolajsenmount to access a PFS, except for root PFS, for more information see
1281bb8e52c0SThomas Nikolajsen.Xr HAMMER 5 .
128215fa4cafSThomas Nikolajsen.\" ==== pfs-update ====
12834567021bSThomas Nikolajsen.It Cm pfs-update Ar dirpath Op Ar options
1284b4448f1aSThomas NikolajsenUpdate the configuration parameters for an existing
1285b4448f1aSThomas Nikolajsen.Nm HAMMER
12864567021bSThomas Nikolajsenfile system or pseudo-filesystem.
12872010519fSThomas NikolajsenOptions that may be specified:
128834ebae70SMatthew Dillon.Bl -tag -width indent
12894567021bSThomas Nikolajsen.It Cm sync-beg-tid= Ns Ar 0x16llx
12902010519fSThomas NikolajsenThis is the automatic snapshot access starting transaction id for
12912010519fSThomas Nikolajsenmirroring slaves.
129234ebae70SMatthew DillonThis parameter is normally updated automatically by the
12934567021bSThomas Nikolajsen.Cm mirror-write
129434ebae70SMatthew Dillondirective.
129534ebae70SMatthew Dillon.Pp
129634ebae70SMatthew DillonIt is important to note that accessing a mirroring slave
1297765c85a8SSascha Wildnerwith a transaction id greater than the last fully synchronized transaction
129834ebae70SMatthew Dillonid can result in an unreliable snapshot since you will be accessing
129934ebae70SMatthew Dillondata that is still undergoing synchronization.
130034ebae70SMatthew Dillon.Pp
13014567021bSThomas NikolajsenManually modifying this field is dangerous and can result in a broken mirror.
13024567021bSThomas Nikolajsen.It Cm sync-end-tid= Ns Ar 0x16llx
1303ddc8e722SMatthew DillonThis is the current synchronization point for mirroring slaves.
130434ebae70SMatthew DillonThis parameter is normally updated automatically by the
13054567021bSThomas Nikolajsen.Cm mirror-write
130634ebae70SMatthew Dillondirective.
130734ebae70SMatthew Dillon.Pp
13082010519fSThomas NikolajsenManually modifying this field is dangerous and can result in a broken mirror.
13094567021bSThomas Nikolajsen.It Cm shared-uuid= Ns Ar uuid
13102010519fSThomas NikolajsenSet the shared UUID for this file system.
13112010519fSThomas NikolajsenAll mirrors must have the same shared UUID.
13122010519fSThomas NikolajsenFor safety purposes the
13134567021bSThomas Nikolajsen.Cm mirror-write
13142010519fSThomas Nikolajsendirectives will refuse to operate on a target with a different shared UUID.
131534ebae70SMatthew Dillon.Pp
131684082922SThomas NikolajsenChanging the shared UUID on an existing, non-empty mirroring target,
13172010519fSThomas Nikolajsenincluding an empty but not completely pruned target,
13182010519fSThomas Nikolajsencan lead to corruption of the mirroring target.
13194567021bSThomas Nikolajsen.It Cm unique-uuid= Ns Ar uuid
13202010519fSThomas NikolajsenSet the unique UUID for this file system.
13212010519fSThomas NikolajsenThis UUID should not be used anywhere else,
13222010519fSThomas Nikolajseneven on exact copies of the file system.
13234567021bSThomas Nikolajsen.It Cm label= Ns Ar string
132434ebae70SMatthew DillonSet a descriptive label for this file system.
13254567021bSThomas Nikolajsen.It Cm snapshots= Ns Ar string
1326226f3799SThomas NikolajsenSpecify the snapshots directory which
1327226f3799SThomas Nikolajsen.Nm
13284567021bSThomas Nikolajsen.Cm cleanup
13292010519fSThomas Nikolajsenwill use to manage this PFS.
1330f85afb25SThomas Nikolajsen.Bl -tag -width indent
1331f85afb25SThomas Nikolajsen.It Nm HAMMER No version 2-
13322010519fSThomas NikolajsenThe snapshots directory does not need to be configured for
1333226f3799SThomas NikolajsenPFS masters and will default to
1334226f3799SThomas Nikolajsen.Pa <pfs>/snapshots .
1335ff1c9800SMatthew Dillon.Pp
1336ff1c9800SMatthew DillonPFS slaves are mirroring slaves so you cannot configure a snapshots
1337ff1c9800SMatthew Dillondirectory on the slave itself to be managed by the slave's machine.
1338226f3799SThomas NikolajsenIn fact, the slave will likely have a
1339226f3799SThomas Nikolajsen.Pa snapshots
1340226f3799SThomas Nikolajsensub-directory mirrored
1341ff1c9800SMatthew Dillonfrom the master, but that directory contains the configuration the master
1342ff1c9800SMatthew Dillonis using for its copy of the file system, not the configuration that we
1343ff1c9800SMatthew Dillonwant to use for our slave.
1344ff1c9800SMatthew Dillon.Pp
1345226f3799SThomas NikolajsenIt is recommended that
1346226f3799SThomas Nikolajsen.Pa <fs>/var/slaves/<name>
1347226f3799SThomas Nikolajsenbe configured for a PFS slave, where
1348226f3799SThomas Nikolajsen.Pa <fs>
1349226f3799SThomas Nikolajsenis the base
1350226f3799SThomas Nikolajsen.Nm HAMMER
1351226f3799SThomas Nikolajsenfile system, and
1352226f3799SThomas Nikolajsen.Pa <name>
1353226f3799SThomas Nikolajsenis an appropriate label.
1354f85afb25SThomas Nikolajsen.It Nm HAMMER No version 3+
1355f85afb25SThomas NikolajsenThe snapshots directory does not need to be configured for PFS masters or
1356f85afb25SThomas Nikolajsenslaves.
1357f85afb25SThomas NikolajsenThe snapshots directory defaults to
1358f85afb25SThomas Nikolajsen.Pa /var/hammer/<pfs>
1359f85afb25SThomas Nikolajsen.Pa ( /var/hammer/root
1360f85afb25SThomas Nikolajsenfor root mount).
1361f85afb25SThomas Nikolajsen.El
1362f85afb25SThomas Nikolajsen.Pp
13632010519fSThomas NikolajsenYou can control snapshot retention on your slave independent of the master.
13644567021bSThomas Nikolajsen.It Cm snapshots-clear
13654567021bSThomas NikolajsenZero out the
13664567021bSThomas Nikolajsen.Cm snapshots
13674567021bSThomas Nikolajsendirectory path for this PFS.
13684567021bSThomas Nikolajsen.It Cm prune-min= Ns Ar N Ns Cm d
1369f85afb25SThomas Nikolajsen.It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \
1370f85afb25SThomas NikolajsenAr hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss
1371e7f926a5SMatthew DillonSet the minimum fine-grained data retention period.
1372e7f926a5SMatthew Dillon.Nm HAMMER
13730bd7a37cSMatthew Dillonalways retains fine-grained history up to the most recent snapshot.
13740bd7a37cSMatthew DillonYou can extend the retention period further by specifying a non-zero
13754567021bSThomas Nikolajsenpruning minimum.
13764567021bSThomas NikolajsenAny snapshot softlinks within the retention period are ignored
13775f22d366SThomas Nikolajsenfor the purposes of pruning (i.e.\& the fine grained history is retained).
13784567021bSThomas NikolajsenNumber of days, hours, minutes and seconds are given as
13794567021bSThomas Nikolajsen.Ar N , hh , mm
13804567021bSThomas Nikolajsenand
13814567021bSThomas Nikolajsen.Ar ss .
13820bd7a37cSMatthew Dillon.Pp
13830bd7a37cSMatthew DillonBecause the transaction id in the snapshot softlink cannot be used
13840bd7a37cSMatthew Dillonto calculate a timestamp,
13850bd7a37cSMatthew Dillon.Nm HAMMER
13864567021bSThomas Nikolajsenuses the earlier of the
13874567021bSThomas Nikolajsen.Fa st_ctime
13884567021bSThomas Nikolajsenor
13894567021bSThomas Nikolajsen.Fa st_mtime
13904567021bSThomas Nikolajsenfield of the softlink to
13910bd7a37cSMatthew Dillondetermine which snapshots fall within the retention period.
13920bd7a37cSMatthew DillonUsers must be sure to retain one of these two fields when manipulating
13930bd7a37cSMatthew Dillonthe softlink.
139434ebae70SMatthew Dillon.El
139534bb69d8SThomas Nikolajsen.\" ==== pfs-upgrade ====
13964567021bSThomas Nikolajsen.It Cm pfs-upgrade Ar dirpath
13972010519fSThomas NikolajsenUpgrade a PFS from slave to master operation.
13984567021bSThomas NikolajsenThe PFS will be rolled back to the current end synchronization transaction id
13992010519fSThomas Nikolajsen(removing any partial synchronizations), and will then become writable.
140034bb69d8SThomas Nikolajsen.Pp
140134bb69d8SThomas Nikolajsen.Em WARNING!
140234bb69d8SThomas Nikolajsen.Nm HAMMER
140334bb69d8SThomas Nikolajsencurrently supports only single masters and using
14042010519fSThomas Nikolajsenthis command can easily result in file system corruption
14052010519fSThomas Nikolajsenif you don't know what you are doing.
140634bb69d8SThomas Nikolajsen.Pp
140734bb69d8SThomas NikolajsenThis directive will refuse to run if any programs have open descriptors
140834bb69d8SThomas Nikolajsenin the PFS, including programs chdir'd into the PFS.
140934bb69d8SThomas Nikolajsen.\" ==== pfs-downgrade ====
14104567021bSThomas Nikolajsen.It Cm pfs-downgrade Ar dirpath
1411aaf93065SThomas NikolajsenDowngrade a master PFS from master to slave operation.
14122010519fSThomas NikolajsenThe PFS becomes read-only and access will be locked to its
14134567021bSThomas Nikolajsen.Cm sync-end-tid .
141434bb69d8SThomas Nikolajsen.Pp
141534bb69d8SThomas NikolajsenThis directive will refuse to run if any programs have open descriptors
141634bb69d8SThomas Nikolajsenin the PFS, including programs chdir'd into the PFS.
141734bb69d8SThomas Nikolajsen.\" ==== pfs-destroy ====
14184567021bSThomas Nikolajsen.It Cm pfs-destroy Ar dirpath
141934bb69d8SThomas NikolajsenThis permanently destroys a PFS.
142034bb69d8SThomas Nikolajsen.Pp
142134bb69d8SThomas NikolajsenThis directive will refuse to run if any programs have open descriptors
142234bb69d8SThomas Nikolajsenin the PFS, including programs chdir'd into the PFS.
14235f22d366SThomas NikolajsenAs safety measure the
14245f22d366SThomas Nikolajsen.Fl y
14255f22d366SThomas Nikolajsenflag have no effect on this directive.
142615fa4cafSThomas Nikolajsen.\" ==== mirror-read ====
14274567021bSThomas Nikolajsen.It Cm mirror-read Ar filesystem Op Ar begin-tid
142834ebae70SMatthew DillonGenerate a mirroring stream to stdout.
142948eadef9SMatthew DillonThe stream ends when the transaction id space has been exhausted.
14305f22d366SThomas Nikolajsen.Ar filesystem
14315f22d366SThomas Nikolajsenmay be a master or slave PFS.
143215fa4cafSThomas Nikolajsen.\" ==== mirror-read-stream ====
14334567021bSThomas Nikolajsen.It Cm mirror-read-stream Ar filesystem Op Ar begin-tid
143448eadef9SMatthew DillonGenerate a mirroring stream to stdout.
143548eadef9SMatthew DillonUpon completion the stream is paused until new data is synced to the
1436aaf93065SThomas Nikolajsen.Ar filesystem ,
1437aaf93065SThomas Nikolajsenthen resumed.
143848eadef9SMatthew DillonOperation continues until the pipe is broken.
1439aaf93065SThomas NikolajsenSee the
1440aaf93065SThomas Nikolajsen.Cm mirror-stream
1441aaf93065SThomas Nikolajsencommand for more details.
144215fa4cafSThomas Nikolajsen.\" ==== mirror-write ====
14434567021bSThomas Nikolajsen.It Cm mirror-write Ar filesystem
144434bb69d8SThomas NikolajsenTake a mirroring stream on stdin.
14455f22d366SThomas Nikolajsen.Ar filesystem
14465f22d366SThomas Nikolajsenmust be a slave PFS.
144734ebae70SMatthew Dillon.Pp
144834ebae70SMatthew DillonThis command will fail if the
14494567021bSThomas Nikolajsen.Cm shared-uuid
145034ebae70SMatthew Dillonconfiguration field for the two file systems do not match.
1451aaf93065SThomas NikolajsenSee the
1452aaf93065SThomas Nikolajsen.Cm mirror-copy
1453aaf93065SThomas Nikolajsencommand for more details.
145401a72c9fSMatthew Dillon.Pp
145501a72c9fSMatthew DillonIf the target PFS does not exist this command will ask you whether
145601a72c9fSMatthew Dillonyou want to create a compatible PFS slave for the target or not.
145715fa4cafSThomas Nikolajsen.\" ==== mirror-dump ====
14589f1b0121SAntonio Huete Jimenez.It Ar mirror-dump Ar [header]
145915fa4cafSThomas NikolajsenA
14604567021bSThomas Nikolajsen.Cm mirror-read
146115fa4cafSThomas Nikolajsencan be piped into a
14624567021bSThomas Nikolajsen.Cm mirror-dump
14632010519fSThomas Nikolajsento dump an ASCII representation of the mirroring stream.
14649f1b0121SAntonio Huete JimenezIf the keyword
14659f1b0121SAntonio Huete Jimenez.Ar header
14669f1b0121SAntonio Huete Jimenezis specified, only the header information is shown.
146715fa4cafSThomas Nikolajsen.\" ==== mirror-copy ====
14684567021bSThomas Nikolajsen.\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem
1469f85afb25SThomas Nikolajsen.It Cm mirror-copy \
1470f6532f03SThomas NikolajsenOo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1471f6532f03SThomas NikolajsenOo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
147284082922SThomas NikolajsenThis is a shortcut which pipes a
14734567021bSThomas Nikolajsen.Cm mirror-read
147484082922SThomas Nikolajsencommand to a
14754567021bSThomas Nikolajsen.Cm mirror-write
14762010519fSThomas Nikolajsencommand.
14772010519fSThomas NikolajsenIf a remote host specification is made the program forks a
14786d9ab5c5SSascha Wildner.Xr ssh 1
1479e2c596b1SChris Turner(or other program as specified by the
1480e2c596b1SChris Turner.Ev HAMMER_RSH
1481e2c596b1SChris Turnerenvironment variable) and execs the
14824567021bSThomas Nikolajsen.Cm mirror-read
148384082922SThomas Nikolajsenand/or
14844567021bSThomas Nikolajsen.Cm mirror-write
148584082922SThomas Nikolajsenon the appropriate host.
14869c67b4d2SMatthew DillonThe source may be a master or slave PFS, and the target must be a slave PFS.
1487d4e5b69bSMatthew Dillon.Pp
1488aaf93065SThomas NikolajsenThis command also establishes full duplex communication and turns on
1489aaf93065SThomas Nikolajsenthe 2-way protocol feature
1490aaf93065SThomas Nikolajsen.Fl ( 2 )
1491aaf93065SThomas Nikolajsenwhich automatically negotiates transaction id
14922010519fSThomas Nikolajsenranges without having to use a cyclefile.
149384082922SThomas NikolajsenIf the operation completes successfully the target PFS's
14944567021bSThomas Nikolajsen.Cm sync-end-tid
14952010519fSThomas Nikolajsenwill be updated.
14962010519fSThomas NikolajsenNote that you must re-chdir into the target PFS to see the updated information.
14972010519fSThomas NikolajsenIf you do not you will still be in the previous snapshot.
149801a72c9fSMatthew Dillon.Pp
149901a72c9fSMatthew DillonIf the target PFS does not exist this command will ask you whether
150001a72c9fSMatthew Dillonyou want to create a compatible PFS slave for the target or not.
150115fa4cafSThomas Nikolajsen.\" ==== mirror-stream ====
15024567021bSThomas Nikolajsen.\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem
1503f85afb25SThomas Nikolajsen.It Cm mirror-stream \
1504f6532f03SThomas NikolajsenOo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1505f6532f03SThomas NikolajsenOo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1506aaf93065SThomas NikolajsenThis is a shortcut which pipes a
1507aaf93065SThomas Nikolajsen.Cm mirror-read-stream
1508aaf93065SThomas Nikolajsencommand to a
1509aaf93065SThomas Nikolajsen.Cm mirror-write
1510aaf93065SThomas Nikolajsencommand.
151148eadef9SMatthew DillonThis command works similarly to
15124567021bSThomas Nikolajsen.Cm mirror-copy
1513e7f926a5SMatthew Dillonbut does not exit after the initial mirroring completes.
1514e7f926a5SMatthew DillonThe mirroring operation will resume as changes continue to be made to the
1515aaf93065SThomas Nikolajsensource.
15162010519fSThomas NikolajsenThe command is commonly used with
151748eadef9SMatthew Dillon.Fl i Ar delay
151848eadef9SMatthew Dillonand
151948eadef9SMatthew Dillon.Fl b Ar bandwidth
152048eadef9SMatthew Dillonoptions to keep the mirroring target in sync with the source on a continuing
152148eadef9SMatthew Dillonbasis.
1522e7f926a5SMatthew Dillon.Pp
1523e7f926a5SMatthew DillonIf the pipe is broken the command will automatically retry after sleeping
15244567021bSThomas Nikolajsenfor a short while.
15254567021bSThomas NikolajsenThe time slept will be 15 seconds plus the time given in the
15260bd7a37cSMatthew Dillon.Fl i
15270bd7a37cSMatthew Dillonoption.
1528e7f926a5SMatthew Dillon.Pp
1529e7f926a5SMatthew DillonThis command also detects the initial-mirroring case and spends some
1530e7f926a5SMatthew Dillontime scanning the B-Tree to find good break points, allowing the initial
15315f22d366SThomas Nikolajsenbulk mirroring operation to be broken down into 4GB pieces.
1532e7f926a5SMatthew DillonThis means that the user can kill and restart the operation and it will
1533e7f926a5SMatthew Dillonnot have to start from scratch once it has gotten past the first chunk.
15340bd7a37cSMatthew DillonThe
1535aaf93065SThomas Nikolajsen.Fl S
1536aaf93065SThomas Nikolajsenoption may be used to change the size of pieces and the
15370bd7a37cSMatthew Dillon.Fl B
15380bd7a37cSMatthew Dillonoption may be used to disable this feature and perform an initial bulk
15390bd7a37cSMatthew Dillontransfer instead.
1540de1c0b31SMatthew Dillon.\" ==== version ====
15414567021bSThomas Nikolajsen.It Cm version Ar filesystem
15423f2565b9SSascha WildnerThis command returns the
15433f2565b9SSascha Wildner.Nm HAMMER
15443f2565b9SSascha Wildnerfile system version for the specified
15454567021bSThomas Nikolajsen.Ar filesystem
15464567021bSThomas Nikolajsenas well as the range of versions supported in the kernel.
1547de1c0b31SMatthew DillonThe
1548de1c0b31SMatthew Dillon.Fl q
1549de1c0b31SMatthew Dillonoption may be used to remove the summary at the end.
1550de1c0b31SMatthew Dillon.\" ==== version-upgrade ====
15514567021bSThomas Nikolajsen.It Cm version-upgrade Ar filesystem Ar version Op Cm force
15525f22d366SThomas NikolajsenUpgrade the
15533f2565b9SSascha Wildner.Nm HAMMER
15544567021bSThomas Nikolajsen.Ar filesystem
15554567021bSThomas Nikolajsento the specified
15564567021bSThomas Nikolajsen.Ar version .
1557de1c0b31SMatthew DillonOnce upgraded a file system may not be downgraded.
1558de1c0b31SMatthew DillonIf you wish to upgrade a file system to a version greater or equal to the
15595f22d366SThomas Nikolajsenwork-in-progress (WIP) version number you must specify the
15604567021bSThomas Nikolajsen.Cm force
1561de1c0b31SMatthew Dillondirective.
1562de1c0b31SMatthew DillonUse of WIP versions should be relegated to testing and may require wiping
1563de1c0b31SMatthew Dillonthe file system as development progresses, even though the WIP version might
1564de1c0b31SMatthew Dillonnot change.
1565de1c0b31SMatthew Dillon.Pp
15664567021bSThomas Nikolajsen.Em NOTE!
15674567021bSThomas NikolajsenThis command operates on the entire
15683f2565b9SSascha Wildner.Nm HAMMER
15694567021bSThomas Nikolajsenfile system and is not a per PFS operation.
15703f2565b9SSascha WildnerAll PFS's will be affected.
1571de1c0b31SMatthew Dillon.Bl -tag -width indent
1572de1c0b31SMatthew Dillon.It 1
15733f2565b9SSascha Wildner.Dx 2.0
15743f2565b9SSascha Wildnerdefault version, first
15753f2565b9SSascha Wildner.Nm HAMMER
15763f2565b9SSascha Wildnerrelease.
1577de1c0b31SMatthew Dillon.It 2
1578f6532f03SThomas Nikolajsen.Dx 2.3 .
1579f6532f03SThomas NikolajsenNew directory entry layout.
15804567021bSThomas NikolajsenThis version is using a new directory hash key.
158116265794SThomas Nikolajsen.It 3
1582856bc468SThomas Nikolajsen.Dx 2.5 .
158316265794SThomas NikolajsenNew snapshot management, using file system meta-data for saving
158416265794SThomas Nikolajsenconfiguration file and snapshots (transaction ids etc.).
158516265794SThomas NikolajsenAlso default snapshots directory has changed.
158616265794SThomas Nikolajsen.It 4
15879d0a6205SMatthew Dillon.Dx 2.6
1588856bc468SThomas Nikolajsendefault version.
15895f22d366SThomas NikolajsenNew undo/redo/flush, giving
15905f22d366SThomas Nikolajsen.Nm HAMMER
15915f22d366SThomas Nikolajsena much faster sync and fsync.
15923fda8610SSascha Wildner.It 5
15933fda8610SSascha Wildner.Dx 2.9 .
15945f22d366SThomas NikolajsenDeduplication support.
15955f22d366SThomas Nikolajsen.It 6
15965f22d366SThomas Nikolajsen.Dx 2.9 .
15975f22d366SThomas NikolajsenDirectory hash ALG1.
15985f22d366SThomas NikolajsenTends to maintain inode number / directory name entry ordering better
15995f22d366SThomas Nikolajsenfor files after minor renaming.
16004c09d9c4SMatthew Dillon.It 7
16014c09d9c4SMatthew Dillon.Dx 4.8 .
1602*d4155bf4SSascha WildnerUse the ISCSI crc32 algorithm instead of our custom polynomial.
1603*d4155bf4SSascha WildnerThis makes it easier to use faster cpu implementation of the crc algorithm.
1604*d4155bf4SSascha WildnerCPU
16054c09d9c4SMatthew Dillonoverhead is reduced but performance is unlikely to be impacted a whole lot.
1606de1c0b31SMatthew Dillon.El
16070dfeb6c8SMatthew Dillon.El
16084567021bSThomas Nikolajsen.Sh PSEUDO-FILESYSTEM (PFS) NOTES
1609b4448f1aSThomas NikolajsenThe root of a PFS is not hooked into the primary
1610b4448f1aSThomas Nikolajsen.Nm HAMMER
16112010519fSThomas Nikolajsenfile system as a directory.
1612b4448f1aSThomas NikolajsenInstead,
1613b4448f1aSThomas Nikolajsen.Nm HAMMER
16144567021bSThomas Nikolajsencreates a special softlink called
16154567021bSThomas Nikolajsen.Ql @@PFS%05d
16164567021bSThomas Nikolajsen(exactly 10 characters long) in the primary
1617b4448f1aSThomas Nikolajsen.Nm HAMMER
1618b4448f1aSThomas Nikolajsenfile system.
1619b4448f1aSThomas Nikolajsen.Nm HAMMER
1620b4448f1aSThomas Nikolajsenthen modifies the contents of the softlink as read by
16219c67b4d2SMatthew Dillon.Xr readlink 2 ,
162284082922SThomas Nikolajsenand thus what you see with an
162316265794SThomas Nikolajsen.Nm ls
162484082922SThomas Nikolajsencommand or if you were to
162516265794SThomas Nikolajsen.Nm cd
162684082922SThomas Nikolajseninto the link.
16279c67b4d2SMatthew DillonIf the PFS is a master the link reflects the current state of the PFS.
16289c67b4d2SMatthew DillonIf the PFS is a slave the link reflects the last completed snapshot, and the
16299c67b4d2SMatthew Dilloncontents of the link will change when the next snapshot is completed, and
16309c67b4d2SMatthew Dillonso forth.
16319c67b4d2SMatthew Dillon.Pp
16322010519fSThomas NikolajsenThe
16339c67b4d2SMatthew Dillon.Nm
16342010519fSThomas Nikolajsenutility employs numerous safeties to reduce user foot-shooting.
16359c67b4d2SMatthew DillonThe
16364567021bSThomas Nikolajsen.Cm mirror-copy
16379c67b4d2SMatthew Dillondirective requires that the target be configured as a slave and that the
16384567021bSThomas Nikolajsen.Cm shared-uuid
16399c67b4d2SMatthew Dillonfield of the mirroring source and target match.
16408babb8e4STomohiro KusumiThe
16418babb8e4STomohiro Kusumi.Cm pfs-master
16428babb8e4STomohiro Kusumiand
16438babb8e4STomohiro Kusumi.Cm pfs-slave
16448babb8e4STomohiro Kusumidirectives require that the PFS softlink be created under the main
16458babb8e4STomohiro Kusumi.Nm
1646*d4155bf4SSascha Wildnerfilesystem mount.
1647*d4155bf4SSascha WildnerYou may only access PFS softlinks via the main
16488babb8e4STomohiro Kusumi.Nm
16498babb8e4STomohiro Kusumifilesystem mount.
16503d048a1bSMatthew Dillon.Sh DOUBLE_BUFFER MODE
16513d048a1bSMatthew DillonThere is a limit to the number of vnodes the kernel can cache, and because
16523d048a1bSMatthew Dillonfile buffers are associated with a vnode the related data cache can get
16533d048a1bSMatthew Dillonblown away when operating on large numbers of files even if the system has
16543d048a1bSMatthew Dillonsufficient memory to hold the file data.
16553d048a1bSMatthew Dillon.Pp
16565f22d366SThomas NikolajsenIf you turn on
16575f22d366SThomas Nikolajsen.Nm HAMMER Ns 's
16585f22d366SThomas Nikolajsendouble buffer mode by setting the
16595f22d366SThomas Nikolajsen.Xr sysctl 8
16605f22d366SThomas Nikolajsennode
16613d048a1bSMatthew Dillon.Va vfs.hammer.double_buffer
16623d048a1bSMatthew Dillonto 1
16633d048a1bSMatthew Dillon.Nm HAMMER
16643d048a1bSMatthew Dillonwill cache file data via the block device and copy it into the per-file
1665*d4155bf4SSascha Wildnerbuffers as needed.
1666*d4155bf4SSascha WildnerThe data will be double-cached at least until the
16673d048a1bSMatthew Dillonbuffer cache throws away the file buffer.
1668bedb3c1cSSascha WildnerThis mode is typically used in conjunction with
16693d048a1bSMatthew Dillon.Xr swapcache 8
16703d048a1bSMatthew Dillonwhen
16713d048a1bSMatthew Dillon.Va vm.swapcache.data_enable
16723d048a1bSMatthew Dillonis turned on in order to prevent unnecessary re-caching of file data
16733d048a1bSMatthew Dillondue to vnode recycling.
16745f22d366SThomas NikolajsenThe swapcache will save the cached VM pages related to
16755f22d366SThomas Nikolajsen.Nm HAMMER Ns 's
16765f22d366SThomas Nikolajsenblock
16773d048a1bSMatthew Dillondevice (which doesn't recycle unless you umount the filesystem) instead
16783d048a1bSMatthew Dillonof the cached VM pages backing the file vnodes.
1679125966e8SMatthew Dillon.Pp
16807c5aac38SSascha WildnerDouble buffering is normally desirable when working with large filesystems,
1681125966e8SMatthew Dillonparticularly when swapcache is used.
1682125966e8SMatthew DillonThe swapcache can only back active VM objects, including the block device,
1683125966e8SMatthew Dillonand large filesystems often have far more inodes than the kernel can support.
1684125966e8SMatthew DillonIn addition, when using this mode, you may wish to reduce the
1685125966e8SMatthew Dillon.Va kern.maxvnodes
1686125966e8SMatthew Dillonsetting for the system to force the system to do less caching of logical
1687125966e8SMatthew Dillonfile buffers and more caching of device buffers, since the device buffers
1688125966e8SMatthew Dillonare backing the logical file buffers.
1689bf2c6489SMatthew Dillon.Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2
169016265794SThomas NikolajsenThis upgrade changes the way directory entries are stored.
169116265794SThomas NikolajsenIt is possible to upgrade a V1 file system to V2 in place, but
1692bf2c6489SMatthew Dillondirectories created prior to the upgrade will continue to use
1693bf2c6489SMatthew Dillonthe old layout.
1694bf2c6489SMatthew Dillon.Pp
1695bf2c6489SMatthew DillonNote that the slave mirroring code in the target kernel had bugs in
1696bf2c6489SMatthew DillonV1 which can create an incompatible root directory on the slave.
169716265794SThomas NikolajsenDo not mix a
169816265794SThomas Nikolajsen.Nm HAMMER
169916265794SThomas Nikolajsenmaster created after the upgrade with a
170016265794SThomas Nikolajsen.Nm HAMMER
1701bf2c6489SMatthew Dillonslave created prior to the upgrade.
1702bf2c6489SMatthew Dillon.Pp
1703bf2c6489SMatthew DillonAny directories created after upgrading will use a new layout.
1704bf2c6489SMatthew Dillon.Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3
170516265794SThomas NikolajsenThis upgrade adds meta-data elements to the B-Tree.
170616265794SThomas NikolajsenIt is possible to upgrade a V2 file system to V3 in place.
170716265794SThomas NikolajsenAfter issuing the upgrade be sure to run a
170816265794SThomas Nikolajsen.Nm
170916265794SThomas Nikolajsen.Cm cleanup
171016265794SThomas Nikolajsento perform post-upgrade tasks.
1711bf2c6489SMatthew Dillon.Pp
171216265794SThomas NikolajsenAfter making this upgrade running a
171316265794SThomas Nikolajsen.Nm
171416265794SThomas Nikolajsen.Cm cleanup
171516265794SThomas Nikolajsenwill move the
171616265794SThomas Nikolajsen.Pa <pfs>/snapshots
1717bf2c6489SMatthew Dillondirectory for each PFS mount into
171816265794SThomas Nikolajsen.Pa /var/hammer/<pfs> .
171916265794SThomas NikolajsenA
172016265794SThomas Nikolajsen.Nm HAMMER
172116265794SThomas Nikolajsenroot mount will migrate
1722bf2c6489SMatthew Dillon.Pa /snapshots
1723bf2c6489SMatthew Dilloninto
1724bf2c6489SMatthew Dillon.Pa /var/hammer/root .
1725bf2c6489SMatthew DillonMigration occurs only once and only if you have not specified
172616265794SThomas Nikolajsena snapshots directory in the PFS configuration.
172716265794SThomas NikolajsenIf you have specified a snapshots directory in the PFS configuration no
1728bf2c6489SMatthew Dillonautomatic migration will occur.
1729bf2c6489SMatthew Dillon.Pp
1730bf2c6489SMatthew DillonFor slaves, if you desire, you can migrate your snapshots
1731bf2c6489SMatthew Dillonconfig to the new location manually and then clear the
1732bf2c6489SMatthew Dillonsnapshot directory configuration in the slave PFS.
1733bf2c6489SMatthew DillonThe new snapshots hierarchy is designed to work with
1734bf2c6489SMatthew Dillonboth master and slave PFSs equally well.
1735bf2c6489SMatthew Dillon.Pp
1736f6532f03SThomas NikolajsenIn addition, the old config file will be moved to file system meta-data,
173716265794SThomas Nikolajseneditable via the new
173816265794SThomas Nikolajsen.Nm
1739bf2c6489SMatthew Dillon.Cm viconfig
174016265794SThomas Nikolajsendirective.
174116265794SThomas NikolajsenThe old config file will be deleted.
1742bf2c6489SMatthew DillonMigration occurs only once.
1743bf2c6489SMatthew Dillon.Pp
1744bf2c6489SMatthew DillonThe V3 file system has new
1745bf2c6489SMatthew Dillon.Cm snap*
1746bf2c6489SMatthew Dillondirectives for creating snapshots.
1747bf2c6489SMatthew DillonAll snapshot directives, including the original, will create
1748bf2c6489SMatthew Dillonmeta-data entries for the snapshots and the pruning code will
1749bf2c6489SMatthew Dillonautomatically incorporate these entries into its list and
1750bf2c6489SMatthew Dillonexpire them the same way it expires softlinks.
175116265794SThomas NikolajsenIf you by accident blow away your snapshot softlinks you can use the
1752bf2c6489SMatthew Dillon.Cm snapls
1753f6532f03SThomas Nikolajsendirective to get a definitive list from the file system meta-data and
1754bf2c6489SMatthew Dillonregenerate them from that list.
175592ed14a3SMatthew Dillon.Pp
175616265794SThomas Nikolajsen.Em WARNING!
175716265794SThomas NikolajsenIf you are using
175816265794SThomas Nikolajsen.Nm
175916265794SThomas Nikolajsento backup file systems your scripts may be using the
176092ed14a3SMatthew Dillon.Cm synctid
176116265794SThomas Nikolajsendirective to generate transaction ids.
176216265794SThomas NikolajsenThis directive does not create a snapshot.
176316265794SThomas NikolajsenYou will have to modify your scripts to use the
176492ed14a3SMatthew Dillon.Cm snapq
176592ed14a3SMatthew Dillondirective to generate the linkbuf for the softlink you create, or
176692ed14a3SMatthew Dillonuse one of the other
176792ed14a3SMatthew Dillon.Cm snap*
176892ed14a3SMatthew Dillondirectives.
176992ed14a3SMatthew DillonThe older
177092ed14a3SMatthew Dillon.Cm snapshot
177192ed14a3SMatthew Dillondirective will continue to work as expected and in V3 it will also
1772f6532f03SThomas Nikolajsenrecord the snapshot transaction id in file system meta-data.
177316265794SThomas NikolajsenYou may also want to make use of the new
177416265794SThomas Nikolajsen.Ar note
177516265794SThomas Nikolajsentag for the meta-data.
177692ed14a3SMatthew Dillon.Pp
177716265794SThomas Nikolajsen.Em WARNING!
177816265794SThomas NikolajsenIf you used to remove snapshot softlinks with
177992ed14a3SMatthew Dillon.Nm rm
178092ed14a3SMatthew Dillonyou should probably start using the
178192ed14a3SMatthew Dillon.Cm snaprm
178292ed14a3SMatthew Dillondirective instead to also remove the related meta-data.
178392ed14a3SMatthew DillonThe pruning code scans the meta-data so just removing the
178492ed14a3SMatthew Dillonsoftlink is not sufficient.
1785856bc468SThomas Nikolajsen.Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4
1786856bc468SThomas NikolajsenThis upgrade changes undo/flush, giving faster sync.
1787856bc468SThomas NikolajsenIt is possible to upgrade a V3 file system to V4 in place.
17885f22d366SThomas NikolajsenThis upgrade reformats the UNDO/REDO FIFO (typically 1GB),
17895f22d366SThomas Nikolajsenso upgrade might take a minute or two depending.
1790856bc468SThomas Nikolajsen.Pp
17915f22d366SThomas NikolajsenVersion 4 allows the UNDO/REDO FIFO to be flushed without also having
1792856bc468SThomas Nikolajsento flush the volume header, removing 2 of the 4 disk syncs typically
1793aaf93065SThomas Nikolajsenrequired for an
1794aaf93065SThomas Nikolajsen.Fn fsync
1795aaf93065SThomas Nikolajsenand removing 1 of the 2 disk syncs typically
1796856bc468SThomas Nikolajsenrequired for a flush sequence.
17975f22d366SThomas NikolajsenVersion 4 also implements the REDO log (see
17985f22d366SThomas Nikolajsen.Sx FSYNC FLUSH MODES
17995f22d366SThomas Nikolajsenbelow) which is capable
1800*d4155bf4SSascha Wildnerof
1801*d4155bf4SSascha Wildner.Fn fsync Ns ing
1802*d4155bf4SSascha Wildnerwith either one disk flush or zero disk flushes.
18033fda8610SSascha Wildner.Sh UPGRADE INSTRUCTIONS HAMMER V4 TO V5
18045f22d366SThomas NikolajsenThis upgrade brings in deduplication support.
18055f22d366SThomas NikolajsenIt is possible to upgrade a V4 file system to V5 in place.
18065f22d366SThomas NikolajsenTechnically it makes the layer2
18075f22d366SThomas Nikolajsen.Va bytes_free
18085f22d366SThomas Nikolajsenfield a signed value instead of unsigned, allowing it to go negative.
18095f22d366SThomas NikolajsenA version 5 filesystem is required for dedup operation.
18105f22d366SThomas Nikolajsen.Sh UPGRADE INSTRUCTIONS HAMMER V5 TO V6
18115f22d366SThomas NikolajsenIt is possible to upgrade a V5 file system to V6 in place.
18124c09d9c4SMatthew Dillon.Sh UPGRADE INSTRUCTIONS HAMMER V6 TO V7
18134c09d9c4SMatthew DillonIt is possible to upgrade a V6 file system to V7 in place.
18144c09d9c4SMatthew DillonAfter upgrading any new files will use the new, faster CRC.
18154c09d9c4SMatthew DillonYou can convert all existing files to use the new CRC by issuing
18164c09d9c4SMatthew Dillona full reblock via 'hammer reblock <fs>'.
18174c09d9c4SMatthew DillonYou only have to do this once.
1818152385a8SMatthew Dillon.Sh FSYNC FLUSH MODES
1819aaf93065SThomas Nikolajsen.Nm HAMMER
1820aaf93065SThomas Nikolajsenimplements five different fsync flush modes via the
1821aaf93065SThomas Nikolajsen.Va vfs.hammer.fsync_mode
1822aaf93065SThomas Nikolajsensysctl, for
1823aaf93065SThomas Nikolajsen.Nm HAMMER
1824aaf93065SThomas Nikolajsenversion 4+ file systems.
1825152385a8SMatthew Dillon.Pp
18269d0a6205SMatthew DillonAs of
1827aaf93065SThomas Nikolajsen.Dx 2.6
18289d0a6205SMatthew Dillonfsync mode 3 is set by default.
18299d0a6205SMatthew DillonREDO operation and recovery is enabled by default.
1830152385a8SMatthew Dillon.Bl -tag -width indent
1831152385a8SMatthew Dillon.It mode 0
1832152385a8SMatthew DillonFull synchronous fsync semantics without REDO.
1833152385a8SMatthew Dillon.Pp
1834aaf93065SThomas Nikolajsen.Nm HAMMER
1835aaf93065SThomas Nikolajsenwill not generate REDOs.
1836aaf93065SThomas NikolajsenA
1837aaf93065SThomas Nikolajsen.Fn fsync
1838aaf93065SThomas Nikolajsenwill completely sync
1839152385a8SMatthew Dillonthe data and meta-data and double-flush the FIFO, including
1840aaf93065SThomas Nikolajsenissuing two disk synchronization commands.
1841aaf93065SThomas NikolajsenThe data is guaranteed
1842aaf93065SThomas Nikolajsento be on the media as of when
1843aaf93065SThomas Nikolajsen.Fn fsync
1844aaf93065SThomas Nikolajsenreturns.
1845152385a8SMatthew DillonNeedless to say, this is slow.
1846152385a8SMatthew Dillon.It mode 1
1847152385a8SMatthew DillonRelaxed asynchronous fsync semantics without REDO.
1848152385a8SMatthew Dillon.Pp
1849152385a8SMatthew DillonThis mode works the same as mode 0 except the last disk synchronization
1850aaf93065SThomas Nikolajsencommand is not issued.
1851aaf93065SThomas NikolajsenIt is faster than mode 0 but not even remotely
1852152385a8SMatthew Dillonclose to the speed you get with mode 2 or mode 3.
1853152385a8SMatthew Dillon.Pp
1854152385a8SMatthew DillonNote that there is no chance of meta-data corruption when using this
1855aaf93065SThomas Nikolajsenmode, it simply means that the data you wrote and then
1856aaf93065SThomas Nikolajsen.Fn fsync Ns 'd
1857aaf93065SThomas Nikolajsenmight not have made it to the media if the storage system crashes at a bad
1858152385a8SMatthew Dillontime.
1859152385a8SMatthew Dillon.It mode 2
1860152385a8SMatthew DillonFull synchronous fsync semantics using REDO.
18615f22d366SThomas NikolajsenNOTE: If not running a
18625f22d366SThomas Nikolajsen.Nm HAMMER
18635f22d366SThomas Nikolajsenversion 4 filesystem or later mode 0 is silently used.
1864152385a8SMatthew Dillon.Pp
1865aaf93065SThomas Nikolajsen.Nm HAMMER
1866aaf93065SThomas Nikolajsenwill generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1867aaf93065SThomas NikolajsenIf this is sufficient to satisfy the
1868aaf93065SThomas Nikolajsen.Fn fsync
18695f22d366SThomas Nikolajsenoperation the blocks will be written out and
1870aaf93065SThomas Nikolajsen.Nm HAMMER
1871aaf93065SThomas Nikolajsenwill wait for the I/Os to complete,
1872152385a8SMatthew Dillonand then followup with a disk sync command to guarantee the data
1873152385a8SMatthew Dillonis on the media before returning.
1874152385a8SMatthew DillonThis is slower than mode 3 and can result in significant disk or
1875152385a8SMatthew DillonSSDs overheads, though not as bad as mode 0 or mode 1.
1876152385a8SMatthew Dillon.It mode 3
1877152385a8SMatthew DillonRelaxed asynchronous fsync semantics using REDO.
18785f22d366SThomas NikolajsenNOTE: If not running a
18795f22d366SThomas Nikolajsen.Nm HAMMER
18805f22d366SThomas Nikolajsenversion 4 filesystem or later mode 1 is silently used.
1881152385a8SMatthew Dillon.Pp
1882aaf93065SThomas Nikolajsen.Nm HAMMER
1883aaf93065SThomas Nikolajsenwill generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1884aaf93065SThomas NikolajsenIf this is sufficient to satisfy the
1885aaf93065SThomas Nikolajsen.Fn fsync
1886aaf93065SThomas Nikolajsenoperation the blocks
1887aaf93065SThomas Nikolajsenwill be written out and
1888aaf93065SThomas Nikolajsen.Nm HAMMER
1889aaf93065SThomas Nikolajsenwill wait for the I/Os to complete,
1890152385a8SMatthew Dillonbut will
1891152385a8SMatthew Dillon.Em NOT
1892152385a8SMatthew Dillonissue a disk synchronization command.
1893152385a8SMatthew Dillon.Pp
1894152385a8SMatthew DillonNote that there is no chance of meta-data corruption when using this
1895aaf93065SThomas Nikolajsenmode, it simply means that the data you wrote and then
1896aaf93065SThomas Nikolajsen.Fn fsync Ns 'd
1897aaf93065SThomas Nikolajsenmight
1898152385a8SMatthew Dillonnot have made it to the media if the storage system crashes at a bad
1899152385a8SMatthew Dillontime.
1900152385a8SMatthew Dillon.Pp
1901152385a8SMatthew DillonThis mode is the fastest production fsyncing mode available.
1902aaf93065SThomas NikolajsenThis mode is equivalent to how the UFS fsync in the
1903aaf93065SThomas Nikolajsen.Bx Ns s
1904aaf93065SThomas Nikolajsenoperates.
1905152385a8SMatthew Dillon.It mode 4
1906152385a8SMatthew Dillonfsync is ignored.
1907152385a8SMatthew Dillon.Pp
1908aaf93065SThomas NikolajsenCalls to
1909aaf93065SThomas Nikolajsen.Fn fsync
1910aaf93065SThomas Nikolajsenwill be ignored.
1911aaf93065SThomas NikolajsenThis mode is primarily designed
1912152385a8SMatthew Dillonfor testing and should not be used on a production system.
1913152385a8SMatthew Dillon.El
19143120b3e8SMatthew Dillon.Sh RESTORING FROM A SNAPSHOT BACKUP
19153120b3e8SMatthew DillonYou restore a snapshot by copying it over to live, but there is a caveat.
19163120b3e8SMatthew DillonThe mtime and atime fields for files accessed via a snapshot is locked
19173120b3e8SMatthew Dillonto the ctime in order to keep the snapshot consistent, because neither
19183120b3e8SMatthew Dillonmtime nor atime changes roll any history.
19193120b3e8SMatthew Dillon.Pp
19203120b3e8SMatthew DillonIn order to avoid unnecessary copying it is recommended that you use
19213120b3e8SMatthew Dillon.Nm cpdup
19223120b3e8SMatthew Dillon.Fl VV
19233120b3e8SMatthew Dillon.Fl v
19245f22d366SThomas Nikolajsenwhen doing the copyback.
19255f22d366SThomas NikolajsenAlso make sure you traverse the snapshot softlink by appending a ".",
19265f22d366SThomas Nikolajsenas in "<snapshotpath>/.", and you match up the directory properly.
19275f22d366SThomas Nikolajsen.Sh RESTORING A PFS FROM A MIRROR
19285f22d366SThomas NikolajsenA PFS can be restored from a mirror with
19295f22d366SThomas Nikolajsen.Cm mirror-copy .
19305f22d366SThomas Nikolajsen.Cm config
19315f22d366SThomas Nikolajsendata must be copied separately.
19325f22d366SThomas NikolajsenAt last the PFS can be upgraded to master using
19335f22d366SThomas Nikolajsen.Cm pfs-upgrade .
19345f22d366SThomas Nikolajsen.Pp
1935a5ff7917STomohiro KusumiIt is not possible to restore the root PFS by using mirroring,
19365f22d366SThomas Nikolajsenas the root PFS is always a master PFS.
19375f22d366SThomas NikolajsenA normal copy (e.g.\& using
19385f22d366SThomas Nikolajsen.Xr cpdup 1 )
19395f22d366SThomas Nikolajsenmust be done, ignoring history.
19405f22d366SThomas NikolajsenIf history is important, old root PFS can me restored to a new PFS, and
19415f22d366SThomas Nikolajsenimportant directories/files can be
19425f22d366SThomas Nikolajsen.Nm null
19435f22d366SThomas Nikolajsenmounted to the new PFS.
1944aaf93065SThomas Nikolajsen.Sh ENVIRONMENT
1945e2c596b1SChris TurnerThe following environment variables affect the execution of
1946e2c596b1SChris Turner.Nm :
1947aaf93065SThomas Nikolajsen.Bl -tag -width ".Ev EDITOR"
1948aaf93065SThomas Nikolajsen.It Ev EDITOR
1949aaf93065SThomas NikolajsenThe editor program specified in the variable
1950aaf93065SThomas Nikolajsen.Ev EDITOR
1951aaf93065SThomas Nikolajsenwill be invoked instead of the default editor, which is
1952aaf93065SThomas Nikolajsen.Xr vi 1 .
1953e2c596b1SChris Turner.It Ev HAMMER_RSH
1954e2c596b1SChris TurnerThe command specified in the variable
1955e2c596b1SChris Turner.Ev HAMMER_RSH
1956e2c596b1SChris Turnerwill be used to initiate remote operations for the mirror-copy and
1957e2c596b1SChris Turnermirror-stream commands instead of the default command, which is
1958e2c596b1SChris Turner.Xr ssh 1 .
1959e2c596b1SChris TurnerThe program will be invoked via
1960e2c596b1SChris Turner.Xr execvp 3
1961e2c596b1SChris Turnerusing a typical
19622458c6f4SSascha Wildner.Xr rsh 1 Pq Pa net/bsdrcmds
1963e2c596b1SChris Turnerstyle
1964e2c596b1SChris Turner.Cm -l user host <remote-command>
1965e2c596b1SChris Turnercommand line.
1966aaf93065SThomas Nikolajsen.It Ev VISUAL
1967aaf93065SThomas NikolajsenSame effect as
1968aaf93065SThomas Nikolajsen.Ev EDITOR
1969aaf93065SThomas Nikolajsenvariable.
19708a403cd0SSascha Wildner.El
1971226f3799SThomas Nikolajsen.Sh FILES
1972226f3799SThomas Nikolajsen.Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
19734567021bSThomas Nikolajsen.It Pa <pfs>/snapshots
1974226f3799SThomas Nikolajsendefault per PFS snapshots directory
197516265794SThomas Nikolajsen.Nm ( HAMMER
197616265794SThomas NikolajsenVERSION 2-)
197716265794SThomas Nikolajsen.It Pa /var/hammer/<pfs>
197816265794SThomas Nikolajsendefault per PFS snapshots directory (not root)
197916265794SThomas Nikolajsen.Nm ( HAMMER
198016265794SThomas NikolajsenVERSION 3+)
198116265794SThomas Nikolajsen.It Pa /var/hammer/root
198216265794SThomas Nikolajsendefault snapshots directory for root directory
198316265794SThomas Nikolajsen.Nm ( HAMMER
198416265794SThomas NikolajsenVERSION 3+)
1985226f3799SThomas Nikolajsen.It Pa <snapshots>/config
19864567021bSThomas Nikolajsenper PFS
1987226f3799SThomas Nikolajsen.Nm
19884567021bSThomas Nikolajsen.Cm cleanup
1989226f3799SThomas Nikolajsenconfiguration file
199016265794SThomas Nikolajsen.Nm ( HAMMER
199116265794SThomas NikolajsenVERSION 2-)
1992226f3799SThomas Nikolajsen.It Pa <fs>/var/slaves/<name>
1993226f3799SThomas Nikolajsenrecommended slave PFS snapshots directory
199416265794SThomas Nikolajsen.Nm ( HAMMER
199516265794SThomas NikolajsenVERSION 2-)
19965f22d366SThomas Nikolajsen.It Pa <fs>/pfs
19975f22d366SThomas Nikolajsenrecommended PFS directory
1998226f3799SThomas Nikolajsen.El
19992d8ff97dSNuno Antunes.Sh EXIT STATUS
20002d8ff97dSNuno Antunes.Ex -std
20010dfeb6c8SMatthew Dillon.Sh SEE ALSO
20024567021bSThomas Nikolajsen.Xr ssh 1 ,
200384082922SThomas Nikolajsen.Xr undo 1 ,
2004b4448f1aSThomas Nikolajsen.Xr HAMMER 5 ,
2005e0331f4fSSascha Wildner.Xr periodic.conf 5 ,
20065f22d366SThomas Nikolajsen.Xr loader 8 ,
200784082922SThomas Nikolajsen.Xr mount_hammer 8 ,
2008bb8e52c0SThomas Nikolajsen.Xr mount_null 8 ,
20095f22d366SThomas Nikolajsen.Xr newfs_hammer 8 ,
20105f22d366SThomas Nikolajsen.Xr swapcache 8 ,
20115f22d366SThomas Nikolajsen.Xr sysctl 8
20120dfeb6c8SMatthew Dillon.Sh HISTORY
20130dfeb6c8SMatthew DillonThe
20140dfeb6c8SMatthew Dillon.Nm
20150dfeb6c8SMatthew Dillonutility first appeared in
20160dfeb6c8SMatthew Dillon.Dx 1.11 .
20170dfeb6c8SMatthew Dillon.Sh AUTHORS
20181cb631f7SFranco Fichtner.An Matthew Dillon Aq Mt dillon@backplane.com
2019