13d0c60d0SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
23d0c60d0SMauro Carvalho Chehab
33d0c60d0SMauro Carvalho Chehab=====================================
43d0c60d0SMauro Carvalho ChehabOCFS2 file system - online file check
53d0c60d0SMauro Carvalho Chehab=====================================
63d0c60d0SMauro Carvalho Chehab
73d0c60d0SMauro Carvalho ChehabThis document will describe OCFS2 online file check feature.
83d0c60d0SMauro Carvalho Chehab
93d0c60d0SMauro Carvalho ChehabIntroduction
103d0c60d0SMauro Carvalho Chehab============
113d0c60d0SMauro Carvalho ChehabOCFS2 is often used in high-availability systems. However, OCFS2 usually
123d0c60d0SMauro Carvalho Chehabconverts the filesystem to read-only when encounters an error. This may not be
133d0c60d0SMauro Carvalho Chehabnecessary, since turning the filesystem read-only would affect other running
143d0c60d0SMauro Carvalho Chehabprocesses as well, decreasing availability.
153d0c60d0SMauro Carvalho ChehabThen, a mount option (errors=continue) is introduced, which would return the
163d0c60d0SMauro Carvalho Chehab-EIO errno to the calling process and terminate further processing so that the
173d0c60d0SMauro Carvalho Chehabfilesystem is not corrupted further. The filesystem is not converted to
183d0c60d0SMauro Carvalho Chehabread-only, and the problematic file's inode number is reported in the kernel
193d0c60d0SMauro Carvalho Chehablog. The user can try to check/fix this file via online filecheck feature.
203d0c60d0SMauro Carvalho Chehab
213d0c60d0SMauro Carvalho ChehabScope
223d0c60d0SMauro Carvalho Chehab=====
233d0c60d0SMauro Carvalho ChehabThis effort is to check/fix small issues which may hinder day-to-day operations
243d0c60d0SMauro Carvalho Chehabof a cluster filesystem by turning the filesystem read-only. The scope of
253d0c60d0SMauro Carvalho Chehabchecking/fixing is at the file level, initially for regular files and eventually
263d0c60d0SMauro Carvalho Chehabto all files (including system files) of the filesystem.
273d0c60d0SMauro Carvalho Chehab
283d0c60d0SMauro Carvalho ChehabIn case of directory to file links is incorrect, the directory inode is
293d0c60d0SMauro Carvalho Chehabreported as erroneous.
303d0c60d0SMauro Carvalho Chehab
313d0c60d0SMauro Carvalho ChehabThis feature is not suited for extravagant checks which involve dependency of
323d0c60d0SMauro Carvalho Chehabother components of the filesystem, such as but not limited to, checking if the
333d0c60d0SMauro Carvalho Chehabbits for file blocks in the allocation has been set. In case of such an error,
343d0c60d0SMauro Carvalho Chehabthe offline fsck should/would be recommended.
353d0c60d0SMauro Carvalho Chehab
363d0c60d0SMauro Carvalho ChehabFinally, such an operation/feature should not be automated lest the filesystem
373d0c60d0SMauro Carvalho Chehabmay end up with more damage than before the repair attempt. So, this has to
383d0c60d0SMauro Carvalho Chehabbe performed using user interaction and consent.
393d0c60d0SMauro Carvalho Chehab
403d0c60d0SMauro Carvalho ChehabUser interface
413d0c60d0SMauro Carvalho Chehab==============
423d0c60d0SMauro Carvalho ChehabWhen there are errors in the OCFS2 filesystem, they are usually accompanied
433d0c60d0SMauro Carvalho Chehabby the inode number which caused the error. This inode number would be the
443d0c60d0SMauro Carvalho Chehabinput to check/fix the file.
453d0c60d0SMauro Carvalho Chehab
463d0c60d0SMauro Carvalho ChehabThere is a sysfs directory for each OCFS2 file system mounting::
473d0c60d0SMauro Carvalho Chehab
483d0c60d0SMauro Carvalho Chehab  /sys/fs/ocfs2/<devname>/filecheck
493d0c60d0SMauro Carvalho Chehab
503d0c60d0SMauro Carvalho ChehabHere, <devname> indicates the name of OCFS2 volume device which has been already
513d0c60d0SMauro Carvalho Chehabmounted. The file above would accept inode numbers. This could be used to
523d0c60d0SMauro Carvalho Chehabcommunicate with kernel space, tell which file(inode number) will be checked or
533d0c60d0SMauro Carvalho Chehabfixed. Currently, three operations are supported, which includes checking
543d0c60d0SMauro Carvalho Chehabinode, fixing inode and setting the size of result record history.
553d0c60d0SMauro Carvalho Chehab
563d0c60d0SMauro Carvalho Chehab1. If you want to know what error exactly happened to <inode> before fixing, do::
573d0c60d0SMauro Carvalho Chehab
583d0c60d0SMauro Carvalho Chehab    # echo "<inode>" > /sys/fs/ocfs2/<devname>/filecheck/check
593d0c60d0SMauro Carvalho Chehab    # cat /sys/fs/ocfs2/<devname>/filecheck/check
603d0c60d0SMauro Carvalho Chehab
613d0c60d0SMauro Carvalho ChehabThe output is like this::
623d0c60d0SMauro Carvalho Chehab
633d0c60d0SMauro Carvalho Chehab    INO		DONE	ERROR
643d0c60d0SMauro Carvalho Chehab    39502		1	GENERATION
653d0c60d0SMauro Carvalho Chehab
663d0c60d0SMauro Carvalho Chehab    <INO> lists the inode numbers.
673d0c60d0SMauro Carvalho Chehab    <DONE> indicates whether the operation has been finished.
683d0c60d0SMauro Carvalho Chehab    <ERROR> says what kind of errors was found. For the detailed error numbers,
693d0c60d0SMauro Carvalho Chehab    please refer to the file linux/fs/ocfs2/filecheck.h.
703d0c60d0SMauro Carvalho Chehab
713d0c60d0SMauro Carvalho Chehab2. If you determine to fix this inode, do::
723d0c60d0SMauro Carvalho Chehab
733d0c60d0SMauro Carvalho Chehab    # echo "<inode>" > /sys/fs/ocfs2/<devname>/filecheck/fix
743d0c60d0SMauro Carvalho Chehab    # cat /sys/fs/ocfs2/<devname>/filecheck/fix
753d0c60d0SMauro Carvalho Chehab
763d0c60d0SMauro Carvalho ChehabThe output is like this:::
773d0c60d0SMauro Carvalho Chehab
783d0c60d0SMauro Carvalho Chehab    INO		DONE	ERROR
793d0c60d0SMauro Carvalho Chehab    39502		1	SUCCESS
803d0c60d0SMauro Carvalho Chehab
813d0c60d0SMauro Carvalho ChehabThis time, the <ERROR> column indicates whether this fix is successful or not.
823d0c60d0SMauro Carvalho Chehab
833d0c60d0SMauro Carvalho Chehab3. The record cache is used to store the history of check/fix results. It's
843d0c60d0SMauro Carvalho Chehabdefault size is 10, and can be adjust between the range of 10 ~ 100. You can
853d0c60d0SMauro Carvalho Chehabadjust the size like this::
863d0c60d0SMauro Carvalho Chehab
873d0c60d0SMauro Carvalho Chehab  # echo "<size>" > /sys/fs/ocfs2/<devname>/filecheck/set
883d0c60d0SMauro Carvalho Chehab
893d0c60d0SMauro Carvalho ChehabFixing stuff
903d0c60d0SMauro Carvalho Chehab============
913d0c60d0SMauro Carvalho ChehabOn receiving the inode, the filesystem would read the inode and the
923d0c60d0SMauro Carvalho Chehabfile metadata. In case of errors, the filesystem would fix the errors
933d0c60d0SMauro Carvalho Chehaband report the problems it fixed in the kernel log. As a precautionary measure,
943d0c60d0SMauro Carvalho Chehabthe inode must first be checked for errors before performing a final fix.
953d0c60d0SMauro Carvalho Chehab
963d0c60d0SMauro Carvalho ChehabThe inode and the result history will be maintained temporarily in a
973d0c60d0SMauro Carvalho Chehabsmall linked list buffer which would contain the last (N) inodes
983d0c60d0SMauro Carvalho Chehabfixed/checked, the detailed errors which were fixed/checked are printed in the
993d0c60d0SMauro Carvalho Chehabkernel log.
100