Merge tag 'v3.10.108' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / ext4 / ext4_jbd2.c
index 451eb404533095fc323218fe5ea0f3caa0af8b16..3517d5af257437c2033c15d536301e1b499c0206 100644 (file)
@@ -75,8 +75,14 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
                ext4_put_nojournal(handle);
                return 0;
        }
-       sb = handle->h_transaction->t_journal->j_private;
+
        err = handle->h_err;
+       if (!handle->h_transaction) {
+               rc = jbd2_journal_stop(handle);
+               return err ? err : rc;
+       }
+
+       sb = handle->h_transaction->t_journal->j_private;
        rc = jbd2_journal_stop(handle);
 
        if (!err)
@@ -219,10 +225,19 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
        set_buffer_prio(bh);
        if (ext4_handle_valid(handle)) {
                err = jbd2_journal_dirty_metadata(handle, bh);
-               if (err) {
-                       /* Errors can only happen if there is a bug */
-                       handle->h_err = err;
-                       __ext4_journal_stop(where, line, handle);
+               /* Errors can only happen if there is a bug */
+               if (WARN_ON_ONCE(err)) {
+                       ext4_journal_abort_handle(where, line, __func__, bh,
+                                                 handle, err);
+                       ext4_error_inode(inode, where, line,
+                                        bh->b_blocknr,
+                                        "journal_dirty_metadata failed: "
+                                        "handle type %u started at line %u, "
+                                        "credits %u/%u, errcode %d",
+                                        handle->h_type,
+                                        handle->h_line_no,
+                                        handle->h_requested_credits,
+                                        handle->h_buffer_credits, err);
                }
        } else {
                if (inode)