Skip to content

Commit 8bb5676

Browse files
Ye Bingregkh
Ye Bin
authored andcommitted
ext4: fix symlink file size not match to file content
commit a2b0b20 upstream. We got issue as follows: [home]# fsck.ext4 -fn ram0yb e2fsck 1.45.6 (20-Mar-2020) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Symlink /p3/d14/d1a/l3d (inode #3494) is invalid. Clear? no Entry 'l3d' in /p3/d14/d1a (3383) has an incorrect filetype (was 7, should be 0). Fix? no As the symlink file size does not match the file content. If the writeback of the symlink data block failed, ext4_finish_bio() handles the end of IO. However this function fails to mark the buffer with BH_write_io_error and so when unmount does journal checkpoint it cannot detect the writeback error and will cleanup the journal. Thus we've lost the correct data in the journal area. To solve this issue, mark the buffer as BH_write_io_error in ext4_finish_bio(). Cc: [email protected] Signed-off-by: Ye Bin <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ba50ea4 commit 8bb5676

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/ext4/page-io.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ static void ext4_finish_bio(struct bio *bio)
134134
continue;
135135
}
136136
clear_buffer_async_write(bh);
137-
if (bio->bi_status)
137+
if (bio->bi_status) {
138+
set_buffer_write_io_error(bh);
138139
buffer_io_error(bh);
140+
}
139141
} while ((bh = bh->b_this_page) != head);
140142
spin_unlock_irqrestore(&head->b_uptodate_lock, flags);
141143
if (!under_io) {

0 commit comments

Comments
 (0)