4.8. Data Journaling

4.8. Data Journaling

Ordinarily, GFS writes only metadata to its journal. File contents are subsequently written to disk by the kernel's periodic sync that flushes file-system buffers. An fsync() call on a file causes the file's data to be written to disk immediately. The call returns when the disk reports that all data is safely written.

Data journaling can result in a reduced fsync() time, especially for small files, because the file data is written to the journal in addition to the metadata. An fsync() returns as soon as the data is written to the journal, which can be substantially faster than the time it takes to write the file data to the main file system.

Applications that rely on fsync() to sync file data may see improved performance by using data journaling. Data journaling can be enabled automatically for any GFS files created in a flagged directory (and all its subdirectories). Existing files with zero length can also have data journaling turned on or off.

Using the gfs_tool command, data journaling is enabled on a directory (and all its subdirectories) or on a zero-length file by setting the inherit_jdata or jdata attribute flags to the directory or file, respectively. The directory and file attribute flags can also be cleared.

Usage

Setting and Clearing the inherit_jdata Flag

gfs_tool setflag inherit_jdata Directory
gfs_tool clearflag inherit_jdata Directory

Setting and Clearing the jdata Flag

gfs_tool setflag jdata File
gfs_tool clearflag jdata File
Directory

Specifies the directory where the flag is set or cleared.

File

Specifies the zero-length file where the flag is set or cleared.

Examples

This example shows setting the inherit_jdata flag on a directory. All files created in the directory or any of its subdirectories will have the jdata flag assigned automatically. Any data written to the files will be journaled.

gfs_tool setflag inherit_jdata /gfs1/data/

This example shows setting the jdata flag on a file. The file must be zero size. Any data written to the file will be journaled.

gfs_tool setflag jdata /gfs1/datafile

Note: This documentation is provided {and copyrighted} by Red Hat®, Inc. and is released via the Open Publication License. The copyright holder has added the further requirement that Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. The CentOS project redistributes these original works (in their unmodified form) as a reference for CentOS-4 because CentOS-4 is built from publicly available, open source SRPMS. The documentation is unmodified to be compliant with upstream distribution policy. Neither CentOS-4 nor the CentOS Project are in any way affiliated with or sponsored by Red Hat®, Inc.