@@ -364,10 +364,10 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
364364
365365 * xe = __find_xattr (cur_addr , last_txattr_addr , NULL , index , len , name );
366366 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" ,
368368 inode -> i_ino );
369369 set_sbi_flag (F2FS_I_SB (inode ), SBI_NEED_FSCK );
370- err = - EFSCORRUPTED ;
370+ err = - ENODATA ;
371371 f2fs_handle_error (F2FS_I_SB (inode ),
372372 ERROR_CORRUPTED_XATTR );
373373 goto out ;
@@ -584,13 +584,12 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
584584
585585 if ((void * )(entry ) + sizeof (__u32 ) > last_base_addr ||
586586 (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" ,
588588 inode -> i_ino );
589589 set_sbi_flag (F2FS_I_SB (inode ), SBI_NEED_FSCK );
590- error = - EFSCORRUPTED ;
591590 f2fs_handle_error (F2FS_I_SB (inode ),
592591 ERROR_CORRUPTED_XATTR );
593- goto cleanup ;
592+ break ;
594593 }
595594
596595 if (!prefix )
@@ -650,7 +649,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
650649
651650 if (size > MAX_VALUE_LEN (inode ))
652651 return - E2BIG ;
653-
652+ retry :
654653 error = read_all_xattrs (inode , ipage , & base_addr );
655654 if (error )
656655 return error ;
@@ -660,7 +659,14 @@ static int __f2fs_setxattr(struct inode *inode, int index,
660659 /* find entry with wanted name. */
661660 here = __find_xattr (base_addr , last_base_addr , NULL , index , len , name );
662661 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" ,
664670 inode -> i_ino );
665671 set_sbi_flag (F2FS_I_SB (inode ), SBI_NEED_FSCK );
666672 error = - EFSCORRUPTED ;
0 commit comments