GFS2
In computing, the Global File System 2 or GFS2 is a shared-disk file system for Linux computer clusters. GFS2 differs from distributed file systems because GFS2 allows all nodes to have direct concurrent access to the same shared block storage. In addition, GFS or GFS2 can also be used as a local filesystem.
GFS has no disconnected operating-mode, and no client or server roles. All nodes in a GFS cluster function as peers. Using GFS in a cluster requires [|hardware] to allow access to the shared storage, and a lock manager to control access to the storage.
The lock manager operates as a separate module: thus GFS and GFS2 can use the Distributed Lock Manager for cluster configurations and the "nolock" lock manager for local filesystems. Older versions of GFS also support GULM, a server-based lock manager which implements redundancy via failover.
GFS and GFS2 are free software, distributed under the terms of the GNU General Public License.
History
Development of GFS began in 1995 and was originally developed by University of Minnesota professor Matthew O'Keefe and a group of students. It was originally written for SGI's IRIX operating system, but in 1998 it was ported to Linux since the open source code provided a more convenient development platform. In late 1999/early 2000 it made its way to Sistina Software, where it lived for a time as an open-source project. In 2001, Sistina made the choice to make GFS a proprietary product.Developers forked OpenGFS from the last public release of GFS and then further enhanced it to include updates allowing it to work with OpenDLM. But OpenGFS and OpenDLM became defunct, since Red Hat purchased Sistina in December 2003 and released GFS and many cluster-infrastructure pieces under the GPL in late June 2004.
Red Hat subsequently financed further development geared towards bug-fixing and stabilization. A further development, GFS2 derives from GFS and was included along with its distributed lock manager in Linux 2.6.19. Red Hat Enterprise Linux 5.2 included GFS2 as a kernel module for evaluation purposes. With the 5.3 update, GFS2 became part of the kernel package.
, GFS forms part of the Fedora, Red Hat Enterprise Linux 5.3 and upwards and associated CentOS Linux distributions. Users can purchase to run GFS fully supported on top of Red Hat Enterprise Linux. Since Red Hat Enterprise Linux version 5.3, Red Hat Enterprise Linux Advanced Platform has included support for GFS at no additional cost.
The following list summarizes some version numbers and major features introduced:
- v1.0 SGI IRIX only
- v3.0 Linux port
- v4 journaling
- v5 Redundant Lock Manager
- v6.1 Distributed Lock Manager
- -
- Red Hat Enterprise Linux 5.3 releases the first fully supported GFS2
Hardware
The DLM requires an IP based network over which to communicate. This is normally just Ethernet, but again, there are many other possible solutions. Depending upon the choice of SAN, it may be possible to combine this, but normal practice involves separate networks for the DLM and storage.
The GFS requires fencing hardware of some kind. This is a requirement of the cluster
infrastructure, rather than GFS/GFS2 itself, but it is required for all multi-node clusters. The usual options include power switches and remote access controllers. Fencing is used to ensure that a node which the cluster believes to be failed cannot suddenly start working again while another node is recovering the journal for the failed node. It can also optionally restart the failed node automatically once the recovery is complete.
Differences from a local filesystem
Although the designers of GFS/GFS2 aimed to emulate a local filesystem closely, there are a number of differences to be aware of. Some of these are due to the existing filesystem interfaces not allowing the passing of information relating to the cluster. Some stem from the difficulty of implementing those features efficiently in a clustered manner. For example:- The flock system call on GFS/GFS2 is not interruptible by signals.
- The fcntl F_GETLK system call returns a PID of any blocking lock. Since this is a cluster filesystem, that PID might refer to a process on any of the nodes which have the filesystem mounted. Since the purpose of this interface is to allow a signal to be sent to the blocking process, this is no longer possible.
- Leases are not supported with the lock_dlm lock module, but they are supported when used as a local filesystem
- dnotify will work on a "same node" basis, but its use with GFS/GFS2 is not recommended
- inotify will also work on a "same node" basis, and is also not recommended
- splice is supported on GFS2 only
When in EX mode, an inode is allowed to cache data and metadata. In SH mode, the inode can cache data and metadata, but it must not be dirty. In DF mode, the inode is allowed to cache metadata only, and again it must not be dirty. The DF mode is used only for direct I/O. In UN mode, the inode must not cache any metadata.
In order that operations which change an inode's data or metadata do not interfere with each other, an EX lock is used. This means that certain operations, such as create/unlink of files from the same directory and writes to the same file should be, in general, restricted to one node in the cluster. Of course, doing these operations from multiple nodes will work as expected, but due to the requirement to flush caches frequently, it will not be very efficient.
The single most frequently asked question about GFS/GFS2 performance is why the performance can be poor with email servers. The solution is to break up the mail spool into separate directories and to try to keep each node reading and writing to a private set of directories.
Journaling
GFS and GFS2 are both journaled file systems; and GFS2 supports a similar set of journaling modes as ext3. In data=writeback mode, only metadata is journaled. This is the only mode supported by GFS, however it is possible to turn on journaling on individual data-files, but only when they are of zero size. Journaled files in GFS have a number of restrictions placed upon them, such asno support for the mmap or sendfile system calls, they also use a different on-disk format from regular files. There is also an "inherit-journal" attribute which when set on a directory causes all files created within that directory to have the journal flag set. This can be used instead of the data=journal mount option which ext3 supports.
GFS2 also supports data=ordered mode which is similar to data=writeback except that dirty data is synced before each journal flush is completed. This ensures that blocks which have been added to an inode will have their content synced back to disk before the metadata is updated to record the new size and thus prevents uninitialised blocks appearing in a file under node failure conditions. The default journaling mode is data=ordered, to match ext3's default.
, GFS2 does not yet support data=journal mode, but it does use the same on-disk format for both regular and journaled files, and it also supports the same journaled and inherit-journal attributes. GFS2 also relaxes the restrictions on when a file may have its journaled attribute changed to any time that the file is not open.
For performance reasons, each node in GFS and GFS2 has its own journal. In GFS the journals are disk extents, in GFS2 the journals are just regular files. The number of nodes which may mount the filesystem at any one time is limited by the number of available journals.
Features of GFS2 compared with GFS
GFS2 adds a number of new features which are not in GFS. Here is a summary of those features not already mentioned in the boxes to the right of this page:- The metadata filesystem – see [|Compatibility and the GFS2 meta filesystem] below
- GFS2 specific trace points have been available since kernel 2.6.32
- The XFS-style quota interface has been available in GFS2 since kernel 2.6.33
- Caching ACLs have been available in GFS2 since 2.6.33
- GFS2 supports the generation of "discard" requests for thin provisioning/SCSI TRIM requests
- GFS2 supports I/O barriers
- FIEMAP ioctl
- Splice support
- mmap/splice support for journaled files
- Far fewer tunables
- Ordered write mode
Compatibility and the GFS2 meta filesystem
- GFS2 has a "meta filesystem" through which processes access system files
- GFS2 uses the same on-disk format for journaled files as for regular files
- GFS2 uses regular files for journals, whereas GFS uses special extents
- GFS2 has some other "per_node" system files
- The layout of the inode is different
- The layout of indirect blocks differs slightly
The GFS2 "meta filesystem" is not a filesystem in its own right, but an alternate root of the main filesystem. Although it behaves like a "normal" filesystem, its contents are the various system files used by GFS2, and normally users do not need to ever look at it. The GFS2 utilities mount and unmount the meta filesystem as required, behind the scenes.