Skip to contentSkip to conversation

xfs: libxfs: move xfs_perag_put late

PATCH In review Pan Bian 3 participants 3 messages Nov 27, 2018 XFS filesystem

lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH v2 1/1 xfs: libxfs: move xfs_perag_put late

The function xfs_alloc_get_freelist calls xfs_perag_put to drop the reference. However, pag->pagf_btreeblks is read and write after the put operation. This patch moves the put operation late.

---
V2: correct the commit log

---
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index e1c0c0d..4be387d 100644
@@ -2435,7 +2435,6 @@ xfs_alloc_get_freelist(
 	be32_add_cpu(&agf->agf_flcount, -1);
 	xfs_trans_agflist_delta(tp, -1);
 	pag->pagf_flcount--;
-	xfs_perag_put(pag);
 
 	logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT;
 	if (btreeblk) {
@@ -2443,6 +2442,7 @@ xfs_alloc_get_freelist(
 		pag->pagf_btreeblks++;
 		logflags |= XFS_AGF_BTREEBLKS;
 	}
+	xfs_perag_put(pag);
 
 	xfs_alloc_log_agf(tp, agbp, logflags);
 	*bnop = bno;
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 3 lines · Pan Bian

The function xfs_alloc_get_freelist calls xfs_perag_put to drop the reference. However, pag->pagf_btreeblks is read and write after the put operation. This patch moves the put operation late.

I'm not a native English speaker too, but I believe it should be "is read and written after..."

But, for the code itself, you can add:

Cheers

Quoted 32 lines

---
V2: correct the commit log

---
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index e1c0c0d..4be387d 100644
@@ -2435,7 +2435,6 @@ xfs_alloc_get_freelist(
 	be32_add_cpu(&agf->agf_flcount, -1);
 	xfs_trans_agflist_delta(tp, -1);
 	pag->pagf_flcount--;
-	xfs_perag_put(pag);
 
 	logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT;
 	if (btreeblk) {
@@ -2443,6 +2442,7 @@ xfs_alloc_get_freelist(
 		pag->pagf_btreeblks++;
 		logflags |= XFS_AGF_BTREEBLKS;
 	}
+	xfs_perag_put(pag);
 
 	xfs_alloc_log_agf(tp, agbp, logflags);
 	*bnop = bno;
Signature · 1 line
2.7.4
Signature · 1 line
Carlos
Reviewed-by
#2 lore raw
Quoted 5 lines · Carlos Maiolino
Quoted 3 lines · Pan Bian

The function xfs_alloc_get_freelist calls xfs_perag_put to drop the reference. However, pag->pagf_btreeblks is read and write after the put operation. This patch moves the put operation late.

Quoted 11 lines

I'm not a native English speaker too, but I believe it should be "is read and written after..."

But, for the code itself, you can add:

Cheers

Quoted 2 lines

Looks ok, will amend the changelog on the way in.

--D

Quoted 33 lines
Quoted 30 lines

---
V2: correct the commit log

---
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index e1c0c0d..4be387d 100644
@@ -2435,7 +2435,6 @@ xfs_alloc_get_freelist(
 	be32_add_cpu(&agf->agf_flcount, -1);
 	xfs_trans_agflist_delta(tp, -1);
 	pag->pagf_flcount--;
-	xfs_perag_put(pag);
 
 	logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT;
 	if (btreeblk) {
@@ -2443,6 +2442,7 @@ xfs_alloc_get_freelist(
 		pag->pagf_btreeblks++;
 		logflags |= XFS_AGF_BTREEBLKS;
 	}
+	xfs_perag_put(pag);
 
 	xfs_alloc_log_agf(tp, agbp, logflags);
 	*bnop = bno;
Signature · 1 line
2.7.4
Signature · 1 line
Carlos