ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
@ 2015-12-22 23:55 Tariq Saeed
  2015-12-30  0:34 ` Mark Fasheh
  0 siblings, 1 reply; 7+ messages in thread
From: Tariq Saeed @ 2015-12-22 23:55 UTC (permalink / raw)
  To: ocfs2-devel

From: Linus Torvalds <torvalds@linux-foundation.org>

Orabug: 21793017

commit 743b5f1434f5 ("ocfs2: take inode lock in ocfs2_iop_set/get_acl()")
introduced this issue.  ocfs2_setattr called by chmod command
holds cluster wide inode lock (Orabug 21685187) when calling
posix_acl_chmod. This latter function in turn calls ocfs2_iop_get_acl
and ocfs2_iop_set_acl.  These two are also called directly from vfs layer
for getfacl/setfacl commands and therefore acquire the cluster wide inode
lock. If a remote conversion request comes after the first inode lock
in ocfs2_setattr, OCFS2_LOCK_BLOCKED will be set in l_flags. This will
cause the second call to inode lock from the  ocfs2_iop_get|set_acl()
to block indefinetly.  The new flag OCFS2_LOCK_IGNORE_BLOCKED will be
used to prevent this blocking.

Signed-off-by: Tariq Saeed <tariq.x.saeed@oracle.com> Signed-off-by:
Junxiao Bi <junxiao.bi@oracle.com>
---
 Makefile           |    2 +-
 fs/ocfs2/acl.c     |    7 +++++--
 fs/ocfs2/dlmglue.c |    3 ++-
 fs/ocfs2/dlmglue.h |    2 ++
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 431067a..d5b3739 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 4
 PATCHLEVEL = 3
 SUBLEVEL = 0
-EXTRAVERSION = -rc7
+EXTRAVERSION =
 NAME = Blurry Fish Butt
 
 # *DOCUMENTATION*
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 0cdf497..4404d9a 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -37,6 +37,7 @@
 #include "xattr.h"
 #include "acl.h"
 
+
 /*
  * Convert from xattr value to acl struct.
  */
@@ -287,7 +288,8 @@ int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 	struct buffer_head *bh = NULL;
 	int status = 0;
 
-	status = ocfs2_inode_lock(inode, &bh, 1);
+	status = ocfs2_inode_lock_full(inode, &bh, 1,
+					OCFS2_LOCK_IGNORE_BLOCKED);
 	if (status < 0) {
 		if (status != -ENOENT)
 			mlog_errno(status);
@@ -309,7 +311,8 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
 	osb = OCFS2_SB(inode->i_sb);
 	if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
 		return NULL;
-	ret = ocfs2_inode_lock(inode, &di_bh, 0);
+	ret = ocfs2_inode_lock_full(inode, &di_bh, 0,
+					OCFS2_LOCK_IGNORE_BLOCKED);
 	if (ret < 0) {
 		if (ret != -ENOENT)
 			mlog_errno(ret);
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 1c91103..ea79e1b 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -1447,7 +1447,8 @@ again:
 	}
 
 	if (lockres->l_flags & OCFS2_LOCK_BLOCKED &&
-	    !ocfs2_may_continue_on_blocked_lock(lockres, level)) {
+	    !ocfs2_may_continue_on_blocked_lock(lockres, level) &&
+	    !(arg_flags & OCFS2_LOCK_IGNORE_BLOCKED)) {
 		/* is the lock is currently blocked on behalf of
 		 * another node */
 		lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BLOCKED, 0);
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h
index d293a22..845831f 100644
--- a/fs/ocfs2/dlmglue.h
+++ b/fs/ocfs2/dlmglue.h
@@ -78,6 +78,8 @@ struct ocfs2_orphan_scan_lvb {
 /* don't block waiting for the downconvert thread, instead return -EAGAIN */
 #define OCFS2_LOCK_NONBLOCK		(0x04)
 
+/* if requested level is <= l_level, ignore BLOCKED flag. */
+#define OCFS2_LOCK_IGNORE_BLOCKED		(0x08)
 /* Locking subclasses of inode cluster lock */
 enum {
 	OI_LS_NORMAL = 0,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
  2015-12-22 23:55 [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang Tariq Saeed
@ 2015-12-30  0:34 ` Mark Fasheh
  2016-01-04 20:57   ` Tariq Saeed
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Fasheh @ 2015-12-30  0:34 UTC (permalink / raw)
  To: ocfs2-devel

On Tue, Dec 22, 2015 at 03:55:50PM -0800, Tariq Saeed wrote:
> From: Linus Torvalds <torvalds@linux-foundation.org>
> 
> Orabug: 21793017
> 
> commit 743b5f1434f5 ("ocfs2: take inode lock in ocfs2_iop_set/get_acl()")
> introduced this issue.  ocfs2_setattr called by chmod command
> holds cluster wide inode lock (Orabug 21685187) when calling
> posix_acl_chmod. This latter function in turn calls ocfs2_iop_get_acl
> and ocfs2_iop_set_acl.  These two are also called directly from vfs layer
> for getfacl/setfacl commands and therefore acquire the cluster wide inode
> lock. If a remote conversion request comes after the first inode lock
> in ocfs2_setattr, OCFS2_LOCK_BLOCKED will be set in l_flags. This will
> cause the second call to inode lock from the  ocfs2_iop_get|set_acl()
> to block indefinetly.  The new flag OCFS2_LOCK_IGNORE_BLOCKED will be
> used to prevent this blocking.


NACK - as I explained earlier on this list we need to refactor the code to
avoid double locking the same resource. It is not acceptable to introduce
recursive locks into the code.
	--Mark

--
Mark Fasheh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
  2015-12-30  0:34 ` Mark Fasheh
@ 2016-01-04 20:57   ` Tariq Saeed
  2016-01-05  0:35     ` Mark Fasheh
  0 siblings, 1 reply; 7+ messages in thread
From: Tariq Saeed @ 2016-01-04 20:57 UTC (permalink / raw)
  To: ocfs2-devel


On 12/29/2015 04:34 PM, Mark Fasheh wrote:
> NACK - as I explained earlier on this list we need to refactor the code to
Not sure how things work in the open source world. Is refactoring to be 
picked by
somebody soon?
Thanks
-Tariq

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
  2016-01-04 20:57   ` Tariq Saeed
@ 2016-01-05  0:35     ` Mark Fasheh
  2016-01-05  1:46       ` Junxiao Bi
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Fasheh @ 2016-01-05  0:35 UTC (permalink / raw)
  To: ocfs2-devel

On Mon, Jan 04, 2016 at 12:57:37PM -0800, Tariq Saeed wrote:
> 
> On 12/29/2015 04:34 PM, Mark Fasheh wrote:
> > NACK - as I explained earlier on this list we need to refactor the code to
> Not sure how things work in the open source world. Is refactoring to be 
> picked by
> somebody soon?

No problem, A couple explanations  / notes:

1) CC me with your patches (someone had to point the last one out to me).

I'll get to reviewing most things but if you CC me then it can happen
sooner.


2) You are fixing the bug and sending the patches. We usually expect the
sender to incorporate feedback into their patch so the answer would be that
you get to to the refactoring :)

If you need to make small changes to the VFS to let this happen (sometimes
we might want 'nolock' variants of funtions, etc), do them in seperate
patches and send them along with your changes.

Hope this helps,
	--Mark

--
Mark Fasheh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
  2016-01-05  0:35     ` Mark Fasheh
@ 2016-01-05  1:46       ` Junxiao Bi
  2016-01-05 23:47         ` Joel Becker
  0 siblings, 1 reply; 7+ messages in thread
From: Junxiao Bi @ 2016-01-05  1:46 UTC (permalink / raw)
  To: ocfs2-devel

Hi Mark,

We may fix this issue in another way, without recursive locking and
without refactoring. We can check before asking for the second locking,
if lock is already hold, then skip the second locking, do you agree
fixing like this?

Thanks,
Junxiao.
On 01/05/2016 08:35 AM, Mark Fasheh wrote:
> On Mon, Jan 04, 2016 at 12:57:37PM -0800, Tariq Saeed wrote:
>>
>> On 12/29/2015 04:34 PM, Mark Fasheh wrote:
>>> NACK - as I explained earlier on this list we need to refactor the code to
>> Not sure how things work in the open source world. Is refactoring to be 
>> picked by
>> somebody soon?
> 
> No problem, A couple explanations  / notes:
> 
> 1) CC me with your patches (someone had to point the last one out to me).
> 
> I'll get to reviewing most things but if you CC me then it can happen
> sooner.
> 
> 
> 2) You are fixing the bug and sending the patches. We usually expect the
> sender to incorporate feedback into their patch so the answer would be that
> you get to to the refactoring :)
> 
> If you need to make small changes to the VFS to let this happen (sometimes
> we might want 'nolock' variants of funtions, etc), do them in seperate
> patches and send them along with your changes.
> 
> Hope this helps,
> 	--Mark
> 
> --
> Mark Fasheh
> 
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
  2016-01-05  1:46       ` Junxiao Bi
@ 2016-01-05 23:47         ` Joel Becker
  2016-01-06  4:47           ` Junxiao Bi
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Becker @ 2016-01-05 23:47 UTC (permalink / raw)
  To: ocfs2-devel

On Tue, Jan 05, 2016 at 09:46:49AM +0800, Junxiao Bi wrote:
> Hi Mark,
> 
> We may fix this issue in another way, without recursive locking and
> without refactoring. We can check before asking for the second locking,
> if lock is already hold, then skip the second locking, do you agree
> fixing like this?

Hey Junxiao,

What is to prevent the second lock from being dropped while in the
middle of the operation?

Joel

-- 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang
  2016-01-05 23:47         ` Joel Becker
@ 2016-01-06  4:47           ` Junxiao Bi
  0 siblings, 0 replies; 7+ messages in thread
From: Junxiao Bi @ 2016-01-06  4:47 UTC (permalink / raw)
  To: ocfs2-devel

Hi Joel,

On 01/06/2016 07:47 AM, Joel Becker wrote:
> On Tue, Jan 05, 2016 at 09:46:49AM +0800, Junxiao Bi wrote:
>> Hi Mark,
>>
>> We may fix this issue in another way, without recursive locking and
>> without refactoring. We can check before asking for the second locking,
>> if lock is already hold, then skip the second locking, do you agree
>> fixing like this?
> 
> Hey Junxiao,
> 
> What is to prevent the second lock from being dropped while in the
> middle of the operation?
Log processes id into lockres when lock is got. When do second locking,
if this lock is already got by this process, then skip it.

Thanks,
Junxiao.

> 
> Joel
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-01-06  4:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-22 23:55 [Ocfs2-devel] [PATCH] add OCFS2_LOCK_IGNORE_BLOCKED arg_flags to ocfs2_cluster_lock() to prevent hang Tariq Saeed
2015-12-30  0:34 ` Mark Fasheh
2016-01-04 20:57   ` Tariq Saeed
2016-01-05  0:35     ` Mark Fasheh
2016-01-05  1:46       ` Junxiao Bi
2016-01-05 23:47         ` Joel Becker
2016-01-06  4:47           ` Junxiao Bi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).