Skip to content

Commit b77428b

Browse files
djwongdchinner
authored andcommitted
xfs: defer should abort intent items if the trans roll fails
If the deferred ops transaction roll fails, we need to abort the intent items if we haven't already logged a done item for it, regardless of whether or not the deferred ops has had a transaction committed. Dave found this while running generic/388. Move the tracepoint to make it easier to track object lifetimes. Reported-by: Dave Chinner <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent c17a8ef commit b77428b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

fs/xfs/libxfs/xfs_defer.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ xfs_defer_intake_work(
199199
struct xfs_defer_pending *dfp;
200200

201201
list_for_each_entry(dfp, &dop->dop_intake, dfp_list) {
202-
trace_xfs_defer_intake_work(tp->t_mountp, dfp);
203202
dfp->dfp_intent = dfp->dfp_type->create_intent(tp,
204203
dfp->dfp_count);
204+
trace_xfs_defer_intake_work(tp->t_mountp, dfp);
205205
list_sort(tp->t_mountp, &dfp->dfp_work,
206206
dfp->dfp_type->diff_items);
207207
list_for_each(li, &dfp->dfp_work)
@@ -221,21 +221,14 @@ xfs_defer_trans_abort(
221221
struct xfs_defer_pending *dfp;
222222

223223
trace_xfs_defer_trans_abort(tp->t_mountp, dop);
224-
/*
225-
* If the transaction was committed, drop the intent reference
226-
* since we're bailing out of here. The other reference is
227-
* dropped when the intent hits the AIL. If the transaction
228-
* was not committed, the intent is freed by the intent item
229-
* unlock handler on abort.
230-
*/
231-
if (!dop->dop_committed)
232-
return;
233224

234-
/* Abort intent items. */
225+
/* Abort intent items that don't have a done item. */
235226
list_for_each_entry(dfp, &dop->dop_pending, dfp_list) {
236227
trace_xfs_defer_pending_abort(tp->t_mountp, dfp);
237-
if (!dfp->dfp_done)
228+
if (dfp->dfp_intent && !dfp->dfp_done) {
238229
dfp->dfp_type->abort_intent(dfp->dfp_intent);
230+
dfp->dfp_intent = NULL;
231+
}
239232
}
240233

241234
/* Shut down FS. */

0 commit comments

Comments
 (0)