Skip to content

Commit 4dfa2b8

Browse files
Christoph Hellwigdjwong
authored andcommitted
xfs: only update mount/resv fields on success in __xfs_ag_resv_init
Try to reserve the blocks first and only then update the fields in or hanging off the mount structure. This way we can call __xfs_ag_resv_init again after a previous failure. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
1 parent 83d230e commit 4dfa2b8

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

fs/xfs/libxfs/xfs_ag_resv.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,22 +200,27 @@ __xfs_ag_resv_init(
200200
struct xfs_mount *mp = pag->pag_mount;
201201
struct xfs_ag_resv *resv;
202202
int error;
203+
xfs_extlen_t reserved;
203204

204-
resv = xfs_perag_resv(pag, type);
205205
if (used > ask)
206206
ask = used;
207-
resv->ar_asked = ask;
208-
resv->ar_reserved = resv->ar_orig_reserved = ask - used;
209-
mp->m_ag_max_usable -= ask;
207+
reserved = ask - used;
210208

211-
trace_xfs_ag_resv_init(pag, type, ask);
212-
213-
error = xfs_mod_fdblocks(mp, -(int64_t)resv->ar_reserved, true);
214-
if (error)
209+
error = xfs_mod_fdblocks(mp, -(int64_t)reserved, true);
210+
if (error) {
215211
trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
216212
error, _RET_IP_);
213+
return error;
214+
}
217215

218-
return error;
216+
mp->m_ag_max_usable -= ask;
217+
218+
resv = xfs_perag_resv(pag, type);
219+
resv->ar_asked = ask;
220+
resv->ar_reserved = resv->ar_orig_reserved = reserved;
221+
222+
trace_xfs_ag_resv_init(pag, type, ask);
223+
return 0;
219224
}
220225

221226
/* Create a per-AG block reservation. */

0 commit comments

Comments
 (0)