Skip to contentSkip to conversation

GFS2: fix recursive locking during rindex truncates

PATCH New Benjamin Marzinski 2 participants 2 messages Nov 24, 2010 – Nov 30, 2010 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GFS2: fix recursive locking during rindex truncates

When you truncate the rindex file, you need to avoid calling gfs2_rindex_hold, since you already hold it. However, if you haven't already read in the resource groups, you need to do that.

---
 fs/gfs2/bmap.c |    9 +++++++--
 fs/gfs2/rgrp.c |    2 +-
 fs/gfs2/rgrp.h |    1 +
 3 files changed, 9 insertions(+), 3 deletions(-)
fs/gfs2/bmap.c +7 -2
Index: gfs2-2.6-nmw/fs/gfs2/bmap.c
===================================================================
@@ -780,7 +780,11 @@ static int do_strip(struct gfs2_inode *i
 	if (metadata)
 		revokes = (height) ? sdp->sd_inptrs : sdp->sd_diptrs;
 
-	error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
+	if (ip != GFS2_I(sdp->sd_rindex))
+		error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
+	else if (!sdp->sd_rgrps)
+		error = gfs2_ri_update(ip);
+
 	if (error)
 		return error;
 
@@ -879,7 +883,8 @@ out_rg_gunlock:
 out_rlist:
 	gfs2_rlist_free(&rlist);
 out:
-	gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
+	if (ip != GFS2_I(sdp->sd_rindex))
+		gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
 	return error;
 }
 
fs/gfs2/rgrp.c +1 -1
Index: gfs2-2.6-nmw/fs/gfs2/rgrp.c
===================================================================
@@ -583,7 +583,7 @@ static int read_rindex_entry(struct gfs2
  * Returns: 0 on successful update, error code otherwise
  */
 
-static int gfs2_ri_update(struct gfs2_inode *ip)
+int gfs2_ri_update(struct gfs2_inode *ip)
 {
 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
 	struct inode *inode = &ip->i_inode;
fs/gfs2/rgrp.h +1 -0
Index: gfs2-2.6-nmw/fs/gfs2/rgrp.h
===================================================================
@@ -46,6 +46,7 @@ gfs2_inplace_reserve_i((ip), __FILE__, _
 
 extern void gfs2_inplace_release(struct gfs2_inode *ip);
 
+extern int gfs2_ri_update(struct gfs2_inode *ip);
 extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n);
 extern int gfs2_alloc_di(struct gfs2_inode *ip, u64 *bn, u64 *generation);
 
#1 lore raw

PATCH 1/1 GFS2: fix recursive locking during rindex truncates

Hi,

Now in the -nmw git tree. Thanks,

Steve.

Quoted 64 lines · Benjamin Marzinski

When you truncate the rindex file, you need to avoid calling gfs2_rindex_hold, since you already hold it. However, if you haven't already read in the resource groups, you need to do that.

---
 fs/gfs2/bmap.c |    9 +++++++--
 fs/gfs2/rgrp.c |    2 +-
 fs/gfs2/rgrp.h |    1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

Index: gfs2-2.6-nmw/fs/gfs2/bmap.c
===================================================================

fs/gfs2/bmap.c +7 -2
@@ -780,7 +780,11 @@ static int do_strip(struct gfs2_inode *i
 	if (metadata)
 		revokes = (height) ? sdp->sd_inptrs : sdp->sd_diptrs;
 
-	error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
+	if (ip != GFS2_I(sdp->sd_rindex))
+		error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
+	else if (!sdp->sd_rgrps)
+		error = gfs2_ri_update(ip);
+
 	if (error)
 		return error;
 
@@ -879,7 +883,8 @@ out_rg_gunlock:
 out_rlist:
 	gfs2_rlist_free(&rlist);
 out:
-	gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
+	if (ip != GFS2_I(sdp->sd_rindex))
+		gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
 	return error;
 }
 

Index: gfs2-2.6-nmw/fs/gfs2/rgrp.c
===================================================================

fs/gfs2/rgrp.c +1 -1
@@ -583,7 +583,7 @@ static int read_rindex_entry(struct gfs2
  * Returns: 0 on successful update, error code otherwise
  */
 
-static int gfs2_ri_update(struct gfs2_inode *ip)
+int gfs2_ri_update(struct gfs2_inode *ip)
 {
 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
 	struct inode *inode = &ip->i_inode;

Index: gfs2-2.6-nmw/fs/gfs2/rgrp.h
===================================================================

fs/gfs2/rgrp.h +1 -0
@@ -46,6 +46,7 @@ gfs2_inplace_reserve_i((ip), __FILE__, _
 
 extern void gfs2_inplace_release(struct gfs2_inode *ip);
 
+extern int gfs2_ri_update(struct gfs2_inode *ip);
 extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n);
 extern int gfs2_alloc_di(struct gfs2_inode *ip, u64 *bn, u64 *generation);