1.\" Copyright (c) 2006-2009 Pawel Jakub Dawidek <pjd@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd February 17, 2009 26.Dt GJOURNAL 8 27.Os 28.Sh NAME 29.Nm gjournal 30.Nd "control utility for journaled devices" 31.Sh SYNOPSIS 32.Nm 33.Cm label 34.Op Fl cfhv 35.Op Fl s Ar jsize 36.Ar dataprov 37.Op Ar jprov 38.Nm 39.Cm stop 40.Op Fl fv 41.Ar name ... 42.Nm 43.Cm sync 44.Op Fl v 45.Nm 46.Cm clear 47.Op Fl v 48.Ar prov ... 49.Nm 50.Cm dump 51.Ar prov ... 52.Nm 53.Cm list 54.Nm 55.Cm status 56.Nm 57.Cm load 58.Nm 59.Cm unload 60.Sh DESCRIPTION 61The 62.Nm 63utility is used for journal configuration on the given GEOM provider. 64The journal and data may be stored on the same provider or on two separate 65providers. 66This is block level journaling, not file system level journaling, which means 67everything gets logged, e.g.\& for file systems, it journals both data and 68metadata. 69The 70.Nm 71GEOM class can talk to file systems, which allows the use of 72.Nm 73for file system journaling and to keep file systems in a consistent state. 74At this time, only UFS file system is supported. 75.Pp 76To configure journaling on the UFS file system using 77.Nm , 78one should first create a 79.Nm 80provider using the 81.Nm 82utility, then run 83.Xr newfs 8 84or 85.Xr tunefs 8 86on it with the 87.Fl J 88flag which instructs UFS to cooperate with the 89.Nm 90provider below. 91There are important differences in how journaled UFS works. 92The most important one is that 93.Xr sync 2 94and 95.Xr fsync 2 96system calls do not work as expected anymore. 97To ensure that data is stored on the data provider, the 98.Nm Cm sync 99command should be used after calling 100.Xr sync 2 . 101For the best performance possible, soft-updates should be disabled when 102.Nm 103is used. 104It is also safe and recommended to use the 105.Cm async 106.Xr mount 8 107option. 108.Pp 109When 110.Nm 111is configured on top of 112.Xr gmirror 8 113or 114.Xr graid3 8 115providers, it also keeps them in a consistent state, thus 116automatic synchronization on power failure or system crash may be disabled 117on those providers. 118.Pp 119The 120.Nm 121utility uses on-disk metadata, stored in the provider's last sector, 122to store all needed information. 123This could be a problem when an existing file system is converted to use 124.Nm . 125.Pp 126The first argument to 127.Nm 128indicates an action to be performed: 129.Bl -tag -width ".Cm status" 130.It Cm label 131Configures 132.Nm 133on the given provider(s). 134If only one provider is given, both data and journal are stored on the same 135provider. 136If two providers are given, the first one will be used as data provider and the 137second will be used as the journal provider. 138.Pp 139Additional options include: 140.Bl -tag -width ".Fl s Ar jsize" 141.It Fl c 142Checksum journal records. 143.It Fl f 144May be used to convert an existing file system to use 145.Nm , 146but only if the journal will be configured on a separate provider and if the 147last sector in the data provider is not used by the existing file system. 148If 149.Nm 150detects that the last sector is used, it will refuse to overwrite it 151and return an error. 152This behavior may be forced by using the 153.Fl f 154flag, which will force 155.Nm 156to overwrite the last sector. 157.It Fl h 158Hardcode provider names in metadata. 159.It Fl s Ar jsize 160Specifies size of the journal if only one provider is used for both data and 161journal. 162The default is one gigabyte. 163Size should be chosen based on provider's load, and not on its size; 164recommended minimum is twice the size of the physical memory installed. 165It is not recommended to use 166.Nm 167for small file systems (e.g.: only few gigabytes big). 168.El 169.It Cm clear 170Clear metadata on the given providers. 171.It Cm stop 172Stop the given provider. 173.Pp 174Additional options include: 175.Bl -tag -width ".Fl f" 176.It Fl f 177Stop the given provider even if it is opened. 178.El 179.It Cm sync 180Trigger journal switch and enforce sending data to the data provider. 181.It Cm dump 182Dump metadata stored on the given providers. 183.It Cm list 184See 185.Xr geom 8 . 186.It Cm status 187See 188.Xr geom 8 . 189.It Cm load 190See 191.Xr geom 8 . 192.It Cm unload 193See 194.Xr geom 8 . 195.El 196.Pp 197Additional options include: 198.Bl -tag -width ".Fl v" 199.It Fl v 200Be more verbose. 201.El 202.Sh EXIT STATUS 203Exit status is 0 on success, and 1 if the command fails. 204.Sh EXAMPLES 205Create a 206.Nm 207based UFS file system and mount it: 208.Bd -literal -offset indent 209gjournal load 210gjournal label da0 211newfs -J /dev/da0.journal 212mount -o async /dev/da0.journal /mnt 213.Ed 214.Pp 215Configure journaling on an existing file system, but only if 216.Nm 217allows this (i.e., if the last sector is not already used by the file system): 218.Bd -literal -offset indent 219umount /dev/da0s1d 220gjournal label da0s1d da0s1e && \e 221 tunefs -J enable -n disable da0s1d.journal && \e 222 mount -o async /dev/da0s1d.journal /mnt || \e 223 mount /dev/da0s1d /mnt 224.Ed 225.Sh SYSCTLS 226Gjournal adds the sysctl level kern.geom.journal. 227The string and integer information available is detailed below. 228The changeable column shows whether a process with appropriate privilege may 229change the value. 230.Bl -column "accept_immediatelyXXXXXX" integerXXX -offset indent 231.It Sy "sysctl name Type Changeable" 232.It "debug integer yes" 233.It "switch_time integer yes" 234.It "force_switch integer yes" 235.It "parallel_flushes integer yes" 236.It "accept_immediately integer yes" 237.It "parallel_copies integer yes" 238.It "record_entries integer yes" 239.It "optimize integer yes" 240.El 241.Bl -tag -width 6n 242.It Li debug 243Setting a non-zero value enables debugging at various levels. 244Debug level 1 will record actions at a journal level, relating to journal 245switches, metadata updates, etc. 246Debug level 2 will record actions at a higher level, relating to the numbers of 247entries in journals, access requests, etc. 248Debug level 3 will record verbose detail, including insertion of I/Os to the 249journal. 250.It Li switch_time 251The maximum number of seconds a journal is allowed to remain open before 252switching to a new journal. 253.It Li force_switch 254Force a journal switch when the journal uses more than N% of the free journal 255space. 256.It Li parallel_flushes 257The number of flush I/O requests to be sent in parallel when flushing the 258journal to the data provider. 259.It Li accept_immediately 260The maximum number of I/O requests accepted at the same time. 261.It Li parallel_copies 262The number of copy I/O requests to send in parallel. 263.It Li record_entries 264The maximum number of record entries to allow in a single journal. 265.It Li optimize 266Controls whether entries in a journal will be optimized by combining overlapping 267I/Os into a single I/O and reordering the entries in a journal. 268This can be disabled by setting the sysctl to 0. 269.El 270.Ss cache 271The string and integer information available for the cache level 272is detailed below. 273The changeable column shows whether a process with appropriate 274privilege may change the value. 275.Bl -column "alloc_failuresXXXXXX" integerXXX -offset indent 276.It Sy "sysctl name Type Changeable" 277.It "used integer no" 278.It "limit integer yes" 279.It "divisor integer no" 280.It "switch integer yes" 281.It "misses integer yes" 282.It "alloc_failures integer yes" 283.El 284.Bl -tag -width 6n 285.It Li used 286The number of bytes currently allocated to the cache. 287.It Li limit 288The maximum number of bytes to be allocated to the cache. 289.It Li divisor 290Sets the cache size to be used as a proportion of kmem_size. 291A value of 2 (the default) will cause the cache size to be set to 1/2 of the 292kmem_size. 293.It Li switch 294Force a journal switch when this percentage of cache has been used. 295.It Li misses 296The number of cache misses, when data has been read, but was not found in the 297cache. 298.It Li alloc_failures 299The number of times memory failed to be allocated to the cache because the cache 300limit was hit. 301.El 302.Ss stats 303The string and integer information available for the statistics level 304is detailed below. 305The changeable column shows whether a process with appropriate 306privilege may change the value. 307.Bl -column "skipped_bytesXXXXXX" integerXXX -offset indent 308.It Sy "sysctl name Type Changeable" 309.It "skipped_bytes integer yes" 310.It "combined_ios integer yes" 311.It "switches integer yes" 312.It "wait_for_copy integer yes" 313.It "journal_full integer yes" 314.It "low_mem integer yes" 315.El 316.Bl -tag -width 6n 317.It Li skipped_bytes 318The number of bytes skipped. 319.It Li combined_ios 320The number of I/Os which were combined by journal optimization. 321.It Li switches 322The number of journal switches. 323.It Li wait_for_copy 324The number of times the journal switch process had to wait for the previous 325journal copy to complete. 326.It Li journal_full 327The number of times the journal was almost full, forcing a journal switch. 328.It Li low_mem 329The number of times the low_mem hook was called. 330.El 331.Sh SEE ALSO 332.Xr geom 4 , 333.Xr geom 8 , 334.Xr mount 8 , 335.Xr newfs 8 , 336.Xr tunefs 8 , 337.Xr umount 8 338.Sh HISTORY 339The 340.Nm 341utility appeared in 342.Fx 7.0 . 343.Sh AUTHORS 344.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org 345