| C H A P T E R 19 |
|
Managing the File System and I/O |
This chapter describes file striping and I/O options, and includes the following sections:
Sometimes a Lustre file system becomes unbalanced, often due to incorrectly-specified stripe settings, or when very large files are created that are not striped over all of the OSTs. If an OST is full and an attempt is made to write more information to the file system, an error occurs. The procedures below describe how to handle a full OST.
The MDS will normally handle space balancing automatically at file creation time, and this procedure is normally not needed, but may be desirable in certain circumstances (e.g. when creating very large files that would consume more than the total free space of the full OSTs).
The example below shows an unbalanced file system:
root@LustreClient01 ~]# lfs df -h UUID bytes Used Available Use% Mounted on lustre-MDT0000_UUID 4.4G 214.5M 3.9G 4% /mnt/lustre[MDT:0] lustre-OST0000_UUID 2.0G 751.3M 1.1G 37% /mnt/lustre[OST:0] lustre-OST0001_UUID 2.0G 755.3M 1.1G 37% /mnt/lustre[OST:1] lustre-OST0002_UUID 2.0G 1.7G 155.1M 86% /mnt/lustre[OST:2] <- lustre-OST0003_UUID 2.0G 751.3M 1.1G 37% /mnt/lustre[OST:3] lustre-OST0004_UUID 2.0G 747.3M 1.1G 37% /mnt/lustre[OST:4] lustre-OST0005_UUID 2.0G 743.3M 1.1G 36% /mnt/lustre[OST:5] filesystem summary: 11.8G 5.4G 5.8G 45% /mnt/lustre
In this case, OST:2 is almost full and when an attempt is made to write additional information to the file system (even with uniform striping over all the OSTs), the write command fails as follows:
[root@LustreClient01 ~]# lfs setstripe /mnt/lustre 4M 0 -1 [root@LustreClient01 ~]# dd if=/dev/zero of=/mnt/lustre/test_3 \ bs=10M count=100 dd: writing `/mnt/lustre/test_3': No space left on device 98+0 records in 97+0 records out 1017192448 bytes (1.0 GB) copied, 23.2411 seconds, 43.8 MB/s
To avoid running out of space in the file system, if the OST usage is imbalanced and one or more OSTs are close to being full while there are others that have a lot of space, the full OSTs may optionally be deactivated at the MDS to prevent the MDS from allocating new objects there.
[root@LustreClient01 ~]# ssh root@192.168.0.10 root@192.168.0.10's password: Last login: Wed Nov 26 13:35:12 2008 from 192.168.0.6
2. Use the lctl dl command to show the status of all file system components:
[root@mds ~]# lctl dl 0 UP mgs MGS MGS 9 1 UP mgc MGC192.168.0.10@tcp e384bb0e-680b-ce25-7bc9-81655dd1e813 5 2 UP mdt MDS MDS_uuid 3 3 UP lov lustre-mdtlov lustre-mdtlov_UUID 4 4 UP mds lustre-MDT0000 lustre-MDT0000_UUID 5 5 UP osc lustre-OST0000-osc lustre-mdtlov_UUID 5 6 UP osc lustre-OST0001-osc lustre-mdtlov_UUID 5 7 UP osc lustre-OST0002-osc lustre-mdtlov_UUID 5 8 UP osc lustre-OST0003-osc lustre-mdtlov_UUID 5 9 UP osc lustre-OST0004-osc lustre-mdtlov_UUID 5 10 UP osc lustre-OST0005-osc lustre-mdtlov_UUID 5
3. Use lctl deactivate to take the full OST offline:
[root@mds ~]# lctl --device 7 deactivate
4. Display the status of the file system components:
[root@mds ~]# lctl dl 0 UP mgs MGS MGS 9 1 UP mgc MGC192.168.0.10@tcp e384bb0e-680b-ce25-7bc9-81655dd1e813 5 2 UP mdt MDS MDS_uuid 3 3 UP lov lustre-mdtlov lustre-mdtlov_UUID 4 4 UP mds lustre-MDT0000 lustre-MDT0000_UUID 5 5 UP osc lustre-OST0000-osc lustre-mdtlov_UUID 5 6 UP osc lustre-OST0001-osc lustre-mdtlov_UUID 5 7 IN osc lustre-OST0002-osc lustre-mdtlov_UUID 5 8 UP osc lustre-OST0003-osc lustre-mdtlov_UUID 5 9 UP osc lustre-OST0004-osc lustre-mdtlov_UUID 5 10 UP osc lustre-OST0005-osc lustre-mdtlov_UUID 5
The device list shows that OST0002 is now inactive. When new files are created in the file system, they will only use the remaining active OSTs. Either manual space rebalancing can be done by migrating data to other OSTs, as shown in the next section, or normal file deletion and creation can be allowed to passively rebalance the space usage.
As stripes cannot be moved within the file system, data must be migrated manually by copying and renaming the file, removing the original file, and renaming the new file with the original file name. The simplest way to do this is to use the lfs_migrate command (see lfs_migrate). However, the steps for migrating a file by hand are also shown here for reference.
1. Identify the file(s) to be moved.
In the example below, output from the getstripe command indicates that the file test_2 is located entirely on OST2:
[client]# lfs getstripe /mnt/lustre/test_2
/mnt/lustre/test_2
obdidx objid objid group
2 8 0x8 0
2. To move single object(s), create a new copy and remove the original. Enter:
[client]# cp -a /mnt/lustre/test_2 /mnt/lustre/test_2.tmp [client]# mv /mnt/lustre/test_2.tmp /mnt/lustre/test_2
3. To migrate large files from one or more OSTs, enter:
[client]# lfs find --ost {OST_UUID} -size +1G | lfs_migrate -y
4. Check the file system balance.
The df output in the example below shows a more balanced system compared to the df output in the example in Checking OST Space Usage.
[client]# lfs df -h UUID bytes Used Available Use% Mounted on lustre-MDT0000_UUID 4.4G 214.5M 3.9G 4% /mnt/lustre[MDT:0] lustre-OST0000_UUID 2.0G 1.3G 598.1M 65% /mnt/lustre[OST:0] lustre-OST0001_UUID 2.0G 1.3G 594.1M 65% /mnt/lustre[OST:1] lustre-OST0002_UUID 2.0G 913.4M 1000.0M 45% /mnt/lustre[OST:2] lustre-OST0003_UUID 2.0G 1.3G 602.1M 65% /mnt/lustre[OST:3] lustre-OST0004_UUID 2.0G 1.3G 606.1M 64% /mnt/lustre[OST:4] lustre-OST0005_UUID 2.0G 1.3G 610.1M 64% /mnt/lustre[OST:5] filesystem summary: 11.8G 7.3G 3.9G 61% /mnt/lustre
Once the deactivated OST(s) no longer are severely imbalanced, due to either active or passive data redistribution, they should be reactivated so they will again have new files allocated on them.
[mds]# lctl --device 7 activate [mds]# lctl dl 0 UP mgs MGS MGS 9 1 UP mgc MGC192.168.0.10@tcp e384bb0e-680b-ce25-7bc9-816dd1e813 5 2 UP mdt MDS MDS_uuid 3 3 UP lov lustre-mdtlov lustre-mdtlov_UUID 4 4 UP mds lustre-MDT0000 lustre-MDT0000_UUID 5 5 UP osc lustre-OST0000-osc lustre-mdtlov_UUID 5 6 UP osc lustre-OST0001-osc lustre-mdtlov_UUID 5 7 UP osc lustre-OST0002-osc lustre-mdtlov_UUID 5 8 UP osc lustre-OST0003-osc lustre-mdtlov_UUID 5 9 UP osc lustre-OST0004-osc lustre-mdtlov_UUID 5 10 UP osc lustre-OST0005-osc lustre-mdtlov_UUID
The OST pools feature enables users to group OSTs together to make object placement more flexible. A 'pool' is the name associated with an arbitrary subset of OSTs in a Lustre cluster.
When an OST pool is defined, it can be used to allocate files. When file or directory striping is set to a pool, only OSTs in the pool are candidates for striping. If a stripe_index is specified which refers to an OST that is not a member of the pool, an error is returned.
OST pools are used only at file creation. If the definition of a pool changes (an OST is added or removed or the pool is destroyed), already-created files are not affected.
| Note - An error (EINVAL) results if you create a file using an empty pool. |
OST pools are defined in the configuration log on the MGS. Use the lctl command to:
The lctl command MUST be run on the MGS. Another requirement for managing OST pools is to either have the MDT and MGS on the same node or have a Lustre client mounted on the MGS node, if it is separate from the MDS. This is needed to validate the pool commands being run are correct.
lctl pool_new <fsname>.<poolname>
| Note - The pool name is an ASCII string up to 16 characters. |
To add the named OST to a pool, run:
lctl pool_add <fsname>.<poolname> <ost_list>
If the leading <fsname> and/or ending _UUID are missing, they are automatically added.
For example, to add even-numbered OSTs to pool1 on file system lustre, run a single command (add) to add many OSTs to the pool at one time:
lctl pool_add lustre.pool1 OST[0-10/2]
| Note - Each time an OST is added to a pool, a new llog configuration record is created. For convenience, you can run a single command. |
To remove a named OST from a pool, run:
lctl pool_remove <fsname>.<poolname> <ost_list>
lctl pool_destroy <fsname>.<poolname>
| Note - All OSTs must be removed from a pool before it can be destroyed. |
To list pools in the named file system, run:
lctl pool_list <fsname> | <pathname>
To list OSTs in a named pool, run:
lctl pool_list <fsname>.<poolname>
Several lfs commands can be run with OST pools. Use the lfs setstripe command to associate a directory with an OST pool. This causes all new regular files and directories in the directory to be created in the pool. The lfs command can be used to list pools in a file system and OSTs in a named pool.
To associate a directory with a pool, so all new files and directories will be created in the pool, run:
lfs setstripe --pool|-p pool_name <filename|dirname>
To set striping patterns, run:
lfs setstripe [--size|-s stripe_size] [--offset|-o start_ost] [--count|-c stripe_count] [--pool|-p pool_name] <dir|filename>
| Note - The --pool option for lfs setstripe is compatible with other modifiers. For example, you can set striping on a directory to use an explicit starting index. |
Here are several suggestions for using OST pools.
To add an OST to existing Lustre file system:
1. Add a new OST by passing on the following commands, run:
$ mkfs.lustre --fsname=spfs --ost --mgsnode=mds16@tcp0 /dev/sda $ mkdir -p /mnt/test/ost0 $ mount -t lustre /dev/sda /mnt/test/ost0
2. Migrate the data (possibly).
The file system is quite unbalanced when new empty OSTs are added. New file creations are automatically balanced. If this is a scratch file system or files are pruned at a regular interval, then no further work may be needed. Files existing prior to the expansion can be rebalanced with an in-place copy, which can be done with a simple script.
The basic method is to copy existing files to a temporary file, then move the temp file over the old one. This should not be attempted with files which are currently being written to by users or applications. This operation redistributes the stripes over the entire set of OSTs.
A very clever migration script would do the following:
If a Lustre administrator wants to explore this approach further, per-OST disk-usage statistics can be found under /proc/fs/lustre/osc/*/rpc_stats
Lustre supports the O_DIRECT flag to open.
Applications using the read() and write() calls must supply buffers aligned on a page boundary (usually 4 K). If the alignment is not correct, the call returns -EINVAL. Direct I/O may help performance in cases where the client is doing a large amount of I/O and is CPU-bound (CPU utilization 100%).
An immutable file or directory is one that cannot be modified, renamed or removed. To do this:
chattr +i <file>
To remove this flag, use chattr -i
This section describes other I/O options, including checksums.
To guard against network data corruption, a Lustre client can perform two types of data checksums: in-memory (for data in client memory) and wire (for data sent over the network). For each checksum type, a 32-bit checksum of the data read or written on both the client and server is computed, to ensure that the data has not been corrupted in transit over the network. The ldiskfs backing file system does NOT do any persistent checksumming, so it does not detect corruption of data in the OST file system.
The checksumming feature is enabled, by default, on individual client nodes. If the client or OST detects a checksum mismatch, then an error is logged in the syslog of the form:
LustreError: BAD WRITE CHECKSUM: changed in transit before arrival at OST: from 192.168.1.1@tcp inum 8991479/2386814769 object 1127239/0 extent [102400-106495]
If this happens, the client will re-read or re-write the affected data up to five times to get a good copy of the data over the network. If it is still not possible, then an I/O error is returned to the application.
To enable both types of checksums (in-memory and wire), run:
echo 1 > /proc/fs/lustre/llite/<fsname>/checksum_pages
To disable both types of checksums (in-memory and wire), run:
echo 0 > /proc/fs/lustre/llite/<fsname>/checksum_pages
To check the status of a wire checksum, run:
lctl get_param osc.*.checksums
By default, Lustre uses the adler32 checksum algorithm, because it is robust and has a lower impact on performance than crc32. The Lustre administrator can change the checksum algorithm via /proc, depending on what is supported in the kernel.
To check which checksum algorithm is being used by Lustre, run:
$ cat /proc/fs/lustre/osc/<fsname>-OST<index>-osc-*/checksum_type
To change the wire checksum algorithm used by Lustre, run:
$ echo <algorithm name> /proc/fs/lustre/osc/<fsname>-OST<index>- \osc-*/checksum_type
| Note - The in-memory checksum always uses the adler32 algorithm, if available, and only falls back to crc32 if adler32 cannot be used. |
In the following example, the cat command is used to determine that Lustre is using the adler32 checksum algorithm. Then the echo command is used to change the checksum algorithm to crc32. A second cat command confirms that the crc32 checksum algorithm is now in use.
$ cat /proc/fs/lustre/osc/lustre-OST0000-osc- \ffff81012b2c48e0/checksum_type crc32 [adler] $ echo crc32 > /proc/fs/lustre/osc/lustre-OST0000-osc- \ffff81012b2c48e0/checksum_type $ cat /proc/fs/lustre/osc/lustre-OST0000-osc- \ffff81012b2c48e0/checksum_type [crc32] adler
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.