]> git.hungrycats.org Git - linux/commitdiff
Btrfs: add a flags field to btrfs_transaction
authorJosef Bacik <jbacik@fb.com>
Thu, 24 Sep 2015 14:46:10 +0000 (10:46 -0400)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Wed, 28 Oct 2015 01:11:44 +0000 (21:11 -0400)
I want to set some per transaction flags, so instead of adding yet another int
lets just convert the current two int indicators to flags and add a flags field
for future use.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
(cherry picked from commit d500be31aceb8a6d6f936e4460dbfd6e6ff99487)
(cherry picked from commit e0d90d690adbd775c998e78a5fc837c49a29394d)

fs/btrfs/extent-tree.c
fs/btrfs/transaction.c
fs/btrfs/transaction.h
fs/btrfs/volumes.c

index 68964150da3c8bfb82baad31e59c7729f8be70ac..9761a07ac16c5cf8267cb01497ef4a764ecf1ae8 100644 (file)
@@ -4019,7 +4019,8 @@ commit_trans:
                        if (IS_ERR(trans))
                                return PTR_ERR(trans);
                        if (have_pinned_space >= 0 ||
-                           trans->transaction->have_free_bgs ||
+                           test_bit(BTRFS_TRANS_HAVE_FREE_BGS,
+                                    &trans->transaction->flags) ||
                            need_commit > 0) {
                                ret = btrfs_commit_transaction(trans, root);
                                if (ret)
@@ -8871,7 +8872,7 @@ again:
         * back off and let this transaction commit
         */
        mutex_lock(&root->fs_info->ro_block_group_mutex);
-       if (trans->transaction->dirty_bg_run) {
+       if (test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &trans->transaction->flags)) {
                u64 transid = trans->transid;
 
                mutex_unlock(&root->fs_info->ro_block_group_mutex);
index 1b646237ad3bd4fdeece62b251c19ac2f87b934c..787d3ad449a9ffab87ca42c3f7ec1207eca16948 100644 (file)
@@ -231,10 +231,9 @@ loop:
         * commit the transaction.
         */
        atomic_set(&cur_trans->use_count, 2);
-       cur_trans->have_free_bgs = 0;
        atomic_set(&cur_trans->pending_ordered, 0);
+       cur_trans->flags = 0;
        cur_trans->start_time = get_seconds();
-       cur_trans->dirty_bg_run = 0;
 
        cur_trans->delayed_refs.href_root = RB_ROOT;
        cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
@@ -1826,7 +1825,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
                return ret;
        }
 
-       if (!cur_trans->dirty_bg_run) {
+       if (!test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &cur_trans->flags)) {
                int run_it = 0;
 
                /* this mutex is also taken before trying to set
@@ -1835,18 +1834,17 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
                 * after a extents from that block group have been
                 * allocated for cache files.  btrfs_set_block_group_ro
                 * will wait for the transaction to commit if it
-                * finds dirty_bg_run = 1
+                * finds BTRFS_TRANS_DIRTY_BG_RUN set.
                 *
-                * The dirty_bg_run flag is also used to make sure only
-                * one process starts all the block group IO.  It wouldn't
+                * The BTRFS_TRANS_DIRTY_BG_RUN flag is also used to make sure
+                * only one process starts all the block group IO.  It wouldn't
                 * hurt to have more than one go through, but there's no
                 * real advantage to it either.
                 */
                mutex_lock(&root->fs_info->ro_block_group_mutex);
-               if (!cur_trans->dirty_bg_run) {
+               if (!test_and_set_bit(BTRFS_TRANS_DIRTY_BG_RUN,
+                                     &cur_trans->flags))
                        run_it = 1;
-                       cur_trans->dirty_bg_run = 1;
-               }
                mutex_unlock(&root->fs_info->ro_block_group_mutex);
 
                if (run_it)
@@ -2116,7 +2114,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_finish_extent_commit(trans, root);
 
-       if (cur_trans->have_free_bgs)
+       if (test_bit(BTRFS_TRANS_HAVE_FREE_BGS, &cur_trans->flags))
                btrfs_clear_space_info_full(root->fs_info);
 
        root->fs_info->last_trans_committed = cur_trans->transid;
index a96b04f5e36461061b56064d717d1cbb9b1f3c10..6c9e78c9a541c760f4ff9baca05930e5756156ed 100644 (file)
@@ -32,6 +32,9 @@ enum btrfs_trans_state {
        TRANS_STATE_MAX                 = 6,
 };
 
+#define BTRFS_TRANS_HAVE_FREE_BGS      0
+#define BTRFS_TRANS_DIRTY_BG_RUN       1
+
 struct btrfs_transaction {
        u64 transid;
        /*
@@ -48,10 +51,7 @@ struct btrfs_transaction {
        atomic_t use_count;
        atomic_t pending_ordered;
 
-       /*
-        * true if there is free bgs operations in this transaction
-        */
-       int have_free_bgs;
+       unsigned long flags;
 
        /* Be protected by fs_info->trans_lock when we want to change it. */
        enum btrfs_trans_state state;
@@ -79,7 +79,6 @@ struct btrfs_transaction {
        spinlock_t dropped_roots_lock;
        struct btrfs_delayed_ref_root delayed_refs;
        int aborted;
-       int dirty_bg_run;
 };
 
 #define __TRANS_FREEZABLE      (1U << 0)
index 1471375a7b41cb1a1a438d3d2e290e96a1097222..fea1aefa2b3057238b634f53d64a4a32bd734c0d 100644 (file)
@@ -1399,7 +1399,7 @@ again:
                btrfs_error(root->fs_info, ret,
                            "Failed to remove dev extent item");
        } else {
-               trans->transaction->have_free_bgs = 1;
+               set_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags);
        }
 out:
        btrfs_free_path(path);