public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: libaokun@huaweicloud.com
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
	linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
	yangerkun@huawei.com, libaokun@huaweicloud.com,
	Baokun Li <libaokun1@huawei.com>
Subject: [PATCH 3/5] ext4: abort journal on data writeback failure if in data_err=abort mode
Date: Fri, 20 Dec 2024 14:07:55 +0800	[thread overview]
Message-ID: <20241220060757.1781418-4-libaokun@huaweicloud.com> (raw)
In-Reply-To: <20241220060757.1781418-1-libaokun@huaweicloud.com>

From: Baokun Li <libaokun1@huawei.com>

If we mount an ext4 fs with data_err=abort option, it should abort on
file data write error. But if the extent is unwritten, we won't add a
JI_WAIT_DATA bit to the inode, so jbd2 won't wait for the inode's data
to be written back and check the inode mapping for errors. The data
writeback failures are not sensed unless the log is watched or fsync
is called.

Therefore, when data_err=abort is enabled, the journal is aborted when
an I/O error is detected in ext4_end_io_end() to make users who are
concerned about the contents of the file happy.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 fs/ext4/page-io.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 6054ec27fb48..058bf4660d7b 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -175,6 +175,7 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
 {
 	struct inode *inode = io_end->inode;
 	handle_t *handle = io_end->handle;
+	struct super_block *sb = inode->i_sb;
 	int ret = 0;
 
 	ext4_debug("ext4_end_io_nolock: io_end 0x%p from inode %lu,list->next 0x%p,"
@@ -190,11 +191,15 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
 		ret = -EIO;
 		if (handle)
 			jbd2_journal_free_reserved(handle);
+		if (test_opt(sb, DATA_ERR_ABORT) &&
+		    !ext4_is_quota_file(inode) &&
+		    ext4_should_order_data(inode))
+			jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret);
 	} else {
 		ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
 	}
-	if (ret < 0 && !ext4_forced_shutdown(inode->i_sb)) {
-		ext4_msg(inode->i_sb, KERN_EMERG,
+	if (ret < 0 && !ext4_forced_shutdown(sb)) {
+		ext4_msg(sb, KERN_EMERG,
 			 "failed to convert unwritten extents to written "
 			 "extents -- potential data loss!  "
 			 "(inode %lu, error %d)", inode->i_ino, ret);
-- 
2.46.1


  parent reply	other threads:[~2024-12-20  6:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20  6:07 [PATCH 0/5] ext4: fix issues caused by data write-back failures libaokun
2024-12-20  6:07 ` [PATCH 1/5] ext4: replace opencoded ext4_end_io_end() in ext4_put_io_end() libaokun
2024-12-20 10:22   ` Markus Elfring
2024-12-20 10:26   ` Jan Kara
2024-12-20  6:07 ` [PATCH 2/5] ext4: do not convert the unwritten extents if data writeback fails libaokun
2024-12-20 10:28   ` Jan Kara
2024-12-20  6:07 ` libaokun [this message]
2024-12-20 10:36   ` [PATCH 3/5] ext4: abort journal on data writeback failure if in data_err=abort mode Jan Kara
2024-12-20 13:39     ` Baokun Li
2025-01-06 14:32       ` Jan Kara
2025-01-08  3:43         ` Baokun Li
2025-01-08 13:43           ` Jan Kara
2025-01-08 14:44             ` Baokun Li
2025-01-08 15:28               ` Jan Kara
2025-01-09  2:45                 ` Baokun Li
2024-12-20  6:07 ` [PATCH 4/5] ext4: remove unused member 'i_unwritten' from 'ext4_inode_info' libaokun
2024-12-20 11:05   ` Jan Kara
2024-12-20  6:07 ` [PATCH 5/5] ext4: pack holes in ext4_inode_info libaokun
2024-12-20 11:06   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220060757.1781418-4-libaokun@huaweicloud.com \
    --to=libaokun@huaweicloud.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=libaokun1@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox