@@ -364,10 +364,10 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
364
364
365
365
* xe = __find_xattr (cur_addr , last_txattr_addr , NULL , index , len , name );
366
366
if (!* xe ) {
367
- f2fs_err (F2FS_I_SB (inode ), "inode (%lu) has corrupted xattr" ,
367
+ f2fs_err (F2FS_I_SB (inode ), "lookup inode (%lu) has corrupted xattr" ,
368
368
inode -> i_ino );
369
369
set_sbi_flag (F2FS_I_SB (inode ), SBI_NEED_FSCK );
370
- err = - EFSCORRUPTED ;
370
+ err = - ENODATA ;
371
371
f2fs_handle_error (F2FS_I_SB (inode ),
372
372
ERROR_CORRUPTED_XATTR );
373
373
goto out ;
@@ -584,13 +584,12 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
584
584
585
585
if ((void * )(entry ) + sizeof (__u32 ) > last_base_addr ||
586
586
(void * )XATTR_NEXT_ENTRY (entry ) > last_base_addr ) {
587
- f2fs_err (F2FS_I_SB (inode ), "inode (%lu) has corrupted xattr" ,
587
+ f2fs_err (F2FS_I_SB (inode ), "list inode (%lu) has corrupted xattr" ,
588
588
inode -> i_ino );
589
589
set_sbi_flag (F2FS_I_SB (inode ), SBI_NEED_FSCK );
590
- error = - EFSCORRUPTED ;
591
590
f2fs_handle_error (F2FS_I_SB (inode ),
592
591
ERROR_CORRUPTED_XATTR );
593
- goto cleanup ;
592
+ break ;
594
593
}
595
594
596
595
if (!prefix )
@@ -650,7 +649,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
650
649
651
650
if (size > MAX_VALUE_LEN (inode ))
652
651
return - E2BIG ;
653
-
652
+ retry :
654
653
error = read_all_xattrs (inode , ipage , & base_addr );
655
654
if (error )
656
655
return error ;
@@ -660,7 +659,14 @@ static int __f2fs_setxattr(struct inode *inode, int index,
660
659
/* find entry with wanted name. */
661
660
here = __find_xattr (base_addr , last_base_addr , NULL , index , len , name );
662
661
if (!here ) {
663
- f2fs_err (F2FS_I_SB (inode ), "inode (%lu) has corrupted xattr" ,
662
+ if (!F2FS_I (inode )-> i_xattr_nid ) {
663
+ f2fs_notice (F2FS_I_SB (inode ),
664
+ "recover xattr in inode (%lu)" , inode -> i_ino );
665
+ f2fs_recover_xattr_data (inode , NULL );
666
+ kfree (base_addr );
667
+ goto retry ;
668
+ }
669
+ f2fs_err (F2FS_I_SB (inode ), "set inode (%lu) has corrupted xattr" ,
664
670
inode -> i_ino );
665
671
set_sbi_flag (F2FS_I_SB (inode ), SBI_NEED_FSCK );
666
672
error = - EFSCORRUPTED ;
0 commit comments