nrelease - fix/improve livecd
[dragonfly.git] / sbin / hammer2 / hammer2.8
1 .\" Copyright (c) 2015-2023 The DragonFly Project.  All rights reserved.
2 .\"
3 .\" This code is derived from software contributed to The DragonFly Project
4 .\" by Matthew Dillon <dillon@backplane.com>
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\"
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in
14 .\"    the documentation and/or other materials provided with the
15 .\"    distribution.
16 .\" 3. Neither the name of The DragonFly Project nor the names of its
17 .\"    contributors may be used to endorse or promote products derived
18 .\"    from this software without specific, prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\"
33 .Dd November 2, 2021
34 .Dt HAMMER2 8
35 .Os
36 .Sh NAME
37 .Nm hammer2
38 .Nd hammer2 file system utility
39 .Sh SYNOPSIS
40 .Nm
41 .Fl h
42 .Nm
43 .Op Fl d
44 .Op Fl s Ar path
45 .Op Fl t Ar type
46 .Op Fl u Ar uuid
47 .Op Fl m Ar mem
48 .Ar command
49 .Op Ar argument ...
50 .Sh DESCRIPTION
51 The
52 .Nm
53 utility provides miscellaneous support functions for a
54 HAMMER2 file system.
55 .Pp
56 The options are as follows:
57 .Bl -tag -width indent
58 .It Fl d
59 Enables debug mode.
60 It can be specified more than once to enable additional debugging messages.
61 In some directives it may cause
62 .Nm
63 to run in foreground instead of being daemonized.
64 .It Fl s Ar path
65 Specify the path to a mounted HAMMER2 filesystem.
66 At least one PFS on a HAMMER2 filesystem must be mounted for the system
67 to act on all PFSs managed by it.
68 Every HAMMER2 filesystem typically has a PFS called "LOCAL" for this purpose.
69 .It Fl t Ar type
70 Specify the type when creating, upgrading, or downgrading a PFS.
71 Supported types are MASTER, SLAVE, SOFT_MASTER, SOFT_SLAVE, CACHE, and DUMMY.
72 If not specified the pfs-create directive will default to MASTER if no
73 UUID is specified, and SLAVE if a UUID is specified.
74 .It Fl u Ar uuid
75 Specify the cluster UUID when creating a PFS.
76 If not specified, a unique, random UUID will be generated.
77 Note that every PFS also has a unique pfs_id which is always generated
78 and cannot be overridden with an option.
79 The { pfs_clid, pfs_fsid } tuple uniquely identifies a component of a cluster.
80 .It Fl m Ar mem
81 Specify how much tracking memory to use for certain directives.
82 At the moment, this option is only applicable to the
83 .Cm bulkfree
84 directive, allowing it to operate in fewer passes when given more memory.
85 A nominal value for a 4TB drive with a ton of stuff on it would be around
86 a gigabyte '-m 1g'.
87 .El
88 .Pp
89 .Nm
90 directives are as shown below.
91 Note that most directives require you to either be CD'd into a hammer2
92 filesystem, specify a path to a mounted hammer2 filesystem via the
93 .Fl s
94 option, or specify a path after the directive.
95 It depends on the directive.
96 All hammer2 filesystems have a PFS called "LOCAL" which is typically mounted
97 locally on the host in order to be able to issue commands for other PFSs
98 on the filesystem.
99 The mount also enables PFS configuration scanning for that filesystem.
100 .Bl -tag -width indent
101 .\" ==== cleanup ====
102 .It Cm cleanup Op path
103 Perform manual cleanup passes on paths or all mounted partitions.
104 .\" ==== connect ====
105 .It Cm connect Ar target
106 Add a cluster link entry to the volume header.
107 The volume header can support up to 255 link entries.
108 This feature is not currently used.
109 .\" ==== destroy ====
110 .It Cm destroy Ar path...
111 Destroy the specified directory entry in a hammer2 filesystem.
112 This bypasses
113 all normal checks and will unconditionally destroy the directory entry.
114 The underlying inode is not checked and, if it does exist, its nlinks count
115 is not decremented.
116 This directive should only be used to destroy a corrupted directory entry
117 which no longer has a working inode.
118 .Pp
119 Note that this command may desynchronize the system namecache for the
120 specified entry.
121 If this happens, you may have to unmount and remount the filesystem.
122 .\" ==== destroy-inum ====
123 .It Cm destroy-inum Ar path...
124 Destroy the specified inode in a hammer2 filesystem.
125 .\" ==== disconnect ====
126 .It Cm disconnect Ar target
127 Delete a cluster link entry from the volume header.
128 This feature is not currently used.
129 .\" ==== emergency-mode-enable ===
130 .It Cm emergency-mode-enable Ar target
131 Flag emergency operations mode in the filesystem.
132 This mode may be used
133 as a last resort to delete files and directories from a full filesystem.
134 Inode creation, file writes, and certain meta-data cleanups are disallowed
135 while emergency mode is active.
136 File and directory removal and mode/attr setting is still allowed.
137 This mode is extremely dangerous and should only be used as a last resort.
138 .Pp
139 This mode allows the filesystem to modify blocks in-place when it is unable
140 to allocate a copy.
141 Thus it is possible to chflags and remove files and
142 directories even when the filesystem is completely full.
143 However, there is a price.
144 This mode of operation WILL LIKELY CORRUPT ANY SNAPSHOTS related
145 to this filesystem.
146 The filesystem will report this condition if it encounters
147 it but if you are forced to use this mode to fix a filesystem full condition
148 your snapshots can get a bit dicey.
149 It is usually safest to delete any related snapshots when using this mode.
150 .Pp
151 You can detect whether related snapshots have been corrupted by running
152 a bulkfree pass and checking the console output for reported CRC errors.
153 If no errors are reported, your snapshots are fine.
154 If errors are reported
155 you should delete related snapshots until bulkfree reports no further errors.
156 .Pp
157 The emergency mode will also make meta-data updates unsafe due to the lack of
158 copy-on-write, causing potential harm if the system unexpectedly panics or
159 loses power.
160 GREAT CARE MUST BE TAKEN WHILE THIS MODE IS ACTIVE.
161 .Bl -enum
162 .It
163 Determine that you are unable to recover space with normal file and directory
164 removal commands due to
165 .Er ENOSPC
166 errors being returned by 'rm', or through the
167 removal of snapshots (if any).  The 'bulkfree' directive must be issued to
168 scan the filesystem and free up the actual space, then check with 'df'.
169 Continue if you still have insufficient space and are unable to remove items
170 normally.
171 .It
172 If you need any related snapshots, this is a good time to copy them elsewhere.
173 .It
174 Idle or kill any processes trying to use the filesystem.
175 .It
176 Issue the emergency-mode-enable directive on the filesystem.
177 Once enabled, run 'sync' to update any dirty inodes which may still
178 be dirty due to not being able to flush.
179 Please remember that this
180 directive is a LAST RESORT, is dangerous, and will likely corrupt any
181 other snapshots you have based on the filesystem you are removing files
182 from.
183 .It
184 Remove file trees as necessary with 'rm -rf' to free space, being cognizant
185 of any warnings issued by the kernel on the console (via 'dmesg') while
186 doing so.
187 .It
188 Issue the 'bulkfree' directive to actually free the space and check that
189 sufficient space has been freed with 'df'.
190 .It
191 If bulkfree reports CHECK errors, or if you have snapshots and insufficient
192 space has been freed, you will need to delete snapshots.
193 Re-run bulkfree and delete snapshots until no errors are reported.
194 .It
195 Issue the emergency-mode-disable directive when done.
196 It might also be a
197 good idea to reboot after using this mode, but theoretically you should not
198 have to.
199 .It
200 Restore services using the filesystem.
201 .El
202 .\" ==== emergency-mode-disable ===
203 .It Cm emergency-mode-disable Ar target
204 Turn off the emergency operations mode on a filesystem, restoring normal
205 operation.
206 .\" ==== growfs ====
207 .It Cm growfs Op fspath...
208 After resizing the disk partition you can issue this command on a
209 mounted hammer2 filesystem to grow into the new space in the partition.
210 This command is run on a live hammer2 filesystem.
211 .\" ==== info ====
212 .It Cm info Op devpath...
213 Access and print the status and super-root entries for all HAMMER2
214 partitions found in /dev/serno or the specified device path(s).
215 The partitions do not have to be mounted.
216 Note that only mounted partitions will be under active management.
217 This is accomplished by mounting at least one PFS within the partition.
218 Typically at least the @LOCAL PFS is mounted.
219 .\" ==== mountall ====
220 .It Cm mountall Op devpath...
221 This directive mounts the @LOCAL PFS on all HAMMER2 partitions found
222 in /dev/serno, or the specified device path(s).
223 The partitions are mounted as /var/hammer2/LOCAL.<id>.
224 Mounts are executed in the background and this command will wait a
225 limited amount of time for the mounts to complete before returning.
226 .\" ==== status ====
227 .It Cm status Op path...
228 Dump a list of all cluster link entries configured in the volume header.
229 .\" ==== hash ====
230 .It Cm hash Op filename...
231 Compute and print the directory hash for any number of filenames.
232 .\" ==== dhash ====
233 .It Cm dhash Op filename...
234 Compute and print the data hash for long directory entry for any number of
235 filenames.
236 .\" ==== pfs-list ====
237 .It Cm pfs-list Op path...
238 List all PFSs associated with all mounted hammer2 storage devices.
239 The list may be restricted to a particular filesystem using
240 .Fl s Ar mount .
241 .Pp
242 Note that hammer2 PFSs associated with storage devices which have not been
243 mounted in any fashion will not be listed.
244 At least one hammer2 label must be mounted for the PFSs on that device to be
245 visible.
246 .\" ==== pfs-clid ====
247 .It Cm pfs-clid Ar label
248 Print the cluster id for a PFS specified by name.
249 .\" ==== pfs-fsid ====
250 .It Cm pfs-fsid Ar label
251 Print the unique filesystem id for a PFS specified by name.
252 .\" ==== pfs-create ====
253 .It Cm pfs-create Ar label
254 Create a local PFS on the mounted HAMMER2 filesystem represented
255 by the current directory, or specified via
256 .Fl s Ar mount .
257 If no UUID is specified the pfs-type defaults to MASTER.
258 If a UUID is specified via the
259 .Fl u
260 option the pfs-type defaults to SLAVE.
261 Other types can be specified with the
262 .Fl t
263 option.
264 .Pp
265 If you wish to add a MASTER to an existing cluster, you must first add it as
266 a SLAVE and then upgrade it to MASTER to properly synchronize it.
267 .Pp
268 The DUMMY pfs-type is used to tie network-accessible clusters into the local
269 machine when no local storage is desired.
270 This type should be used on minimal H2 partitions or entirely in ram for
271 netboot-centric systems to provide a tie-in point for the mount command,
272 or on more complex systems where you need to also access network-centric
273 clusters.
274 .Pp
275 The CACHE or SLAVE pfs-type is typically used when the main store is on
276 the network but local storage is desired to improve performance.
277 SLAVE is also used when a backup is desired.
278 .Pp
279 Generally speaking, you can mount any PFS element of a cluster in order to
280 access the cluster via the full cluster protocol.
281 There are two exceptions.
282 If you mount a SOFT_SLAVE or a SOFT_MASTER then soft quorum semantics are
283 employed... the soft slave or soft master's current state will always be used
284 and the quorum protocol will not be used.
285 The soft PFS will still be
286 synchronized to masters in the background when available.
287 Also, you can use
288 .Sq mount -o local
289 to mount ONLY a local HAMMER2 PFS and
290 not run any network or quorum protocols for the mount.
291 All such mounts except for a SOFT_MASTER mount will be read-only.
292 Other than that, you will be mounting the whole cluster when you mount any
293 PFS within the cluster.
294 .Pp
295 DUMMY - Create a PFS skeleton intended to be the mount point for a
296 more complex cluster, probably one that is entirely network based.
297 No data will be synchronized to this PFS so it is suitable for use
298 in a network boot image or memory filesystem.
299 This allows you to create placeholders for mount points on your local
300 disk, SSD, or memory disk.
301 .Pp
302 CACHE - Create a PFS for caching portions of the cluster piecemeal.
303 This is similar to a SLAVE but does not synchronize the entire contents of
304 the cluster to the PFS.
305 Elements found in the CACHE PFS which are validated against the cluster
306 will be read, presumably a faster access than having to go to the cluster.
307 Only local CACHEs will be updated.
308 Network-accessible CACHE PFSs might be read but will not be written to.
309 If you have a large hard-drive-based cluster you can set up localized
310 SSD CACHE PFSs to improve performance.
311 .Pp
312 SLAVE - Create a PFS which maintains synchronization with and provides a
313 read-only copy of the cluster.
314 HAMMER2 will prioritize local SLAVEs for data retrieval after validating
315 their transaction id against the cluster.
316 The difference between a CACHE and a SLAVE is that the SLAVE is synchronized
317 to a full copy of the cluster and thus can serve as a backup or be staged
318 for use as a MASTER later on.
319 .Pp
320 SOFT_SLAVE - Create a PFS which maintains synchronization with and provides
321 a read-only copy of the cluster.
322 This is one of the special mount cases.
323 A SOFT_SLAVE will synchronize with
324 the cluster when the cluster is available, but can still be accessed when
325 the cluster is not available.
326 .Pp
327 MASTER - Create a PFS which will hold a master copy of the cluster.
328 If you create several MASTER PFSs with the same cluster id you are
329 effectively creating a multi-master cluster and causing a quorum and
330 cache coherency protocol to be used to validate operations.
331 The total number of masters is stored in each PFSs making up the cluster.
332 Filesystem operations will stall for normal mounts if a quorum cannot be
333 obtained to validate the operation.
334 MASTER nodes which go offline and return later will synchronize in the
335 background.
336 Note that when adding a MASTER to an existing cluster you must add the
337 new PFS as a SLAVE and then upgrade it to a MASTER.
338 .Pp
339 SOFT_MASTER - Create a PFS which maintains synchronization with and provides
340 a read-write copy of the cluster.
341 This is one of the special mount cases.
342 A SOFT_MASTER will synchronize with
343 the cluster when the cluster is available, but can still be read AND written
344 to even when the cluster is not available.
345 Modifications made to a SOFT_MASTER will be automatically flushed to the
346 cluster when it becomes accessible again, and vise-versa.
347 Manual intervention may be required if a conflict occurs during
348 synchronization.
349 .\" ==== pfs-delete ====
350 .It Cm pfs-delete Op label...
351 Destroy a PFS by name.
352 All hammer2 mount points will be checked, however this directive will refuse to
353 delete a PFS whos name is duplicated on multiple mount points.
354 A specific mount point may be specified to restrict the deletion via the
355 .Fl s Ar mount
356 option.
357 .\" ==== recover ====
358 .It Cm recover Ar media Ar path Ar destdir
359 Recover a file or directory tree by scanning the raw media partition,
360 with minimal requirements for an intact topology.  The results are written
361 to the destination directory.
362 .Pp
363 The recovery path can be anchored at (any) root by prefixing it with a "/".
364 If not anchored, any matching sub-tree will be recovered and combined into
365 one place on the destination (not as separate sub-trees since that requires
366 topological knowledge that might not be available).  Roots include all
367 PFS roots and snapshot roots, as well as disconnected roots from COW updates
368 (aka to be able to undelete a file or directory sub-tree).
369 .Pp
370 The path may specify a directory or file to restore.  Note that if you
371 specify something like ".cshrc", then all ".cshrc" files found in the
372 entire filesystem will be recovered.  Multiple references to the same
373 physical inode with the same filename in the same directory are filtered out.
374 .Pp
375 This function is meant for catastrophic recovery or corrupted media or
376 recovery for deleted files that are not otherwise available in snapshots.
377 All possible versions of files will be recovered and suffixed as "*.%05d"
378 with an iterator.
379 .Pp
380 The hammer2 recovery function is not meant to generate a fully operational
381 filesystem in the target directory.  All files will be versioned and contain
382 iteration suffixes.  Many files and sub-directory trees may wind up glommed
383 together in one place.  However, this function will recover mtime, ownership,
384 group, modes, and flags.  Recovered files are fully validated and any missing
385 data will cause the file to be renamed with a ".corrupted" suffix.
386 .Pp
387 Memory requirements - This function needs to track inodes and paths and
388 can eat a considerable amount of ram, and it tends to be random-access
389 so while swap can make ends meet, it might slow the scan down drastically
390 if it has to eat into it much.
391 Ram consumption scales with the number of inodes found.  Call it a few
392 gigabytes up to 500GB of media and approaching 64GB on busy 4TB media.
393 Busy meaning, say, 50 million topological inodes turning into 1 billion
394 inodes located by the media scan.
395 .\" ==== recover-relaxed ====
396 .It Cm recover-relaxed Ar media Ar path Ar destdir
397 This version of the recover directive relaxes bref checks.  Under normal
398 operation, only brefs with check codes are allowed because we get too many
399 false hits otherwise.  In relaxed mode, bref's with the check code disabled
400 are also allowed.
401 .Pp
402 You should only need to use the relaxed version if you have turned off
403 CRCs on the files you want to recover.
404 .\" ==== recover-file ====
405 .It Cm recover-file Ar media Ar path Ar destdir
406 This version of recover is the normal strict-mode recover but explicitly
407 indicates that the path being recovered is a regular file and not a
408 directory.  Prevents junk recursions when entries corresponding to the
409 last path element appear to be directories.
410 .\" ==== snapshot ====
411 .It Cm snapshot Ar path Op label
412 Create a snapshot of a directory.
413 The snapshot will be created on the same hammer2 storage device as the
414 directory.
415 This can only be used on a local PFS, and is only really useful if the PFS
416 contains a complete copy of what you desire to snapshot so that typically
417 means a local MASTER, SOFT_MASTER, SLAVE, or SOFT_SLAVE must be present.
418 Snapshots are created simply by flushing a PFS mount to disk and then copying
419 the directory inode to the PFS.
420 The topology is snapshotted without having to be copied or scanned and
421 take no additional space.
422 However, bulkfree scans may take longer.
423 Snapshots are effectively separate from the cluster they came from
424 and can be used as a starting point for a new cluster.
425 So unless you build a new cluster from the snapshot, it will stay local
426 to the machine it was made on.
427 .Pp
428 Snapshots can be maintained automatically with
429 .Xr periodic 8 .
430 See
431 .Xr periodic.conf 5
432 for details of enabling and configuring the functionality.
433 .\" ==== snapshot-debug ====
434 .It Cm snapshot-debug Ar path Op label
435 Snapshot without filesystem sync.
436 .\" ==== service ====
437 .It Cm service
438 Start the
439 .Nm
440 service daemon.
441 This daemon is also automatically started when you run
442 .Xr mount_hammer2 8 .
443 The hammer2 service daemon handles incoming TCP connections and maintains
444 outgoing TCP connections.
445 It will interconnect available services on the
446 machine (e.g. hammer2 mounts and xdisks) to the network.
447 .\" ==== stat ====
448 .It Cm stat Op path...
449 Print the inode statistics, compression, and other meta-data associated
450 with a list of paths.
451 .\" ==== leaf ====
452 .It Cm leaf
453 XXX
454 .\" ==== shell ====
455 .It Cm shell Op host
456 Start a debug shell to the local hammer2 service daemon via the DMSG protocol.
457 .\" ==== debugspan ====
458 .It Cm debugspan Ar target
459 (do not use)
460 .\" ==== rsainit ====
461 .It Cm rsainit Op path
462 Create the
463 .Pa /etc/hammer2
464 directory and initialize a public/private keypair in that directory for
465 use by the network cluster protocols.
466 .\" ==== show ====
467 .It Cm show Ar devpath
468 Dump the radix tree for the HAMMER2 filesystem by scanning a
469 block device directly.
470 No mount is required.
471 .\" ==== freemap ====
472 .It Cm freemap Ar devpath
473 Dump the freemap tree for the HAMMER2 filesystem by scanning a
474 block device directly.
475 No mount is required.
476 .\" ==== volhdr ====
477 .It Cm volhdr Ar devpath
478 Dump the volume header for the HAMMER2 filesystem by scanning a
479 block device directly.
480 No mount is required.
481 .\" ==== volume-list ====
482 .It Cm volume-list Op path...
483 List all volumes associated with all mounted hammer2 storage devices.
484 The list may be restricted to a particular filesystem using
485 .Fl s Ar mount .
486 .Pp
487 Note that hammer2 volumes associated with storage devices which have not been
488 mounted in any fashion will not be listed.
489 At least one hammer2 label must be mounted for the volumes on that device to be
490 visible.
491 .\" ==== setcomp ====
492 .It Cm setcomp Ar mode[:level] Ar path...
493 Set the compression mode as specified for any newly created elements at or
494 under the path if not overridden by deeper elements.
495 Available modes are none, autozero, lz4, or zlib.
496 When zlib is used the compression level can be set.
497 The default will be 6 which is the best trade-off between performance and
498 time.
499 .Pp
500 newfs_hammer2 will set the default compression to lz4 which prioritizes
501 speed over performance.
502 Also note that HAMMER2 contains a heuristic and will not attempt to
503 compress every block if it detects a sufficient amount of uncompressable
504 data.
505 .Pp
506 Hammer2 compression is only effective when it can reduce the size of dataset
507 (typically a 64KB block) by one or more powers of 2.  A 64K block which
508 only compresses to 40K will not yield any storage improvement.
509 .Pp
510 Generally speaking you do not want to set the compression mode to
511 .Sq none ,
512 as this will cause blocks of all-zeros to be written as all-zero blocks,
513 instead of holes.
514 The
515 .Sq autozero
516 compression mode detects blocks of all-zeros
517 and writes them as holes.
518 .\" ==== setcheck ====
519 .It Cm setcheck Ar check Ar path...
520 Set the check code as specified for any newly created elements at or under
521 the path if not overridden by deeper elements.
522 Available codes are default, disabled, crc32, xxhash64, or sha192.
523 .Pp
524 Normally HAMMER2 does not overwrite data blocks on the media in order to ensure
525 snapshot integrity.
526 Replacement data blocks will be reallocated.
527 However, if the compression mode is set to
528 .Sq none
529 and the check code is set to
530 .Sq disabled
531 HAMMER2 will overwrite data on the media in-place.
532 In this mode of operation,
533 snapshots will not be able to snapshot the data against later changes
534 made to the file, and de-duplication will no longer function on any
535 data related to the file.
536 However, you can still recover the most recent data from previously
537 taken snapshots if you accidentally remove the file.
538 .\" ==== clrcheck ====
539 .It Cm clrcheck Op path...
540 Clear the check code override for the specified paths.
541 Overrides may still be present in deeper elements.
542 .\" ==== setcrc32 ====
543 .It Cm setcrc32 Op path...
544 Set the check code to the ISCSI 32-bit CRC for any newly created elements
545 at or under the path if not overridden by deeper elements.
546 .\" ==== setxxhash64 ====
547 .It Cm setxxhash64 Op path...
548 Set the check code to XXHASH64, a fast 64-bit hash
549 .\" ==== setsha192 ====
550 .It Cm setsha192 Op path...
551 Set the check code to SHA192 for any newly created elements at or under
552 the path if not overridden by deeper elements.
553 .\" ==== bulkfree ====
554 .It Cm bulkfree Ar path
555 Run a bulkfree pass on a HAMMER2 mount.
556 You can specify any PFS for the mount, the bulkfree pass is run on the
557 entire partition.
558 Note that it takes two passes to actually free space.
559 By default this directive will use up to 1/16 physical memory to track
560 the freemap.
561 The amount of memory used may be overridden with the
562 .Op Fl m Ar mem
563 option.
564 .\" ==== printinode ====
565 .It Cm printinode Ar path
566 Dump inode.
567 .\" ==== dumpchain ====
568 .It Cm dumpchain Op path Op chnflags
569 Dump in-memory chain topology.
570 .El
571 .Sh SYSCTLS
572 .Bl -tag -width indent
573 .It Va vfs.hammer2.dedup_enable "(default on)"
574 Enables live de-duplication.
575 Any recently read data that is on-media
576 (already synchronized to media) is tested against pending writes for
577 compatibility.
578 If a match is found, the write will reference the
579 existing on-media data instead of writing new data.
580 .It Va vfs.hammer2.always_compress "(default off)"
581 This disables the H2 compression heuristic and forces H2 to always
582 try to compress data blocks, even if they look uncompressable.
583 Enabling this option reduces performance but has higher de-duplication
584 repeatability.
585 .It Va vfs.hammer2.cluster_data_read "(default 4)"
586 .It Va vfs.hammer2.cluster_meta_read "(default 1)"
587 Set the amount of read-ahead clustering to perform on data and meta-data
588 blocks.
589 .It Va vfs.hammer2.cluster_write "(default 0)"
590 Set the amount of write-behind clustering to perform in buffers.
591 Each buffer represents 64KB.
592 The default is 0 and higher values typically do not improve performance.
593 A value of 0 disables clustered writes.
594 This variable applies to the underlying media device, not to logical
595 file writes, so it should not interfere with temporary file optimization.
596 Generally speaking you want this enabled to generate smoothly pipelined
597 writes to the media.
598 .It Va vfs.hammer2.bulkfree_tps "(default 5000)"
599 Set bulkfree's maximum scan rate.
600 This is primarily intended to limit
601 I/O utilization on SSDs and CPU utilization when the meta-data is mostly
602 cached in memory.
603 .El
604 .Sh SETTING UP /etc/hammer2
605 The
606 .Sq rsainit
607 directive will create the
608 .Pa /etc/hammer2
609 directory with appropriate permissions and also generate a public key
610 pair in this directory for the machine.
611 These files will be
612 .Pa rsa.pub
613 and
614 .Pa rsa.prv
615 and needless to say, the private key shouldn't leave the host.
616 .Pp
617 The service daemon will also scan the
618 .Pa /etc/hammer2/autoconn
619 file which contains a list of hosts which it will automatically maintain
620 connections to to form your cluster.
621 The service daemon will automatically reconnect on any failure and will
622 also monitor the file for changes.
623 .Pp
624 When the service daemon receives a connection it expects to find a
625 public key for that connection in a file in
626 .Pa /etc/hammer2/remote/
627 called
628 .Pa <IPADDR>.pub .
629 You normally copy the
630 .Pa rsa.pub
631 key from the host in question to this file.
632 The IP address must match exactly or the connection will not be allowed.
633 .Pp
634 If you want to use an unencrypted connection you can create empty,
635 dummy files in the remote directory in the form
636 .Pa <IPADDR>.none .
637 We do not recommend using unencrypted connections.
638 .Sh CLUSTER SERVICES
639 Currently there are two services which use the cluster network infrastructure,
640 HAMMER2 mounts and XDISK.
641 Any HAMMER2 mount will make all PFSs for that filesystem available to the
642 cluster.
643 And if the XDISK kernel module is loaded, the hammer2 service daemon will make
644 your machine's block devices available to the cluster (you must load the
645 xdisk.ko kernel module before starting the hammer2 service).
646 They will show up as
647 .Pa /dev/xa*
648 and
649 .Pa /dev/serno/*
650 devices on the remote machines making up the cluster.
651 Remote block devices are just what they appear to be... direct access to a
652 block device on a remote machine.
653 If the link goes down remote accesses
654 will stall until it comes back up again, then automatically requeue any
655 pending I/O and resume as if nothing happened.
656 However, if the server hosting the physical disks crashes or is rebooted,
657 any remote opens to its devices will see a permanent I/O failure requiring a
658 close and open sequence to re-establish.
659 The latter is necessary because the server's drives might not have committed
660 the data before the crash, but had already acknowledged the transfer.
661 .Pp
662 Data commits work exactly the same as they do for real block devices.
663 The originater must issue a BUF_CMD_FLUSH.
664 .Sh ADDING A NEW MASTER TO A CLUSTER
665 When you
666 .Xr newfs_hammer2 8
667 a HAMMER2 filesystem or use the
668 .Sq pfs-create
669 directive on one already mounted
670 to create a new PFS, with no special options, you wind up with a PFS
671 typed as a MASTER and a unique cluster UUID, but because there is only one
672 PFS for that cluster (for each PFS you create via pfs-create), it will
673 act just like a normal filesystem would act and does not require any special
674 protocols to operate.
675 .Pp
676 If you use the
677 .Sq pfs-create
678 directive along with the
679 .Fl u
680 option to specify a cluster UUID that already exists in the cluster,
681 you are adding a PFS to an existing cluster and this can trigger a whole
682 series of events in the background.
683 When you specify the
684 .Fl u
685 option in a
686 .Sq pfs-create ,
687 .Nm
688 will by default create a SLAVE PFS.
689 In fact, this is what must be created first even if you want to add a new
690 MASTER to your cluster.
691 .Pp
692 The most common action a system admin will want to take is to upgrade or
693 downgrade a PFS.
694 A new MASTER can be added to the cluster by upgrading an existing SLAVE
695 to MASTER.
696 A MASTER can be removed from the cluster by downgrading it to a SLAVE.
697 Upgrades and downgrades will put nodes in the cluster in a transition state
698 until the operation is complete.
699 For downgrades the transition state is fleeting unless one or more other
700 masters has not acknowledged the change.
701 For upgrades a background synchronization process must complete before the
702 transition can be said to be complete, and the node remains (really) a SLAVE
703 until that transition is complete.
704 .Sh USE CASES FOR A SOFT_MASTER
705 The SOFT_MASTER PFS type is a special type which must be specifically
706 mounted by a machine.
707 It is a R/W mount which does not use the quorum protocol and is not
708 cache coherent with the cluster, but which synchronizes from the cluster
709 and allows modifying operations which will synchronize to the cluster.
710 The most common case is to use a SOFT_MASTER PFS in a laptop allowing you
711 to work on your laptop when you are on the road and not connected to
712 your main servers, and for the laptop to synchronize when a connection is
713 available.
714 .Sh USE CASES FOR A SOFT_SLAVE
715 A SOFT_SLAVE PFS type is a special type which must be specifically mounted
716 by a machine.
717 It is a RO mount which does not use the quorum protocol and is not
718 cache coherent with the cluster.
719 It will receive synchronization from
720 the cluster when network connectivity is available but will not stall if
721 network connectivity is lost.
722 .Sh FSYNC FLUSH MODES
723 TODO.
724 .Sh RESTORING FROM A SNAPSHOT BACKUP
725 TODO.
726 .Sh PERFORMANCE TUNING
727 Because HAMMER2 implements compression, decompression, and dedup natively,
728 it always double-buffers file data.
729 This means that the file data is
730 cached via the device vnode (in compressed / dedupped-form) and the same
731 data is also cached by the file vnode (in decompressed / non-dedupped form).
732 .Pp
733 While HAMMER2 will try to age the logical file buffers on its, some
734 additional performance tuning may be necessary for optimal operation
735 whether swapcache is used or not.
736 Our recommendation is to reduce the
737 number of vnodes (and thus also the logical buffer cache behind the
738 vnodes) that the system caches via the
739 .Va kern.maxvnodes
740 sysctl.
741 .Pp
742 Too-large a value will result in excessive double-caching and can cause
743 unnecessary read disk I/O.
744 We recommend a number between 25000 and 250000 vnodes, depending on your
745 use case.
746 Keep in mind that even though the vnode cache is smaller, this will make
747 room for a great deal more device-level buffer caching which can encompasses
748 far more data and meta-data than the vnode-level caching.
749 .Sh ENVIRONMENT
750 TODO.
751 .Sh FILES
752 .Bl -tag -width ".It Pa <fs>/abc/defghi/<name>" -compact
753 .It Pa /etc/hammer2/
754 .It Pa /etc/hammer2/rsa.pub
755 .It Pa /etc/hammer2/rsa.prv
756 .It Pa /etc/hammer2/autoconn
757 .It Pa /etc/hammer2/remote/<IP>.pub
758 .It Pa /etc/hammer2/remote/<IP>.none
759 .El
760 .Sh EXIT STATUS
761 .Ex -std
762 .Sh SEE ALSO
763 .Xr xdisk 4 ,
764 .Xr periodic.conf 5 ,
765 .Xr mount_hammer2 8 ,
766 .Xr mount_null 8 ,
767 .Xr newfs_hammer2 8 ,
768 .Xr swapcache 8 ,
769 .Xr sysctl 8
770 .Sh HISTORY
771 The
772 .Nm
773 utility first appeared in
774 .Dx 4.1 .
775 .Sh AUTHORS
776 .An Matthew Dillon Aq Mt dillon@backplane.com