man.bsd.lv manual page server

Manual Page Search Parameters

HAMMER2(8) System Manager's Manual HAMMER2(8)

hammer2hammer2 file system utility

hammer2 -h

hammer2 [-s path] [-t type] [-u uuid] [-m mem] command [argument ...]

The hammer2 utility provides miscellaneous support functions for a HAMMER2 file system.

The options are as follows:

path
Specify the path to a mounted HAMMER2 filesystem. At least one PFS on a HAMMER2 filesystem must be mounted for the system to act on all PFSs managed by it. Every HAMMER2 filesystem typically has a PFS called "LOCAL" for this purpose.
type
Specify the type when creating, upgrading, or downgrading a PFS. Supported types are MASTER, SLAVE, SOFT_MASTER, SOFT_SLAVE, CACHE, and DUMMY. If not specified the pfs-create directive will default to MASTER if no uuid is specified, and SLAVE if a uuid is specified.
uuid
Specify the cluster uuid when creating a PFS. If not specified, a unique, random uuid will be generated. Note that every PFS also has a unique pfs_id which is always generated and cannot be overridden with an option. The { pfs_clid, pfs_fsid } tuple uniquely identifies a component of a cluster.
mem
Specify how much tracking memory to use for certain directives. At the moment, this option is only applicable to the bulkfree directive, allowing it to operate in fewer passes when given more memory. A nominal value for a 4TB drive with a ton of stuff on it would be around a gigabyte '-m 1g'.

hammer2 directives are as shown below. Note that most directives require you to either be CD'd into a hammer2 filesystem, specify a path to a mounted hammer2 filesystem via the -s option, or specify a path after the directive. It depends on the directive. All hammer2 filesystem have a PFS called "LOCAL" which is typically mounted locally on the host in order to be able to issue commands for other PFSs on the filesystem. The mount also enables PFS configuration scanning for that filesystem.

[path]
Perform manual cleanup passes on paths or all mounted partitions.
target
Add a cluster link entry to the volume header. The volume header can support up to 255 link entries. This feature is not currently used.
path
Destroy the specified directory entry in a hammer2 filesystem. This bypasses all normal checks and will unconditionally destroy the directory entry. The underlying inode is not checked and, if it does exist, its nlinks count is not decremented. This directive should only be used to destroy a corrupted directory entry which no longer has a working inode.

Note that this command may desynchronize the system namecache for the specified entry. If this happens, you may have to unmount and remount the filesystem.

target
Delete a cluster link entry from the volume header. This feature is not currently used.
[devpath]
Access and print the status and super-root entries for all HAMMER2 partitions found in /dev/serno or the specified device path(s). The partitions do not have to be mounted. Note that only mounted partitions will be under active management. This is accomplished by mounting at least one PFS within the partition. Typically at least the @LOCAL PFS is mounted.
[devpath]
This directive mounts the @LOCAL PFS on all HAMMER2 partitions found in /dev/serno, or the specified device path(s). The partitions are mounted as /var/hammer2/LOCAL.<id>. Mounts are executed in the background and this command will wait a limited amount of time for the mounts to complete before returning.
path...
Dump a list of all cluster link entries configured in the volume header.
filename...
Compute and print the directory hash for any number of filenames.
[path...]
List all local PFSs available on a mounted HAMMER2 filesystem, their type, and their current status. You must mount at least one PFS in order to be able to access the whole list.
label
Print the cluster id for a PFS specified by name.
label
Print the unique filesystem id for a PFS specified by name.
label
Create a local PFS on a mounted HAMMER2 filesystem. If no uuid is specified the pfs-type defaults to MASTER. If a uuid is specified via the -u option the pfs-type defaults to SLAVE. Other types can be specified with the -t option.

If you wish to add a MASTER to an existing cluster, you must first add it as a SLAVE and then upgrade it to MASTER to properly synchronize it.

The DUMMY pfs-type is used to tie network-accessible clusters into the local machine when no local storage is desired. This type should be used on minimal H2 partitions or entirely in ram for netboot-centric systems to provide a tie-in point for the mount command, or on more complex systems where you need to also access network-centric clusters.

The CACHE or SLAVE pfs-type is typically used when the main store is on the network but local storage is desired to improve performance. SLAVE is also used when a backup is desired.

Generally speaking, you can mount any PFS element of a cluster in order to access the cluster via the full cluster protocol. There are two exceptions. If you mount a SOFT_SLAVE or a SOFT_MASTER then soft quorum semantics are employed... the soft slave or soft master's current state will always be used and the quorum protocol will not be used. The soft PFS will still be synchronized to masters in the background when available. Also, you can use ‘mount -o local’ to mount ONLY a local HAMMER2 PFS and not run any network or quorum protocols for the mount. All such mounts except for a SOFT_MASTER mount will be read-only. Other than that, you will be mounting the whole cluster when you mount any PFS within the cluster.

DUMMY - Create a PFS skeleton intended to be the mount point for a more complex cluster, probably one that is entirely network based. No data will be synchronized to this PFS so it is suitable for use in a network boot image or memory filesystem. This allows you to create placeholders for mount points on your local disk, SSD, or memory disk.

CACHE - Create a PFS for caching portions of the cluster piecemeal. This is similar to a SLAVE but does not synchronize the entire contents of the cluster to the PFS. Elements found in the CACHE PFS which are validated against the cluster will be read, presumably a faster access than having to go to the cluster. Only local CACHEs will be updated. Network-accessible CACHE PFSs might be read but will not be written to. If you have a large hard-drive-based cluster you can set up localized SSD CACHE PFSs to improve performance.

SLAVE - Create a PFS which maintains synchronization with and provides a read-only copy of the cluster. HAMMER2 will prioritize local SLAVEs for data retrieval after validating their transaction id against the cluster. The difference between a CACHE and a SLAVE is that the SLAVE is synchronized to a full copy of the cluster and thus can serve as a backup or be staged for use as a MASTER later on.

SOFT_SLAVE - Create a PFS which maintains synchronization with and provides a read-only copy of the cluster. This is one of the special mount cases. A SOFT_SLAVE will synchronize with the cluster when the cluster is available, but can still be accessed when the cluster is not available.

MASTER - Create a PFS which will hold a master copy of the cluster. If you create several MASTER PFSs with the same cluster id you are effectively creating a multi-master cluster and causing a quorum and cache coherency protocol to be used to validate operations. The total number of masters is stored in each PFSs making up the cluster. Filesystem operations will stall for normal mounts if a quorum cannot be obtained to validate the operation. MASTER nodes which go offline and return later will synchronize in the background. Note that when adding a MASTER to an existing cluster you must add the new PFS as a SLAVE and then upgrade it to a MASTER.

SOFT_MASTER - Create a PFS which maintains synchronization with and provides a read-write copy of the cluster. This is one of the special mount cases. A SOFT_MASTER will synchronize with the cluster when the cluster is available, but can still be read AND written to even when the cluster is not available. Modifications made to a SOFT_MASTER will be automatically flushed to the cluster when it becomes accessible again, and vise-versa. Manual intervention may be required if a conflict occurs during synchronization.

label
Delete a local PFS on a mounted HAMMER2 filesystem. Deleting a PFS of type MASTER requires first downgrading it to a SLAVE (XXX).
path [label]
Create a snapshot of a directory. This can only be used on a local PFS, and is only really useful if the PFS contains a complete copy of what you desire to snapshot so that typically means a local MASTER, SOFT_MASTER, SLAVE, or SOFT_SLAVE must be present. Snapshots are created simply by flushing a PFS mount to disk and then copying the directory inode to the PFS. The topology is snapshotted without having to be copied or scanned. Snapshots are effectively separate from the cluster they came from and can be used as a starting point for a new cluster. So unless you build a new cluster from the snapshot, it will stay local to the machine it was made on.
Start the hammer2 service daemon. This daemon is also automatically started when you run mount_hammer2(8). The hammer2 service daemon handles incoming TCP connections and maintains outgoing TCP connections. It will interconnect available services on the machine (e.g. hammer2 mounts and xdisks) to the network.
[path...]
Print the inode statistics, compression, and other meta-data associated with a list of paths.
XXX
Start a debug shell to the local hammer2 service daemon via the DMSG protocol.
(do not use)
Create the /etc/hammer2 directory and initialize a public/private keypair in that directory for use by the network cluster protocols.
devpath
Dump the radix tree for the HAMMER2 filesystem by scanning a block device directly. No mount is required. Dump the freemap tree for the HAMMER2 filesystem by scanning a block device directly. No mount is required.
devpath
 
mode[:level] [path...]
Set the compression mode as specified for any newly created elements at or under the path if not overridden by deeper elements. Available modes are none, autozero, lz4, or zlib. When zlib is used the compression level can be set. The default will be 6 which is the best trade-off between performance and time.

newfs_hammer2 will set the default compression to lz4 which prioritizes speed over performance. Also note that HAMMER2 contains a heuristic and will not attempt to compress every block if it detects a sufficient amount of uncompressable data.

Hammer2 compression is only effective when it can reduce the size of dataset (typically a 64KB block) by one or more powers of 2. A 64K block which only compresses to 40K will not yield any storage improvement.

Generally speaking you do not want to set the compression mode to ‘none’, as this will cause blocks of all-zeros to be written as all-zero blocks, instead of holes. The ‘autozero’ compression mode detects blocks of all-zeros and writes them as holes. However, HAMMER2 will rewrite data in-place if the compression mode is set to ‘none’ and the check code is set to ‘disabled’. Formal snapshots will still snapshot such files. However, de-duplication will no longer function on the data blocks.

check [path...]
Set the check code as specified for any newly created elements at or under the path if not overridden by deeper elements. Available codes are default, disabled, crc32, xxhash64, or sha192.
[path...]
Clear the check code override for the specified paths. Overrides may still be present in deeper elements.
[path...]
Set the check code to the ISCSI 32-bit CRC for any newly created elements at or under the path if not overridden by deeper elements.
[path...]
Set the check code to XXHASH64, a fast 64-bit hash
[path...]
Set the check code to SHA192 for any newly created elements at or under the path if not overridden by deeper elements.
[path...]
Run a bulkfree pass on a HAMMER2 mount. You can specify any PFS for the mount, the bulkfree pass is run on the entire partition. Note that it takes two passes to actually free space. By default this directive will use up to 1/16 physical memory to track the freemap. The amount of memory used may be overridden with the [-m mem] option.

vfs.hammer2.dedup_enable (default on)
Enables live de-duplication. Any recently read data that is on-media (already synchronized to media) is tested against pending writes for compatibility. If a match is found, the write will reference the existing on-media data instead of writing new data.
vfs.hammer2.always_compress (default off)
This disables the H2 compression heuristic and forces H2 to always try to compress data blocks, even if they look uncompressable. Enabling this option reduces performance but has higher de-duplication repeatability.
vfs.hammer2.cluster_data_read (default 4)
 
vfs.hammer2.cluster_meta_read (default 1)
Set the amount of read-ahead clustering to perform on data and meta-data blocks.
vfs.hammer2.cluster_write (default 4)
Set the amount of write-behind clustering to perform in buffers. Each buffer represents 64KB. The default is 4 and higher values typically do not improve performance. A value of 0 disables clustered writes. This variable applies to the underlying media device, not to logical file writes, so it should not interfere with temporary file optimization. Generally speaking you want this enabled to generate smoothly pipelined writes to the media.
vfs.hammer2.bulkfree_tps (default 5000)
Set bulkfree's maximum scan rate. This is primarily intended to limit I/O utilization on SSDs and cpu utilization when the meta-data is mostly cached in memory.

The ‘rsainit’ directive will create the /etc/hammer2 directory with appropriate permissions and also generate a public key pair in this directory for the machine. These files will be rsa.pub and rsa.prv and needless to say, the private key shouldn't leave the host.

The service daemon will also scan the /etc/hammer2/autoconn file which contains a list of hosts which it will automatically maintain connections to to form your cluster. The service daemon will automatically reconnect on any failure and will also monitor the file for changes.

When the service daemon receives a connection it expects to find a public key for that connection in a file in /etc/hammer2/remote/ called <IPADDR>.pub. You normally copy the rsa.pub key from the host in question to this file. The IP address must match exactly or the connection will not be allowed.

If you want to use an unencrypted connection you can create empty, dummy files in the remote directory in the form <IPADDR>.none. We do not recommend using unencrypted connections.

Currently there are two services which use the cluster network infrastructure, HAMMER2 mounts and XDISK. Any HAMMER2 mount will make all PFSs for that filesystem available to the cluster. And if the XDISK kernel module is loaded, the hammer2 service daemon will make your machine's block devices available to the cluster (you must load the xdisk.ko kernel module before starting the hammer2 service). They will show up as /dev/xa* and /dev/serno/* devices on the remote machines making up the cluster. Remote block devices are just what they appear to be... direct access to a block device on a remote machine. If the link goes down remote accesses will stall until it comes back up again, then automatically requeue any pending I/O and resume as if nothing happened. However, if the server hosting the physical disks crashes or is rebooted, any remote opens to its devices will see a permanent I/O failure requiring a close and open sequence to re-establish. The latter is necessary because the server's drives might not have committed the data before the crash, but had already acknowledged the transfer.

Data commits work exactly the same as they do for real block devices. The originater must issue a BUF_CMD_FLUSH.

When you newfs_hammer2(8) a HAMMER2 filesystem or use the ‘pfs-create’ directive on one already mounted to create a new PFS, with no special options, you wind up with a PFS typed as a MASTER and a unique cluster uuid, but because there is only one PFS for that cluster (for each PFS you create via pfs-create), it will act just like a normal filesystem would act and does not require any special protocols to operate.

If you use the ‘pfs-create’ directive along with the -u option to specify a cluster uuid that already exists in the cluster, you are adding a PFS to an existing cluster and this can trigger a whole series of events in the background. When you specify the -u option in a ‘pfs-create’, hammer2 will by default create a SLAVE PFS. In fact, this is what must be created first even if you want to add a new MASTER to your cluster.

The most common action a system admin will want to take is to upgrade or downgrade a PFS. A new MASTER can be added to the cluster by upgrading an existing SLAVE to MASTER. A MASTER can be removed from the cluster by downgrading it to a SLAVE. Upgrades and downgrades will put nodes in the cluster in a transition state until the operation is complete. For downgrades the transition state is fleeting unless one or more other masters has not acknowledged the change. For upgrades a background synchronization process must complete before the transition can be said to be complete, and the node remains (really) a SLAVE until that transition is complete.

The SOFT_MASTER PFS type is a special type which must be specifically mounted by a machine. It is a R/W mount which does not use the quorum protocol and is not cache coherent with the cluster, but which synchronizes from the cluster and allows modifying operations which will synchronize to the cluster. The most common case is to use a SOFT_MASTER PFS in a laptop allowing you to work on your laptop when you are on the road and not connected to your main servers, and for the laptop to synchronize when a connection is available.

A SOFT_SLAVE PFS type is a special type which must be specifically mounted by a machine. It is a RO mount which does not use the quorum protocol and is not cache coherent with the cluster. It will receive synchronization from the cluster when network connectivity is available but will not stall if network connectivity is lost.

TODO.

TODO.

Because HAMMER2 implements compression, decompression, and dedup natively, it always double-buffers file data. This means that the file data is cached via the device vnode (in compressed / dedupped-form) and the same data is also cached by the file vnode (in decompressed / non-dedupped form).

While HAMMER2 will try to age the logical file buffers on its, some additional performance tuning may be necessary for optimal operation whether swapcache is used or not. Our recommendation is to reduce the number of vnodes (and thus also the logical buffer cache behind the vnodes) that the system caches via the kern.maxvnodes sysctl.

Too-large a value will result in excessive double-caching and can cause unnecessary read disk I/O. We recommend a number between 25000 and 250000 vnodes, depending on your use case. Keep in mind that even though the vnode cache is smaller, this will make room for a great deal more device-level buffer caching which can encompasses far more data and meta-data than the vnode-level caching.

TODO.

/etc/hammer2/
 
/etc/hammer2/rsa.pub
 
/etc/hammer2/rsa.prv
 
/etc/hammer2/autoconn
 
/etc/hammer2/remote/<IP>.pub
 
/etc/hammer2/remote/<IP>.none
 

The hammer2 utility exits 0 on success, and >0 if an error occurs.

mount_hammer2(8), mount_null(8), newfs_hammer2(8), swapcache(8), sysctl(8)

The hammer2 utility first appeared in DragonFly 4.1.

Matthew Dillon <dillon@backplane.com>

December 2, 2017 DragonFly-5.6.1