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
66 Among its features are instant crash recovery,
67 large file systems spanning multiple volumes,
68 data integrity checking,
69 fine grained history retention,
70 mirroring capability, and pseudo file systems.
72 All functions related to managing
74 file systems are provided by the
83 For a more detailed introduction refer to the paper and slides listed in the
86 For some common usages of
91 .Ss Instant Crash Recovery
92 After a non-graceful system shutdown,
94 file systems will be brought back into a fully coherent state
95 when mounting the file system, usually within a few seconds.
96 .Ss Large File Systems & Multi Volume
99 file system can be up to 1 Exabyte in size.
100 It can span up to 256 volumes,
101 each volume occupies a
103 disk slice or partition, or another special file,
104 and can be up to 4096 TB in size.
107 file system size is 50 GB.
108 For volumes over 2 TB in size
112 normally need to be used.
113 .Ss Data Integrity Checking
115 has high focus on data integrity,
116 CRC checks are made for all major structures and data.
118 snapshots implements features to make data integrity checking easier:
119 The atime and mtime fields are locked to the ctime
120 for files accessed via a snapshot.
123 field is based on the PFS
125 and not on any real device.
126 This means that archiving the contents of a snapshot with e.g.\&
128 and piping it to something like
130 will yield a consistent result.
131 The consistency is also retained on mirroring targets.
135 file system uses 64 bit, hexadecimal transaction IDs to refer to historical
136 file or directory data.
142 .Li 0x00000001061a8ba6 .
149 .Ss History & Snapshots
150 History metadata on the media is written with every sync operation, so that
151 by default the resolution of a file's history is 30-60 seconds until the next
153 Prior versions of files or directories are generally accessible by appending
155 and a transaction ID to the name.
156 The common way of accessing history, however, is by taking snapshots.
158 Snapshots are softlinks to prior versions of directories and their files.
159 Their data will be retained across prune operations for as long as the
161 Removing the softlink enables the file system to reclaim the space
162 again upon the next prune & reblock operations.
172 .Ss Pruning & Reblocking
173 Pruning is the act of deleting file system history.
174 By default only history used by the given snapshots
175 and history from after the latest snapshot will be retained.
176 By setting the per PFS parameter
178 history is guaranteed to be saved at least this time interval.
179 All other history is deleted.
180 Reblocking will reorder all elements and thus defragment the file system and
181 free space for reuse.
182 After pruning a file system must be reblocked to recover all available space.
183 Reblocking is needed even when using the
196 .Ar prune-everything ,
203 .Ss Mirroring & Pseudo File Systems
204 In order to allow inode numbers to be duplicated on the slaves
206 mirroring feature uses
207 .Dq Pseudo File Systems
211 file system supports up to 65535 PFSs.
212 Multiple slaves per master are supported, but multiple masters per slave
214 Slaves are always read-only.
215 Upgrading slaves to masters and downgrading masters to slaves are supported.
217 It is recommended to use a
219 mount to access a PFS;
220 this way no tools are confused by the PFS root being a symlink
221 and inodes not being unique across a
239 .Ar mirror-read-stream ,
244 file systems support NFS export.
245 NFS export of PFSs is done using
248 For example, to export the PFS
249 .Pa /hammer/pfs/data ,
254 and export the latter path.
256 Don't export a directory containing a PFS (e.g.\&
266 (subdirectory may be escaped if exported).
268 .Ss Preparing the File System
269 To create and mount a
278 file systems must have a unique name on a per-machine basis.
279 .Bd -literal -offset indent
280 newfs_hammer -L HOME /dev/ad0s1d
281 mount_hammer /dev/ad0s1d /home
284 Similarly, multi volume file systems can be created and mounted by
285 specifying additional arguments.
286 .Bd -literal -offset indent
287 newfs_hammer -L MULTIHOME /dev/ad0s1d /dev/ad1s1d
288 mount_hammer /dev/ad0s1d /dev/ad1s1d /home
291 Once created and mounted,
293 file systems need periodic clean up making snapshots, pruning and reblocking,
294 in order to have access to history and file system not to fill up.
295 For this it is recommended to use the
303 .Nm hammer Ar cleanup
307 It is also possible to perform these operations individually via
309 For example, to reblock the
311 file system every night at 2:15 for up to 5 minutes:
312 .Bd -literal -offset indent
313 15 2 * * * hammer -c /var/run/HOME.reblock -t 300 reblock /home \e
321 command provides several ways of taking snapshots.
322 They all assume a directory where snapshots are kept.
323 .Bd -literal -offset indent
325 hammer snapshot /home /snaps/snap1
326 (...after some changes in /home...)
327 hammer snapshot /home /snaps/snap2
332 point to the state of the
334 directory at the time each snapshot was taken, and could now be used to copy
335 the data somewhere else for backup purposes.
339 is set up to create nightly snapshots of all
343 and to keep them for 60 days.
345 A snapshot directory is also the argument to the
348 command which frees historical data from the file system that is not
349 pointed to by any snapshot link and is not from after the latest snapshot.
350 .Bd -literal -offset indent
355 Mirroring can be set up using
358 To associate the slave with the master its shared UUID should be set to
359 the master's shared UUID as output by the
360 .Nm hammer Ar pfs-master
362 .Bd -literal -offset indent
363 hammer pfs-master /home/pfs/master
364 hammer pfs-slave /home/pfs/slave shared-uuid=<master's shared uuid>
369 link is unusable for as long as no mirroring operation has taken place.
371 To mirror the master's data, either pipe a
375 or, as a short-cut, use the
377 command (which works across a
380 Initial mirroring operation has to be done to the PFS path (as
382 can't access it yet).
383 .Bd -literal -offset indent
384 hammer mirror-copy /home/pfs/master /home/pfs/slave
387 After this initial step
389 mount can be setup for
390 .Pa /home/pfs/slave .
391 Further operations can use
394 .Bd -literal -offset indent
395 mount_null /home/pfs/master /home/master
396 mount_null /home/pfs/slave /home/slave
398 hammer mirror-copy /home/master /home/slave
401 To NFS export from the
407 without PFSs, and the PFS
408 .Pa /hammer/pfs/data ,
409 the latter is null mounted to
416 .Bd -literal -offset indent
417 /hammer/pfs/data /hammer/data null rw
424 .Bd -literal -offset indent
445 .%O http://www.dragonflybsd.org/hammer/hammer.pdf
446 .%T "The HAMMER Filesystem"
451 .%O http://www.dragonflybsd.org/hammer/nycbsdcon/
452 .%T "Slideshow from NYCBSDCon 2008"
457 .%O http://www.ntecs.de/sysarch09/HAMMER.pdf
458 .%T "Slideshow for a presentation held at KIT (http://www.kit.edu)."
460 .Sh FILESYSTEM PERFORMANCE
463 file system has a front-end which processes VNOPS and issues necessary
464 block reads from disk, and a back-end which handles meta-data updates
465 on-media and performs all meta-data write operations.
466 Bulk file write operations are handled by the front-end.
469 defers meta-data updates virtually no meta-data read operations will be
470 issued by the frontend while writing large amounts of data to the file system
471 or even when creating new files or directories, and even though the
472 kernel prioritizes reads over writes the fact that writes are cached by
473 the drive itself tends to lead to excessive priority given to writes.
475 There are four bioq sysctls, shown below with default values,
476 which can be adjusted to give reads a higher priority:
477 .Bd -literal -offset indent
478 kern.bioq_reorder_minor_bytes: 262144
479 kern.bioq_reorder_burst_bytes: 3000000
480 kern.bioq_reorder_minor_interval: 5
481 kern.bioq_reorder_burst_interval: 60
484 If a higher read priority is desired it is recommended that the
485 .Fa kern.bioq_reorder_minor_interval
486 be increased to 15, 30, or even 60, and the
487 .Fa kern.bioq_reorder_burst_bytes
488 be decreased to 262144 or 524288.
492 file system first appeared in
498 file system was designed and implemented by
499 .An Matthew Dillon Aq dillon@backplane.com .
500 This manual page was written by