<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>@Gang</p>
    <p>Thank you very much!<br>
    </p>
    <p>I have fixed this issue through upgrading the openmpi.</p>
    <p>I have tested this patch using ocfs2-test. It can work fine.</p>
    <p>@Andrew Please can you help me to summit this patch?<br>
    </p>
    <p><br>
    </p>
    <p>Thanks</p>
    <p>Sunny<br>
    </p>
    <div class="moz-cite-prefix">在 2019/10/24 上午10:02, Gang He 写道:<br>
    </div>
    <blockquote type="cite"
cite="mid:CH2PR18MB320662998E1EC2BA01BA0B88CF6A0@CH2PR18MB3206.namprd18.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:宋体;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:宋体;
        color:black;}
span.tlid-translation
        {mso-style-name:tlid-translation;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US">Hi Sunny,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US">This is a mpi problem in your environment, you
            can look at how to run mpi successfully in your Linux
            distribution.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US">For us, mpi can work normally, e.g. SLES12SP4
            SLE15SP1.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US">Thanks<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US">Gang<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.5pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D"
            lang="EN-US"><o:p> </o:p></span></p>
        <div style="border:none;border-left:solid blue 1.5pt;padding:0cm
          0cm 0cm 4.0pt">
          <div>
            <div style="border:none;border-top:solid #E1E1E1
              1.0pt;padding:3.0pt 0cm 0cm 0cm">
              <p class="MsoNormal"><b><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext"
                    lang="EN-US">From:</span></b><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext"
                  lang="EN-US"> sunnyZhang
                  [<a class="moz-txt-link-freetext" href="mailto:sunny.s.zhang@oracle.com">mailto:sunny.s.zhang@oracle.com</a>]
                  <br>
                  <b>Sent:</b> 2019</span><span
                  style="font-size:11.0pt;color:windowtext">年</span><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext"
                  lang="EN-US">10</span><span
                  style="font-size:11.0pt;color:windowtext">月</span><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext"
                  lang="EN-US">23</span><span
                  style="font-size:11.0pt;color:windowtext">日</span><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:windowtext"
                  lang="EN-US"> 17:15<br>
                  <b>To:</b> Gang He <a class="moz-txt-link-rfc2396E" href="mailto:GHe@suse.com">&lt;GHe@suse.com&gt;</a><br>
                  <b>Subject:</b> Re: [Ocfs2-devel] [PATCH V2 1/2]
                  ocfs2: protect extent tree in the
                  ocfs2_prepare_inode_for_write<o:p></o:p></span></p>
            </div>
          </div>
          <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
          <p><span lang="EN-US">Hi Gang,<o:p></o:p></span></p>
          <p><span lang="EN-US">I try to test these patches using
              ocfs2-test. <o:p></o:p></span></p>
          <p><span lang="EN-US">But there is a error about openmpi. <o:p></o:p></span></p>
          <p><span class="tlid-translation"><span lang="EN">Have you
                ever encountered a similar issue before?</span></span><span
              lang="EN-US"><o:p></o:p></span></p>
          <p><span lang="EN-US">Logs are as following.<o:p></o:p></span></p>
          <p><span lang="EN-US">2019/10/23,17:02:38  [*] Remote Mount
              among nodes ol6u9ext3,zhangsn:<br>
              2019/10/23,17:02:38 
              /home/ocfs2test/bin/ocfs2/bin/remote_mount.py -l
              ocfs2-multi-refcount-tests-x86_64 -m /mnt/ocfs2 -n
              ol6u9ext3,zhangsn<br>
              + /usr/lib64/openmpi/bin/mpirun --allow-run-as-root -mca
              btl tcp,self -mca plm_rsh_agent ssh:rsh -np 2 --host
              ol6u9ext3,zhangsn /home/ocfs2test/bin/ocfs2/bin/command.py
              --mount -l ocfs2-multi-refcount-tests-x86_64 -m /mnt/ocfs2<br>
              2019/10/23,17:02:51  [1] Basic Functional Test,
              CMD:/usr/lib64/openmpi/bin/mpirun -mca plm_rsh_agent
              ssh:rsh -mca btl tcp,self  -np 4 --host ol6u9ext3,zhangsn
              /home/ocfs2test/bin/ocfs2/bin/multi_reflink_test -i 1 -l
              104857600 -n 10 -w /mnt/ocfs2/ocfs2-multi-refcount-tests
              -f<br>
[zhangsn][[58639,1],2][btl_tcp_frag.c:215:mca_btl_tcp_frag_recv]
              mca_btl_tcp_frag_recv: readv failed: Connection reset by
              peer (104)<br>
              [*Round 0 Test Running*]<br>
              Test 1: Multi-nodes basic refcount test.<br>
                *SubTest 1:Prepare original inode
              /mnt/ocfs2/ocfs2-multi-refcount-tests/multi_original_basic_refile.<br>
              create file
              /mnt/ocfs2/ocfs2-multi-refcount-tests/multi_original_basic_refile
              failed:13:Permission denied<br>
              Rank:0 on Host(ol6u9ext3) abort!<br>
--------------------------------------------------------------------------<br>
              MPI_ABORT was invoked on rank 0 in communicator
              MPI_COMM_WORLD<br>
              with errorcode 1.<br>
              <br>
              NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI
              processes.<br>
              You may or may not see output from other processes,
              depending on<br>
              exactly when Open MPI kills them.<br>
--------------------------------------------------------------------------<br>
[ol6u9ext3][[58639,1],1][btl_tcp_frag.c:215:mca_btl_tcp_frag_recv]
              mca_btl_tcp_frag_recv: readv failed: Connection reset by
              peer (104)<o:p></o:p></span></p>
          <p><span lang="EN-US"><o:p> </o:p></span></p>
          <p><span lang="EN-US">Thanks<o:p></o:p></span></p>
          <div>
            <p class="MsoNormal">在<span lang="EN-US"> 2019/9/27 </span>下午<span
                lang="EN-US">3:15, sunnyZhang
              </span>写道<span lang="EN-US">:<o:p></o:p></span></p>
          </div>
          <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
            <p class="MsoNormal"><span lang="EN-US">Hi Gang, <br>
                <br>
                Thanks for review. <br>
                <br>
                I will try to test using ocfs2-test. <br>
                <br>
                <br>
                Thanks <br>
                <br>
              </span>在<span lang="EN-US"> 2019/9/25 </span>下午<span
                lang="EN-US">6:33, Gang He </span>
              写道<span lang="EN-US">: <br>
                <br>
                <o:p></o:p></span></p>
            <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
              <p class="MsoNormal"><span lang="EN-US"><br>
                  <br>
                  <o:p></o:p></span></p>
              <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
                <p class="MsoNormal"><span lang="EN-US">-----Original
                    Message----- <br>
                    From: <a
                      href="mailto:ocfs2-devel-bounces@oss.oracle.com"
                      moz-do-not-send="true">ocfs2-devel-bounces@oss.oracle.com</a>
                    <br>
                    [<a href="mailto:ocfs2-devel-bounces@oss.oracle.com"
                      moz-do-not-send="true">mailto:ocfs2-devel-bounces@oss.oracle.com</a>]
                    On Behalf Of Shuning Zhang
                    <br>
                    Sent: 2019</span>年<span lang="EN-US">9</span>月<span
                    lang="EN-US">18</span>日<span lang="EN-US"> 10:03
                    <br>
                    To: <a href="mailto:ocfs2-devel@oss.oracle.com"
                      moz-do-not-send="true">ocfs2-devel@oss.oracle.com</a>
                    <br>
                    Subject: [Ocfs2-devel] [PATCH V2 1/2] ocfs2: protect
                    extent tree in the <br>
                    ocfs2_prepare_inode_for_write <br>
                    <br>
                    When the extent tree is modified, it should be
                    protected by inode cluster lock <br>
                    and ip_alloc_sem. <br>
                    <br>
                    The extent tree is accessed and modified in the
                    ocfs2_prepare_inode_for_write, <br>
                    but isn't protected by ip_alloc_sem. <br>
                    <br>
                    The following is a case. The function ocfs2_fiemap
                    is accessing the extent tree, <br>
                    which is modified at the same time. <br>
                    <br>
                    [47145.974472] kernel BUG at
                    fs/ocfs2/extent_map.c:475! <br>
                    [47145.974480] invalid opcode: 0000 [#1] SMP
                    [47145.974489] Modules <br>
                    linked in: tun ocfs2 ocfs2_nodemanager configfs
                    ocfs2_stackglue xen_netback <br>
                    xen_blkback xen_gntalloc xen_gntdev xen_evtchn xenfs
                    xen_privcmd vfat fat <br>
                    bnx2fc fcoe libfcoe libfc scsi_transport_fc sunrpc
                    bridge 8021q mrp garp stp llc <br>
                    ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core
                    ib_addr dm_round_robin <br>
                    dm_multipath sg pcspkr raid1 shpchp ipmi_devintf
                    ipmi_msghandler ext4 <br>
                    jbd2 mbcache2 sd_mod nvme nvme_core bnxt_en xhci_pci
                    xhci_hcd <br>
                    crc32c_intel be2iscsi bnx2i cnic uio cxgb4i cxgb4
                    cxgb3i libcxgbi ipv6 cxgb3 <br>
                    mdio qla4xxx wmi dm_mirror dm_region_hash dm_log
                    dm_mod iscsi_tcp <br>
                    libiscsi_tcp libiscsi scsi_transport_iscsi
                    iscsi_ibft iscsi_boot_sysfs <br>
                    [47145.974636] CPU: 16 PID: 14047 Comm: o2info Not
                    tainted <br>
                    4.1.12-124.23.1.el6uek.x86_64 #2 <br>
                    [47145.974646] Hardware name: Oracle Corporation
                    ORACLE SERVER <br>
                    X7-2L/ASM, MB MECH, X7-2L, BIOS 42040600 10/19/2018
                    [47145.974658] <br>
                    task: ffff88019487e200 ti: ffff88003daa4000 task.ti:
                    <br>
                    ffff88003daa4000 <br>
                    [47145.974667] RIP: e030:[&lt;ffffffffa05e4840&gt;] 
                    [&lt;ffffffffa05e4840&gt;] <br>
                    ocfs2_get_clusters_nocache.isra.11+0x390/0x550
                    [ocfs2] [47145.974708] <br>
                    RSP: e02b:ffff88003daa7d88  EFLAGS: 00010287
                    [47145.974713] RAX: <br>
                    00000000000000de RBX: ffff8801d1104030 RCX: <br>
                    ffff8801d1104e10 <br>
                    [47145.974719] RDX: 00000000000000de RSI:
                    000000000009ec40 RDI: <br>
                    ffff8801d1104e24 <br>
                    [47145.974725] RBP: ffff88003daa7df8 R08:
                    ffff88003daa7e38 R09: <br>
                    0000000000000000 <br>
                    [47145.974732] R10: 000000000009ec3f R11:
                    0000000000000246 R12: <br>
                    000000000009ec3f <br>
                    [47145.974739] R13: ffff88004c419000 R14:
                    0000000000000002 R15: <br>
                    ffff88003daa7e28 <br>
                    [47145.974754] FS:  00007fdbccc92720(0000)
                    GS:ffff880358800000(0000) <br>
                    knlGS:ffff880358800000 <br>
                    [47145.974764] CS:  e033 DS: 0000 ES: 0000 CR0:
                    0000000080050033 <br>
                    [47145.974772] CR2: 00007fd5dfcd8350 CR3:
                    0000000208677000 CR4: <br>
                    0000000000042660 <br>
                    [47145.974785] Stack: <br>
                    [47145.974790]  ffff88003daa7df8 00002000a05e249b
                    ffff8801d1104000 <br>
                    ffff88003daa7e2c [47145.974802]  ffff88003daa7e38
                    ffff88000cc484c0 <br>
                    ffff880145f5b478 <br>
                    0000000000000000 <br>
                    [47145.974811]  0000000000002000 ffff88000cc484c0
                    ffff88003daa7ea0 <br>
                    0000000000000000 <br>
                    [47145.974820] Call Trace: <br>
                    [47145.974837]  [&lt;ffffffffa05e53e3&gt;]
                    ocfs2_fiemap+0x1e3/0x430 [ocfs2] <br>
                    [47145.974848]  [&lt;ffffffff816f644f&gt;] ?
                    xen_hypervisor_callback+0x7f/0x120 <br>
                    [47145.974855]  [&lt;ffffffff816f6448&gt;] ? <br>
                    xen_hypervisor_callback+0x78/0x120 <br>
                    [47145.974861]  [&lt;ffffffff816f64a3&gt;] ? <br>
                    xen_hypervisor_callback+0xd3/0x120 <br>
                    [47145.974872]  [&lt;ffffffff81220905&gt;]
                    do_vfs_ioctl+0x155/0x510 <br>
                    [47145.974878]  [&lt;ffffffff81220d41&gt;]
                    SyS_ioctl+0x81/0xa0 [47145.974885] <br>
                    [&lt;ffffffff816f1b9f&gt;] ?
                    system_call_after_swapgs+0xe9/0x190 <br>
                    [47145.974891]  [&lt;ffffffff816f1b98&gt;] ? <br>
                    system_call_after_swapgs+0xe2/0x190 <br>
                    [47145.974899]  [&lt;ffffffff816f1b91&gt;] ? <br>
                    system_call_after_swapgs+0xdb/0x190 <br>
                    [47145.974905]  [&lt;ffffffff816f1c5e&gt;]
                    system_call_fastpath+0x18/0xd8 <br>
                    [47145.974910] Code: 18 48 c7 c6 60 7f 65 a0 31 c0
                    bb e2 ff ff ff 48 8b 4a 40 <br>
                    48 8b 7a 28 48 c7 c2 78 2d 66 a0 e8 38 4f 05 00 e9
                    28 fe ff ff 0f 1f 00 &lt;0f&gt; <br>
                    0b 66 0f 1f 44 00 00 bb 86 ff ff ff e9 13 fe ff ff
                    66 0f 1f [47145.975000] RIP <br>
                    [&lt;ffffffffa05e4840&gt;] <br>
                    ocfs2_get_clusters_nocache.isra.11+0x390/0x550
                    [ocfs2] [47145.975018] <br>
                    RSP &lt;ffff88003daa7d88&gt; [47145.989999] ---[ end
                    trace <br>
                    c8aa0c8180e869dc ]--- [47146.087579] Kernel panic -
                    not syncing: Fatal <br>
                    exception [47146.087691] Kernel Offset: disabled <br>
                    <br>
                    Signed-off-by: Shuning Zhang <a
                      href="mailto:sunny.s.zhang@oracle.com"
                      moz-do-not-send="true">&lt;sunny.s.zhang@oracle.com&gt;</a>
                    <o:p></o:p></span></p>
              </blockquote>
              <p class="MsoNormal"><span lang="EN-US">The change looks
                  good. <br>
                  If possible, please run ocfs2-test test suits to
                  verify if the change causes any regressive deadlock.
                  <br>
                  Reviewed-by: Gang He <a href="mailto:ghe@suse.com"
                    moz-do-not-send="true">&lt;ghe@suse.com&gt;</a> <br>
                  <br>
                  <br>
                  <o:p></o:p></span></p>
              <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
                <p class="MsoNormal"><span lang="EN-US">--- <br>
                      fs/ocfs2/file.c | 129 <br>
++++++++++++++++++++++++++++++++++++++++++++--------- <br>
                    --- <br>
                      1 file changed, 101 insertions(+), 28 deletions(-)
                    <br>
                    <br>
                    diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index
                    4435df3..dff4ab2 100644 <br>
                    --- a/fs/ocfs2/file.c <br>
                    +++ b/fs/ocfs2/file.c <br>
                    @@ -2119,27 +2119,90 @@ static int <br>
                    ocfs2_prepare_inode_for_refcount(struct inode
                    *inode, <br>
                          return ret; <br>
                      } <br>
                    <br>
                    +static int ocfs2_inode_lock_for_extent_tree(struct
                    inode *inode, <br>
                    +                        struct buffer_head **di_bh,
                    <br>
                    +                        int meta_level, <br>
                    +                        int overwrite_io, <br>
                    +                        int write_sem, <br>
                    +                        int wait) <br>
                    +{ <br>
                    +    int ret = 0; <br>
                    + <br>
                    +    if (wait) <br>
                    +        ret = ocfs2_inode_lock(inode, NULL,
                    meta_level); <br>
                    +    else <br>
                    +        ret = ocfs2_try_inode_lock(inode, <br>
                    +            overwrite_io ? NULL : di_bh,
                    meta_level); <br>
                    +    if (ret &lt; 0) { <br>
                    +        goto out; <br>
                    +    } <br>
                    + <br>
                    +    if (wait) { <br>
                    +        if (write_sem) <br>
                    +           
                    down_write(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem); <br>
                    +        else <br>
                    +           
                    down_read(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem); <br>
                    +    } else { <br>
                    +        if (write_sem) <br>
                    +            ret =
                    down_write_trylock(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem);
                    <br>
                    +        else <br>
                    +            ret =
                    down_read_trylock(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem);
                    <br>
                    + <br>
                    +        if (!ret) { <br>
                    +            ret = -EAGAIN; <br>
                    +            goto out_unlock; <br>
                    +        } <br>
                    +    } <br>
                    + <br>
                    +    return ret; <br>
                    + <br>
                    +out_unlock: <br>
                    +    brelse(*di_bh); <br>
                    +    ocfs2_inode_unlock(inode, meta_level); <br>
                    +out: <br>
                    +    return ret; <br>
                    +} <br>
                    + <br>
                    +static void
                    ocfs2_inode_unlock_for_extent_tree(struct inode
                    *inode, <br>
                    +                           struct buffer_head
                    **di_bh, <br>
                    +                           int meta_level, <br>
                    +                           int write_sem) <br>
                    +{ <br>
                    +    if (write_sem) <br>
                    +       
                    up_write(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem); <br>
                    +    else <br>
                    +       
                    up_read(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem); <br>
                    + <br>
                    +    brelse(*di_bh); <br>
                    +    *di_bh = NULL; <br>
                    + <br>
                    +    if (meta_level &gt;= 0) <br>
                    +        ocfs2_inode_unlock(inode, meta_level); } <br>
                    + <br>
                      static int ocfs2_prepare_inode_for_write(struct
                    file *file, <br>
                                           loff_t pos, size_t count, int
                    wait)  { <br>
                    -    int ret = 0, meta_level = 0, overwrite_io = 0;
                    <br>
                    +    int ret = 0, meta_level = 0, overwrite_io = 0,
                    write_sem = 0; <br>
                          struct dentry *dentry =
                    file-&gt;f_path.dentry; <br>
                          struct inode *inode = d_inode(dentry); <br>
                          struct buffer_head *di_bh = NULL; <br>
                          loff_t end; <br>
                    +    u32 cpos; <br>
                    +    u32 clusters; <br>
                    <br>
                          /* <br>
                           * We start with a read level meta lock and
                    only jump to an ex <br>
                           * if we need to make modifications here. <br>
                           */ <br>
                          for(;;) { <br>
                    -        if (wait) <br>
                    -            ret = ocfs2_inode_lock(inode, NULL,
                    meta_level); <br>
                    -        else <br>
                    -            ret = ocfs2_try_inode_lock(inode, <br>
                    -                overwrite_io ? NULL : &amp;di_bh,
                    meta_level); <br>
                    +        ret =
                    ocfs2_inode_lock_for_extent_tree(inode, <br>
                    +                               &amp;di_bh, <br>
                    +                               meta_level, <br>
                    +                               overwrite_io, <br>
                    +                               write_sem, <br>
                    +                               wait); <br>
                              if (ret &lt; 0) { <br>
                    -            meta_level = -1; <br>
                                  if (ret != -EAGAIN) <br>
                                      mlog_errno(ret); <br>
                                  goto out; <br>
                    @@ -2151,15 +2214,8 @@ static int
                    ocfs2_prepare_inode_for_write(struct <br>
                    file *file, <br>
                               */ <br>
                              if (!wait &amp;&amp; !overwrite_io) { <br>
                                  overwrite_io = 1; <br>
                    -            if
                    (!down_read_trylock(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem))
                    { <br>
                    -                ret = -EAGAIN; <br>
                    -                goto out_unlock; <br>
                    -            } <br>
                    <br>
                                  ret = ocfs2_overwrite_io(inode, di_bh,
                    pos, count); <br>
                    -            brelse(di_bh); <br>
                    -            di_bh = NULL; <br>
                    -           
                    up_read(&amp;OCFS2_I(inode)-&gt;ip_alloc_sem); <br>
                                  if (ret &lt; 0) { <br>
                                      if (ret != -EAGAIN) <br>
                                          mlog_errno(ret); <br>
                    @@ -2178,7 +2234,10 @@ static int
                    ocfs2_prepare_inode_for_write(struct <br>
                    file *file, <br>
                               * set inode-&gt;i_size at the end of a
                    write. */ <br>
                              if (should_remove_suid(dentry)) { <br>
                                  if (meta_level == 0) { <br>
                    -                ocfs2_inode_unlock(inode,
                    meta_level); <br>
                    +               
                    ocfs2_inode_unlock_for_extent_tree(inode, <br>
                    +                                   &amp;di_bh, <br>
                    +                                   meta_level, <br>
                    +                                   write_sem); <br>
                                      meta_level = 1; <br>
                                      continue; <br>
                                  } <br>
                    @@ -2194,18 +2253,32 @@ static int
                    ocfs2_prepare_inode_for_write(struct <br>
                    file *file, <br>
                    <br>
                              ret =
                    ocfs2_check_range_for_refcount(inode, pos, count); <br>
                              if (ret == 1) { <br>
                    -            ocfs2_inode_unlock(inode, meta_level);
                    <br>
                    -            meta_level = -1; <br>
                    - <br>
                    -            ret =
                    ocfs2_prepare_inode_for_refcount(inode, <br>
                    -                                   file, <br>
                    -                                   pos, <br>
                    -                                   count, <br>
                    -                                  
                    &amp;meta_level); <br>
                    +           
                    ocfs2_inode_unlock_for_extent_tree(inode, <br>
                    +                               &amp;di_bh, <br>
                    +                               meta_level, <br>
                    +                               write_sem); <br>
                    +            ret =
                    ocfs2_inode_lock_for_extent_tree(inode, <br>
                    +                                   &amp;di_bh, <br>
                    +                                   meta_level, <br>
                    +                                   overwrite_io, <br>
                    +                                   1, <br>
                    +                                   wait); <br>
                    +            write_sem = 1; <br>
                    +            if (ret &lt; 0) { <br>
                    +                if (ret != -EAGAIN) <br>
                    +                    mlog_errno(ret); <br>
                    +                goto out; <br>
                    +            } <br>
                    + <br>
                    +            cpos = pos &gt;&gt;
                    OCFS2_SB(inode-&gt;i_sb)-&gt;s_clustersize_bits; <br>
                    +            clusters = <br>
                    +               
                    ocfs2_clusters_for_bytes(inode-&gt;i_sb, pos +
                    count) - cpos; <br>
                    +            ret = ocfs2_refcount_cow(inode, di_bh,
                    cpos, clusters, UINT_MAX); <br>
                              } <br>
                    <br>
                              if (ret &lt; 0) { <br>
                    -            mlog_errno(ret); <br>
                    +            if (ret != -EAGAIN) <br>
                    +                mlog_errno(ret); <br>
                                  goto out_unlock; <br>
                              } <br>
                    <br>
                    @@ -2216,10 +2289,10 @@ static int
                    ocfs2_prepare_inode_for_write(struct <br>
                    file *file, <br>
                         
                    trace_ocfs2_prepare_inode_for_write(OCFS2_I(inode)-&gt;ip_blkno,
                    <br>
                                              pos, count, wait); <br>
                    <br>
                    -    brelse(di_bh); <br>
                    - <br>
                    -    if (meta_level &gt;= 0) <br>
                    -        ocfs2_inode_unlock(inode, meta_level); <br>
                    +    ocfs2_inode_unlock_for_extent_tree(inode, <br>
                    +                       &amp;di_bh, <br>
                    +                       meta_level, <br>
                    +                       write_sem); <br>
                    <br>
                      out: <br>
                          return ret; <br>
                    -- <br>
                    2.7.4 <br>
                    <br>
                    <br>
                    _______________________________________________ <br>
                    Ocfs2-devel mailing list <br>
                    <a href="mailto:Ocfs2-devel@oss.oracle.com"
                      moz-do-not-send="true">Ocfs2-devel@oss.oracle.com</a>
                    <br>
                    <a
                      href="https://oss.oracle.com/mailman/listinfo/ocfs2-devel"
                      moz-do-not-send="true">https://oss.oracle.com/mailman/listinfo/ocfs2-devel</a>
                    <o:p></o:p></span></p>
              </blockquote>
            </blockquote>
          </blockquote>
        </div>
      </div>
    </blockquote>
  </body>
</html>