cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 PATCH] GFS2: Fix allocation error bug with recursive rgrp glocking
       [not found] <97915428.38585535.1527707643430.JavaMail.zimbra@redhat.com>
@ 2018-05-30 19:14 ` Bob Peterson
  2018-05-31 11:08   ` Andreas Gruenbacher
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Peterson @ 2018-05-30 19:14 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Before this patch function gfs2_write_begin, upon discovering an
error, called gfs2_trim_blocks while the rgrp glock was still held.
That's because gfs2_inplace_release is not called until later.
This patch reorganizes the logic a bit so gfs2_inplace_release
is called to release the lock prior to the call to gfs2_trim_blocks,
thus preventing the glock recursion.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 fs/gfs2/aops.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index f58716567972..629e614b324c 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -746,16 +746,13 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
 	unlock_page(page);
 	put_page(page);
 
-	gfs2_trans_end(sdp);
-	if (pos + len > ip->i_inode.i_size)
-		gfs2_trim_blocks(&ip->i_inode);
-	goto out_trans_fail;
-
 out_endtrans:
 	gfs2_trans_end(sdp);
 out_trans_fail:
 	if (alloc_required) {
 		gfs2_inplace_release(ip);
+		if (pos + len > ip->i_inode.i_size)
+			gfs2_trim_blocks(&ip->i_inode);
 out_qunlock:
 		gfs2_quota_unlock(ip);
 	}



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

* [Cluster-devel] [GFS2 PATCH] GFS2: Fix allocation error bug with recursive rgrp glocking
  2018-05-30 19:14 ` [Cluster-devel] [GFS2 PATCH] GFS2: Fix allocation error bug with recursive rgrp glocking Bob Peterson
@ 2018-05-31 11:08   ` Andreas Gruenbacher
  2018-05-31 12:26     ` Bob Peterson
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Gruenbacher @ 2018-05-31 11:08 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Bob,

On 30 May 2018 at 21:14, Bob Peterson <rpeterso@redhat.com> wrote:
> Before this patch function gfs2_write_begin, upon discovering an
> error, called gfs2_trim_blocks while the rgrp glock was still held.
> That's because gfs2_inplace_release is not called until later.

agreed.

> This patch reorganizes the logic a bit so gfs2_inplace_release
> is called to release the lock prior to the call to gfs2_trim_blocks,
> thus preventing the glock recursion.

gfs2_trim_blocks only needs to be called after __block_write_begin but
with your proposed patch, it also ends up being called on other error
paths.  This complicates gfs2_write_begin, so how about the below patch
instead?

Thanks,
Andreas

---
 fs/gfs2/aops.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index f58716567972..66e7172e0134 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -747,18 +747,21 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
 	put_page(page);
 
 	gfs2_trans_end(sdp);
-	if (pos + len > ip->i_inode.i_size)
-		gfs2_trim_blocks(&ip->i_inode);
-	goto out_trans_fail;
+	if (alloc_required) {
+		gfs2_inplace_release(ip);
+		if (pos + len > ip->i_inode.i_size)
+			gfs2_trim_blocks(&ip->i_inode);
+	}
+	goto out_qunlock;
 
 out_endtrans:
 	gfs2_trans_end(sdp);
 out_trans_fail:
-	if (alloc_required) {
+	if (alloc_required)
 		gfs2_inplace_release(ip);
 out_qunlock:
+	if (alloc_required)
 		gfs2_quota_unlock(ip);
-	}
 out_unlock:
 	if (&ip->i_inode == sdp->sd_rindex) {
 		gfs2_glock_dq(&m_ip->i_gh);
-- 
2.17.0



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

* [Cluster-devel] [GFS2 PATCH] GFS2: Fix allocation error bug with recursive rgrp glocking
  2018-05-31 11:08   ` Andreas Gruenbacher
@ 2018-05-31 12:26     ` Bob Peterson
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Peterson @ 2018-05-31 12:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> Bob,
> 
> On 30 May 2018 at 21:14, Bob Peterson <rpeterso@redhat.com> wrote:
> > Before this patch function gfs2_write_begin, upon discovering an
> > error, called gfs2_trim_blocks while the rgrp glock was still held.
> > That's because gfs2_inplace_release is not called until later.
> 
> agreed.
> 
> > This patch reorganizes the logic a bit so gfs2_inplace_release
> > is called to release the lock prior to the call to gfs2_trim_blocks,
> > thus preventing the glock recursion.
> 
> gfs2_trim_blocks only needs to be called after __block_write_begin but
> with your proposed patch, it also ends up being called on other error
> paths.  This complicates gfs2_write_begin, so how about the below patch
> instead?
> 
> Thanks,
> Andreas

Hi Andreas,

My previous version looked a lot like yours, so yes, I'll take your
version instead. It's going to be overwritten by your iomap-write
patch set eventually anyway.

Regards,

Bob Peterson



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

end of thread, other threads:[~2018-05-31 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <97915428.38585535.1527707643430.JavaMail.zimbra@redhat.com>
2018-05-30 19:14 ` [Cluster-devel] [GFS2 PATCH] GFS2: Fix allocation error bug with recursive rgrp glocking Bob Peterson
2018-05-31 11:08   ` Andreas Gruenbacher
2018-05-31 12:26     ` Bob Peterson

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).