2023-12-13 01:51:36

by Zhihao Cheng

[permalink] [raw]
Subject: [PATCH v2 0/5] jbd2: Add errseq to detect writeback

According to discussions in [1], this patchset adds errseq in journal to
enable JDB2 detecting meatadata writeback error of fs dev. Then, orginal
checking mechanism could be removed.

[1] https://lore.kernel.org/all/[email protected]/T/

v1->v2:
Fix some misspelling words.
Patch 1: "fallen on" -> "written to"
Patch 4: "can detects" -> "can detect"

Zhihao Cheng (5):
jbd2: Add errseq to detect client fs's bdev writeback error
jbd2: Replace journal state flag by checking errseq
jbd2: Remove unused 'JBD2_CHECKPOINT_IO_ERROR' and 'j_atomic_flags'
jbd2: Abort journal when detecting metadata writeback error of fs dev
ext4: Move ext4_check_bdev_write_error() into nojournal mode

fs/ext4/ext4_jbd2.c | 5 ++---
fs/jbd2/checkpoint.c | 11 -----------
fs/jbd2/journal.c | 11 ++++++-----
fs/jbd2/recovery.c | 7 +------
fs/jbd2/transaction.c | 14 ++++++++++++++
include/linux/jbd2.h | 37 ++++++++++++++++++++++++++-----------
6 files changed, 49 insertions(+), 36 deletions(-)

--
2.39.2



2023-12-13 01:52:28

by Zhihao Cheng

[permalink] [raw]
Subject: [PATCH v2 2/5] jbd2: Replace journal state flag by checking errseq

Now JBD2 detects metadata writeback error of fs dev according to errseq.
Replace journal state flag by checking errseq.

Signed-off-by: Zhihao Cheng <[email protected]>
Suggested-by: Jan Kara <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
fs/jbd2/journal.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 559938a82379..b6c114c11b97 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1862,7 +1862,7 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,

if (is_journal_aborted(journal))
return -EIO;
- if (test_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags)) {
+ if (jbd2_check_fs_dev_write_error(journal)) {
jbd2_journal_abort(journal, -EIO);
return -EIO;
}
@@ -2160,12 +2160,12 @@ int jbd2_journal_destroy(journal_t *journal)

/*
* OK, all checkpoint transactions have been checked, now check the
- * write out io error flag and abort the journal if some buffer failed
- * to write back to the original location, otherwise the filesystem
- * may become inconsistent.
+ * writeback errseq of fs dev and abort the journal if some buffer
+ * failed to write back to the original location, otherwise the
+ * filesystem may become inconsistent.
*/
if (!is_journal_aborted(journal) &&
- test_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags))
+ jbd2_check_fs_dev_write_error(journal))
jbd2_journal_abort(journal, -EIO);

if (journal->j_sb_buffer) {
--
2.39.2


2023-12-13 01:55:37

by Zhihao Cheng

[permalink] [raw]
Subject: [PATCH v2 3/5] jbd2: Remove unused 'JBD2_CHECKPOINT_IO_ERROR' and 'j_atomic_flags'

Since 'JBD2_CHECKPOINT_IO_ERROR' and j_atomic_flags' are not useful
anymore after fs dev's errseq is imported into jbd2, just remove them.

Signed-off-by: Zhihao Cheng <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
fs/jbd2/checkpoint.c | 11 -----------
include/linux/jbd2.h | 11 -----------
2 files changed, 22 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 118699fff2f9..1c97e64c4784 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -556,7 +556,6 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
struct transaction_chp_stats_s *stats;
transaction_t *transaction;
journal_t *journal;
- struct buffer_head *bh = jh2bh(jh);

JBUFFER_TRACE(jh, "entry");

@@ -569,16 +568,6 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)

JBUFFER_TRACE(jh, "removing from transaction");

- /*
- * If we have failed to write the buffer out to disk, the filesystem
- * may become inconsistent. We cannot abort the journal here since
- * we hold j_list_lock and we have to be careful about races with
- * jbd2_journal_destroy(). So mark the writeback IO error in the
- * journal here and we abort the journal later from a better context.
- */
- if (buffer_write_io_error(bh))
- set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags);
-
__buffer_unlink(jh);
jh->b_cp_transaction = NULL;
percpu_counter_dec(&journal->j_checkpoint_jh_count);
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index cea1aa70ae36..971f3e826e15 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -755,11 +755,6 @@ struct journal_s
*/
unsigned long j_flags;

- /**
- * @j_atomic_flags: Atomic journaling state flags.
- */
- unsigned long j_atomic_flags;
-
/**
* @j_errno:
*
@@ -1406,12 +1401,6 @@ JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
#define JBD2_JOURNAL_FLUSH_VALID (JBD2_JOURNAL_FLUSH_DISCARD | \
JBD2_JOURNAL_FLUSH_ZEROOUT)

-/*
- * Journal atomic flag definitions
- */
-#define JBD2_CHECKPOINT_IO_ERROR 0x001 /* Detect io error while writing
- * buffer back to disk */
-
/*
* Function declarations for the journaling transaction and buffer
* management
--
2.39.2


2024-01-09 02:55:05

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH v2 0/5] jbd2: Add errseq to detect writeback


On Wed, 13 Dec 2023 09:32:19 +0800, Zhihao Cheng wrote:
> According to discussions in [1], this patchset adds errseq in journal to
> enable JDB2 detecting meatadata writeback error of fs dev. Then, orginal
> checking mechanism could be removed.
>
> [1] https://lore.kernel.org/all/[email protected]/T/
>
> v1->v2:
> Fix some misspelling words.
> Patch 1: "fallen on" -> "written to"
> Patch 4: "can detects" -> "can detect"
>
> [...]

Applied, thanks!

[1/5] jbd2: Add errseq to detect client fs's bdev writeback error
commit: 990b6b5b13b7993b7f44740c0add3119d407ccbf
[2/5] jbd2: Replace journal state flag by checking errseq
commit: 62ec1707cb071c95706d1bab85fbee8d5a3d2f24
[3/5] jbd2: Remove unused 'JBD2_CHECKPOINT_IO_ERROR' and 'j_atomic_flags'
commit: 8a4fd33d879fb303b207f06ea6340d73f698c4ed
[4/5] jbd2: Abort journal when detecting metadata writeback error of fs dev
commit: b4e73e61268903d82dacff2bc6f4bb766c6ed555
[5/5] ext4: Move ext4_check_bdev_write_error() into nojournal mode
commit: ada3fb86a3f3aea40903d5ad9aeec708dc049b8b

Best regards,
--
Theodore Ts'o <[email protected]>