1*3d0c60d0SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0 2*3d0c60d0SMauro Carvalho Chehab 3*3d0c60d0SMauro Carvalho Chehab===================================== 4*3d0c60d0SMauro Carvalho ChehabOCFS2 file system - online file check 5*3d0c60d0SMauro Carvalho Chehab===================================== 6*3d0c60d0SMauro Carvalho Chehab 7*3d0c60d0SMauro Carvalho ChehabThis document will describe OCFS2 online file check feature. 8*3d0c60d0SMauro Carvalho Chehab 9*3d0c60d0SMauro Carvalho ChehabIntroduction 10*3d0c60d0SMauro Carvalho Chehab============ 11*3d0c60d0SMauro Carvalho ChehabOCFS2 is often used in high-availability systems. However, OCFS2 usually 12*3d0c60d0SMauro Carvalho Chehabconverts the filesystem to read-only when encounters an error. This may not be 13*3d0c60d0SMauro Carvalho Chehabnecessary, since turning the filesystem read-only would affect other running 14*3d0c60d0SMauro Carvalho Chehabprocesses as well, decreasing availability. 15*3d0c60d0SMauro Carvalho ChehabThen, a mount option (errors=continue) is introduced, which would return the 16*3d0c60d0SMauro Carvalho Chehab-EIO errno to the calling process and terminate further processing so that the 17*3d0c60d0SMauro Carvalho Chehabfilesystem is not corrupted further. The filesystem is not converted to 18*3d0c60d0SMauro Carvalho Chehabread-only, and the problematic file's inode number is reported in the kernel 19*3d0c60d0SMauro Carvalho Chehablog. The user can try to check/fix this file via online filecheck feature. 20*3d0c60d0SMauro Carvalho Chehab 21*3d0c60d0SMauro Carvalho ChehabScope 22*3d0c60d0SMauro Carvalho Chehab===== 23*3d0c60d0SMauro Carvalho ChehabThis effort is to check/fix small issues which may hinder day-to-day operations 24*3d0c60d0SMauro Carvalho Chehabof a cluster filesystem by turning the filesystem read-only. The scope of 25*3d0c60d0SMauro Carvalho Chehabchecking/fixing is at the file level, initially for regular files and eventually 26*3d0c60d0SMauro Carvalho Chehabto all files (including system files) of the filesystem. 27*3d0c60d0SMauro Carvalho Chehab 28*3d0c60d0SMauro Carvalho ChehabIn case of directory to file links is incorrect, the directory inode is 29*3d0c60d0SMauro Carvalho Chehabreported as erroneous. 30*3d0c60d0SMauro Carvalho Chehab 31*3d0c60d0SMauro Carvalho ChehabThis feature is not suited for extravagant checks which involve dependency of 32*3d0c60d0SMauro Carvalho Chehabother components of the filesystem, such as but not limited to, checking if the 33*3d0c60d0SMauro Carvalho Chehabbits for file blocks in the allocation has been set. In case of such an error, 34*3d0c60d0SMauro Carvalho Chehabthe offline fsck should/would be recommended. 35*3d0c60d0SMauro Carvalho Chehab 36*3d0c60d0SMauro Carvalho ChehabFinally, such an operation/feature should not be automated lest the filesystem 37*3d0c60d0SMauro Carvalho Chehabmay end up with more damage than before the repair attempt. So, this has to 38*3d0c60d0SMauro Carvalho Chehabbe performed using user interaction and consent. 39*3d0c60d0SMauro Carvalho Chehab 40*3d0c60d0SMauro Carvalho ChehabUser interface 41*3d0c60d0SMauro Carvalho Chehab============== 42*3d0c60d0SMauro Carvalho ChehabWhen there are errors in the OCFS2 filesystem, they are usually accompanied 43*3d0c60d0SMauro Carvalho Chehabby the inode number which caused the error. This inode number would be the 44*3d0c60d0SMauro Carvalho Chehabinput to check/fix the file. 45*3d0c60d0SMauro Carvalho Chehab 46*3d0c60d0SMauro Carvalho ChehabThere is a sysfs directory for each OCFS2 file system mounting:: 47*3d0c60d0SMauro Carvalho Chehab 48*3d0c60d0SMauro Carvalho Chehab /sys/fs/ocfs2/<devname>/filecheck 49*3d0c60d0SMauro Carvalho Chehab 50*3d0c60d0SMauro Carvalho ChehabHere, <devname> indicates the name of OCFS2 volume device which has been already 51*3d0c60d0SMauro Carvalho Chehabmounted. The file above would accept inode numbers. This could be used to 52*3d0c60d0SMauro Carvalho Chehabcommunicate with kernel space, tell which file(inode number) will be checked or 53*3d0c60d0SMauro Carvalho Chehabfixed. Currently, three operations are supported, which includes checking 54*3d0c60d0SMauro Carvalho Chehabinode, fixing inode and setting the size of result record history. 55*3d0c60d0SMauro Carvalho Chehab 56*3d0c60d0SMauro Carvalho Chehab1. If you want to know what error exactly happened to <inode> before fixing, do:: 57*3d0c60d0SMauro Carvalho Chehab 58*3d0c60d0SMauro Carvalho Chehab # echo "<inode>" > /sys/fs/ocfs2/<devname>/filecheck/check 59*3d0c60d0SMauro Carvalho Chehab # cat /sys/fs/ocfs2/<devname>/filecheck/check 60*3d0c60d0SMauro Carvalho Chehab 61*3d0c60d0SMauro Carvalho ChehabThe output is like this:: 62*3d0c60d0SMauro Carvalho Chehab 63*3d0c60d0SMauro Carvalho Chehab INO DONE ERROR 64*3d0c60d0SMauro Carvalho Chehab 39502 1 GENERATION 65*3d0c60d0SMauro Carvalho Chehab 66*3d0c60d0SMauro Carvalho Chehab <INO> lists the inode numbers. 67*3d0c60d0SMauro Carvalho Chehab <DONE> indicates whether the operation has been finished. 68*3d0c60d0SMauro Carvalho Chehab <ERROR> says what kind of errors was found. For the detailed error numbers, 69*3d0c60d0SMauro Carvalho Chehab please refer to the file linux/fs/ocfs2/filecheck.h. 70*3d0c60d0SMauro Carvalho Chehab 71*3d0c60d0SMauro Carvalho Chehab2. If you determine to fix this inode, do:: 72*3d0c60d0SMauro Carvalho Chehab 73*3d0c60d0SMauro Carvalho Chehab # echo "<inode>" > /sys/fs/ocfs2/<devname>/filecheck/fix 74*3d0c60d0SMauro Carvalho Chehab # cat /sys/fs/ocfs2/<devname>/filecheck/fix 75*3d0c60d0SMauro Carvalho Chehab 76*3d0c60d0SMauro Carvalho ChehabThe output is like this::: 77*3d0c60d0SMauro Carvalho Chehab 78*3d0c60d0SMauro Carvalho Chehab INO DONE ERROR 79*3d0c60d0SMauro Carvalho Chehab 39502 1 SUCCESS 80*3d0c60d0SMauro Carvalho Chehab 81*3d0c60d0SMauro Carvalho ChehabThis time, the <ERROR> column indicates whether this fix is successful or not. 82*3d0c60d0SMauro Carvalho Chehab 83*3d0c60d0SMauro Carvalho Chehab3. The record cache is used to store the history of check/fix results. It's 84*3d0c60d0SMauro Carvalho Chehabdefault size is 10, and can be adjust between the range of 10 ~ 100. You can 85*3d0c60d0SMauro Carvalho Chehabadjust the size like this:: 86*3d0c60d0SMauro Carvalho Chehab 87*3d0c60d0SMauro Carvalho Chehab # echo "<size>" > /sys/fs/ocfs2/<devname>/filecheck/set 88*3d0c60d0SMauro Carvalho Chehab 89*3d0c60d0SMauro Carvalho ChehabFixing stuff 90*3d0c60d0SMauro Carvalho Chehab============ 91*3d0c60d0SMauro Carvalho ChehabOn receiving the inode, the filesystem would read the inode and the 92*3d0c60d0SMauro Carvalho Chehabfile metadata. In case of errors, the filesystem would fix the errors 93*3d0c60d0SMauro Carvalho Chehaband report the problems it fixed in the kernel log. As a precautionary measure, 94*3d0c60d0SMauro Carvalho Chehabthe inode must first be checked for errors before performing a final fix. 95*3d0c60d0SMauro Carvalho Chehab 96*3d0c60d0SMauro Carvalho ChehabThe inode and the result history will be maintained temporarily in a 97*3d0c60d0SMauro Carvalho Chehabsmall linked list buffer which would contain the last (N) inodes 98*3d0c60d0SMauro Carvalho Chehabfixed/checked, the detailed errors which were fixed/checked are printed in the 99*3d0c60d0SMauro Carvalho Chehabkernel log. 100