f2fs: set SBI_NEED_FSCK for xattr corruption case

If xattr is corrupted, let's print kernel message and set SBI_NEED_FSCK
for further repair.

Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Chao Yu 2019-06-20 11:36:15 +08:00 коммит произвёл Jaegeuk Kim
Родитель 10f966bbf5
Коммит c83414aedf
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -346,6 +346,9 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
*xe = __find_xattr(cur_addr, last_txattr_addr, index, len, name); *xe = __find_xattr(cur_addr, last_txattr_addr, index, len, name);
if (!*xe) { if (!*xe) {
f2fs_err(F2FS_I_SB(inode), "inode (%lu) has corrupted xattr",
inode->i_ino);
set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK);
err = -EFSCORRUPTED; err = -EFSCORRUPTED;
goto out; goto out;
} }
@ -622,6 +625,9 @@ static int __f2fs_setxattr(struct inode *inode, int index,
/* find entry with wanted name. */ /* find entry with wanted name. */
here = __find_xattr(base_addr, last_base_addr, index, len, name); here = __find_xattr(base_addr, last_base_addr, index, len, name);
if (!here) { if (!here) {
f2fs_err(F2FS_I_SB(inode), "inode (%lu) has corrupted xattr",
inode->i_ino);
set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto exit; goto exit;
} }