Skip to contentSkip to conversation

xfs: unlock the AGI buffer when looping in xfs_dialloc

PATCH In review Christoph Hellwig 4 participants 4 messages Aug 7, 2012 – Aug 16, 2012 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: unlock the AGI buffer when looping in xfs_dialloc

Also update some commens in the area to make the code easier to read.

---
 fs/xfs/xfs_ialloc.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
fs/xfs/xfs_ialloc.c +9 -8
Index: xfs/fs/xfs/xfs_ialloc.c
===================================================================
@@ -962,23 +962,22 @@ xfs_dialloc(
 		if (!pag->pagi_freecount && !okalloc)
 			goto nextag;
 
+		/*
+		 * Then read in the AGI buffer and recheck with the AGI buffer
+		 * lock held.
+		 */
 		error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
 		if (error)
 			goto out_error;
 
-		/*
-		 * Once the AGI has been read in we have to recheck
-		 * pagi_freecount with the AGI buffer lock held.
-		 */
 		if (pag->pagi_freecount) {
 			xfs_perag_put(pag);
 			goto out_alloc;
 		}
 
-		if (!okalloc) {
-			xfs_trans_brelse(tp, agbp);
-			goto nextag;
-		}
+		if (!okalloc)
+			goto nextag_relse_buffer;
+
 
 		error = xfs_ialloc_ag_alloc(tp, agbp, &ialloced);
 		if (error) {
@@ -1007,6 +1006,8 @@ xfs_dialloc(
 			return 0;
 		}
 
+nextag_relse_buffer:
+		xfs_trans_brelse(tp, agbp);
 nextag:
 		xfs_perag_put(pag);
 		if (++agno == mp->m_sb.sb_agcount)

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Christoph Hellwig

Also update some commens in the area to make the code easier to read.

Looks great. Just last weekend, I noticed that the unlock is also missing in the current version of xfs_dialloc() and not just patch #7.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
In reply to Christoph Hellwig

Hey Christoph,

Quoted 3 lines · Christoph Hellwig

Also update some commens in the area to make the code easier to read.

This seems to fix a regression that was introduced in

commit 55d6af64, 'xfs: refactor xfs_ialloc_ag_select'

Christoph, could you comment on why this has not caused problems in testing? I am sort of suprised we haven't had any ill effects.

I'll add this patch into our next pull request.

Thanks,
Ben

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs