xfs: refactor xfs_trans_reserve() interface

With the new xfs_trans_res structure has been introduced, the log
reservation size, log count as well as log flags are pre-initialized
at mount time.  So it's time to refine xfs_trans_reserve() interface
to be more neat.

Also, introduce a new helper M_RES() to return a pointer to the
mp->m_resv structure to simplify the input.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
This commit is contained in:
Jie Liu
2013-08-12 20:49:59 +10:00
committed by Ben Myers
parent 783cb6d172
commit 3d3c8b5222
21 changed files with 150 additions and 197 deletions

View File

@@ -56,7 +56,7 @@ void
xfs_trans_init(
struct xfs_mount *mp)
{
xfs_trans_resv_calc(mp, &mp->m_resv);
xfs_trans_resv_calc(mp, M_RES(mp));
}
/*
@@ -180,12 +180,10 @@ xfs_trans_dup(
*/
int
xfs_trans_reserve(
xfs_trans_t *tp,
uint blocks,
uint logspace,
uint rtextents,
uint flags,
uint logcount)
struct xfs_trans *tp,
struct xfs_trans_res *resp,
uint blocks,
uint rtextents)
{
int error = 0;
int rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
@@ -211,13 +209,15 @@ xfs_trans_reserve(
/*
* Reserve the log space needed for this transaction.
*/
if (logspace > 0) {
if (resp->tr_logres > 0) {
bool permanent = false;
ASSERT(tp->t_log_res == 0 || tp->t_log_res == logspace);
ASSERT(tp->t_log_count == 0 || tp->t_log_count == logcount);
ASSERT(tp->t_log_res == 0 ||
tp->t_log_res == resp->tr_logres);
ASSERT(tp->t_log_count == 0 ||
tp->t_log_count == resp->tr_logcount);
if (flags & XFS_TRANS_PERM_LOG_RES) {
if (resp->tr_logflags & XFS_TRANS_PERM_LOG_RES) {
tp->t_flags |= XFS_TRANS_PERM_LOG_RES;
permanent = true;
} else {
@@ -226,20 +226,21 @@ xfs_trans_reserve(
}
if (tp->t_ticket != NULL) {
ASSERT(flags & XFS_TRANS_PERM_LOG_RES);
ASSERT(resp->tr_logflags & XFS_TRANS_PERM_LOG_RES);
error = xfs_log_regrant(tp->t_mountp, tp->t_ticket);
} else {
error = xfs_log_reserve(tp->t_mountp, logspace,
logcount, &tp->t_ticket,
XFS_TRANSACTION, permanent,
tp->t_type);
error = xfs_log_reserve(tp->t_mountp,
resp->tr_logres,
resp->tr_logcount,
&tp->t_ticket, XFS_TRANSACTION,
permanent, tp->t_type);
}
if (error)
goto undo_blocks;
tp->t_log_res = logspace;
tp->t_log_count = logcount;
tp->t_log_res = resp->tr_logres;
tp->t_log_count = resp->tr_logcount;
}
/*
@@ -264,10 +265,10 @@ xfs_trans_reserve(
* reservations which have already been performed.
*/
undo_log:
if (logspace > 0) {
if (resp->tr_logres > 0) {
int log_flags;
if (flags & XFS_TRANS_PERM_LOG_RES) {
if (resp->tr_logflags & XFS_TRANS_PERM_LOG_RES) {
log_flags = XFS_LOG_REL_PERM_RESERV;
} else {
log_flags = 0;
@@ -1014,7 +1015,7 @@ xfs_trans_roll(
struct xfs_inode *dp)
{
struct xfs_trans *trans;
unsigned int logres, count;
struct xfs_trans_res tres;
int error;
/*
@@ -1026,8 +1027,8 @@ xfs_trans_roll(
/*
* Copy the critical parameters from one trans to the next.
*/
logres = trans->t_log_res;
count = trans->t_log_count;
tres.tr_logres = trans->t_log_res;
tres.tr_logcount = trans->t_log_count;
*tpp = xfs_trans_dup(trans);
/*
@@ -1058,8 +1059,8 @@ xfs_trans_roll(
* across this call, or that anything that is locked be logged in
* the prior and the next transactions.
*/
error = xfs_trans_reserve(trans, 0, logres, 0,
XFS_TRANS_PERM_LOG_RES, count);
tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
error = xfs_trans_reserve(trans, &tres, 0, 0);
/*
* Ensure that the inode is in the new transaction and locked.
*/