Skip to content

Commit 9789dd9

Browse files
committed
xfs: perag initialization should only touch m_ag_max_usable for AG 0
We call __xfs_ag_resv_init to make a per-AG reservation for each AG. This makes the reservation per-AG, not per-filesystem. Therefore, it is incorrect to adjust m_ag_max_usable for each AG. Adjust it only when we're reserving AG 0's blocks so that we only do it once per fs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
1 parent ee70daa commit 9789dd9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/xfs/libxfs/xfs_ag_resv.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ __xfs_ag_resv_free(
156156
trace_xfs_ag_resv_free(pag, type, 0);
157157

158158
resv = xfs_perag_resv(pag, type);
159-
pag->pag_mount->m_ag_max_usable += resv->ar_asked;
159+
if (pag->pag_agno == 0)
160+
pag->pag_mount->m_ag_max_usable += resv->ar_asked;
160161
/*
161162
* AGFL blocks are always considered "free", so whatever
162163
* was reserved at mount time must be given back at umount.
@@ -216,7 +217,14 @@ __xfs_ag_resv_init(
216217
return error;
217218
}
218219

219-
mp->m_ag_max_usable -= ask;
220+
/*
221+
* Reduce the maximum per-AG allocation length by however much we're
222+
* trying to reserve for an AG. Since this is a filesystem-wide
223+
* counter, we only make the adjustment for AG 0. This assumes that
224+
* there aren't any AGs hungrier for per-AG reservation than AG 0.
225+
*/
226+
if (pag->pag_agno == 0)
227+
mp->m_ag_max_usable -= ask;
220228

221229
resv = xfs_perag_resv(pag, type);
222230
resv->ar_asked = ask;

0 commit comments

Comments
 (0)