[Ocfs2-tools-devel] Several problems I found in fsck.ocfs2 when checking symlink file. Need your suggestions.

tao.ma tao.ma at oracle.com
Wed Oct 18 02:30:59 PDT 2006


During my implementation of fswreck to corrupt errors of symlink, I 
found follow problems which exist in current fsck.ocfs2. I am not sure 
how to patch it. So any of your suggestion is appreciated.

The most severe one:
A normal symlink will cause fsck.ocfs2 to create error 'LINK_BLOCKS'.
For example:
mkfs.ocfs2 -b 512 -C 4k -N 4 /dev/sdb1  
mount /dev/sdb1
ln -s 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
aa  
after running fsck.ocfs2, the error 'LINK_BLOCKS' will be created.
The reason is that:
When the link name is longer than the blocksize, one cluster will be 
allocated to this file.
So as fsck.ocfs2 runs, o2fsck_check_blocks calls 
ocfs2_block_iterate_inode to iterate the whole cluster and add 
vb.vb_num_block correspondingly. As for symlink file it will be equal to 
block_per_cluster. While in check_link_data, the 'expected' block is 
calculated according to the length of link name. So in this example, the 
link name don't occupy the whole cluster, and fsck.ocfs2 think it is wrong.
I have no idea of how to correct this type of error. Just test if 
expected <= cluster * block_per_cluster? Is it enough?

A normal problem:
When we meet with some error in check_link_data and want to clear the 
file, currently the solution is not good. Only i_links_count is set to 0 
and actually this doesn't remove the inode. So the next time when we use 
fsck.ocfs2, this problem will happen.
You can also refer to the comments of the source code of clearing.
/*
 * XXX we should have a helper that clears an inode and backs it out of
 * any book-keeping that it might have been included in, as though it
 * was never seen.  the alternative is to restart pass1 which seems
 * goofy.
 */
I propose to remove the valid flag of this file(And actually it should 
do this from the manpage of fsck.ocfs2). The same problem happens to 
error 'DIR_ZERO' as you can see from the source code.

A minor problem:
In function o2fsck_check_blocks, when it met with a symlink file and 
i_clusters==0, it will go out without checking the extents.
While in check_link_data, it check the error of LINK_FAST_DATA which has 
i_cluster==0 as a prerequisite, so this should never happens.
So I propose to remove this check.






More information about the Ocfs2-tools-devel mailing list