hammer2 - Add emergency mode to allow recovery of ENOSPC edge cases
[dragonfly.git] / sbin / hammer2 / hammer2.8
1 .\" Copyright (c) 2015-2019 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 September 29, 2019
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 s Ar path
44 .Op Fl t Ar type
45 .Op Fl u Ar uuid
46 .Op Fl m Ar mem
47 .Ar command
48 .Op Ar argument ...
49 .Sh DESCRIPTION
50 The
51 .Nm
52 utility provides miscellaneous support functions for a
53 HAMMER2 file system.
54 .Pp
55 The options are as follows:
56 .Bl -tag -width indent
57 .It Fl s Ar path
58 Specify the path to a mounted HAMMER2 filesystem.
59 At least one PFS on a HAMMER2 filesystem must be mounted for the system
60 to act on all PFSs managed by it.
61 Every HAMMER2 filesystem typically has a PFS called "LOCAL" for this purpose.
62 .It Fl t Ar type
63 Specify the type when creating, upgrading, or downgrading a PFS.
64 Supported types are MASTER, SLAVE, SOFT_MASTER, SOFT_SLAVE, CACHE, and DUMMY.
65 If not specified the pfs-create directive will default to MASTER if no
66 uuid is specified, and SLAVE if a uuid is specified.
67 .It Fl u Ar uuid
68 Specify the cluster uuid when creating a PFS.  If not specified, a unique,
69 random uuid will be generated.
70 Note that every PFS also has a unique pfs_id which is always generated
71 and cannot be overridden with an option.
72 The { pfs_clid, pfs_fsid } tuple uniquely identifies a component of a cluster.
73 .It Fl m Ar mem
74 Specify how much tracking memory to use for certain directives.
75 At the moment, this option is only applicable to the
76 .Cm bulkfree
77 directive, allowing it to operate in fewer passes when given more memory.
78 A nominal value for a 4TB drive with a ton of stuff on it would be around
79 a gigabyte '-m 1g'.
80 .El
81 .Pp
82 .Nm
83 directives are as shown below.
84 Note that most directives require you to either be CD'd into a hammer2
85 filesystem, specify a path to a mounted hammer2 filesystem via the
86 .Fl s
87 option, or specify a path after the directive.
88 It depends on the directive.
89 All hammer2 filesystem have a PFS called "LOCAL" which is typically mounted
90 locally on the host in order to be able to issue commands for other PFSs
91 on the filesystem.
92 The mount also enables PFS configuration scanning for that filesystem.
93 .Bl -tag -width indent
94 .\" ==== cleanup ====
95 .It Cm cleanup Op path
96 Perform manual cleanup passes on paths or all mounted partitions.
97 .\" ==== connect ====
98 .It Cm connect Ar target
99 Add a cluster link entry to the volume header.
100 The volume header can support up to 255 link entries.
101 This feature is not currently used.
102 .\" ==== destroy ====
103 .It Cm destroy Ar path...
104 Destroy the specified directory entry in a hammer2 filesystem.  This bypasses
105 all normal checks and will unconditionally destroy the directory entry.
106 The underlying inode is not checked and, if it does exist, its nlinks count
107 is not decremented.
108 This directive should only be used to destroy a corrupted directory entry
109 which no longer has a working inode.
110 .Pp
111 Note that this command may desynchronize the system namecache for the
112 specified entry.  If this happens, you may have to unmount and remount the
113 filesystem.
114 .\" ==== destroy-inum ====
115 .It Cm destroy-inum Ar path...
116 Destroy the specified inode in a hammer2 filesystem.
117 .\" ==== disconnect ====
118 .It Cm disconnect Ar target
119 Delete a cluster link entry from the volume header.
120 This feature is not currently used.
121 .\" ==== emergency-mode-enable ===
122 .It Cm emergency-mode-enable Ar target
123 Flag emergency operations mode in the filesystem.  This mode may be used
124 as a last resort to delete files and directories from a full filesystem.
125 Inode creation, file writes, and certain meta-data cleanups are disallowed
126 while emergency mode is active.
127 File and directory removal and mode/attr setting is still allowed.
128 This mode is extremely dangerous and should only be used as a last resort.
129 .Pp
130 This mode allows the filesystem to modify blocks in-place when it is unable
131 to allocate a copy.  Thus it is possible to chflags and remove files and
132 directories even when the filesystem is completely full.  However, there
133 is a price.  This mode of operation WILL LIKELY CORRUPT ANY SNAPSHOTS related
134 to this filesystem.  The filesystem will report this condition if it encounters
135 it but if you are forced to use this mode to fix a filesystem full condition
136 your snapshots can get a bit dicey.  It is usually safest to delete any
137 related snapshots when using this mode.
138 .Pp
139 You can detect whether related snapshots have been corrupted by running
140 a bulkfree pass and checking the console output for reported CRC errors.
141 If no errors are reported, your snapshots are fine.  If errors are reported
142 you should delete related snapshots until bulkfree reports no further errors.
143 .Pp
144 The emergency mode will also make meta-data updates unsafe due to the lack of
145 copy-on-write, causing potential harm if the system unexpectedly panics or
146 loses power.  GREAT CARE MUST BE TAKEN WHILE THIS MODE IS ACTIVE.
147 .Pp
148 .Bl -tag -width indent
149 .It (1)
150 Determine that you are unable to recover space with normal file and directory
151 removal commands due to ENOSPC errors being returned by 'rm', or through the
152 removal of snapshots (if any).  The 'bulkfree' directive must be issued to
153 scan the filesystem and free up the actual space, then check with 'df'.
154 Continue if you still have insufficient space and are unable to remove items
155 normally.
156 .It (2)
157 If you need any related snapshots, this is a good time to copy them elsewhere.
158 .It (3)
159 Idle or kill any processes trying to use the filesystem.
160 .It (4)
161 Issue the emergency-mode-enable directive on the filesystem.
162 Once enabled, run 'sync' to update any dirty inodes which may still
163 be dirty due to not being able to flush.  Please remember that this
164 directive is a LAST RESORT, is dangerous, and will likely corrupt any
165 other snapshots you have based on the filesystem you are removing files
166 from.
167 .It (5)
168 Remove file trees as necessary with 'rm -rf' to free space, being cognizant
169 of any warnings issued by the kernel on the console (via 'dmesg') while
170 doing so.
171 .It (6)
172 Issue the 'bulkfree' directive to actually free the space and check that
173 sufficient space has been freed with 'df'.
174 .It (7)
175 If bulkfree reports CHECK errors, or if you have snapshots and insufficient
176 space has been freed, you will need to delete snapshots.  Re-run bulkfree
177 and delete snapshots until no errors are reported.
178 .It (8)
179 Issue the emergency-mode-disable directive when done.  It might also be a
180 good idea to reboot after using this mode, but theoretically you should not
181 have to.
182 .It (9)
183 Restore services using the filesystem.
184 .El
185 .Pp
186 .\" ==== emergency-mode-disable ===
187 .It Cm emergency-mode-disable Ar target
188 Turn off the emergency operations mode on a filesystem, restoring normal
189 operation.
190 .\" ==== info ====
191 .It Cm info Op devpath...
192 Access and print the status and super-root entries for all HAMMER2
193 partitions found in /dev/serno or the specified device path(s).
194 The partitions do not have to be mounted.
195 Note that only mounted partitions will be under active management.
196 This is accomplished by mounting at least one PFS within the partition.
197 Typically at least the @LOCAL PFS is mounted.
198 .\" ==== mountall ====
199 .It Cm mountall Op devpath...
200 This directive mounts the @LOCAL PFS on all HAMMER2 partitions found
201 in /dev/serno, or the specified device path(s).
202 The partitions are mounted as /var/hammer2/LOCAL.<id>.
203 Mounts are executed in the background and this command will wait a
204 limited amount of time for the mounts to complete before returning.
205 .\" ==== status ====
206 .It Cm status Op path...
207 Dump a list of all cluster link entries configured in the volume header.
208 .\" ==== hash ====
209 .It Cm hash Op filename...
210 Compute and print the directory hash for any number of filenames.
211 .\" ==== dhash ====
212 .It Cm dhash Op filename...
213 Compute and print the data hash for long directory entry for any number of filenames.
214 .\" ==== pfs-list ====
215 .It Cm pfs-list Op path...
216 List all local PFSs available on a mounted HAMMER2 filesystem, their type,
217 and their current status.
218 You must mount at least one PFS in order to be able to access the whole list.
219 .\" ==== pfs-clid ====
220 .It Cm pfs-clid Ar label
221 Print the cluster id for a PFS specified by name.
222 .\" ==== pfs-fsid ====
223 .It Cm pfs-fsid Ar label
224 Print the unique filesystem id for a PFS specified by name.
225 .\" ==== pfs-create ====
226 .It Cm pfs-create Ar label
227 Create a local PFS on a mounted HAMMER2 filesystem.
228 If no uuid is specified the pfs-type defaults to MASTER.
229 If a uuid is specified via the
230 .Fl u
231 option the pfs-type defaults to SLAVE.
232 Other types can be specified with the
233 .Fl t
234 option.
235 .Pp
236 If you wish to add a MASTER to an existing cluster, you must first add it as
237 a SLAVE and then upgrade it to MASTER to properly synchronize it.
238 .Pp
239 The DUMMY pfs-type is used to tie network-accessible clusters into the local
240 machine when no local storage is desired.
241 This type should be used on minimal H2 partitions or entirely in ram for
242 netboot-centric systems to provide a tie-in point for the mount command,
243 or on more complex systems where you need to also access network-centric
244 clusters.
245 .Pp
246 The CACHE or SLAVE pfs-type is typically used when the main store is on
247 the network but local storage is desired to improve performance.
248 SLAVE is also used when a backup is desired.
249 .Pp
250 Generally speaking, you can mount any PFS element of a cluster in order to
251 access the cluster via the full cluster protocol.
252 There are two exceptions.
253 If you mount a SOFT_SLAVE or a SOFT_MASTER then soft quorum semantics are
254 employed... the soft slave or soft master's current state will always be used
255 and the quorum protocol will not be used.  The soft PFS will still be
256 synchronized to masters in the background when available.
257 Also, you can use
258 .Sq mount -o local
259 to mount ONLY a local HAMMER2 PFS and
260 not run any network or quorum protocols for the mount.
261 All such mounts except for a SOFT_MASTER mount will be read-only.
262 Other than that, you will be mounting the whole cluster when you mount any
263 PFS within the cluster.
264 .Pp
265 DUMMY - Create a PFS skeleton intended to be the mount point for a
266 more complex cluster, probably one that is entirely network based.
267 No data will be synchronized to this PFS so it is suitable for use
268 in a network boot image or memory filesystem.
269 This allows you to create placeholders for mount points on your local
270 disk, SSD, or memory disk.
271 .Pp
272 CACHE - Create a PFS for caching portions of the cluster piecemeal.
273 This is similar to a SLAVE but does not synchronize the entire contents of
274 the cluster to the PFS.
275 Elements found in the CACHE PFS which are validated against the cluster
276 will be read, presumably a faster access than having to go to the cluster.
277 Only local CACHEs will be updated.
278 Network-accessible CACHE PFSs might be read but will not be written to.
279 If you have a large hard-drive-based cluster you can set up localized
280 SSD CACHE PFSs to improve performance.
281 .Pp
282 SLAVE - Create a PFS which maintains synchronization with and provides a
283 read-only copy of the cluster.
284 HAMMER2 will prioritize local SLAVEs for data retrieval after validating
285 their transaction id against the cluster.
286 The difference between a CACHE and a SLAVE is that the SLAVE is synchronized
287 to a full copy of the cluster and thus can serve as a backup or be staged
288 for use as a MASTER later on.
289 .Pp
290 SOFT_SLAVE - Create a PFS which maintains synchronization with and provides
291 a read-only copy of the cluster.
292 This is one of the special mount cases.  A SOFT_SLAVE will synchronize with
293 the cluster when the cluster is available, but can still be accessed when
294 the cluster is not available.
295 .Pp
296 MASTER - Create a PFS which will hold a master copy of the cluster.
297 If you create several MASTER PFSs with the same cluster id you are
298 effectively creating a multi-master cluster and causing a quorum and
299 cache coherency protocol to be used to validate operations.
300 The total number of masters is stored in each PFSs making up the cluster.
301 Filesystem operations will stall for normal mounts if a quorum cannot be
302 obtained to validate the operation.
303 MASTER nodes which go offline and return later will synchronize in the
304 background.
305 Note that when adding a MASTER to an existing cluster you must add the
306 new PFS as a SLAVE and then upgrade it to a MASTER.
307 .Pp
308 SOFT_MASTER - Create a PFS which maintains synchronization with and provides
309 a read-write copy of the cluster.
310 This is one of the special mount cases.  A SOFT_MASTER will synchronize with
311 the cluster when the cluster is available, but can still be read AND written
312 to even when the cluster is not available.
313 Modifications made to a SOFT_MASTER will be automatically flushed to the
314 cluster when it becomes accessible again, and vise-versa.
315 Manual intervention may be required if a conflict occurs during
316 synchronization.
317 .\" ==== pfs-delete ====
318 .It Cm pfs-delete Ar label
319 Delete a local PFS on a mounted HAMMER2 filesystem.
320 Deleting a PFS of type MASTER requires first downgrading it to a SLAVE (XXX).
321 .\" ==== snapshot ====
322 .It Cm snapshot Ar path Op label
323 Create a snapshot of a directory.
324 This can only be used on a local PFS, and is only really useful if the PFS
325 contains a complete copy of what you desire to snapshot so that typically
326 means a local MASTER, SOFT_MASTER, SLAVE, or SOFT_SLAVE must be present.
327 Snapshots are created simply by flushing a PFS mount to disk and then copying
328 the directory inode to the PFS.
329 The topology is snapshotted without having to be copied or scanned.
330 Snapshots are effectively separate from the cluster they came from
331 and can be used as a starting point for a new cluster.
332 So unless you build a new cluster from the snapshot, it will stay local
333 to the machine it was made on.
334 .\" ==== snapshot-debug ====
335 .It Cm snapshot-debug Ar path Op label
336 Snapshot without filesystem sync.
337 .\" ==== service ====
338 .It Cm service
339 Start the
340 .Nm
341 service daemon.
342 This daemon is also automatically started when you run
343 .Xr mount_hammer2 8 .
344 The hammer2 service daemon handles incoming TCP connections and maintains
345 outgoing TCP connections.  It will interconnect available services on the
346 machine (e.g. hammer2 mounts and xdisks) to the network.
347 .\" ==== stat ====
348 .It Cm stat Op path...
349 Print the inode statistics, compression, and other meta-data associated
350 with a list of paths.
351 .\" ==== leaf ====
352 .It Cm leaf
353 XXX
354 .\" ==== shell ====
355 .It Cm shell Op host
356 Start a debug shell to the local hammer2 service daemon via the DMSG protocol.
357 .\" ==== debugspan ====
358 .It Cm debugspan Ar target
359 (do not use)
360 .\" ==== rsainit ====
361 .It Cm rsainit Op path
362 Create the
363 .Pa /etc/hammer2
364 directory and initialize a public/private keypair in that directory for
365 use by the network cluster protocols.
366 .\" ==== show ====
367 .It Cm show Ar devpath
368 Dump the radix tree for the HAMMER2 filesystem by scanning a
369 block device directly.  No mount is required.
370 .\" ==== freemap ====
371 .It Cm freemap Ar devpath
372 Dump the freemap tree for the HAMMER2 filesystem by scanning a
373 block device directly.  No mount is required.
374 .\" ==== volhdr ====
375 .It Cm volhdr Ar devpath
376 Dump the volume header for the HAMMER2 filesystem by scanning a
377 block device directly.  No mount is required.
378 .\" ==== setcomp ====
379 .It Cm setcomp Ar mode[:level] Ar path...
380 Set the compression mode as specified for any newly created elements at or
381 under the path if not overridden by deeper elements.
382 Available modes are none, autozero, lz4, or zlib.
383 When zlib is used the compression level can be set.
384 The default will be 6 which is the best trade-off between performance and
385 time.
386 .Pp
387 newfs_hammer2 will set the default compression to lz4 which prioritizes
388 speed over performance.
389 Also note that HAMMER2 contains a heuristic and will not attempt to
390 compress every block if it detects a sufficient amount of uncompressable
391 data.
392 .Pp
393 Hammer2 compression is only effective when it can reduce the size of dataset
394 (typically a 64KB block) by one or more powers of 2.  A 64K block which
395 only compresses to 40K will not yield any storage improvement.
396 .Pp
397 Generally speaking you do not want to set the compression mode to
398 .Sq none ,
399 as this will cause blocks of all-zeros to be written as all-zero blocks,
400 instead of holes.  The
401 .Sq autozero
402 compression mode detects blocks of all-zeros
403 and writes them as holes.  However, HAMMER2 will rewrite data in-place if
404 the compression mode is set to
405 .Sq none
406 and the check code is set to
407 .Sq  disabled .
408 Formal snapshots will still snapshot such files.  However,
409 de-duplication will no longer function on the data blocks.
410 .\" ==== setcheck ====
411 .It Cm setcheck Ar check Ar path...
412 Set the check code as specified for any newly created elements at or under
413 the path if not overridden by deeper elements.
414 Available codes are default, disabled, crc32, xxhash64, or sha192.
415 .\" ==== clrcheck ====
416 .It Cm clrcheck Op path...
417 Clear the check code override for the specified paths.
418 Overrides may still be present in deeper elements.
419 .\" ==== setcrc32 ====
420 .It Cm setcrc32 Op path...
421 Set the check code to the ISCSI 32-bit CRC for any newly created elements
422 at or under the path if not overridden by deeper elements.
423 .\" ==== setxxhash64 ====
424 .It Cm setxxhash64 Op path...
425 Set the check code to XXHASH64, a fast 64-bit hash
426 .\" ==== setsha192 ====
427 .It Cm setsha192 Op path...
428 Set the check code to SHA192 for any newly created elements at or under
429 the path if not overridden by deeper elements.
430 .\" ==== bulkfree ====
431 .It Cm bulkfree Ar path
432 Run a bulkfree pass on a HAMMER2 mount.
433 You can specify any PFS for the mount, the bulkfree pass is run on the
434 entire partition.
435 Note that it takes two passes to actually free space.
436 By default this directive will use up to 1/16 physical memory to track
437 the freemap.  The amount of memory used may be overridden with the
438 .Op Fl m Ar mem
439 option.
440 .\" ==== printinode ====
441 .It Cm printinode Ar path
442 Dump inode.
443 .\" ==== dumpchain ====
444 .It Cm dumpchain Op path Op chnflags
445 Dump in-memory chain topology.
446 .El
447 .Sh SYSCTLS
448 .Bl -tag -width indent
449 .It Va vfs.hammer2.dedup_enable (default on)
450 Enables live de-duplication.  Any recently read data that is on-media
451 (already synchronized to media) is tested against pending writes for
452 compatibility.  If a match is found, the write will reference the
453 existing on-media data instead of writing new data.
454 .It Va vfs.hammer2.always_compress (default off)
455 This disables the H2 compression heuristic and forces H2 to always
456 try to compress data blocks, even if they look uncompressable.
457 Enabling this option reduces performance but has higher de-duplication
458 repeatability.
459 .It Va vfs.hammer2.cluster_data_read (default 4)
460 .It Va vfs.hammer2.cluster_meta_read (default 1)
461 Set the amount of read-ahead clustering to perform on data and meta-data
462 blocks.
463 .It Va vfs.hammer2.cluster_write (default 4)
464 Set the amount of write-behind clustering to perform in buffers.  Each
465 buffer represents 64KB.  The default is 4 and higher values typically do
466 not improve performance.  A value of 0 disables clustered writes.
467 This variable applies to the underlying media device, not to logical
468 file writes, so it should not interfere with temporary file optimization.
469 Generally speaking you want this enabled to generate smoothly pipelined
470 writes to the media.
471 .It Va vfs.hammer2.bulkfree_tps (default 5000)
472 Set bulkfree's maximum scan rate.  This is primarily intended to limit
473 I/O utilization on SSDs and cpu utilization when the meta-data is mostly
474 cached in memory.
475 .El
476 .Sh SETTING UP /etc/hammer2
477 The
478 .Sq rsainit
479 directive will create the
480 .Pa /etc/hammer2
481 directory with appropriate permissions and also generate a public key
482 pair in this directory for the machine.  These files will be
483 .Pa rsa.pub
484 and
485 .Pa rsa.prv
486 and needless to say, the private key shouldn't leave the host.
487 .Pp
488 The service daemon will also scan the
489 .Pa /etc/hammer2/autoconn
490 file which contains a list of hosts which it will automatically maintain
491 connections to to form your cluster.
492 The service daemon will automatically reconnect on any failure and will
493 also monitor the file for changes.
494 .Pp
495 When the service daemon receives a connection it expects to find a
496 public key for that connection in a file in
497 .Pa /etc/hammer2/remote/
498 called
499 .Pa <IPADDR>.pub .
500 You normally copy the
501 .Pa rsa.pub
502 key from the host in question to this file.
503 The IP address must match exactly or the connection will not be allowed.
504 .Pp
505 If you want to use an unencrypted connection you can create empty,
506 dummy files in the remote directory in the form
507 .Pa <IPADDR>.none .
508 We do not recommend using unencrypted connections.
509 .Sh CLUSTER SERVICES
510 Currently there are two services which use the cluster network infrastructure,
511 HAMMER2 mounts and XDISK.
512 Any HAMMER2 mount will make all PFSs for that filesystem available to the
513 cluster.
514 And if the XDISK kernel module is loaded, the hammer2 service daemon will make
515 your machine's block devices available to the cluster (you must load the
516 xdisk.ko kernel module before starting the hammer2 service).
517 They will show up as
518 .Pa /dev/xa*
519 and
520 .Pa /dev/serno/*
521 devices on the remote machines making up the cluster.
522 Remote block devices are just what they appear to be... direct access to a
523 block device on a remote machine.  If the link goes down remote accesses
524 will stall until it comes back up again, then automatically requeue any
525 pending I/O and resume as if nothing happened.
526 However, if the server hosting the physical disks crashes or is rebooted,
527 any remote opens to its devices will see a permanent I/O failure requiring a
528 close and open sequence to re-establish.
529 The latter is necessary because the server's drives might not have committed
530 the data before the crash, but had already acknowledged the transfer.
531 .Pp
532 Data commits work exactly the same as they do for real block devices.
533 The originater must issue a BUF_CMD_FLUSH.
534 .Sh ADDING A NEW MASTER TO A CLUSTER
535 When you
536 .Xr newfs_hammer2 8
537 a HAMMER2 filesystem or use the
538 .Sq pfs-create
539 directive on one already mounted
540 to create a new PFS, with no special options, you wind up with a PFS
541 typed as a MASTER and a unique cluster uuid, but because there is only one
542 PFS for that cluster (for each PFS you create via pfs-create), it will
543 act just like a normal filesystem would act and does not require any special
544 protocols to operate.
545 .Pp
546 If you use the
547 .Sq pfs-create
548 directive along with the
549 .Fl u
550 option to specify a cluster uuid that already exists in the cluster,
551 you are adding a PFS to an existing cluster and this can trigger a whole
552 series of events in the background.
553 When you specify the
554 .Fl u
555 option in a
556 .Sq pfs-create ,
557 .Nm
558 will by default create a SLAVE PFS.
559 In fact, this is what must be created first even if you want to add a new
560 MASTER to your cluster.
561 .Pp
562 The most common action a system admin will want to take is to upgrade or
563 downgrade a PFS.
564 A new MASTER can be added to the cluster by upgrading an existing SLAVE
565 to MASTER.
566 A MASTER can be removed from the cluster by downgrading it to a SLAVE.
567 Upgrades and downgrades will put nodes in the cluster in a transition state
568 until the operation is complete.
569 For downgrades the transition state is fleeting unless one or more other
570 masters has not acknowledged the change.
571 For upgrades a background synchronization process must complete before the
572 transition can be said to be complete, and the node remains (really) a SLAVE
573 until that transition is complete.
574 .Sh USE CASES FOR A SOFT_MASTER
575 The SOFT_MASTER PFS type is a special type which must be specifically
576 mounted by a machine.
577 It is a R/W mount which does not use the quorum protocol and is not
578 cache coherent with the cluster, but which synchronizes from the cluster
579 and allows modifying operations which will synchronize to the cluster.
580 The most common case is to use a SOFT_MASTER PFS in a laptop allowing you
581 to work on your laptop when you are on the road and not connected to
582 your main servers, and for the laptop to synchronize when a connection is
583 available.
584 .Sh USE CASES FOR A SOFT_SLAVE
585 A SOFT_SLAVE PFS type is a special type which must be specifically mounted
586 by a machine.
587 It is a RO mount which does not use the quorum protocol and is not
588 cache coherent with the cluster.  It will receive synchronization from
589 the cluster when network connectivity is available but will not stall if
590 network connectivity is lost.
591 .Sh FSYNC FLUSH MODES
592 TODO.
593 .Sh RESTORING FROM A SNAPSHOT BACKUP
594 TODO.
595 .Sh PERFORMANCE TUNING
596 Because HAMMER2 implements compression, decompression, and dedup natively,
597 it always double-buffers file data.  This means that the file data is
598 cached via the device vnode (in compressed / dedupped-form) and the same
599 data is also cached by the file vnode (in decompressed / non-dedupped form).
600 .Pp
601 While HAMMER2 will try to age the logical file buffers on its, some
602 additional performance tuning may be necessary for optimal operation
603 whether swapcache is used or not.  Our recommendation is to reduce the
604 number of vnodes (and thus also the logical buffer cache behind the
605 vnodes) that the system caches via the
606 .Va kern.maxvnodes
607 sysctl.
608 .Pp
609 Too-large a value will result in excessive double-caching and can cause
610 unnecessary read disk I/O.
611 We recommend a number between 25000 and 250000 vnodes, depending on your
612 use case.
613 Keep in mind that even though the vnode cache is smaller, this will make
614 room for a great deal more device-level buffer caching which can encompasses
615 far more data and meta-data than the vnode-level caching.
616 .Sh ENVIRONMENT
617 TODO.
618 .Sh FILES
619 .Bl -tag -width ".It Pa <fs>/abc/defghi/<name>" -compact
620 .It Pa /etc/hammer2/
621 .It Pa /etc/hammer2/rsa.pub
622 .It Pa /etc/hammer2/rsa.prv
623 .It Pa /etc/hammer2/autoconn
624 .It Pa /etc/hammer2/remote/<IP>.pub
625 .It Pa /etc/hammer2/remote/<IP>.none
626 .El
627 .Sh EXIT STATUS
628 .Ex -std
629 .Sh SEE ALSO
630 .Xr mount_hammer2 8 ,
631 .Xr mount_null 8 ,
632 .Xr newfs_hammer2 8 ,
633 .Xr swapcache 8 ,
634 .Xr sysctl 8
635 .Sh HISTORY
636 The
637 .Nm
638 utility first appeared in
639 .Dx 4.1 .
640 .Sh AUTHORS
641 .An Matthew Dillon Aq Mt dillon@backplane.com