* [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal
@ 2018-11-16 8:58 Junxiao Bi
2018-11-19 1:32 ` piaojun
2018-11-19 2:28 ` jiangyiwen
0 siblings, 2 replies; 5+ messages in thread
From: Junxiao Bi @ 2018-11-16 8:58 UTC (permalink / raw)
To: ocfs2-devel
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 <junxiao.bi@oracle.com>
---
fs/ocfs2/journal.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index b63c97f4318e..25d678c92fbb 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -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 */
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal
2018-11-16 8:58 [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal Junxiao Bi
@ 2018-11-19 1:32 ` piaojun
2018-11-19 1:45 ` Junxiao Bi
2018-11-19 2:28 ` jiangyiwen
1 sibling, 1 reply; 5+ messages in thread
From: piaojun @ 2018-11-19 1:32 UTC (permalink / raw)
To: ocfs2-devel
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
On 2018/11/16 16:58, Junxiao Bi wrote:
> 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 <junxiao.bi@oracle.com>
> ---
> fs/ocfs2/journal.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index b63c97f4318e..25d678c92fbb 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -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 */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal
2018-11-19 1:32 ` piaojun
@ 2018-11-19 1:45 ` Junxiao Bi
0 siblings, 0 replies; 5+ messages in thread
From: Junxiao Bi @ 2018-11-19 1:45 UTC (permalink / raw)
To: ocfs2-devel
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.
On 11/19/18 9:32 AM, piaojun wrote:
> 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
>
> On 2018/11/16 16:58, Junxiao Bi wrote:
>> 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 <junxiao.bi@oracle.com>
>> ---
>> fs/ocfs2/journal.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
>> index b63c97f4318e..25d678c92fbb 100644
>> --- a/fs/ocfs2/journal.c
>> +++ b/fs/ocfs2/journal.c
>> @@ -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 */
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal
2018-11-16 8:58 [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal Junxiao Bi
2018-11-19 1:32 ` piaojun
@ 2018-11-19 2:28 ` jiangyiwen
2018-11-19 2:43 ` Junxiao Bi
1 sibling, 1 reply; 5+ messages in thread
From: jiangyiwen @ 2018-11-19 2:28 UTC (permalink / raw)
To: ocfs2-devel
On 2018/11/16 16:58, Junxiao Bi wrote:
> 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 <junxiao.bi@oracle.com>
> ---
> fs/ocfs2/journal.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index b63c97f4318e..25d678c92fbb 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -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.
> 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 */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal
2018-11-19 2:28 ` jiangyiwen
@ 2018-11-19 2:43 ` Junxiao Bi
0 siblings, 0 replies; 5+ messages in thread
From: Junxiao Bi @ 2018-11-19 2:43 UTC (permalink / raw)
To: ocfs2-devel
On 11/19/18 10:28 AM, jiangyiwen wrote:
> On 2018/11/16 16:58, Junxiao Bi wrote:
>> 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 <junxiao.bi@oracle.com>
>> ---
>> fs/ocfs2/journal.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
>> index b63c97f4318e..25d678c92fbb 100644
>> --- a/fs/ocfs2/journal.c
>> +++ b/fs/ocfs2/journal.c
>> @@ -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 ?
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.
>
> Thanks.
> Yiwen.
>
>> 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 */
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-11-19 2:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-16 8:58 [Ocfs2-devel] [PATCH] ocfs2: clear journal dirty flag after shutdown journal Junxiao Bi
2018-11-19 1:32 ` piaojun
2018-11-19 1:45 ` Junxiao Bi
2018-11-19 2:28 ` jiangyiwen
2018-11-19 2:43 ` Junxiao Bi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).