ocfs2: clear journal dirty flag after shutdown journal
PATCH 1/1 ocfs2: clear journal dirty flag after shutdown journal
Dirty flag of the journal should be cleared at the last stage of umount, if do it before jbd2_journal_destroy(), then some metadata in uncommitted transaction could be lost due to io error, but as dirty flag of journal was already cleared, we can't find that until run a full fsck. This may cause system panic or other corruption.
--- fs/ocfs2/journal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ocfs2/journal.c +4 -4
@@ -1017,6 +1017,10 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } +/* Shutdown the kernel journal system */ +jbd2_journal_destroy (journal->j_journal); + journal->j_journal =NULL ; +if (status ==0 ) {/* * Do not toggle if flush was unsuccessful otherwise
@@ -1027,10 +1031,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } -/* Shutdown the kernel journal system */ -jbd2_journal_destroy (journal->j_journal); - journal->j_journal =NULL ; -OCFS2_I (inode)->ip_open_count--;/* unlock our journal */
Signature · 1 line
2.17.1
PATCH 1/1 ocfs2: clear journal dirty flag after shutdown journal
Hi Junxiao,
I'm very interested in this bug, and it seems causing read-only if involving metadata. Could you help show how to reproduce this problem?
Thanks,
Jun
Quoted 38 lines · Junxiao Bi
Dirty flag of the journal should be cleared at the last stage of umount, if do it before
jbd2_journal_destroy(), then some metadata in uncommitted transaction could be lost due to io error, but as dirty flag of journal was already cleared, we can't find that until run a full fsck. This may cause system panic or other corruption.Signed-off-by Junxiao Bi <[email protected]>--- fs/ocfs2/journal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/ocfs2/journal.c +4
-4@@ -1017,6 +1017,10 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } +/* Shutdown the kernel journal system */ +jbd2_journal_destroy (journal->j_journal); + journal->j_journal =NULL ; +if (status ==0 ) {/* * Do not toggle if flush was unsuccessful otherwise @@ -1027,10 +1031,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } -/* Shutdown the kernel journal system */ -jbd2_journal_destroy (journal->j_journal); - journal->j_journal =NULL ; -OCFS2_I (inode)->ip_open_count--;/* unlock our journal */
PATCH 1/1 ocfs2: clear journal dirty flag after shutdown journal
Hi Jun,
ocfs2_journal_shutdown() was only invoked during umount, jbd2 will force all uncommitted metadata to disk, there is no set fs readonly for io error in that case. To reproduce, you need cause storage return io error between ocfs2_journal_toggle_dirty() and jbd2_journal_destroy().
1020 if (status == 0) {
1021 /*
1022 * Do not toggle if flush was unsuccessful otherwise 1023 * will leave dirty metadata in a "clean" journal 1024 */
1025 status = ocfs2_journal_toggle_dirty(osb, 0, 0);
1026 if (status < 0)
1027 mlog_errno(status);
1028 }
1029
1030 /* Shutdown the kernel journal system */
1031 jbd2_journal_destroy(journal->j_journal);
Thanks,
Junxiao.
Quoted 47 lines · piaojun
Hi Junxiao,
I'm very interested in this bug, and it seems causing read-only if involving metadata. Could you help show how to reproduce this problem?
Thanks,
JunQuoted 38 lines · Junxiao Bi
Dirty flag of the journal should be cleared at the last stage of umount, if do it before
jbd2_journal_destroy(), then some metadata in uncommitted transaction could be lost due to io error, but as dirty flag of journal was already cleared, we can't find that until run a full fsck. This may cause system panic or other corruption.Signed-off-by Junxiao Bi <[email protected]>--- fs/ocfs2/journal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/ocfs2/journal.c +4
-4@@ -1017,6 +1017,10 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } +/* Shutdown the kernel journal system */ +jbd2_journal_destroy (journal->j_journal); + journal->j_journal =NULL ; +if (status ==0 ) {/* * Do not toggle if flush was unsuccessful otherwise @@ -1027,10 +1031,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } -/* Shutdown the kernel journal system */ -jbd2_journal_destroy (journal->j_journal); - journal->j_journal =NULL ; -OCFS2_I (inode)->ip_open_count--;/* unlock our journal */
PATCH 1/1 ocfs2: clear journal dirty flag after shutdown journal
In reply to Junxiao BiQuoted 16 lines · Junxiao Bi
Dirty flag of the journal should be cleared at the last stage of umount, if do it before
jbd2_journal_destroy(), then some metadata in uncommitted transaction could be lost due to io error, but as dirty flag of journal was already cleared, we can't find that until run a full fsck. This may cause system panic or other corruption.Signed-off-by Junxiao Bi <[email protected]>--- fs/ocfs2/journal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/ocfs2/journal.c +0
-0
fs/ocfs2/journal.c void ocfs2_journal_shutdown(struct ocfs2_super *osb) · line 1023
Quoted 7 lines
fs/ocfs2/journal.c +4
-0@@ -1017,6 +1017,10 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } +/* Shutdown the kernel journal system */ +jbd2_journal_destroy (journal->j_journal); + journal->j_journal =NULL ; +
Hi Junxiao,
I feel this adjustment doesn't make any sense. When jbd2_journal_destroy() is done, it still call ocfs2_journal_toggle_dirty() to clean dirty flag. Am I wrong or understand error ?
Thanks.
Yiwen.
Quoted 15 lines
fs/ocfs2/journal.c +0
-4if (status ==0 ) {/* * Do not toggle if flush was unsuccessful otherwise @@ -1027,10 +1031,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } -/* Shutdown the kernel journal system */ -jbd2_journal_destroy (journal->j_journal); - journal->j_journal =NULL ; -OCFS2_I (inode)->ip_open_count--;/* unlock our journal */
PATCH 1/1 ocfs2: clear journal dirty flag after shutdown journal
Quoted 26 lines · jiangyiwen
Quoted 16 lines · Junxiao Bi
Dirty flag of the journal should be cleared at the last stage of umount, if do it before
jbd2_journal_destroy(), then some metadata in uncommitted transaction could be lost due to io error, but as dirty flag of journal was already cleared, we can't find that until run a full fsck. This may cause system panic or other corruption.Signed-off-by Junxiao Bi <[email protected]>--- fs/ocfs2/journal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/ocfs2/journal.c +0
-0fs/ocfs2/journal.c void ocfs2_journal_shutdown(struct ocfs2_super *osb) · line 1023
Quoted 7 lines
fs/ocfs2/journal.c +4
-0@@ -1017,6 +1017,10 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } +/* Shutdown the kernel journal system */ +jbd2_journal_destroy (journal->j_journal); + journal->j_journal =NULL ; +Hi Junxiao,
Quoted 3 lines
I feel this adjustment doesn't make any sense. When
jbd2_journal_destroy()is done, it still callocfs2_journal_toggle_dirty()to clean dirty flag. Am I wrong or understand error ?
Oh, missed checking the return value of jbd2_journal_destroy(), if failed, should not call ocfs2_journal_toggle_dirty(). Thanks for pointing this.
Thanks,
Junxiao.
Quoted 20 lines
Thanks.
Yiwen.Quoted 15 lines
fs/ocfs2/journal.c +0
-4if (status ==0 ) {/* * Do not toggle if flush was unsuccessful otherwise @@ -1027,10 +1031,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)mlog_errno (status); } -/* Shutdown the kernel journal system */ -jbd2_journal_destroy (journal->j_journal); - journal->j_journal =NULL ; -OCFS2_I (inode)->ip_open_count--;/* unlock our journal */