提交 f78c3901 编写于 作者: C Christoph Hellwig 提交者: Dave Chinner

xfs: fix xfs_log_done interface

Instead of the confusing flags argument pass a boolean flag to indicate if
we want to release or regrant a log reservation.

Also ensure that xfs_log_done always drop the reference on the log ticket,
to both simplify the code and make the logic in xfs_trans_roll easier
to understand.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDave Chinner <dchinner@redhat.com>
Signed-off-by: NDave Chinner <david@fromorbit.com>
上级 70393313
...@@ -513,7 +513,7 @@ xfs_log_done( ...@@ -513,7 +513,7 @@ xfs_log_done(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xlog_ticket *ticket, struct xlog_ticket *ticket,
struct xlog_in_core **iclog, struct xlog_in_core **iclog,
uint flags) bool regrant)
{ {
struct xlog *log = mp->m_log; struct xlog *log = mp->m_log;
xfs_lsn_t lsn = 0; xfs_lsn_t lsn = 0;
...@@ -526,14 +526,11 @@ xfs_log_done( ...@@ -526,14 +526,11 @@ xfs_log_done(
(((ticket->t_flags & XLOG_TIC_INITED) == 0) && (((ticket->t_flags & XLOG_TIC_INITED) == 0) &&
(xlog_commit_record(log, ticket, iclog, &lsn)))) { (xlog_commit_record(log, ticket, iclog, &lsn)))) {
lsn = (xfs_lsn_t) -1; lsn = (xfs_lsn_t) -1;
if (ticket->t_flags & XLOG_TIC_PERM_RESERV) { regrant = false;
flags |= XFS_LOG_REL_PERM_RESERV;
}
} }
if ((ticket->t_flags & XLOG_TIC_PERM_RESERV) == 0 || if (!regrant) {
(flags & XFS_LOG_REL_PERM_RESERV)) {
trace_xfs_log_done_nonperm(log, ticket); trace_xfs_log_done_nonperm(log, ticket);
/* /*
...@@ -541,7 +538,6 @@ xfs_log_done( ...@@ -541,7 +538,6 @@ xfs_log_done(
* request has been made to release a permanent reservation. * request has been made to release a permanent reservation.
*/ */
xlog_ungrant_log_space(log, ticket); xlog_ungrant_log_space(log, ticket);
xfs_log_ticket_put(ticket);
} else { } else {
trace_xfs_log_done_perm(log, ticket); trace_xfs_log_done_perm(log, ticket);
...@@ -553,6 +549,7 @@ xfs_log_done( ...@@ -553,6 +549,7 @@ xfs_log_done(
ticket->t_flags |= XLOG_TIC_INITED; ticket->t_flags |= XLOG_TIC_INITED;
} }
xfs_log_ticket_put(ticket);
return lsn; return lsn;
} }
......
...@@ -110,15 +110,6 @@ static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) ...@@ -110,15 +110,6 @@ static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
#define XFS_LSN_CMP(x,y) _lsn_cmp(x,y) #define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
/*
* Macros, structures, prototypes for interface to the log manager.
*/
/*
* Flags to xfs_log_done()
*/
#define XFS_LOG_REL_PERM_RESERV 0x1
/* /*
* Flags to xfs_log_force() * Flags to xfs_log_force()
* *
...@@ -138,7 +129,7 @@ struct xfs_log_callback; ...@@ -138,7 +129,7 @@ struct xfs_log_callback;
xfs_lsn_t xfs_log_done(struct xfs_mount *mp, xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
struct xlog_ticket *ticket, struct xlog_ticket *ticket,
struct xlog_in_core **iclog, struct xlog_in_core **iclog,
uint flags); bool regrant);
int _xfs_log_force(struct xfs_mount *mp, int _xfs_log_force(struct xfs_mount *mp,
uint flags, uint flags,
int *log_forced); int *log_forced);
......
...@@ -624,7 +624,7 @@ xlog_cil_push( ...@@ -624,7 +624,7 @@ xlog_cil_push(
spin_unlock(&cil->xc_push_lock); spin_unlock(&cil->xc_push_lock);
/* xfs_log_done always frees the ticket on error. */ /* xfs_log_done always frees the ticket on error. */
commit_lsn = xfs_log_done(log->l_mp, tic, &commit_iclog, 0); commit_lsn = xfs_log_done(log->l_mp, tic, &commit_iclog, false);
if (commit_lsn == -1) if (commit_lsn == -1)
goto out_abort; goto out_abort;
...@@ -777,10 +777,6 @@ xfs_log_commit_cil( ...@@ -777,10 +777,6 @@ xfs_log_commit_cil(
{ {
struct xlog *log = mp->m_log; struct xlog *log = mp->m_log;
struct xfs_cil *cil = log->l_cilp; struct xfs_cil *cil = log->l_cilp;
int log_flags = 0;
if (!regrant)
log_flags = XFS_LOG_REL_PERM_RESERV;
/* lock out background commit */ /* lock out background commit */
down_read(&cil->xc_ctx_lock); down_read(&cil->xc_ctx_lock);
...@@ -795,7 +791,7 @@ xfs_log_commit_cil( ...@@ -795,7 +791,7 @@ xfs_log_commit_cil(
if (commit_lsn) if (commit_lsn)
*commit_lsn = tp->t_commit_lsn; *commit_lsn = tp->t_commit_lsn;
xfs_log_done(mp, tp->t_ticket, NULL, log_flags); xfs_log_done(mp, tp->t_ticket, NULL, regrant);
xfs_trans_unreserve_and_mod_sb(tp); xfs_trans_unreserve_and_mod_sb(tp);
/* /*
......
...@@ -251,14 +251,7 @@ xfs_trans_reserve( ...@@ -251,14 +251,7 @@ xfs_trans_reserve(
*/ */
undo_log: undo_log:
if (resp->tr_logres > 0) { if (resp->tr_logres > 0) {
int log_flags; xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, false);
if (resp->tr_logflags & XFS_TRANS_PERM_LOG_RES) {
log_flags = XFS_LOG_REL_PERM_RESERV;
} else {
log_flags = 0;
}
xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, log_flags);
tp->t_ticket = NULL; tp->t_ticket = NULL;
tp->t_log_res = 0; tp->t_log_res = 0;
tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES;
...@@ -954,13 +947,7 @@ __xfs_trans_commit( ...@@ -954,13 +947,7 @@ __xfs_trans_commit(
*/ */
xfs_trans_unreserve_and_mod_dquots(tp); xfs_trans_unreserve_and_mod_dquots(tp);
if (tp->t_ticket) { if (tp->t_ticket) {
int log_flags = 0; commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, regrant);
if (regrant)
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
else
log_flags = XFS_LOG_REL_PERM_RESERV;
commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, log_flags);
if (commit_lsn == -1 && !error) if (commit_lsn == -1 && !error)
error = -EIO; error = -EIO;
} }
...@@ -1014,13 +1001,8 @@ xfs_trans_cancel( ...@@ -1014,13 +1001,8 @@ xfs_trans_cancel(
xfs_trans_unreserve_and_mod_sb(tp); xfs_trans_unreserve_and_mod_sb(tp);
xfs_trans_unreserve_and_mod_dquots(tp); xfs_trans_unreserve_and_mod_dquots(tp);
if (tp->t_ticket) { if (tp->t_ticket)
uint log_flags = 0; xfs_log_done(mp, tp->t_ticket, NULL, false);
if (tp->t_flags & XFS_TRANS_PERM_LOG_RES)
log_flags = XFS_LOG_REL_PERM_RESERV;
xfs_log_done(mp, tp->t_ticket, NULL, log_flags);
}
/* mark this thread as no longer being in a transaction */ /* mark this thread as no longer being in a transaction */
current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
...@@ -1072,13 +1054,6 @@ xfs_trans_roll( ...@@ -1072,13 +1054,6 @@ xfs_trans_roll(
trans = *tpp; trans = *tpp;
/*
* transaction commit worked ok so we can drop the extra ticket
* reference that we gained in xfs_trans_dup()
*/
xfs_log_ticket_put(trans->t_ticket);
/* /*
* Reserve space in the log for th next transaction. * Reserve space in the log for th next transaction.
* This also pushes items in the "AIL", the list of logged items, * This also pushes items in the "AIL", the list of logged items,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册