blob: 2257bb53edc1b12350da1f67f07089c5738a8b24 [file] [log] [blame]
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +01001.. SPDX-License-Identifier: GPL-2.0
2
3=====================================
4OCFS2 file system - online file check
5=====================================
Gang Hed750c422016-03-22 14:24:33 -07006
7This document will describe OCFS2 online file check feature.
8
9Introduction
10============
Masanari Iidaa039ba32016-07-01 20:28:18 +090011OCFS2 is often used in high-availability systems. However, OCFS2 usually
Gang Hed750c422016-03-22 14:24:33 -070012converts the filesystem to read-only when encounters an error. This may not be
13necessary, since turning the filesystem read-only would affect other running
14processes as well, decreasing availability.
15Then, a mount option (errors=continue) is introduced, which would return the
Masanari Iidaa039ba32016-07-01 20:28:18 +090016-EIO errno to the calling process and terminate further processing so that the
Gang Hed750c422016-03-22 14:24:33 -070017filesystem is not corrupted further. The filesystem is not converted to
18read-only, and the problematic file's inode number is reported in the kernel
19log. The user can try to check/fix this file via online filecheck feature.
20
21Scope
22=====
23This effort is to check/fix small issues which may hinder day-to-day operations
24of a cluster filesystem by turning the filesystem read-only. The scope of
25checking/fixing is at the file level, initially for regular files and eventually
26to all files (including system files) of the filesystem.
27
28In case of directory to file links is incorrect, the directory inode is
29reported as erroneous.
30
31This feature is not suited for extravagant checks which involve dependency of
32other components of the filesystem, such as but not limited to, checking if the
33bits for file blocks in the allocation has been set. In case of such an error,
34the offline fsck should/would be recommended.
35
36Finally, such an operation/feature should not be automated lest the filesystem
37may end up with more damage than before the repair attempt. So, this has to
38be performed using user interaction and consent.
39
40User interface
41==============
42When there are errors in the OCFS2 filesystem, they are usually accompanied
43by the inode number which caused the error. This inode number would be the
44input to check/fix the file.
45
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010046There is a sysfs directory for each OCFS2 file system mounting::
Gang Hed750c422016-03-22 14:24:33 -070047
48 /sys/fs/ocfs2/<devname>/filecheck
49
Masanari Iidaa039ba32016-07-01 20:28:18 +090050Here, <devname> indicates the name of OCFS2 volume device which has been already
Gang Hed750c422016-03-22 14:24:33 -070051mounted. The file above would accept inode numbers. This could be used to
52communicate with kernel space, tell which file(inode number) will be checked or
53fixed. Currently, three operations are supported, which includes checking
54inode, fixing inode and setting the size of result record history.
55
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +0100561. If you want to know what error exactly happened to <inode> before fixing, do::
Gang Hed750c422016-03-22 14:24:33 -070057
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010058 # echo "<inode>" > /sys/fs/ocfs2/<devname>/filecheck/check
59 # cat /sys/fs/ocfs2/<devname>/filecheck/check
Gang Hed750c422016-03-22 14:24:33 -070060
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010061The output is like this::
Gang Hed750c422016-03-22 14:24:33 -070062
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010063 INO DONE ERROR
64 39502 1 GENERATION
Gang Hed750c422016-03-22 14:24:33 -070065
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010066 <INO> lists the inode numbers.
67 <DONE> indicates whether the operation has been finished.
68 <ERROR> says what kind of errors was found. For the detailed error numbers,
69 please refer to the file linux/fs/ocfs2/filecheck.h.
Gang Hed750c422016-03-22 14:24:33 -070070
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +0100712. If you determine to fix this inode, do::
Gang Hed750c422016-03-22 14:24:33 -070072
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010073 # echo "<inode>" > /sys/fs/ocfs2/<devname>/filecheck/fix
74 # cat /sys/fs/ocfs2/<devname>/filecheck/fix
75
76The output is like this:::
77
78 INO DONE ERROR
79 39502 1 SUCCESS
Gang Hed750c422016-03-22 14:24:33 -070080
81This time, the <ERROR> column indicates whether this fix is successful or not.
82
833. The record cache is used to store the history of check/fix results. It's
Masanari Iidaa039ba32016-07-01 20:28:18 +090084default size is 10, and can be adjust between the range of 10 ~ 100. You can
Mauro Carvalho Chehab3d0c60d2020-02-17 17:12:14 +010085adjust the size like this::
Gang Hed750c422016-03-22 14:24:33 -070086
87 # echo "<size>" > /sys/fs/ocfs2/<devname>/filecheck/set
88
89Fixing stuff
90============
Masanari Iidaa039ba32016-07-01 20:28:18 +090091On receiving the inode, the filesystem would read the inode and the
Gang Hed750c422016-03-22 14:24:33 -070092file metadata. In case of errors, the filesystem would fix the errors
93and report the problems it fixed in the kernel log. As a precautionary measure,
94the inode must first be checked for errors before performing a final fix.
95
96The inode and the result history will be maintained temporarily in a
97small linked list buffer which would contain the last (N) inodes
98fixed/checked, the detailed errors which were fixed/checked are printed in the
99kernel log.