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