]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/jbd/commit.c
jbd: Convert atomic_inc() to get_bh()
[net-next-2.6.git] / fs / jbd / commit.c
index 28a9ddaa0c496f85625ccab2d543fc5e0886872b..a89c4630b1ed8a0048a36cfb9718d9aaba3a08ec 100644 (file)
@@ -119,7 +119,6 @@ static int journal_write_commit_record(journal_t *journal,
        struct buffer_head *bh;
        journal_header_t *header;
        int ret;
-       int barrier_done = 0;
 
        if (is_journal_aborted(journal))
                return 0;
@@ -137,34 +136,36 @@ static int journal_write_commit_record(journal_t *journal,
 
        JBUFFER_TRACE(descriptor, "write commit block");
        set_buffer_dirty(bh);
+
        if (journal->j_flags & JFS_BARRIER) {
-               set_buffer_ordered(bh);
-               barrier_done = 1;
-       }
-       ret = sync_dirty_buffer(bh);
-       if (barrier_done)
-               clear_buffer_ordered(bh);
-       /* is it possible for another commit to fail at roughly
-        * the same time as this one?  If so, we don't want to
-        * trust the barrier flag in the super, but instead want
-        * to remember if we sent a barrier request
-        */
-       if (ret == -EOPNOTSUPP && barrier_done) {
-               char b[BDEVNAME_SIZE];
+               ret = __sync_dirty_buffer(bh, WRITE_SYNC | WRITE_BARRIER);
 
-               printk(KERN_WARNING
-                       "JBD: barrier-based sync failed on %s - "
-                       "disabling barriers\n",
-                       bdevname(journal->j_dev, b));
-               spin_lock(&journal->j_state_lock);
-               journal->j_flags &= ~JFS_BARRIER;
-               spin_unlock(&journal->j_state_lock);
+               /*
+                * Is it possible for another commit to fail at roughly
+                * the same time as this one?  If so, we don't want to
+                * trust the barrier flag in the super, but instead want
+                * to remember if we sent a barrier request
+                */
+               if (ret == -EOPNOTSUPP) {
+                       char b[BDEVNAME_SIZE];
 
-               /* And try again, without the barrier */
-               set_buffer_uptodate(bh);
-               set_buffer_dirty(bh);
+                       printk(KERN_WARNING
+                               "JBD: barrier-based sync failed on %s - "
+                               "disabling barriers\n",
+                               bdevname(journal->j_dev, b));
+                       spin_lock(&journal->j_state_lock);
+                       journal->j_flags &= ~JFS_BARRIER;
+                       spin_unlock(&journal->j_state_lock);
+
+                       /* And try again, without the barrier */
+                       set_buffer_uptodate(bh);
+                       set_buffer_dirty(bh);
+                       ret = sync_dirty_buffer(bh);
+               }
+       } else {
                ret = sync_dirty_buffer(bh);
        }
+
        put_bh(bh);             /* One for getblk() */
        journal_put_journal_head(descriptor);
 
@@ -610,13 +611,13 @@ void journal_commit_transaction(journal_t *journal)
                /* Bump b_count to prevent truncate from stumbling over
                    the shadowed buffer!  @@@ This can go if we ever get
                    rid of the BJ_IO/BJ_Shadow pairing of buffers. */
-               atomic_inc(&jh2bh(jh)->b_count);
+               get_bh(jh2bh(jh));
 
                /* Make a temporary IO buffer with which to write it out
                    (this will requeue both the metadata buffer and the
                    temporary IO buffer). new_bh goes on BJ_IO*/
 
-               set_bit(BH_JWrite, &jh2bh(jh)->b_state);
+               set_buffer_jwrite(jh2bh(jh));
                /*
                 * akpm: journal_write_metadata_buffer() sets
                 * new_bh->b_transaction to commit_transaction.
@@ -626,7 +627,7 @@ void journal_commit_transaction(journal_t *journal)
                JBUFFER_TRACE(jh, "ph3: write metadata");
                flags = journal_write_metadata_buffer(commit_transaction,
                                                      jh, &new_jh, blocknr);
-               set_bit(BH_JWrite, &jh2bh(new_jh)->b_state);
+               set_buffer_jwrite(jh2bh(new_jh));
                wbuf[bufs++] = jh2bh(new_jh);
 
                /* Record the new block's tag in the current descriptor
@@ -736,7 +737,7 @@ wait_for_iobuf:
                    shadowed buffer */
                jh = commit_transaction->t_shadow_list->b_tprev;
                bh = jh2bh(jh);
-               clear_bit(BH_JWrite, &bh->b_state);
+               clear_buffer_jwrite(bh);
                J_ASSERT_BH(bh, buffer_jbddirty(bh));
 
                /* The metadata is now released for reuse, but we need