1.\" Copyright (c) 2007 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.\" $DragonFly: src/sbin/hammer/hammer.8,v 1.58 2008/11/13 02:04:27 dillon Exp $ 34.\" 35.Dd February 12, 2010 36.Dt HAMMER 8 37.Os 38.Sh NAME 39.Nm hammer 40.Nd HAMMER file system utility 41.Sh SYNOPSIS 42.Nm 43.Fl h 44.Nm 45.Op Fl 2BqrvXy 46.Op Fl b Ar bandwidth 47.Op Fl c Ar cyclefile 48.Op Fl f Ar blkdevs 49.\" .Op Fl s Ar linkpath 50.Op Fl i Ar delay 51.Op Fl p Ar ssh-port 52.Op Fl t Ar seconds 53.Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead 54.Op Fl S Ar splitsize 55.Ar command 56.Op Ar argument ... 57.Sh DESCRIPTION 58This manual page documents the 59.Nm 60utility which provides miscellaneous functions related to managing a 61.Nm HAMMER 62file system. 63For a general introduction to the 64.Nm HAMMER 65file system, its features, and 66examples on how to set up and maintain one, see 67.Xr HAMMER 5 . 68.Pp 69The options are as follows: 70.Bl -tag -width indent 71.It Fl h 72Get help. 73.It Fl 2 74Tell the mirror commands to use a 2-way protocol, which allows 75automatic negotiation of transaction id ranges. 76This option is automatically enabled by the 77.Cm mirror-copy 78command. 79.It Fl b Ar bandwidth 80Specify a bandwidth limit in bytes per second for mirroring streams. 81This option is typically used to prevent batch mirroring operations from 82loading down the machine. 83The bandwidth may be suffixed with 84.Cm k , m , 85or 86.Cm g 87to specify values in kilobytes, megabytes, and gigabytes per second. 88If no suffix is specified, bytes per second is assumed. 89.Pp 90Unfortunately this is only applicable to the pre-compression bandwidth 91when compression is used, so a better solution would probably be to 92use a 93.Xr ipfw 8 94pipe or a 95.Xr pf 4 96queue. 97.It Fl c Ar cyclefile 98When pruning, rebalancing or reblocking you can tell the utility 99to start at the object id stored in the specified file. 100If the file does not exist 101.Nm 102will start at the beginning. 103If 104.Nm 105is told to run for a 106specific period of time and is unable to complete the operation it will 107write out the current object id so the next run can pick up where it left off. 108If 109.Nm 110runs to completion it will delete 111.Ar cyclefile . 112.It Fl f Ar blkdevs 113Specify the volumes making up a 114.Nm HAMMER 115file system. 116.Ar Blkdevs 117is a colon-separated list of devices, each specifying a 118.Nm HAMMER 119volume. 120.It Fl i Ar delay 121When maintaining a streaming mirroring this option specifies the 122minimum delay after a batch ends before the next batch is allowed 123to start. 124The default is five seconds. 125.It Fl p Ar ssh-port 126This passes the 127.Fl p Ar ssh-port 128option to 129.Xr ssh 1 130when using a remote 131specification for the source and/or destination. 132.It Fl q 133Decrease verboseness. 134May be specified multiple times. 135.It Fl r 136Specify recursion for those commands which support it. 137.It Fl t Ar seconds 138When pruning, rebalancing or reblocking you can tell the utility to stop 139after a certain period of time. 140This option is used along with the 141.Fl c Ar cyclefile 142option to prune, rebalance or reblock incrementally. 143.It Fl v 144Increase verboseness. 145May be specified multiple times. 146.It Fl y 147Force "yes" for any interactive question. 148.It Fl B 149Bulk transfer. 150.Cm Mirror-stream 151will not attempt to break-up large initial bulk transfers into smaller 152pieces. 153This can save time but if the link is lost in the middle of the 154initial bulk transfer you will have to start over from scratch. 155This option is not recommended. 156For more information see the 157.Fl S 158option. 159.It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead 160Set the memory cache size for any raw 161.Tn I/O . 162The default is 16MB. 163A suffix of 164.Cm k 165for kilobytes and 166.Cm m 167for megabytes is allowed, 168else the cache size is specified in bytes. 169.Pp 170The read-behind/read-ahead defaults to 4 171.Nm HAMMER 172blocks. 173.Pp 174This option is typically only used with diagnostic commands 175as kernel-supported commands will use the kernel's buffer cache. 176.It Fl S Ar splitsize 177Specify the bulk splitup size in bytes for mirroring streams. 178When a 179.Cm mirror-stream 180is first started 181.Nm 182will do an initial run-through of the data to calculate good 183transaction ids to cut up the bulk transfers, creating 184restart points in case the stream is interrupted. 185If we don't do this and the stream is interrupted it might 186have to start all over again. 187The default is a splitsize of 4G. 188.Pp 189At the moment the run-through is disk-bandwidth-heavy but some 190future version will limit the run-through to just the B-Tree 191records and not the record data. 192.Pp 193The splitsize may be suffixed with 194.Cm k , m , 195or 196.Cm g 197to specify values in kilobytes, megabytes, or gigabytes. 198If no suffix is specified, bytes is assumed. 199.Pp 200When mirroring very large filesystems the minimum recommended 201split side is 4G. 202A small split size may wind up generating a great deal of overhead 203but very little actual incremental data and is not recommended. 204.It Fl X 205Enable compression for any remote ssh specifications. 206Unfortunately the 207.Fl C 208option has already been reserved for other purposes so we had to use 209a different letter. 210This option is typically used with the mirroring directives. 211.It Fl y 212Force "yes" for any interactive question. 213.El 214.Pp 215The commands are as follows: 216.Bl -tag -width indent 217.\" ==== synctid ==== 218.It Cm synctid Ar filesystem Op Cm quick 219Generates a guaranteed, formal 64 bit transaction id representing the 220current state of the specified 221.Nm HAMMER 222file system. 223The file system will be synced to the media. 224.Pp 225If the 226.Cm quick 227keyword is specified the file system will be soft-synced, meaning that a 228crash might still undo the state of the file system as of the transaction 229id returned but any new modifications will occur after the returned 230transaction id as expected. 231.Pp 232This operation does not create a snapshot. 233It is meant to be used 234to track temporary fine-grained changes to a subset of files and 235will only remain valid for 236.Ql @@ 237snapshot access purposes for the 238.Cm prune-min 239period configured for the PFS. 240If you desire a real snapshot then the 241.Cm snapq 242directive may be what you are looking for. 243.\" ==== bstats ==== 244.It Cm bstats Op Ar interval 245Output 246.Nm HAMMER 247B-Tree statistics until interrupted. 248Pause 249.Ar interval 250seconds between each display. 251The default interval is one second. 252.\" ==== iostats ==== 253.It Cm iostats Op Ar interval 254Output 255.Nm HAMMER 256.Tn I/O 257statistics until interrupted. 258Pause 259.Ar interval 260seconds between each display. 261The default interval is one second. 262.\" ==== history ==== 263.It Cm history Ar path ... 264Show the modification history for 265.Nm HAMMER 266file's inode and data. 267.\" ==== blockmap ==== 268.It Cm blockmap 269Dump the blockmap for the file system. 270The 271.Nm HAMMER 272blockmap is two-layer 273blockmap representing the maximum possible file system size of 1 Exabyte. 274Needless to say the second layer is only present for blocks which exist. 275.Nm HAMMER Ns 's 276blockmap represents 8-Megabyte blocks, called big-blocks. 277Each big-block has an append 278point, a free byte count, and a typed zone id which allows content to be 279reverse engineered to some degree. 280.Pp 281In 282.Nm HAMMER 283allocations are essentially appended to a selected big-block using 284the append offset and deducted from the free byte count. 285When space is freed the free byte count is adjusted but 286.Nm HAMMER 287does not track holes in big-blocks for reallocation. 288A big-block must be completely freed, either 289through normal file system operations or through reblocking, before 290it can be reused. 291.Pp 292Data blocks can be shared by deducting the space used from the free byte 293count for each shared references, though 294.Nm HAMMER 295does not yet make use of this feature. 296This means the free byte count can legally go negative. 297.Pp 298This command needs the 299.Fl f 300flag. 301.\" ==== checkmap ==== 302.It Cm checkmap 303Check the blockmap allocation count. 304.Nm 305will scan the B-Tree, collect allocation information, and 306construct a blockmap in-memory. It will then check that blockmap 307against the on-disk blockmap. 308.Pp 309This command needs the 310.Fl f 311flag. 312.\" ==== show ==== 313.It Cm show Op Ar lo Ns Cm \&: Ns Ar objid 314Dump the B-Tree. 315By default this command will validate all B-Tree 316linkages and CRCs, including data CRCs, and will report the most verbose 317information it can dig up. 318Any errors will show up with a 319.Ql B 320in column 1 along with various 321other error flags. 322.Pp 323If you specify a localization field or a localization:obj_id field, 324.Ar lo Ns Cm \&: Ns Ar objid , 325the dump will 326search for the key printing nodes as it recurses down, and then 327will iterate forwards. 328These fields are specified in HEX. 329Note that the pfsid is the top 16 bits of the 32 bit localization 330field so PFS #1 would be 00010000. 331.Pp 332If you use 333.Fl q 334the command will report less information about the inode contents. 335.Pp 336If you use 337.Fl qq 338the command will not report the content of the inode or other typed 339data at all. 340.Pp 341If you use 342.Fl qqq 343the command will not report volume header information, big-block fill 344ratios, mirror transaction ids, or report or check data CRCs. 345B-Tree CRCs and linkages are still checked. 346.Pp 347This command needs the 348.Fl f 349flag. 350.\" ==== show-undo ==== 351.It Cm show-undo 352.Nm ( HAMMER 353VERSION 4+) 354Dump the UNDO map. 355.Pp 356This command needs the 357.Fl f 358flag. 359.\" .It Ar blockmap 360.\" Dump the B-Tree, record, large-data, and small-data blockmaps, showing 361.\" physical block assignments and free space percentages. 362.\" ==== recover ==== 363.It Cm recover Ar targetdir 364This is a low level command which operates on the filesystem image and 365attempts to locate and recover files from a corrupted filesystem. The 366entire image is scanned linearly looking for B-Tree nodes. Any node 367found which passes its crc test is scanned for file, inode, and directory 368fragments and the target directory is populated with the resulting data. 369files and directories in the target directory are initially named after 370the object id and are renamed as fragmentory information is processed. 371.Pp 372This command keeps track of filename/objid translations and may eat a 373considerably amount of memory while operating. 374.Pp 375This command is literally the last line of defense when it comes to 376recovering data from a dead filesystem. 377.\" ==== namekey1 ==== 378.It Cm namekey1 Ar filename 379Generate a 380.Nm HAMMER 38164 bit directory hash for the specified file name, using 382the original directory hash algorithm in version 1 of the file system. 383The low 32 bits are used as an iterator for hash collisions and will be 384output as 0. 385.\" ==== namekey2 ==== 386.It Cm namekey2 Ar filename 387Generate a 388.Nm HAMMER 38964 bit directory hash for the specified file name, using 390the new directory hash algorithm in version 2 of the file system. 391The low 32 bits are still used as an iterator but will start out containing 392part of the hash key. 393.\" ==== namekey32 ==== 394.It Cm namekey32 Ar filename 395Generate the top 32 bits of a 396.Nm HAMMER 39764 bit directory hash for the specified file name. 398.\" ==== info ==== 399.It Cm info 400Shows extended information about all the mounted 401.Nm HAMMER 402file systems. 403The information is divided into sections: 404.Bl -tag -width indent 405.It Volume identification 406General information, like the label of the 407.Nm HAMMER 408filesystem, the number of volumes it contains, the FSID, and the 409.Nm HAMMER 410version being used. 411.It Big block information 412Big block statistics, such as total, used, reserved and free big blocks. 413.It Space information 414Information about space used on the filesystem. 415Currently total size, used, reserved and free space are displayed. 416.It PFS information 417Basic information about the PFSs currently present on a 418.Nm HAMMER 419filesystem. 420.Pp 421.Dq PFS ID 422is the ID of the PFS, with 0 being the root PFS. 423.Dq Snaps 424is the current snapshot count on the PFS. 425.Dq Mounted on 426displays the mount point of the PFS is currently mounted on (if any). 427.El 428.\" ==== cleanup ==== 429.It Cm cleanup Op Ar filesystem ... 430This is a meta-command which executes snapshot, prune, rebalance and reblock 431commands on the specified 432.Nm HAMMER 433file systems. 434If no 435.Ar filesystem 436is specified this command will clean-up all 437.Nm HAMMER 438file systems in use, including PFS's. 439To do this it will scan all 440.Nm HAMMER 441and 442.Nm null 443mounts, extract PFS id's, and clean-up each PFS found. 444.Pp 445This command will access a snapshots 446directory and a configuration file for each 447.Ar filesystem , 448creating them if necessary. 449.Bl -tag -width indent 450.It Nm HAMMER No version 2- 451The configuration file is 452.Pa config 453in the snapshots directory which defaults to 454.Pa <pfs>/snapshots . 455.It Nm HAMMER No version 3+ 456The configuration file is saved in file system meta-data, see 457.Nm 458.Cm config . 459The snapshots directory defaults to 460.Pa /var/hammer/<pfs> 461.Pa ( /var/hammer/root 462for root mount). 463.El 464.Pp 465The format of the configuration file is: 466.Bd -literal -offset indent 467snapshots <period> <retention-time> [any] 468prune <period> <max-runtime> 469rebalance <period> <max-runtime> 470reblock <period> <max-runtime> 471recopy <period> <max-runtime> 472.Ed 473.Pp 474Defaults are: 475.Bd -literal -offset indent 476snapshots 1d 60d # 0d 0d for PFS /tmp, /var/tmp, /usr/obj 477prune 1d 5m 478rebalance 1d 5m 479reblock 1d 5m 480recopy 30d 10m 481.Ed 482.Pp 483Time is given with a suffix of 484.Cm d , 485.Cm h , 486.Cm m 487or 488.Cm s 489meaning day, hour, minute and second. 490.Pp 491If the 492.Cm snapshots 493directive has a period of 0 and a retention time of 0 494then snapshot generation is disabled, removal of old snapshots are 495disabled, and prunes will use 496.Cm prune-everything . 497If the 498.Cm snapshots 499directive has a period of 0 but a non-zero retention time 500then this command will not create any new snapshots but will remove old 501snapshots it finds based on the retention time. 502.Pp 503By default only snapshots in the form 504.Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM 505are processed. 506If the 507.Cm any 508directive is specified as a third argument on the 509.Cm snapshots 510config line then any softlink of the form 511.Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM 512or 513.Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM 514will be processed. 515.Pp 516A prune max-runtime of 0 means unlimited. 517.Pp 518If period hasn't passed since the previous 519.Cm cleanup 520run nothing is done. 521For example a day has passed when midnight is passed (localtime). 522By default, 523.Dx 524is set up to run 525.Nm Ar cleanup 526nightly via 527.Xr periodic 8 . 528.Pp 529The default configuration file will create a daily snapshot, do a daily 530pruning, rebalancing and reblocking run and a monthly recopy run. 531Reblocking is defragmentation with a level of 95%, 532and recopy is full defragmentation. 533.Pp 534By default prune and rebalance operations are time limited to 5 minutes, 535reblock operations to a bit over 5 minutes, 536and recopy operations to a bit over 10 minutes. 537Reblocking and recopy runs are each broken down into four separate functions: 538btree, inodes, dirs and data. 539Each function is time limited to the time given in the configuration file, 540but the btree, inodes and dirs functions usually does not take very long time, 541full defragmentation is always used for these three functions. 542Also note that this directive will by default disable snapshots on 543the following PFS's: 544.Pa /tmp , 545.Pa /var/tmp 546and 547.Pa /usr/obj . 548.Pp 549The defaults may be adjusted by modifying the configuration file. 550The pruning and reblocking commands automatically maintain a cyclefile 551for incremental operation. 552If you interrupt (^C) the program the cyclefile will be updated, 553but a sub-command 554may continue to run in the background for a few seconds until the 555.Nm HAMMER 556ioctl detects the interrupt. 557The 558.Cm snapshots 559PFS option can be set to use another location for the snapshots directory. 560.Pp 561Work on this command is still in progress. 562Expected additions: 563An ability to remove snapshots dynamically as the 564file system becomes full. 565.\" ==== config ==== 566.It Cm config Op Ar filesystem Op Ar configfile 567.Nm ( HAMMER 568VERSION 3+) 569Show or change configuration for 570.Ar filesystem . 571If zero or one arguments are specified this function dumps the current 572configuration file to stdout. 573Zero arguments specifies the PFS containing the current directory. 574This configuration file is stored in file system meta-data. 575If two arguments are specified this function installs a new config file. 576.Pp 577In 578.Nm HAMMER 579versions less than 3 the configuration file is by default stored in 580.Pa <pfs>/snapshots/config , 581but in all later versions the configuration file is stored in file system 582meta-data. 583.\" ==== viconfig ==== 584.It Cm viconfig Op Ar filesystem 585.Nm ( HAMMER 586VERSION 3+) 587Edit the configuration file and reinstall into file system meta-data when done. 588Zero arguments specifies the PFS containing the current directory. 589.\" ==== volume-add ==== 590.It Cm volume-add Ar device Ar filesystem 591This command will format 592.Ar device 593and add all of its space to 594.Ar filesystem . 595.Pp 596.Em NOTE! 597All existing data contained on 598.Ar device 599will be destroyed by this operation! 600If 601.Ar device 602contains a valid 603.Nm HAMMER 604file system, formatting will be denied. 605You can overcome this sanity check 606by using 607.Xr dd 1 608to erase the beginning sectors of the device. 609Also remember that you have to specify 610.Ar device , 611together with any other device that make up the file system, 612colon-separated to 613.Pa /etc/fstab 614and 615.Xr mount_hammer 8 . 616.\" ==== volume-del ==== 617.It Cm volume-del Ar device Ar filesystem 618This command will remove volume 619.Ar device 620from 621.Ar filesystem . 622.Pp 623Remember that you have to remove 624.Ar device 625from the colon-separated list in 626.Pa /etc/fstab 627and 628.Xr mount_hammer 8 . 629.\" ==== snapshot ==== 630.It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir 631.It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note 632Takes a snapshot of the file system either explicitly given by 633.Ar filesystem 634or implicitly derived from the 635.Ar snapshot-dir 636argument and creates a symlink in the directory provided by 637.Ar snapshot-dir 638pointing to the snapshot. 639If 640.Ar snapshot-dir 641is not a directory, it is assumed to be a format string passed to 642.Xr strftime 3 643with the current time as parameter. 644If 645.Ar snapshot-dir 646refers to an existing directory, a default format string of 647.Ql snap-%Y%d%m-%H%M 648is assumed and used as name for the newly created symlink. 649.Pp 650Snapshot is a per PFS operation, so a 651.Nm HAMMER 652file system and each PFS in it have to be snapshot separately. 653.Pp 654Example, assuming that 655.Pa /mysnapshots 656is on file system 657.Pa / 658and that 659.Pa /obj 660and 661.Pa /usr 662are file systems on their own, the following invocations: 663.Bd -literal -offset indent 664hammer snapshot /mysnapshots 665 666hammer snapshot /mysnapshots/%Y-%m-%d 667 668hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d 669 670hammer snapshot /usr /my/snaps/usr "note" 671.Ed 672.Pp 673Would create symlinks similar to: 674.Bd -literal -offset indent 675/mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16 676 677/mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16 678 679/mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16 680 681/my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16 682.Ed 683.Pp 684When run on a 685.Nm HAMMER 686version 3+ file system the snapshot is also recorded in file system meta-data 687along with the optional 688.Ar note . 689See the 690.Cm snapls 691directive. 692.\" ==== snap* ==== 693.It Cm snap Ar path Op Ar note 694.Nm ( HAMMER 695VERSION 3+) 696Create a snapshot for the PFS containing 697.Ar path 698and create a snapshot softlink. 699If the path specified is a 700directory a standard snapshot softlink will be created in the directory. 701The snapshot softlink points to the base of the mounted PFS. 702.It Cm snaplo Ar path Op Ar note 703.Nm ( HAMMER 704VERSION 3+) 705Create a snapshot for the PFS containing 706.Ar path 707and create a snapshot softlink. 708If the path specified is a 709directory a standard snapshot softlink will be created in the directory. 710The snapshot softlink points into the directory it is contained in. 711.It Cm snapq Ar dir Op Ar note 712.Nm ( HAMMER 713VERSION 3+) 714Create a snapshot for the PFS containing the specified directory but do 715not create a softlink. 716Instead output a path which can be used to access 717the directory via the snapshot. 718.Pp 719An absolute or relative path may be specified. 720The path will be used as-is as a prefix in the path output to stdout. 721As with the other 722snap and snapshot directives the snapshot transaction id will be registered 723in the file system meta-data. 724.It Cm snaprm Ar path Ar ... 725.It Cm snaprm Ar transid Ar ... 726.It Cm snaprm Ar filesystem Ar transid Ar ... 727.Nm ( HAMMER 728VERSION 3+) 729Remove a snapshot given its softlink or transaction id. 730If specifying a transaction id 731the snapshot is removed from file system meta-data but you are responsible 732for removing any related softlinks. 733.Pp 734If a softlink path is specified the filesystem and transaction id 735is derived from the contents of the softlink. 736If just a transaction id is specified it is assumed to be a snapshot 737in the HAMMER filesystem you are currently chdir'd into. 738You can also specify the filesystem and transaction id explicitly. 739.It Cm snapls Op Ar path ... 740.Nm ( HAMMER 741VERSION 3+) 742Dump the snapshot meta-data for PFSs containing each 743.Ar path 744listing all available snapshots and their notes. 745If no arguments are specified snapshots for the PFS containing the 746current directory are listed. 747This is the definitive list of snapshots for the file system. 748.\" ==== prune ==== 749.It Cm prune Ar softlink-dir 750Prune the file system based on previously created snapshot softlinks. 751Pruning is the act of deleting file system history. 752The 753.Cm prune 754command will delete file system history such that 755the file system state is retained for the given snapshots, 756and all history after the latest snapshot. 757By setting the per PFS parameter 758.Cm prune-min , 759history is guaranteed to be saved at least this time interval. 760All other history is deleted. 761.Pp 762The target directory is expected to contain softlinks pointing to 763snapshots of the file systems you wish to retain. 764The directory is scanned non-recursively and the mount points and 765transaction ids stored in the softlinks are extracted and sorted. 766The file system is then explicitly pruned according to what is found. 767Cleaning out portions of the file system is as simple as removing a 768snapshot softlink and then running the 769.Cm prune 770command. 771.Pp 772As a safety measure pruning only occurs if one or more softlinks are found 773containing the 774.Ql @@ 775snapshot id extension. 776Currently the scanned softlink directory must contain softlinks pointing 777to a single 778.Nm HAMMER 779mount. 780The softlinks may specify absolute or relative paths. 781Softlinks must use 20-character 782.Ql @@0x%016llx 783transaction ids, as might be returned from 784.Nm Cm synctid Ar filesystem . 785.Pp 786Pruning is a per PFS operation, so a 787.Nm HAMMER 788file system and each PFS in it have to be pruned separately. 789.Pp 790Note that pruning a file system may not immediately free-up space, 791though typically some space will be freed if a large number of records are 792pruned out. 793The file system must be reblocked to completely recover all available space. 794.Pp 795Example, lets say your that you didn't set 796.Cm prune-min , 797and snapshot directory contains the following links: 798.Bd -literal -offset indent 799lrwxr-xr-x 1 root wheel 29 May 31 17:57 snap1 -> 800/usr/obj/@@0x10d2cd05b7270d16 801 802lrwxr-xr-x 1 root wheel 29 May 31 17:58 snap2 -> 803/usr/obj/@@0x10d2cd13f3fde98f 804 805lrwxr-xr-x 1 root wheel 29 May 31 17:59 snap3 -> 806/usr/obj/@@0x10d2cd222adee364 807.Ed 808.Pp 809If you were to run the 810.Cm prune 811command on this directory, then the 812.Nm HAMMER 813.Pa /usr/obj 814mount will be pruned to retain the above three snapshots. 815In addition, history for modifications made to the file system older than 816the oldest snapshot will be destroyed and history for potentially fine-grained 817modifications made to the file system more recently than the most recent 818snapshot will be retained. 819.Pp 820If you then delete the 821.Pa snap2 822softlink and rerun the 823.Cm prune 824command, 825history for modifications pertaining to that snapshot would be destroyed. 826.Pp 827In 828.Nm HAMMER 829file system versions 3+ this command also scans the snapshots stored 830in the file system meta-data and includes them in the prune. 831.\" ==== prune-everything ==== 832.It Cm prune-everything Ar filesystem 833This command will remove all historical records from the file system. 834This directive is not normally used on a production system. 835.Pp 836This command does not remove snapshot softlinks but will delete all 837snapshots recorded in file system meta-data (for file system version 3+). 838The user is responsible for deleting any softlinks. 839.Pp 840Pruning is a per PFS operation, so a 841.Nm HAMMER 842file system and each PFS in it have to be pruned separately. 843.\" ==== rebalance ==== 844.It Cm rebalance Ar filesystem Op Ar saturation_percentage 845This command will rebalance the B-Tree, nodes with small number of 846elements will be combined and element counts will be smoothed out 847between nodes. 848.Pp 849The saturation percentage is between 50% and 100%. 850The default is 75% (the 851.Sq % 852suffix is not needed). 853.Pp 854Rebalancing is a per PFS operation, so a 855.Nm HAMMER 856file system and each PFS in it have to be rebalanced separately. 857.\" ==== reblock* ==== 858.It Cm reblock Ar filesystem Op Ar fill_percentage 859.It Cm reblock-btree Ar filesystem Op Ar fill_percentage 860.It Cm reblock-inodes Ar filesystem Op Ar fill_percentage 861.It Cm reblock-dirs Ar filesystem Op Ar fill_percentage 862.It Cm reblock-data Ar filesystem Op Ar fill_percentage 863Attempt to defragment and free space for reuse by reblocking a live 864.Nm HAMMER 865file system. 866Big-blocks cannot be reused by 867.Nm HAMMER 868until they are completely free. 869This command also has the effect of reordering all elements, effectively 870defragmenting the file system. 871.Pp 872The default fill percentage is 100% and will cause the file system to be 873completely defragmented. 874All specified element types will be reallocated and rewritten. 875If you wish to quickly free up space instead try specifying 876a smaller fill percentage, such as 90% or 80% (the 877.Sq % 878suffix is not needed). 879.Pp 880Since this command may rewrite the entire contents of the disk it is 881best to do it incrementally from a 882.Xr cron 8 883job along with the 884.Fl c Ar cyclefile 885and 886.Fl t Ar seconds 887options to limit the run time. 888The file system would thus be defragmented over long period of time. 889.Pp 890It is recommended that separate invocations be used for each data type. 891B-Tree nodes, inodes, and directories are typically the most important 892elements needing defragmentation. 893Data can be defragmented over a longer period of time. 894.Pp 895Reblocking is a per PFS operation, so a 896.Nm HAMMER 897file system and each PFS in it have to be reblocked separately. 898.\" ==== pfs-status ==== 899.It Cm pfs-status Ar dirpath ... 900Retrieve the mirroring configuration parameters for the specified 901.Nm HAMMER 902file systems or pseudo-filesystems (PFS's). 903.\" ==== pfs-master ==== 904.It Cm pfs-master Ar dirpath Op Ar options 905Create a pseudo-filesystem (PFS) inside a 906.Nm HAMMER 907file system. 908Up to 65535 such file systems can be created. 909Each PFS uses an independent inode numbering space making it suitable 910for use as a replication source or target. 911.Pp 912The 913.Cm pfs-master 914directive creates a PFS that you can read, write, and use as a mirroring 915source. 916.Pp 917It is recommended to use a 918.Nm null 919mount to access a PFS, for more information see 920.Xr HAMMER 5 . 921.\" ==== pfs-slave ==== 922.It Cm pfs-slave Ar dirpath Op Ar options 923Create a pseudo-filesystem (PFS) inside a 924.Nm HAMMER 925file system. 926Up to 65535 such file systems can be created. 927Each PFS uses an independent inode numbering space making it suitable 928for use as a replication source or target. 929.Pp 930The 931.Cm pfs-slave 932directive creates a PFS that you can use as a mirroring target. 933You will not be able to access a slave PFS until you have completed the 934first mirroring operation with it as the target (its root directory will 935not exist until then). 936.Pp 937Access to the pfs-slave via the special softlink, as described in the 938.Sx PFS NOTES 939below, allows 940.Nm HAMMER 941to 942dynamically modify the snapshot transaction id by returning a dynamic result 943from 944.Xr readlink 2 945calls. 946.Pp 947A PFS can only be truly destroyed with the 948.Cm pfs-destroy 949directive. 950Removing the softlink will not destroy the underlying PFS. 951.Pp 952It is recommended to use a 953.Nm null 954mount to access a PFS, for more information see 955.Xr HAMMER 5 . 956.\" ==== pfs-update ==== 957.It Cm pfs-update Ar dirpath Op Ar options 958Update the configuration parameters for an existing 959.Nm HAMMER 960file system or pseudo-filesystem. 961Options that may be specified: 962.Bl -tag -width indent 963.It Cm sync-beg-tid= Ns Ar 0x16llx 964This is the automatic snapshot access starting transaction id for 965mirroring slaves. 966This parameter is normally updated automatically by the 967.Cm mirror-write 968directive. 969.Pp 970It is important to note that accessing a mirroring slave 971with a transaction id greater than the last fully synchronized transaction 972id can result in an unreliable snapshot since you will be accessing 973data that is still undergoing synchronization. 974.Pp 975Manually modifying this field is dangerous and can result in a broken mirror. 976.It Cm sync-end-tid= Ns Ar 0x16llx 977This is the current synchronization point for mirroring slaves. 978This parameter is normally updated automatically by the 979.Cm mirror-write 980directive. 981.Pp 982Manually modifying this field is dangerous and can result in a broken mirror. 983.It Cm shared-uuid= Ns Ar uuid 984Set the shared UUID for this file system. 985All mirrors must have the same shared UUID. 986For safety purposes the 987.Cm mirror-write 988directives will refuse to operate on a target with a different shared UUID. 989.Pp 990Changing the shared UUID on an existing, non-empty mirroring target, 991including an empty but not completely pruned target, 992can lead to corruption of the mirroring target. 993.It Cm unique-uuid= Ns Ar uuid 994Set the unique UUID for this file system. 995This UUID should not be used anywhere else, 996even on exact copies of the file system. 997.It Cm label= Ns Ar string 998Set a descriptive label for this file system. 999.It Cm snapshots= Ns Ar string 1000Specify the snapshots directory which 1001.Nm 1002.Cm cleanup 1003will use to manage this PFS. 1004.Bl -tag -width indent 1005.It Nm HAMMER No version 2- 1006The snapshots directory does not need to be configured for 1007PFS masters and will default to 1008.Pa <pfs>/snapshots . 1009.Pp 1010PFS slaves are mirroring slaves so you cannot configure a snapshots 1011directory on the slave itself to be managed by the slave's machine. 1012In fact, the slave will likely have a 1013.Pa snapshots 1014sub-directory mirrored 1015from the master, but that directory contains the configuration the master 1016is using for its copy of the file system, not the configuration that we 1017want to use for our slave. 1018.Pp 1019It is recommended that 1020.Pa <fs>/var/slaves/<name> 1021be configured for a PFS slave, where 1022.Pa <fs> 1023is the base 1024.Nm HAMMER 1025file system, and 1026.Pa <name> 1027is an appropriate label. 1028.It Nm HAMMER No version 3+ 1029The snapshots directory does not need to be configured for PFS masters or 1030slaves. 1031The snapshots directory defaults to 1032.Pa /var/hammer/<pfs> 1033.Pa ( /var/hammer/root 1034for root mount). 1035.El 1036.Pp 1037You can control snapshot retention on your slave independent of the master. 1038.It Cm snapshots-clear 1039Zero out the 1040.Cm snapshots 1041directory path for this PFS. 1042.It Cm prune-min= Ns Ar N Ns Cm d 1043.It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \ 1044Ar hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss 1045Set the minimum fine-grained data retention period. 1046.Nm HAMMER 1047always retains fine-grained history up to the most recent snapshot. 1048You can extend the retention period further by specifying a non-zero 1049pruning minimum. 1050Any snapshot softlinks within the retention period are ignored 1051for the purposes of pruning (the fine grained history is retained). 1052Number of days, hours, minutes and seconds are given as 1053.Ar N , hh , mm 1054and 1055.Ar ss . 1056.Pp 1057Because the transaction id in the snapshot softlink cannot be used 1058to calculate a timestamp, 1059.Nm HAMMER 1060uses the earlier of the 1061.Fa st_ctime 1062or 1063.Fa st_mtime 1064field of the softlink to 1065determine which snapshots fall within the retention period. 1066Users must be sure to retain one of these two fields when manipulating 1067the softlink. 1068.El 1069.\" ==== pfs-upgrade ==== 1070.It Cm pfs-upgrade Ar dirpath 1071Upgrade a PFS from slave to master operation. 1072The PFS will be rolled back to the current end synchronization transaction id 1073(removing any partial synchronizations), and will then become writable. 1074.Pp 1075.Em WARNING! 1076.Nm HAMMER 1077currently supports only single masters and using 1078this command can easily result in file system corruption 1079if you don't know what you are doing. 1080.Pp 1081This directive will refuse to run if any programs have open descriptors 1082in the PFS, including programs chdir'd into the PFS. 1083.\" ==== pfs-downgrade ==== 1084.It Cm pfs-downgrade Ar dirpath 1085Downgrade a master PFS from master to slave operation. 1086The PFS becomes read-only and access will be locked to its 1087.Cm sync-end-tid . 1088.Pp 1089This directive will refuse to run if any programs have open descriptors 1090in the PFS, including programs chdir'd into the PFS. 1091.\" ==== pfs-destroy ==== 1092.It Cm pfs-destroy Ar dirpath 1093This permanently destroys a PFS. 1094.Pp 1095This directive will refuse to run if any programs have open descriptors 1096in the PFS, including programs chdir'd into the PFS. 1097.\" ==== mirror-read ==== 1098.It Cm mirror-read Ar filesystem Op Ar begin-tid 1099Generate a mirroring stream to stdout. 1100The stream ends when the transaction id space has been exhausted. 1101.\" ==== mirror-read-stream ==== 1102.It Cm mirror-read-stream Ar filesystem Op Ar begin-tid 1103Generate a mirroring stream to stdout. 1104Upon completion the stream is paused until new data is synced to the 1105.Ar filesystem , 1106then resumed. 1107Operation continues until the pipe is broken. 1108See the 1109.Cm mirror-stream 1110command for more details. 1111.\" ==== mirror-write ==== 1112.It Cm mirror-write Ar filesystem 1113Take a mirroring stream on stdin. 1114.Pp 1115This command will fail if the 1116.Cm shared-uuid 1117configuration field for the two file systems do not match. 1118See the 1119.Cm mirror-copy 1120command for more details. 1121.Pp 1122If the target PFS does not exist this command will ask you whether 1123you want to create a compatible PFS slave for the target or not. 1124.\" ==== mirror-dump ==== 1125.It Cm mirror-dump 1126A 1127.Cm mirror-read 1128can be piped into a 1129.Cm mirror-dump 1130to dump an ASCII representation of the mirroring stream. 1131.\" ==== mirror-copy ==== 1132.\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem 1133.It Cm mirror-copy \ 1134Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \ 1135Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem 1136This is a shortcut which pipes a 1137.Cm mirror-read 1138command to a 1139.Cm mirror-write 1140command. 1141If a remote host specification is made the program forks a 1142.Xr ssh 1 1143and execs the 1144.Cm mirror-read 1145and/or 1146.Cm mirror-write 1147on the appropriate host. 1148The source may be a master or slave PFS, and the target must be a slave PFS. 1149.Pp 1150This command also establishes full duplex communication and turns on 1151the 2-way protocol feature 1152.Fl ( 2 ) 1153which automatically negotiates transaction id 1154ranges without having to use a cyclefile. 1155If the operation completes successfully the target PFS's 1156.Cm sync-end-tid 1157will be updated. 1158Note that you must re-chdir into the target PFS to see the updated information. 1159If you do not you will still be in the previous snapshot. 1160.Pp 1161If the target PFS does not exist this command will ask you whether 1162you want to create a compatible PFS slave for the target or not. 1163.\" ==== mirror-stream ==== 1164.\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem 1165.It Cm mirror-stream \ 1166Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \ 1167Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem 1168This is a shortcut which pipes a 1169.Cm mirror-read-stream 1170command to a 1171.Cm mirror-write 1172command. 1173This command works similarly to 1174.Cm mirror-copy 1175but does not exit after the initial mirroring completes. 1176The mirroring operation will resume as changes continue to be made to the 1177source. 1178The command is commonly used with 1179.Fl i Ar delay 1180and 1181.Fl b Ar bandwidth 1182options to keep the mirroring target in sync with the source on a continuing 1183basis. 1184.Pp 1185If the pipe is broken the command will automatically retry after sleeping 1186for a short while. 1187The time slept will be 15 seconds plus the time given in the 1188.Fl i 1189option. 1190.Pp 1191This command also detects the initial-mirroring case and spends some 1192time scanning the B-Tree to find good break points, allowing the initial 1193bulk mirroring operation to be broken down into 100MB pieces. 1194This means that the user can kill and restart the operation and it will 1195not have to start from scratch once it has gotten past the first chunk. 1196The 1197.Fl S 1198option may be used to change the size of pieces and the 1199.Fl B 1200option may be used to disable this feature and perform an initial bulk 1201transfer instead. 1202.\" ==== version ==== 1203.It Cm version Ar filesystem 1204This command returns the 1205.Nm HAMMER 1206file system version for the specified 1207.Ar filesystem 1208as well as the range of versions supported in the kernel. 1209The 1210.Fl q 1211option may be used to remove the summary at the end. 1212.\" ==== version-upgrade ==== 1213.It Cm version-upgrade Ar filesystem Ar version Op Cm force 1214This command upgrades the 1215.Nm HAMMER 1216.Ar filesystem 1217to the specified 1218.Ar version . 1219Once upgraded a file system may not be downgraded. 1220If you wish to upgrade a file system to a version greater or equal to the 1221work-in-progress version number you must specify the 1222.Cm force 1223directive. 1224Use of WIP versions should be relegated to testing and may require wiping 1225the file system as development progresses, even though the WIP version might 1226not change. 1227.Pp 1228.Em NOTE! 1229This command operates on the entire 1230.Nm HAMMER 1231file system and is not a per PFS operation. 1232All PFS's will be affected. 1233.Bl -tag -width indent 1234.It 1 1235.Dx 2.0 1236default version, first 1237.Nm HAMMER 1238release. 1239.It 2 1240.Dx 2.3 . 1241New directory entry layout. 1242This version is using a new directory hash key. 1243.It 3 1244.Dx 2.5 . 1245New snapshot management, using file system meta-data for saving 1246configuration file and snapshots (transaction ids etc.). 1247Also default snapshots directory has changed. 1248.It 4 1249.Dx 2.6 1250default version. 1251New undo/redo/flush, giving HAMMER a much faster sync and fsync. 1252.El 1253.El 1254.Sh PSEUDO-FILESYSTEM (PFS) NOTES 1255The root of a PFS is not hooked into the primary 1256.Nm HAMMER 1257file system as a directory. 1258Instead, 1259.Nm HAMMER 1260creates a special softlink called 1261.Ql @@PFS%05d 1262(exactly 10 characters long) in the primary 1263.Nm HAMMER 1264file system. 1265.Nm HAMMER 1266then modifies the contents of the softlink as read by 1267.Xr readlink 2 , 1268and thus what you see with an 1269.Nm ls 1270command or if you were to 1271.Nm cd 1272into the link. 1273If the PFS is a master the link reflects the current state of the PFS. 1274If the PFS is a slave the link reflects the last completed snapshot, and the 1275contents of the link will change when the next snapshot is completed, and 1276so forth. 1277.Pp 1278The 1279.Nm 1280utility employs numerous safeties to reduce user foot-shooting. 1281The 1282.Cm mirror-copy 1283directive requires that the target be configured as a slave and that the 1284.Cm shared-uuid 1285field of the mirroring source and target match. 1286.Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2 1287This upgrade changes the way directory entries are stored. 1288It is possible to upgrade a V1 file system to V2 in place, but 1289directories created prior to the upgrade will continue to use 1290the old layout. 1291.Pp 1292Note that the slave mirroring code in the target kernel had bugs in 1293V1 which can create an incompatible root directory on the slave. 1294Do not mix a 1295.Nm HAMMER 1296master created after the upgrade with a 1297.Nm HAMMER 1298slave created prior to the upgrade. 1299.Pp 1300Any directories created after upgrading will use a new layout. 1301.Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3 1302This upgrade adds meta-data elements to the B-Tree. 1303It is possible to upgrade a V2 file system to V3 in place. 1304After issuing the upgrade be sure to run a 1305.Nm 1306.Cm cleanup 1307to perform post-upgrade tasks. 1308.Pp 1309After making this upgrade running a 1310.Nm 1311.Cm cleanup 1312will move the 1313.Pa <pfs>/snapshots 1314directory for each PFS mount into 1315.Pa /var/hammer/<pfs> . 1316A 1317.Nm HAMMER 1318root mount will migrate 1319.Pa /snapshots 1320into 1321.Pa /var/hammer/root . 1322Migration occurs only once and only if you have not specified 1323a snapshots directory in the PFS configuration. 1324If you have specified a snapshots directory in the PFS configuration no 1325automatic migration will occur. 1326.Pp 1327For slaves, if you desire, you can migrate your snapshots 1328config to the new location manually and then clear the 1329snapshot directory configuration in the slave PFS. 1330The new snapshots hierarchy is designed to work with 1331both master and slave PFSs equally well. 1332.Pp 1333In addition, the old config file will be moved to file system meta-data, 1334editable via the new 1335.Nm 1336.Cm viconfig 1337directive. 1338The old config file will be deleted. 1339Migration occurs only once. 1340.Pp 1341The V3 file system has new 1342.Cm snap* 1343directives for creating snapshots. 1344All snapshot directives, including the original, will create 1345meta-data entries for the snapshots and the pruning code will 1346automatically incorporate these entries into its list and 1347expire them the same way it expires softlinks. 1348If you by accident blow away your snapshot softlinks you can use the 1349.Cm snapls 1350directive to get a definitive list from the file system meta-data and 1351regenerate them from that list. 1352.Pp 1353.Em WARNING! 1354If you are using 1355.Nm 1356to backup file systems your scripts may be using the 1357.Cm synctid 1358directive to generate transaction ids. 1359This directive does not create a snapshot. 1360You will have to modify your scripts to use the 1361.Cm snapq 1362directive to generate the linkbuf for the softlink you create, or 1363use one of the other 1364.Cm snap* 1365directives. 1366The older 1367.Cm snapshot 1368directive will continue to work as expected and in V3 it will also 1369record the snapshot transaction id in file system meta-data. 1370You may also want to make use of the new 1371.Ar note 1372tag for the meta-data. 1373.Pp 1374.Em WARNING! 1375If you used to remove snapshot softlinks with 1376.Nm rm 1377you should probably start using the 1378.Cm snaprm 1379directive instead to also remove the related meta-data. 1380The pruning code scans the meta-data so just removing the 1381softlink is not sufficient. 1382.Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4 1383This upgrade changes undo/flush, giving faster sync. 1384It is possible to upgrade a V3 file system to V4 in place. 1385This upgrade reformats the UNDO FIFO (typically 1GB), so upgrade might take 1386a minute or two depending. 1387.Pp 1388Version 4 allows the UNDO FIFO to be flushed without also having 1389to flush the volume header, removing 2 of the 4 disk syncs typically 1390required for an 1391.Fn fsync 1392and removing 1 of the 2 disk syncs typically 1393required for a flush sequence. 1394Version 4 also implements the REDO log (see below) which is capable 1395of fsync()ing with either one disk flush or zero disk flushes. 1396.Sh FSYNC FLUSH MODES 1397.Nm HAMMER 1398implements five different fsync flush modes via the 1399.Va vfs.hammer.fsync_mode 1400sysctl, for 1401.Nm HAMMER 1402version 4+ file systems. 1403.Pp 1404As of 1405.Dx 2.6 1406fsync mode 3 is set by default. 1407REDO operation and recovery is enabled by default. 1408.Bl -tag -width indent 1409.It mode 0 1410Full synchronous fsync semantics without REDO. 1411.Pp 1412.Nm HAMMER 1413will not generate REDOs. 1414A 1415.Fn fsync 1416will completely sync 1417the data and meta-data and double-flush the FIFO, including 1418issuing two disk synchronization commands. 1419The data is guaranteed 1420to be on the media as of when 1421.Fn fsync 1422returns. 1423Needless to say, this is slow. 1424.It mode 1 1425Relaxed asynchronous fsync semantics without REDO. 1426.Pp 1427This mode works the same as mode 0 except the last disk synchronization 1428command is not issued. 1429It is faster than mode 0 but not even remotely 1430close to the speed you get with mode 2 or mode 3. 1431.Pp 1432Note that there is no chance of meta-data corruption when using this 1433mode, it simply means that the data you wrote and then 1434.Fn fsync Ns 'd 1435might not have made it to the media if the storage system crashes at a bad 1436time. 1437.Pp 1438.It mode 2 1439Full synchronous fsync semantics using REDO. 1440NOTE: If not running 1441a HAMMER version 4 filesystem or later mode 0 is silently used. 1442.Pp 1443.Nm HAMMER 1444will generate REDOs in the UNDO/REDO FIFO based on a heuristic. 1445If this is sufficient to satisfy the 1446.Fn fsync 1447operation the blocks 1448will be written out and 1449.Nm HAMMER 1450will wait for the I/Os to complete, 1451and then followup with a disk sync command to guarantee the data 1452is on the media before returning. 1453This is slower than mode 3 and can result in significant disk or 1454SSDs overheads, though not as bad as mode 0 or mode 1. 1455.Pp 1456.It mode 3 1457Relaxed asynchronous fsync semantics using REDO. 1458NOTE: If not running 1459a HAMMER version 4 filesystem or later mode 1 is silently used. 1460.Pp 1461.Nm HAMMER 1462will generate REDOs in the UNDO/REDO FIFO based on a heuristic. 1463If this is sufficient to satisfy the 1464.Fn fsync 1465operation the blocks 1466will be written out and 1467.Nm HAMMER 1468will wait for the I/Os to complete, 1469but will 1470.Em NOT 1471issue a disk synchronization command. 1472.Pp 1473Note that there is no chance of meta-data corruption when using this 1474mode, it simply means that the data you wrote and then 1475.Fn fsync Ns 'd 1476might 1477not have made it to the media if the storage system crashes at a bad 1478time. 1479.Pp 1480This mode is the fastest production fsyncing mode available. 1481This mode is equivalent to how the UFS fsync in the 1482.Bx Ns s 1483operates. 1484.Pp 1485.It mode 4 1486fsync is ignored. 1487.Pp 1488Calls to 1489.Fn fsync 1490will be ignored. 1491This mode is primarily designed 1492for testing and should not be used on a production system. 1493.El 1494.Sh RESTORING FROM A SNAPSHOT BACKUP 1495You restore a snapshot by copying it over to live, but there is a caveat. 1496The mtime and atime fields for files accessed via a snapshot is locked 1497to the ctime in order to keep the snapshot consistent, because neither 1498mtime nor atime changes roll any history. 1499.Pp 1500In order to avoid unnecessary copying it is recommended that you use 1501.Nm cpdup 1502.Fl VV 1503.Fl v 1504when doing the copyback. Also make sure you traverse the snapshot softlink 1505by appending a ".", as in "<snapshotpath>/.", and you match up the directory 1506properly. 1507.Sh EXIT STATUS 1508.Ex -std 1509.Sh ENVIRONMENT 1510If the following environment variables exist, they will be used by: 1511.Bl -tag -width ".Ev EDITOR" 1512.It Ev EDITOR 1513The editor program specified in the variable 1514.Ev EDITOR 1515will be invoked instead of the default editor, which is 1516.Xr vi 1 . 1517.It Ev VISUAL 1518Same effect as 1519.Ev EDITOR 1520variable. 1521.El 1522.Sh FILES 1523.Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact 1524.It Pa <pfs>/snapshots 1525default per PFS snapshots directory 1526.Nm ( HAMMER 1527VERSION 2-) 1528.It Pa /var/hammer/<pfs> 1529default per PFS snapshots directory (not root) 1530.Nm ( HAMMER 1531VERSION 3+) 1532.It Pa /var/hammer/root 1533default snapshots directory for root directory 1534.Nm ( HAMMER 1535VERSION 3+) 1536.It Pa <snapshots>/config 1537per PFS 1538.Nm 1539.Cm cleanup 1540configuration file 1541.Nm ( HAMMER 1542VERSION 2-) 1543.It Pa <fs>/var/slaves/<name> 1544recommended slave PFS snapshots directory 1545.Nm ( HAMMER 1546VERSION 2-) 1547.El 1548.\".Sh EXAMPLES 1549.Sh SEE ALSO 1550.Xr ssh 1 , 1551.Xr undo 1 , 1552.Xr HAMMER 5 , 1553.Xr periodic.conf 5 , 1554.Xr mount_hammer 8 , 1555.Xr mount_null 8 , 1556.Xr newfs_hammer 8 1557.Sh HISTORY 1558The 1559.Nm 1560utility first appeared in 1561.Dx 1.11 . 1562.Sh AUTHORS 1563.An Matthew Dillon Aq dillon@backplane.com 1564