3 .\" The DragonFly Project. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in
13 .\" the documentation and/or other materials provided with the
15 .\" 3. Neither the name of The DragonFly Project nor the names of its
16 .\" contributors may be used to endorse or promote products derived
17 .\" from this software without specific, prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 .Nd HAMMER file system
39 To compile this driver into the kernel,
40 place the following line in your
41 kernel configuration file:
42 .Bd -ragged -offset indent
46 Alternatively, to load the driver as a
47 module at boot time, place the following line in
49 .Bd -literal -offset indent
55 .Bd -literal -offset indent
56 /dev/ad0s1d[:/dev/ad1s1d:...] /mnt hammer rw 2 0
61 file system provides facilities to store file system data onto disk devices
62 and is intended to replace
64 as the default file system for
67 Among its features are instant crash recovery,
68 large file systems spanning multiple volumes,
69 data integrity checking,
71 fine grained history retention and snapshots,
72 pseudo-filesystems (PFSs),
73 mirroring capability and
74 unlimited number of files and links.
76 All functions related to managing
78 file systems are provided by the
88 For a more detailed introduction refer to the paper and slides listed in the
91 For some common usages of
100 .Ss Instant Crash Recovery
101 After a non-graceful system shutdown,
103 file systems will be brought back into a fully coherent state
104 when mounting the file system, usually within a few seconds.
108 mount fails due redo recovery (stage 2 recovery) being corrupted, a
109 workaround to skip this stage can be applied by setting the following tunable:
110 .Bd -literal -offset indent
111 vfs.hammer.skip_redo=<value>
115 .Bl -tag -width indent
117 Run redo recovery normally and fail to mount in the case of error (default).
119 Run redo recovery but continue mounting if an error appears.
121 Completely bypass redo recovery.
126 .Ss Large File Systems & Multi Volume
129 file system can be up to 1 Exabyte in size.
130 It can span up to 256 volumes,
131 each volume occupies a
133 disk slice or partition, or another special file,
134 and can be up to 4096 TB in size.
137 file system size is 50 GB.
138 For volumes over 2 TB in size
142 normally need to be used.
153 .Ss Data Integrity Checking
155 has high focus on data integrity,
156 CRC checks are made for all major structures and data.
158 snapshots implements features to make data integrity checking easier:
159 The atime and mtime fields are locked to the ctime
160 for files accessed via a snapshot.
163 field is based on the PFS
165 and not on any real device.
166 This means that archiving the contents of a snapshot with e.g.\&
168 and piping it to something like
170 will yield a consistent result.
171 The consistency is also retained on mirroring targets.
172 .Ss Data Deduplication
173 To save disk space data deduplication can be used.
174 Data deduplication will identify data blocks which occur multiple times
175 and only store one copy, multiple reference will be made to this copy.
187 file system uses 64-bit transaction ids to refer to historical
188 file or directory data.
189 Transaction ids used by
191 are monotonically increasing over time.
193 when a transaction is made,
195 will always use higher transaction ids for following transactions.
196 A transaction id is given in hexadecimal format
199 .Li 0x00000001061a8ba6 .
210 .Ss History & Snapshots
211 History metadata on the media is written with every sync operation, so that
212 by default the resolution of a file's history is 30-60 seconds until the next
214 Prior versions of files and directories are generally accessible by appending
216 and a transaction id to the name.
217 The common way of accessing history, however, is by taking snapshots.
219 Snapshots are softlinks to prior versions of directories and their files.
220 Their data will be retained across prune operations for as long as the
222 Removing the softlink enables the file system to reclaim the space
223 again upon the next prune & reblock operations.
226 Version 3+ snapshots are also maintained as file system meta-data.
243 .Ss Pruning & Reblocking
244 Pruning is the act of deleting file system history.
245 By default only history used by the given snapshots
246 and history from after the latest snapshot will be retained.
247 By setting the per PFS parameter
249 history is guaranteed to be saved at least this time interval.
250 All other history is deleted.
251 Reblocking will reorder all elements and thus defragment the file system and
252 free space for reuse.
253 After pruning a file system must be reblocked to recover all available space.
254 Reblocking is needed even when using the
267 .Cm prune-everything ,
274 .Ss Pseudo-Filesystems (PFSs)
275 A pseudo-filesystem, PFS for short, is a sub file system in a
280 file system is shared between all PFSs in it,
281 so each PFS is free to use all remaining space.
284 file system supports up to 65536 PFSs.
287 file system is PFS# 0, it is called the root PFS and is always a master PFS.
289 A non-root PFS can be either master or slave.
290 Slaves are always read-only,
291 so they can't be updated by normal file operations, only by
293 operations like mirroring and pruning.
294 Upgrading slaves to masters and downgrading masters to slaves are supported.
296 It is recommended to use a
298 mount to access a PFS, except for root PFS;
299 this way no tools are confused by the PFS root being a symlink
300 and inodes not being unique across a
306 operations operates per PFS,
307 this includes mirroring, offline deduping, pruning, reblocking and rebalancing.
322 Mirroring is copying of all data in a file system, including snapshots
323 and other historical data.
324 In order to allow inode numbers to be duplicated on the slaves
326 mirroring feature uses PFSs.
327 A master or slave PFS can be mirrored to a slave PFS.
328 I.e.\& for mirroring multiple slaves per master are supported,
329 but multiple masters per slave are not.
331 does not support multi-master clustering and mirroring.
339 .Cm mirror-read-stream ,
342 .Ss Fsync Flush Modes
345 file system implements several different
347 flush modes, the mode used is set via the
348 .Va vfs.hammer.flush_mode
352 .Ss Unlimited Number of Files and Links
353 There is no limit on the number of files or links in a
355 file system, apart from available disk space.
358 file systems support NFS export.
359 NFS export of PFSs is done using
361 mounts (for file/directory in root PFS
363 mount is not needed).
364 For example, to export the PFS
365 .Pa /hammer/pfs/data ,
370 and export the latter path.
372 Don't export a directory containing a PFS (e.g.\&
380 above) should be exported (subdirectory may be escaped if exported).
381 .Ss File System Versions
382 As new features have been introduced to
384 a version number has been bumped.
387 file system has a version, which can be upgraded to support new features.
393 .Cm version-upgrade ;
397 .Ss Preparing the File System
398 To create and mount a
407 file systems must have a unique name on a per-machine basis.
408 .Bd -literal -offset indent
409 newfs_hammer -L HOME /dev/ad0s1d
410 mount_hammer /dev/ad0s1d /home
413 Similarly, multi volume file systems can be created and mounted by
414 specifying additional arguments.
415 .Bd -literal -offset indent
416 newfs_hammer -L MULTIHOME /dev/ad0s1d /dev/ad1s1d
417 mount_hammer /dev/ad0s1d /dev/ad1s1d /home
420 Once created and mounted,
422 file systems need periodic clean up making snapshots, pruning and reblocking,
423 in order to have access to history and file system not to fill up.
424 For this it is recommended to use the
432 .Nm hammer Cm cleanup
436 It is also possible to perform these operations individually via
438 For example, to reblock the
440 file system every night at 2:15 for up to 5 minutes:
441 .Bd -literal -offset indent
442 15 2 * * * hammer -c /var/run/HOME.reblock -t 300 reblock /home \e
450 command provides several ways of taking snapshots.
451 They all assume a directory where snapshots are kept.
452 .Bd -literal -offset indent
454 hammer snapshot /home /snaps/snap1
455 (...after some changes in /home...)
456 hammer snapshot /home /snaps/snap2
461 point to the state of the
463 directory at the time each snapshot was taken, and could now be used to copy
464 the data somewhere else for backup purposes.
468 is set up to create nightly snapshots of all
472 and to keep them for 60 days.
474 A snapshot directory is also the argument to the
477 command which frees historical data from the file system that is not
478 pointed to by any snapshot link and is not from after the latest snapshot
481 .Bd -literal -offset indent
486 Mirroring is set up using
488 pseudo-filesystems (PFSs).
489 To associate the slave with the master its shared UUID should be set to
490 the master's shared UUID as output by the
491 .Nm hammer Cm pfs-master
493 .Bd -literal -offset indent
494 hammer pfs-master /home/pfs/master
495 hammer pfs-slave /home/pfs/slave shared-uuid=<master's shared uuid>
500 link is unusable for as long as no mirroring operation has taken place.
502 To mirror the master's data, either pipe a
506 or, as a short-cut, use the
508 command (which works across a
511 Initial mirroring operation has to be done to the PFS path (as
513 can't access it yet).
514 .Bd -literal -offset indent
515 hammer mirror-copy /home/pfs/master /home/pfs/slave
518 It is also possible to have the target PFS auto created
519 by just issuing the same
521 command, if the target PFS doesn't exist you will be prompted
522 if you would like to create it.
523 You can even omit the prompting by using the
526 .Bd -literal -offset indent
527 hammer -y mirror-copy /home/pfs/master /home/pfs/slave
530 After this initial step
532 mount can be setup for
533 .Pa /home/pfs/slave .
534 Further operations can use
537 .Bd -literal -offset indent
538 mount_null /home/pfs/master /home/master
539 mount_null /home/pfs/slave /home/slave
541 hammer mirror-copy /home/master /home/slave
544 To NFS export from the
550 without PFSs, and the PFS
551 .Pa /hammer/pfs/data ,
561 .Bd -literal -offset indent
562 /hammer/pfs/data /hammer/data null rw
569 .Bd -literal -offset indent
575 .It "hammer: System has insuffient buffers to rebalance the tree. nbuf < %d"
578 PFS uses quite a bit of memory and
579 can't be done on low memory systems.
580 It has been reported to fail on 512MB systems.
581 Rebalancing isn't critical for
583 file system operation;
610 .%O http://www.dragonflybsd.org/hammer/hammer.pdf
611 .%T "The HAMMER Filesystem"
616 .%O http://www.dragonflybsd.org/presentations/nycbsdcon08/
617 .%T "Slideshow from NYCBSDCon 2008"
622 .%O http://www.ntecs.de/talks/HAMMER.pdf
623 .%T "Slideshow for a presentation held at KIT (http://www.kit.edu)"
625 .Sh FILESYSTEM PERFORMANCE
628 file system has a front-end which processes VNOPS and issues necessary
629 block reads from disk, and a back-end which handles meta-data updates
630 on-media and performs all meta-data write operations.
631 Bulk file write operations are handled by the front-end.
634 defers meta-data updates virtually no meta-data read operations will be
635 issued by the frontend while writing large amounts of data to the file system
636 or even when creating new files or directories, and even though the
637 kernel prioritizes reads over writes the fact that writes are cached by
638 the drive itself tends to lead to excessive priority given to writes.
640 There are four bioq sysctls, shown below with default values,
641 which can be adjusted to give reads a higher priority:
642 .Bd -literal -offset indent
643 kern.bioq_reorder_minor_bytes: 262144
644 kern.bioq_reorder_burst_bytes: 3000000
645 kern.bioq_reorder_minor_interval: 5
646 kern.bioq_reorder_burst_interval: 60
649 If a higher read priority is desired it is recommended that the
650 .Va kern.bioq_reorder_minor_interval
651 be increased to 15, 30, or even 60, and the
652 .Va kern.bioq_reorder_burst_bytes
653 be decreased to 262144 or 524288.
657 file system first appeared in
663 file system was designed and implemented by
664 .An Matthew Dillon Aq Mt dillon@backplane.com ,
665 data deduplication was added by
667 This manual page was written by
670 .An Thomas Nikolajsen .