All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@huawei.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH] ocfs2: fix double unlock in case retry after free truncate log
Date: Wed, 14 Sep 2016 16:13:06 +0800	[thread overview]
Message-ID: <57D90692.90008@huawei.com> (raw)
In-Reply-To: <836ecbe3-f534-161e-c46c-2902412dd21b@suse.com>

Hi Eric,

On 2016/9/14 15:57, Eric Ren wrote:
> Hello Joseph,
> 
> Thanks for fixing up this.
> 
> On 09/14/2016 12:15 PM, Joseph Qi wrote:
>> If ocfs2_reserve_cluster_bitmap_bits fails with ENOSPC, it will try to
>> free truncate log and then retry. Since ocfs2_try_to_free_truncate_log
>> will lock/unlock global bitmap inode, we have to unlock it before
>> calling this function. But when retry reserve and it fails with no
> You mean the retry succeeds by "retry reserve", right? I fail to understand in which situation
> the retry will fail to get global bitmap inode lock. Because I didn't see this problem when I
> tested my patch, could you explain a bit more?
> 
> Eric
Before retry it has inode unlocked, but ac inode is still valid. And
if inode lock fails this time, it will goto bail and do inode unlock
again.

Thanks,
Joseph

>> global bitmap inode lock taken, it will unlock again in error handling
>> branch and BUG.
>> This issue also exists if no need retry and then ocfs2_inode_lock fails.
>> So fix it.
>>
>> Fixes: 2070ad1aebff ("ocfs2: retry on ENOSPC if sufficient space in
>> truncate log"
>> Signed-off-by: Jospeh Qi <joseph.qi@huawei.com>
>> Signed-off-by: Jiufei Xue <xuejiufei@huawei.com>
>> ---
>>   fs/ocfs2/suballoc.c | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
>> index ea47120..041453b 100644
>> --- a/fs/ocfs2/suballoc.c
>> +++ b/fs/ocfs2/suballoc.c
>> @@ -1199,14 +1199,23 @@ retry:
>>               inode_unlock((*ac)->ac_inode);
>>
>>               ret = ocfs2_try_to_free_truncate_log(osb, bits_wanted);
>> -            if (ret == 1)
>> +            if (ret == 1) {
>> +                iput((*ac)->ac_inode);
>> +                (*ac)->ac_inode = NULL;
>>                   goto retry;
>> +            }
>>
>>               if (ret < 0)
>>                   mlog_errno(ret);
>>
>>               inode_lock((*ac)->ac_inode);
>> -            ocfs2_inode_lock((*ac)->ac_inode, NULL, 1);
>> +            status = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1);
>> +            if (status < 0) {
>> +                inode_unlock((*ac)->ac_inode);
>> +                iput((*ac)->ac_inode);
>> +                (*ac)->ac_inode = NULL;
>> +                goto bail;
>> +            }
>>           }
>>           if (status < 0) {
>>               if (status != -ENOSPC)
> 
> 
> 
> .
> 

  reply	other threads:[~2016-09-14  8:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14  4:15 [Ocfs2-devel] [PATCH] ocfs2: fix double unlock in case retry after free truncate log Joseph Qi
2016-09-14  7:57 ` Eric Ren
2016-09-14  8:13   ` Joseph Qi [this message]
2016-09-18  5:07     ` Eric Ren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57D90692.90008@huawei.com \
    --to=joseph.qi@huawei.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.