]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - fs/gfs2/log.c
gfs2: convert to use DEFINE_SEQ_ATTRIBUTE macro
[mirror_ubuntu-hirsute-kernel.git] / fs / gfs2 / log.c
index 3763c9ff1406bdbe102db85e2f5a68bf166e5c09..a83e6426e26eee092674e20848d47afb107c409f 100644 (file)
@@ -902,7 +902,7 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)
 }
 
 /**
- * drain_bd - drain the buf and databuf queue for a failed transaction
+ * trans_drain - drain the buf and databuf queue for a failed transaction
  * @tr: the transaction to drain
  *
  * When this is called, we're taking an error exit for a log write that failed
@@ -954,10 +954,8 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
                goto out;
 
        /* Log might have been flushed while we waited for the flush lock */
-       if (gl && !test_bit(GLF_LFLUSH, &gl->gl_flags)) {
-               up_write(&sdp->sd_log_flush_lock);
-               return;
-       }
+       if (gl && !test_bit(GLF_LFLUSH, &gl->gl_flags))
+               goto out;
        trace_gfs2_log_flush(sdp, 1, flags);
 
        if (flags & GFS2_LOG_HEAD_FLUSH_SHUTDOWN)
@@ -971,25 +969,25 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
                if (unlikely (state == SFS_FROZEN))
                        if (gfs2_assert_withdraw_delayed(sdp,
                               !tr->tr_num_buf_new && !tr->tr_num_databuf_new))
-                               goto out;
+                               goto out_withdraw;
        }
 
        if (unlikely(state == SFS_FROZEN))
                if (gfs2_assert_withdraw_delayed(sdp, !sdp->sd_log_num_revoke))
-                       goto out;
+                       goto out_withdraw;
        if (gfs2_assert_withdraw_delayed(sdp,
                        sdp->sd_log_num_revoke == sdp->sd_log_committed_revoke))
-               goto out;
+               goto out_withdraw;
 
        gfs2_ordered_write(sdp);
        if (gfs2_withdrawn(sdp))
-               goto out;
+               goto out_withdraw;
        lops_before_commit(sdp, tr);
        if (gfs2_withdrawn(sdp))
-               goto out;
+               goto out_withdraw;
        gfs2_log_submit_bio(&sdp->sd_log_bio, REQ_OP_WRITE);
        if (gfs2_withdrawn(sdp))
-               goto out;
+               goto out_withdraw;
 
        if (sdp->sd_log_head != sdp->sd_log_flush_head) {
                log_flush_wait(sdp);
@@ -1000,7 +998,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
                log_write_header(sdp, flags);
        }
        if (gfs2_withdrawn(sdp))
-               goto out;
+               goto out_withdraw;
        lops_after_commit(sdp, tr);
 
        gfs2_log_lock(sdp);
@@ -1020,7 +1018,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
                if (!sdp->sd_log_idle) {
                        empty_ail1_list(sdp);
                        if (gfs2_withdrawn(sdp))
-                               goto out;
+                               goto out_withdraw;
                        atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */
                        trace_gfs2_log_blocks(sdp, -1);
                        log_write_header(sdp, flags);
@@ -1033,27 +1031,30 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
                        atomic_set(&sdp->sd_freeze_state, SFS_FROZEN);
        }
 
-out:
-       if (gfs2_withdrawn(sdp)) {
-               trans_drain(tr);
-               /**
-                * If the tr_list is empty, we're withdrawing during a log
-                * flush that targets a transaction, but the transaction was
-                * never queued onto any of the ail lists. Here we add it to
-                * ail1 just so that ail_drain() will find and free it.
-                */
-               spin_lock(&sdp->sd_ail_lock);
-               if (tr && list_empty(&tr->tr_list))
-                       list_add(&tr->tr_list, &sdp->sd_ail1_list);
-               spin_unlock(&sdp->sd_ail_lock);
-               ail_drain(sdp); /* frees all transactions */
-               tr = NULL;
-       }
-
+out_end:
        trace_gfs2_log_flush(sdp, 0, flags);
+out:
        up_write(&sdp->sd_log_flush_lock);
-
        gfs2_trans_free(sdp, tr);
+       if (gfs2_withdrawing(sdp))
+               gfs2_withdraw(sdp);
+       return;
+
+out_withdraw:
+       trans_drain(tr);
+       /**
+        * If the tr_list is empty, we're withdrawing during a log
+        * flush that targets a transaction, but the transaction was
+        * never queued onto any of the ail lists. Here we add it to
+        * ail1 just so that ail_drain() will find and free it.
+        */
+       spin_lock(&sdp->sd_ail_lock);
+       if (tr && list_empty(&tr->tr_list))
+               list_add(&tr->tr_list, &sdp->sd_ail1_list);
+       spin_unlock(&sdp->sd_ail_lock);
+       ail_drain(sdp); /* frees all transactions */
+       tr = NULL;
+       goto out_end;
 }
 
 /**