All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next v2] ext4: Fix symlink file size not match to file content
@ 2022-03-21 14:44 Ye Bin
  2022-03-31 14:51 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Ye Bin @ 2022-03-21 14:44 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-ext4; +Cc: linux-kernel, jack, lczerner, Ye Bin

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().

Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/page-io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 495ce59fb4ad..14695e2b5042 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -134,8 +134,10 @@ static void ext4_finish_bio(struct bio *bio)
 				continue;
 			}
 			clear_buffer_async_write(bh);
-			if (bio->bi_status)
+			if (bio->bi_status) {
+				set_buffer_write_io_error(bh);
 				buffer_io_error(bh);
+			}
 		} while ((bh = bh->b_this_page) != head);
 		spin_unlock_irqrestore(&head->b_uptodate_lock, flags);
 		if (!under_io) {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next v2] ext4: Fix symlink file size not match to file content
  2022-03-21 14:44 [PATCH -next v2] ext4: Fix symlink file size not match to file content Ye Bin
@ 2022-03-31 14:51 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2022-03-31 14:51 UTC (permalink / raw)
  To: adilger.kernel, linux-ext4, Ye Bin
  Cc: Theodore Ts'o, jack, linux-kernel, lczerner

On Mon, 21 Mar 2022 22:44:38 +0800, Ye Bin wrote:
> 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
> 
> [...]

Applied, thanks!

[1/1] ext4: Fix symlink file size not match to file content
      commit: 0f0b8dbeb99a74259062597fd669208e3500792c

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-31 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 14:44 [PATCH -next v2] ext4: Fix symlink file size not match to file content Ye Bin
2022-03-31 14:51 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.