Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1559411
| From | Eric Ren <zren@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points |
| Date | 2017-01-16 04:10 +0100 |
| Message-ID | <t05Qd-2Ee-1@gated-at.bofh.it> (permalink) |
| References | <sWij0-4TE-21@gated-at.bofh.it> <sWiCl-50p-29@gated-at.bofh.it> <sZ1F0-4HH-7@gated-at.bofh.it> <sZ3x7-5Sp-9@gated-at.bofh.it> <t05wS-2hK-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Junxiao,
On 01/16/2017 10:46 AM, Junxiao Bi wrote:
>>> If had_lock==true, it is a bug? I think we should BUG_ON for it, that
>>> can help us catch bug at the first time.
>> Good idea! But I'm not sure if "ocfs2_setattr" is always the first one
>> who takes the cluster lock.
>> It's harder for me to name all the possible paths;-/
> The BUG_ON() can help catch the path where ocfs2_setattr is not the
> first one.
Yes, I understand. But, the problem is that the vfs entries calling order is out of our control.
I don't want to place an assertion where I'm not 100% sure it's absolutely right;-)
Thanks,
Eric
>
> Thanks,
> Junxiao.
>
>>>
>>>> + if (had_lock)
>>>> + arg_flags = OCFS2_META_LOCK_GETBH;
>>>> + status = ocfs2_inode_lock_full(inode, &bh, 1, arg_flags);
>>>> if (status < 0) {
>>>> if (status != -ENOENT)
>>>> mlog_errno(status);
>>>> goto bail_unlock_rw;
>>>> }
>>>> - inode_locked = 1;
>>>> + if (!had_lock) {
>>>> + ocfs2_add_holder(lockres, &oh);
>>>> + inode_locked = 1;
>>>> + }
>>>> if (size_change) {
>>>> status = inode_newsize_ok(inode, attr->ia_size);
>>>> @@ -1260,7 +1270,8 @@ int ocfs2_setattr(struct dentry *dentry, struct
>>>> iattr *attr)
>>>> bail_commit:
>>>> ocfs2_commit_trans(osb, handle);
>>>> bail_unlock:
>>>> - if (status) {
>>>> + if (status && inode_locked) {
>>>> + ocfs2_remove_holder(lockres, &oh);
>>>> ocfs2_inode_unlock(inode, 1);
>>>> inode_locked = 0;
>>>> }
>>>> @@ -1278,8 +1289,10 @@ int ocfs2_setattr(struct dentry *dentry,
>>>> struct iattr *attr)
>>>> if (status < 0)
>>>> mlog_errno(status);
>>>> }
>>>> - if (inode_locked)
>>>> + if (inode_locked) {
>>>> + ocfs2_remove_holder(lockres, &oh);
>>>> ocfs2_inode_unlock(inode, 1);
>>>> + }
>>>> brelse(bh);
>>>> return status;
>>>> @@ -1321,20 +1334,31 @@ int ocfs2_getattr(struct vfsmount *mnt,
>>>> int ocfs2_permission(struct inode *inode, int mask)
>>>> {
>>>> int ret;
>>>> + int has_locked;
>>>> + struct ocfs2_holder oh;
>>>> + struct ocfs2_lock_res *lockres;
>>>> if (mask & MAY_NOT_BLOCK)
>>>> return -ECHILD;
>>>> - ret = ocfs2_inode_lock(inode, NULL, 0);
>>>> - if (ret) {
>>>> - if (ret != -ENOENT)
>>>> - mlog_errno(ret);
>>>> - goto out;
>>>> + lockres = &OCFS2_I(inode)->ip_inode_lockres;
>>>> + has_locked = (ocfs2_is_locked_by_me(lockres) != NULL);
>>> The same thing as ocfs2_setattr.
>> OK. I will think over your suggestions!
>>
>> Thanks,
>> Eric
>>
>>> Thanks,
>>> Junxiao.
>>>> + if (!has_locked) {
>>>> + ret = ocfs2_inode_lock(inode, NULL, 0);
>>>> + if (ret) {
>>>> + if (ret != -ENOENT)
>>>> + mlog_errno(ret);
>>>> + goto out;
>>>> + }
>>>> + ocfs2_add_holder(lockres, &oh);
>>>> }
>>>> ret = generic_permission(inode, mask);
>>>> - ocfs2_inode_unlock(inode, 0);
>>>> + if (!has_locked) {
>>>> + ocfs2_remove_holder(lockres, &oh);
>>>> + ocfs2_inode_unlock(inode, 0);
>>>> + }
>>>> out:
>>>> return ret;
>>>> }
>>>>
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] fix deadlock caused by recursive cluster locking Eric Ren <zren@suse.com> - 2017-01-05 16:40 +0100
[PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-05 17:00 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Joseph Qi <jiangqi903@gmail.com> - 2017-01-06 07:20 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-06 08:20 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Joseph Qi <jiangqi903@gmail.com> - 2017-01-06 08:30 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-06 09:30 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Joseph Qi <jiangqi903@gmail.com> - 2017-01-06 10:10 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-06 10:40 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Joseph Qi <jiangqi903@gmail.com> - 2017-01-06 11:00 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-06 13:10 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Joseph Qi <jiangqi903@gmail.com> - 2017-01-09 02:20 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-09 03:20 +0100
Re: [Ocfs2-devel] [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-12 12:30 +0100
Re: [Ocfs2-devel] [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Joseph Qi <jiangqi903@gmail.com> - 2017-01-12 12:40 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points kbuild test robot <lkp@intel.com> - 2017-01-06 19:00 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Junxiao Bi <junxiao.bi@oracle.com> - 2017-01-13 05:30 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-13 07:30 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Junxiao Bi <junxiao.bi@oracle.com> - 2017-01-16 03:50 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-16 04:10 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Junxiao Bi <junxiao.bi@oracle.com> - 2017-01-16 04:20 +0100
Re: [PATCH 2/2] ocfs2: fix deadlocks when taking inode lock at vfs entry points Eric Ren <zren@suse.com> - 2017-01-16 04:30 +0100
csiph-web