• Aucun résultat trouvé

Write Barriers

Chapter 6. The XFS File System

XFS is a highly scalable, high-performance file system which was originally designed at Silicon Graphics, Inc. XFS is the default file system for Red Hat Enterprise Linux 7.

Main Feat u res

XFS supports metadata journaling, which facilitates quicker crash recovery. The XFS file system can also be defragmented and enlarged while mounted and active. In addition, Red Hat Enterprise Linux 7 supports backup and restore utilities specific to XFS.

Allo cat io n Feat u res

XFS features the following allocation schemes:

Extent-based allocation

Stripe-aware allocation policies Delayed allocation

Space pre-allocation

Delayed allocation and other performance optimizations affect XFS the same way that they do ext4. Namely, a program's writes to an XFS file system are not guaranteed to be on-disk unless the program issues an fsync() call afterwards.

For more information on the implications of delayed allocation on a file system (ext4 and XFS), refer to Allocation Features in Chapter 5, The Ext4 File System.

Note

Creating or expanding files occasionally fails with an unexpected ENOSPC write failure even though the disk space appears to be sufficient. This is due to XFS's performance-oriented design. In practice, it does not become a problem since it only occurs if remaining space is only a few blocks.

O t h er XFS Feat u res

The XFS file system also supports the following:

Extended attributes (xattr)

This allows the system to associate several additional name/value pairs per file. It is enabled by default.

Quota journaling

This avoids the need for lengthy quota consistency checks after a crash.

Project/directory quotas

This allows quota restrictions over a directory tree.

Subsecond timestamps

This allows timestamps to go to the subsecond.

6.1. Creat ing an XFS File Syst em

To create an XFS file system, use the mkfs. xfs /d ev/device command. In general, the default options are optimal for common use.

When using mkfs. xfs on a block device containing an existing file system, use the -f option to force an overwrite of that file system.

Examp le 6 .1. mkfs. xfs co mman d o u t p u t

Below is a sample output of the mkfs. xfs command:

meta-data=/dev/device isize=256 agcount=4, agsize=3277258 blks

= sectsz=512 attr=2

data = bsize=4096 blocks=13109032, imaxpct=25

= sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0

log =internal log bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

Note

After an XFS file system is created, its size cannot be reduced. However, it can still be enlarged using the xfs_g ro wfs command (refer to Section 6.4, “ Increasing the Size of an XFS File System”).

For striped block devices (for example, RAID5 arrays), the stripe geometry can be specified at the time of file system creation. Using proper stripe geometry greatly enhances the performance of an XFS filesystem.

When creating filesystems on LVM or MD volumes, mkfs. xfs chooses an optimal geometry. This may also be true on some hardware RAIDs that export geometry information to the operating system.

If the device exports stripe geometry information, mkfs (for ext3, ext4, and xfs) will automatically use this geometry. If stripe geometry is not detected by mkfs and even though the storage does, in fact, have stripe geometry, it is possible to manually specify it at mkfs time using the following options:

su = value

Specifies a stripe unit or RAID chunk size. The value must be specified in bytes, with an optional k, m, or g suffix.

sw= value

Specifies the number of data disks in a RAID device, or the number of stripe units in the stripe.

The following example specifies a chunk size of 64k on a RAID device containing 4 stripe units:

⁠Chapt er 6 . T he XFS File Syst em

# mkfs. xfs -d su= 6 4 k,sw= 4 /d ev/device

For more information about creating XFS file systems, refer to man mkfs. xfs and the Red Hat Enterprise Linux Performance Tuning Guide, chapter Basic Tuning for XFS.

6.2. Mount ing an XFS File Syst em

An XFS file system can be mounted with no extra options, for example:

# mo unt /d ev/device /mount/point

The default for Red Hat Enterprise Linux 7 is inode64.

Note

Unlike mke2fs, mkfs.xfs does not utilize a configuration file; they are all specified on the command line.

Write Barriers

By default, XFS uses write barriers to ensure file system integrity even when power is lost to a device with write caches enabled. For devices without write caches, or with battery-backed write caches, disable the barriers by using the no barri er option:

# mo unt -o no barri er /dev/device /mount/point

For more information about write barriers, refer to Chapter 22, Write Barriers.

6.3. XFS Quot a Management

The XFS quota subsystem manages limits on disk space (blocks) and file (inode) usage. XFS quotas control or report on usage of these items on a user, group, or directory or project level. Also, note that while user, group, and directory or project quotas are enabled independently, group and project quotas are mutually exclusive.

When managing on a per-directory or per-project basis, XFS manages the disk usage of directory hierarchies associated with a specific project. In doing so, XFS recognizes cross-organizational

"group" boundaries between projects. This provides a level of control that is broader than what is available when managing quotas for users or groups.

XFS quotas are enabled at mount time, with specific mount options. Each mount option can also be specified as no enfo rce; this will allow usage reporting without enforcing any limits. Valid quota mount options are:

uq uo ta/uq no enfo rce - User quotas g q uo ta/g q no enfo rce - Group quotas pq uo ta/pq no enfo rce - Project quota

Once quotas are enabled, the xfs_q uo ta tool can be used to set limits and report on disk usage. By default, xfs_q uo ta is run interactively, and in basic mode. Basic mode sub-commands simply report usage, and are available to all users. Basic xfs_q uo ta sub-commands include:

q u o t a username/userID

Show usage and limits for the given username or numeric userID d f

Shows free and used counts for blocks and inodes.

In contrast, xfs_q uo ta also has an expert mode. The sub-commands of this mode allow actual configuration of limits, and are available only to users with elevated privileges. To use expert mode sub-commands interactively, run xfs_q uo ta -x. Expert mode sub-commands include:

rep o rt /path

Reports quota information for a specific file system.

limit

Modify quota limits.

For a complete list of sub-commands for either basic or expert mode, use the sub-command hel p.

All sub-commands can also be run directly from a command line using the -c option, with -x for expert sub-commands.

Examp le 6 .2. Disp lay a samp le q u o t a rep o rt

For example, to display a sample quota report for /ho me (on /d ev/bl o ckd evi ce), use the command xfs_q uo ta -x -c ' repo rt -h' /ho me. This will display output similar to the following:

User quota on /home (/dev/blockdevice)

Blocks User ID Used Soft Hard Warn/Grace --- --- root 0 0 0 00 [---]

testuser 103.4G 0 0 00 [---]

...

To set a soft and hard inode count limit of 500 and 700 respectively for user jo hn (whose home directory is /ho me/jo hn), use the following command:

# xfs_q uo ta -x -c ' l i mi t i so ft= 50 0 i hard = 70 0 jo hn' /ho me/

In this case, pass mount_point which is the mounted xfs file system.

By default, the l i mi t sub-command recognizes targets as users. When configuring the limits for a group, use the -g option (as in the previous example). Similarly, use -p for projects.

Soft and hard block limits can also be configured using bso ft or bhard instead of i so ft or i hard.

Writ e Barriers

Examp le 6 .3. Set a so f t an d h ard b lo ck limit

For example, to set a soft and hard block limit of 1000m and 1200m, respectively, to group acco unti ng on the /targ et/path file system, use the following command:

# xfs_q uo ta -x -c ' l i mi t -g bso ft= 10 0 0 m bhard = 120 0 m acco unti ng ' /targ et/path

Note

The commands bso ft and bhard count by the byte.

Important

While real-time blocks (rtbhard/rtbso ft) are described in man xfs_q uo ta as valid units when setting quotas, the real-time sub-volume is not enabled in this release. As such, the rtbhard and rtbso ft options are not applicable.