Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4dfa2b84 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 83d230eb
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -200,24 +200,29 @@ __xfs_ag_resv_init(
	struct xfs_mount		*mp = pag->pag_mount;
	struct xfs_ag_resv		*resv;
	int				error;
	xfs_extlen_t			reserved;

	resv = xfs_perag_resv(pag, type);
	if (used > ask)
		ask = used;
	resv->ar_asked = ask;
	resv->ar_reserved = resv->ar_orig_reserved = ask - used;
	mp->m_ag_max_usable -= ask;

	trace_xfs_ag_resv_init(pag, type, ask);
	reserved = ask - used;

	error = xfs_mod_fdblocks(mp, -(int64_t)resv->ar_reserved, true);
	if (error)
	error = xfs_mod_fdblocks(mp, -(int64_t)reserved, true);
	if (error) {
		trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
				error, _RET_IP_);

		return error;
	}

	mp->m_ag_max_usable -= ask;

	resv = xfs_perag_resv(pag, type);
	resv->ar_asked = ask;
	resv->ar_reserved = resv->ar_orig_reserved = reserved;

	trace_xfs_ag_resv_init(pag, type, ask);
	return 0;
}

/* Create a per-AG block reservation. */
int
xfs_ag_resv_init(