OCFS2-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [Ocfs2-devel] [PATCH] ocfs2: fix unbalanced locking
@ 2020-07-24 12:44 Pavel Machek
  2020-07-27  7:15 ` Joseph Qi
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Machek @ 2020-07-24 12:44 UTC (permalink / raw)
  To: trivial, mark, jlbec, joseph.qi, ocfs2-devel, linux-kernel,
	Linus Torvalds


Based on what fails, function can return with nfs_sync_rwlock either
locked or unlocked. That can not be right.

Always return with lock unlocked on error.

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>

diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 751bc4dc7466..8e3a369086db 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2871,9 +2871,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
 
 	status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
 				    0, 0);
-	if (status < 0)
+	if (status < 0) {
 		mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status);
 
+		if (ex)
+			up_write(&osb->nfs_sync_rwlock);
+		else
+			up_read(&osb->nfs_sync_rwlock);
+	}
+
 	return status;
 }
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20200724/907bc246/attachment.bin 

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

* [Ocfs2-devel] [PATCH] ocfs2: fix unbalanced locking
  2020-07-24 12:44 [Ocfs2-devel] [PATCH] ocfs2: fix unbalanced locking Pavel Machek
@ 2020-07-27  7:15 ` Joseph Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Qi @ 2020-07-27  7:15 UTC (permalink / raw)
  To: Pavel Machek, trivial, mark, jlbec, ocfs2-devel, linux-kernel,
	Linus Torvalds, Junxiao Bi, Andrew Morton



On 2020/7/24 20:44, Pavel Machek wrote:
> 
> Based on what fails, function can return with nfs_sync_rwlock either
> locked or unlocked. That can not be right.
> 
> Always return with lock unlocked on error.
> 
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>

Looks good.

Fixes: 4cd9973f9ff6 ("ocfs2: avoid inode removal while nfsd is accessing it")
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> 
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index 751bc4dc7466..8e3a369086db 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -2871,9 +2871,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
>  
>  	status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
>  				    0, 0);
> -	if (status < 0)
> +	if (status < 0) {
>  		mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status);
>  
> +		if (ex)
> +			up_write(&osb->nfs_sync_rwlock);
> +		else
> +			up_read(&osb->nfs_sync_rwlock);
> +	}
> +
>  	return status;
>  }
>  
> 

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 12:44 [Ocfs2-devel] [PATCH] ocfs2: fix unbalanced locking Pavel Machek
2020-07-27  7:15 ` Joseph Qi

OCFS2-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/ocfs2-devel/0 ocfs2-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ocfs2-devel ocfs2-devel/ https://lore.kernel.org/ocfs2-devel \
		ocfs2-devel@oss.oracle.com
	public-inbox-index ocfs2-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.oracle.oss.ocfs2-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git