ocfs2: unlock rw lock if inode lock failed
PATCH 1/1 ocfs2: unlock rw lock if inode lock failed
In ocfs2_file_aio_write, it does ocfs2_rw_lock first and then ocfs2_inode_lock. But if ocfs2_inode_lock failed, it goes to out_sems without unlocking rw lock. This will cause a bug in ocfs2_lock_res_free when testing res->l_ex_holders, which is increased in __ocfs2_cluster_lock and decreased in __ocfs2_cluster_unlock.
--- fs/ocfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/file.c +1 -1
@@ -2290,7 +2290,7 @@ relock: ret =ocfs2_inode_lock (inode,NULL ,1 );if (ret <0 ) {mlog_errno (ret); - goto out_sems; + goto out; }ocfs2_inode_unlock (inode,1 );
Signature · 1 line
1.7.9.7
PATCH 1/1 ocfs2: unlock rw lock if inode lock failed
Looks good to me.
Quoted 29 lines · Joseph Qi
In
ocfs2_file_aio_write, it doesocfs2_rw_lockfirst and thenocfs2_inode_lock. But ifocfs2_inode_lockfailed, it goes toout_semswithout unlocking rw lock. This will cause a bug inocfs2_lock_res_freewhen testingres->l_ex_holders, which is increased in__ocfs2_cluster_lockand decreased in__ocfs2_cluster_unlock.Signed-off-by Joseph Qi <[email protected]>--- fs/ocfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ocfs2/file.c +1
-2@@ -2290,7 +2290,7 @@ relock: ret =ocfs2_inode_lock (inode,NULL ,1 );if (ret <0 ) {mlog_errno (ret); - goto out_sems; + goto out; }ocfs2_inode_unlock (inode,1 ); --1.7.9.7
Quoted 5 lines
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20130506/5718074c/attachment.html
PATCH 1/1 ocfs2: unlock rw lock if inode lock failed
In reply to Joseph QiQuoted 11 lines · On Mon, 6 May 2013 22:43:39 +0800 Joseph Qi <[email protected]> wrote:
In
ocfs2_file_aio_write, it doesocfs2_rw_lockfirst and thenocfs2_inode_lock. But ifocfs2_inode_lockfailed, it goes toout_semswithout unlocking rw lock. This will cause a bug inocfs2_lock_res_freewhen testingres->l_ex_holders, which is increased in__ocfs2_cluster_lockand decreased in__ocfs2_cluster_unlock....
fs/ocfs2/file.c relock: · line 2296
Quoted 8 lines
fs/ocfs2/file.c +1
-1@@ -2290,7 +2290,7 @@ relock: ret =ocfs2_inode_lock (inode,NULL ,1 );if (ret <0 ) {mlog_errno (ret); - goto out_sems; + goto out; }ocfs2_inode_unlock (inode,1 );
That seems like a fairly serious bug. How long has it been there and what userspace actions are required to trigger it?
(I'm trying to work out which kernel versions we should merge the fix into, but the changelog didn't give me enough info to determine this)
PATCH 1/1 ocfs2: unlock rw lock if inode lock failed
It should almost never trigger. ocfs2_inode_lock() should always succeed and only return after it has gotten the required lock.
Quoted 25 lines · Andrew Morton
Quoted 11 lines · On Mon, 6 May 2013 22:43:39 +0800 Joseph Qi <[email protected]> wrote:
In
ocfs2_file_aio_write, it doesocfs2_rw_lockfirst and thenocfs2_inode_lock. But ifocfs2_inode_lockfailed, it goes toout_semswithout unlocking rw lock. This will cause a bug inocfs2_lock_res_freewhen testingres->l_ex_holders, which is increased in__ocfs2_cluster_lockand decreased in__ocfs2_cluster_unlock....
fs/ocfs2/file.c relock: · line 2296
Quoted 8 lines
fs/ocfs2/file.c +1
-1@@ -2290,7 +2290,7 @@ relock: ret =ocfs2_inode_lock (inode,NULL ,1 );if (ret <0 ) {mlog_errno (ret); - goto out_sems; + goto out; }ocfs2_inode_unlock (inode,1 );That seems like a fairly serious bug. How long has it been there and what userspace actions are required to trigger it?
Quoted 9 lines
(I'm trying to work out which kernel versions we should merge the fix into, but the changelog didn't give me enough info to determine this)
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20130508/4ec622c9/attachment.html
PATCH 1/1 ocfs2: unlock rw lock if inode lock failed
In reply to Andrew MortonQuoted 25 lines · Andrew Morton
Quoted 11 lines · On Mon, 6 May 2013 22:43:39 +0800 Joseph Qi <[email protected]> wrote:
In
ocfs2_file_aio_write, it doesocfs2_rw_lockfirst and thenocfs2_inode_lock. But ifocfs2_inode_lockfailed, it goes toout_semswithout unlocking rw lock. This will cause a bug inocfs2_lock_res_freewhen testingres->l_ex_holders, which is increased in__ocfs2_cluster_lockand decreased in__ocfs2_cluster_unlock....
fs/ocfs2/file.c relock: · line 2296
Quoted 8 lines
fs/ocfs2/file.c +1
-1@@ -2290,7 +2290,7 @@ relock: ret =ocfs2_inode_lock (inode,NULL ,1 );if (ret <0 ) {mlog_errno (ret); - goto out_sems; + goto out; }ocfs2_inode_unlock (inode,1 );That seems like a fairly serious bug. How long has it been there and what userspace actions are required to trigger it?
Quoted 6 lines
(I'm trying to work out which kernel versions we should merge the fix into, but the changelog didn't give me enough info to determine this)
.
Sorry for the delayed reply.
The reproducible case is lots of write IOs plus storage link down and then restore.
And my kernel is 3.0.13.