<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    According to the call trace, umount hangs because
    ocfs2_commit_thread<br>
    can't exit. So I think we'd better put the logic into
    ocfs2_commit_thread,<br>
    which can be align with kthread_should_stop to identify the case.<br>
    <br>
    Thanks,<br>
    Joseph<br>
    <br>
    <div class="moz-cite-prefix">On 17/1/7 20:01, Gechangwei wrote:<br>
    </div>
    <blockquote
cite="mid:63ADC13FD55D6546B7DECE290D39E37342E739A1@H3CMLB12-EX.srv.huawei-3com.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Hi,</p>
      <p>When journal flushing in ocfs2_commit_cache() fails, following
        umount procedure at stage of shutting journal may be blocked due
        to non-zero transactions number.</p>
      <p>Once jbd2_journal_flush() fails, the journal will be marked as
        ABORT state inner JBD2. There is no way to come back afterwards.</p>
      <p>So there is no chance to set transactions number to zero, thus,
        shutting journal may be blocked .<br>
      </p>
      <p><br>
      </p>
      <p>ocfs2_commit_thread()<br>
      </p>
      <p>    ocfs2_commit_cache()</p>
      <p>        jbd2_journal_flush() -&gt; failure takes journal into
        ABORT state, thus, transaction number will never set to zero<br>
      </p>
      <p><br>
      </p>
      <p>The back trace is cited blow:</p>
      <p>[&lt;ffffffff8109de0c&gt;] kthread_stop+0x4c/0x150<br>
        [&lt;ffffffffc056a887&gt;] ocfs2_journal_shutdown+0xa7/0x400
        [ocfs2]<br>
        [&lt;ffffffffc059fbde&gt;] ocfs2_dismount_volume+0xbe/0x4a0
        [ocfs2]<br>
        [&lt;ffffffffc059fff7&gt;] ocfs2_put_super+0x37/0xb0 [ocfs2]<br>
        [&lt;ffffffff8120534e&gt;] generic_shutdown_super+0x7e/0x110<br>
        [&lt;ffffffff81205410&gt;] kill_block_super+0x30/0x80<br>
        [&lt;ffffffff81205669&gt;] deactivate_locked_super+0x59/0x90<br>
        [&lt;ffffffff812062ee&gt;] deactivate_super+0x4e/0x70<br>
        [&lt;ffffffff81222423&gt;] cleanup_mnt+0x43/0x90<br>
        [&lt;ffffffff812224c2&gt;] __cleanup_mnt+0x12/0x20<br>
        [&lt;ffffffff8109c247&gt;] task_work_run+0xb7/0xf0<br>
        [&lt;ffffffff81016f7c&gt;] do_notify_resume+0x8c/0xa0<br>
        [&lt;ffffffff817f8384&gt;] int_signal+0x12/0x17<br>
        [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff</p>
      <p>Through crash debug tool, It can seen that j_num_trans field is
        set to 2.<br>
      </p>
      <p>struct ocfs2_journal {<br>
          j_state = OCFS2_JOURNAL_IN_SHUTDOWN, <br>
          j_journal = 0xffff8800b4926000, <br>
          j_inode = 0xffff880122aba298, <br>
          j_osb = 0xffff880093caa000, <br>
          j_bh = 0xffff8800a09df888, <br>
          j_num_trans = {<br>
            counter = 0x2<br>
          }, <br>
          j_lock = {<br>
            {<br>
              rlock = {<br>
                raw_lock = {<br>
                  {</p>
      <p><br>
      </p>
      <p>To solve this issue, I propose a patch. Any comments will be
        welcomed.</p>
      <p>Since journal has been marked as ABORT and flushing journal
        failure will free all corresponding buffer heads, it will be
        safe to directly set transactions number to zero.<br>
      </p>
      <p><br>
      </p>
      <p>From 98f42f5f52851ed84eb372a3e09a413a30ea2664 Mon Sep 17
        00:00:00 2001<br>
        From: gechangwei <a moz-do-not-send="true"
          class="moz-txt-link-rfc2396E"
          href="mailto:ge.changwei@h3c.com">
          &lt;ge.changwei@h3c.com&gt;</a><br>
        Date: Sat, 7 Jan 2017 19:48:13 +0800<br>
        Subject: [PATCH] fix umount hang after flushing journal failure<br>
        <br>
        Signed-off-by: gechangwei <a moz-do-not-send="true"
          class="moz-txt-link-rfc2396E"
          href="mailto:ge.changwei@h3c.com">
          &lt;ge.changwei@h3c.com&gt;</a><br>
        ---<br>
         fs/ocfs2/journal.c | 1 +<br>
         1 file changed, 1 insertion(+)<br>
        <br>
        diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c<br>
        index a244f14..dab2094 100644<br>
        --- a/fs/ocfs2/journal.c<br>
        +++ b/fs/ocfs2/journal.c<br>
        @@ -326,6 +326,7 @@ static int ocfs2_commit_cache(struct
        ocfs2_super *osb)<br>
             status = jbd2_journal_flush(journal-&gt;j_journal);<br>
             jbd2_journal_unlock_updates(journal-&gt;j_journal);<br>
             if (status &lt; 0) {<br>
        +        atomic_set(&amp;journal-&gt;j_num_trans, 0);<br>
                 up_write(&amp;journal-&gt;j_trans_barrier);<br>
                 mlog_errno(status);<br>
                 goto finally;<br>
        -- <br>
        2.5.1.windows.1<br>
        <br>
      </p>
      <p><br>
      </p>
      <span style="font-size:7.5pt;font-family:华文细黑;color:gray"><span
          lang="EN-US">-------------------------------------------------------------------------------------------------------------------------------------<br>
        </span>本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出<span
          lang="EN-US"><br>
        </span>的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、<span
          lang="EN-US"><br>
        </span>或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本<span
          lang="EN-US"><br>
        </span>邮件!<span lang="EN-US"><br>
        </span></span><span
style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:gray"
        lang="EN-US">This e-mail and its attachments contain
        confidential information from H3C, which is
        <br>
        intended only for the person or entity whose address is listed
        above. Any use of the
        <br>
        information contained herein in any way (including, but not
        limited to, total or partial
        <br>
        disclosure, reproduction, or dissemination) by persons other
        than the intended <br>
        recipient(s) is prohibited. If you receive this e-mail in error,
        please notify the sender
        <br>
        by phone or email immediately and delete it!</span>
    </blockquote>
    <br>
  </body>
</html>