xfs
[Top] [All Lists]

[PATCH 5/5] xfs: handle CIl transaction commit failures correctly

To: xfs@xxxxxxxxxxx
Subject: [PATCH 5/5] xfs: handle CIl transaction commit failures correctly
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 19 Jan 2011 15:30:00 +1100
In-reply-to: <1295411400-15614-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1295411400-15614-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Failure to commit a transaction into the CIL is not handled
correctly. This currently can only happen when racing with a
shutdown, so it rare. Handle the error similar to a log vector
memory allocation failure, and for both failures clear the PF_TRANS
flag from the task correctly.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/xfs_trans.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 50753d3..504a804 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1754,15 +1754,26 @@ xfs_trans_commit_cil(
         */
        log_vector = xfs_trans_alloc_log_vecs(tp);
        if (!log_vector)
-               return ENOMEM;
+               goto out_enomem;
 
        error = xfs_log_commit_cil(mp, tp, log_vector, commit_lsn, flags);
-       if (error)
-               return error;
+       if (error) {
+               /*
+                * We will only get an error if no modifications have been
+                * made to the items in the transaction. Hence treat it
+                 the same as a memory allocation failure.
+                */
+               goto out_enomem;
+       }
 
        current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
        xfs_trans_free(tp);
        return 0;
+
+out_enomem:
+       /* caller cleans up transaction */
+       current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);
+       return ENOMEM;
 }
 
 /*
-- 
1.7.2.3

<Prev in Thread] Current Thread [Next in Thread>