]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Split out btree_trigger_flags
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 31 Dec 2019 21:17:42 +0000 (16:17 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:33 +0000 (17:08 -0400)
The trigger flags really belong with individual btree_insert_entries,
not the transaction commit flags - this splits out those  flags and
unifies them with the BCH_BUCKET_MARK flags. Todo - split out
btree_trigger.c from buckets.c

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
22 files changed:
fs/bcachefs/acl.c
fs/bcachefs/alloc_background.c
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_types.h
fs/bcachefs/btree_update.h
fs/bcachefs/btree_update_interior.c
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/buckets.c
fs/bcachefs/buckets.h
fs/bcachefs/dirent.c
fs/bcachefs/ec.c
fs/bcachefs/fs-io.c
fs/bcachefs/fsck.c
fs/bcachefs/inode.c
fs/bcachefs/io.c
fs/bcachefs/migrate.c
fs/bcachefs/move.c
fs/bcachefs/quota.c
fs/bcachefs/recovery.c
fs/bcachefs/reflink.c
fs/bcachefs/str_hash.h
fs/bcachefs/tests.c

index 5a8d8311c08dd1ac61baf872a7da9f0c90760765..acc1d03c79e4fce8209115bb87c4ec81747f3c89 100644 (file)
@@ -380,7 +380,7 @@ int bch2_acl_chmod(struct btree_trans *trans,
        }
 
        new->k.p = iter->pos;
-       bch2_trans_update(trans, iter, &new->k_i);
+       bch2_trans_update(trans, iter, &new->k_i, 0);
        *new_acl = acl;
        acl = NULL;
 err:
index bd3e46d066bdd5134fa591a98f59a5e68d6e0e95..5bc8e75314036ce9f60e80359542ef12a96ec950 100644 (file)
@@ -222,8 +222,8 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
 
        for_each_btree_key(&trans, iter, BTREE_ID_ALLOC, POS_MIN, 0, k, ret)
                bch2_mark_key(c, k, 0, 0, NULL, 0,
-                             BCH_BUCKET_MARK_ALLOC_READ|
-                             BCH_BUCKET_MARK_NOATOMIC);
+                             BTREE_TRIGGER_ALLOC_READ|
+                             BTREE_TRIGGER_NOATOMIC);
 
        ret = bch2_trans_exit(&trans) ?: ret;
        if (ret) {
@@ -235,8 +235,8 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
                if (j->btree_id == BTREE_ID_ALLOC)
                        bch2_mark_key(c, bkey_i_to_s_c(j->k),
                                      0, 0, NULL, 0,
-                                     BCH_BUCKET_MARK_ALLOC_READ|
-                                     BCH_BUCKET_MARK_NOATOMIC);
+                                     BTREE_TRIGGER_ALLOC_READ|
+                                     BTREE_TRIGGER_NOATOMIC);
 
        percpu_down_write(&c->mark_lock);
        bch2_dev_usage_from_buckets(c);
@@ -314,11 +314,10 @@ retry:
        a->k.p = iter->pos;
        bch2_alloc_pack(a, new_u);
 
-       bch2_trans_update(trans, iter, &a->k_i);
+       bch2_trans_update(trans, iter, &a->k_i,
+                         BTREE_TRIGGER_NORUN);
        ret = bch2_trans_commit(trans, NULL, NULL,
-                               BTREE_INSERT_NOFAIL|
-                               BTREE_INSERT_NOMARK|
-                               flags);
+                               BTREE_INSERT_NOFAIL|flags);
 err:
        if (ret == -EINTR)
                goto retry;
@@ -383,8 +382,7 @@ int bch2_alloc_replay_key(struct bch_fs *c, struct bkey_i *k)
        ret = bch2_alloc_write_key(&trans, iter,
                                   BTREE_INSERT_NOFAIL|
                                   BTREE_INSERT_LAZY_RW|
-                                  BTREE_INSERT_JOURNAL_REPLAY|
-                                  BTREE_INSERT_NOMARK);
+                                  BTREE_INSERT_JOURNAL_REPLAY);
        bch2_trans_exit(&trans);
        return ret < 0 ? ret : 0;
 }
@@ -901,7 +899,8 @@ retry:
        a->k.p = iter->pos;
        bch2_alloc_pack(a, u);
 
-       bch2_trans_update(trans, iter, &a->k_i);
+       bch2_trans_update(trans, iter, &a->k_i,
+                         BTREE_TRIGGER_BUCKET_INVALIDATE);
 
        /*
         * XXX:
@@ -917,7 +916,6 @@ retry:
                                BTREE_INSERT_NOFAIL|
                                BTREE_INSERT_USE_RESERVE|
                                BTREE_INSERT_USE_ALLOC_RESERVE|
-                               BTREE_INSERT_BUCKET_INVALIDATE|
                                flags);
        if (ret == -EINTR)
                goto retry;
index 2eaf6a55c06c10510e049d3b329fa25546ec4b82..a0b65267cf760fa6db09263f4ea964ec18d7cfc4 100644 (file)
@@ -118,8 +118,8 @@ static int bch2_gc_mark_key(struct bch_fs *c, struct bkey_s_c k,
        struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
        const struct bch_extent_ptr *ptr;
        unsigned flags =
-               BCH_BUCKET_MARK_GC|
-               (initial ? BCH_BUCKET_MARK_NOATOMIC : 0);
+               BTREE_TRIGGER_GC|
+               (initial ? BTREE_TRIGGER_NOATOMIC : 0);
        int ret = 0;
 
        if (initial) {
@@ -296,8 +296,8 @@ static int mark_journal_key(struct bch_fs *c, enum btree_id id,
                           BTREE_ITER_SLOTS, k, ret) {
                percpu_down_read(&c->mark_lock);
                ret = bch2_mark_overwrite(&trans, iter, k, insert, NULL,
-                                        BCH_BUCKET_MARK_GC|
-                                        BCH_BUCKET_MARK_NOATOMIC);
+                                        BTREE_TRIGGER_GC|
+                                        BTREE_TRIGGER_NOATOMIC);
                percpu_up_read(&c->mark_lock);
 
                if (!ret)
@@ -409,7 +409,7 @@ static void bch2_mark_superblocks(struct bch_fs *c)
        gc_pos_set(c, gc_phase(GC_PHASE_SB));
 
        for_each_online_member(ca, c, i)
-               bch2_mark_dev_superblock(c, ca, BCH_BUCKET_MARK_GC);
+               bch2_mark_dev_superblock(c, ca, BTREE_TRIGGER_GC);
        mutex_unlock(&c->sb_lock);
 }
 
@@ -426,7 +426,7 @@ static void bch2_mark_pending_btree_node_frees(struct bch_fs *c)
                if (d->index_update_done)
                        bch2_mark_key(c, bkey_i_to_s_c(&d->key),
                                      0, 0, NULL, 0,
-                                     BCH_BUCKET_MARK_GC);
+                                     BTREE_TRIGGER_GC);
 
        mutex_unlock(&c->btree_interior_update_lock);
 }
@@ -447,7 +447,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c)
                fifo_for_each_entry(i, &ca->free_inc, iter)
                        bch2_mark_alloc_bucket(c, ca, i, true,
                                               gc_pos_alloc(c, NULL),
-                                              BCH_BUCKET_MARK_GC);
+                                              BTREE_TRIGGER_GC);
 
 
 
@@ -455,7 +455,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c)
                        fifo_for_each_entry(i, &ca->free[j], iter)
                                bch2_mark_alloc_bucket(c, ca, i, true,
                                                       gc_pos_alloc(c, NULL),
-                                                      BCH_BUCKET_MARK_GC);
+                                                      BTREE_TRIGGER_GC);
        }
 
        spin_unlock(&c->freelist_lock);
@@ -469,7 +469,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c)
                        ca = bch_dev_bkey_exists(c, ob->ptr.dev);
                        bch2_mark_alloc_bucket(c, ca, PTR_BUCKET_NR(ca, &ob->ptr), true,
                                               gc_pos_alloc(c, ob),
-                                              BCH_BUCKET_MARK_GC);
+                                              BTREE_TRIGGER_GC);
                }
                spin_unlock(&ob->lock);
        }
index 6d95a5674e97880d879b0830cb82e9fcc7bd459d..63d04873addb91c44a979476321f421e5eeca975 100644 (file)
@@ -245,6 +245,7 @@ static inline enum btree_iter_type btree_iter_type(struct btree_iter *iter)
 }
 
 struct btree_insert_entry {
+       unsigned                trigger_flags;
        struct bkey_i           *k;
        struct btree_iter       *iter;
 };
@@ -484,6 +485,32 @@ static inline bool btree_node_is_extents(struct btree *b)
         (1U << BKEY_TYPE_INODES)|                      \
         (1U << BKEY_TYPE_REFLINK))
 
+enum btree_trigger_flags {
+       __BTREE_TRIGGER_NORUN,          /* Don't run triggers at all */
+       __BTREE_TRIGGER_NOOVERWRITES,   /* Don't run triggers on overwrites */
+
+       __BTREE_TRIGGER_INSERT,
+       __BTREE_TRIGGER_OVERWRITE,
+       __BTREE_TRIGGER_OVERWRITE_SPLIT,
+
+       __BTREE_TRIGGER_GC,
+       __BTREE_TRIGGER_BUCKET_INVALIDATE,
+       __BTREE_TRIGGER_ALLOC_READ,
+       __BTREE_TRIGGER_NOATOMIC,
+};
+
+#define BTREE_TRIGGER_NORUN            (1U << __BTREE_TRIGGER_NORUN)
+#define BTREE_TRIGGER_NOOVERWRITES     (1U << __BTREE_TRIGGER_NOOVERWRITES)
+
+#define BTREE_TRIGGER_INSERT           (1U << __BTREE_TRIGGER_INSERT)
+#define BTREE_TRIGGER_OVERWRITE                (1U << __BTREE_TRIGGER_OVERWRITE)
+#define BTREE_TRIGGER_OVERWRITE_SPLIT  (1U << __BTREE_TRIGGER_OVERWRITE_SPLIT)
+
+#define BTREE_TRIGGER_GC               (1U << __BTREE_TRIGGER_GC)
+#define BTREE_TRIGGER_BUCKET_INVALIDATE        (1U << __BTREE_TRIGGER_BUCKET_INVALIDATE)
+#define BTREE_TRIGGER_ALLOC_READ       (1U << __BTREE_TRIGGER_ALLOC_READ)
+#define BTREE_TRIGGER_NOATOMIC         (1U << __BTREE_TRIGGER_NOATOMIC)
+
 static inline bool btree_node_type_needs_gc(enum btree_node_type type)
 {
        return BTREE_NODE_TYPE_HAS_TRIGGERS & (1U << type);
index 7f61351aed71f3ab73e15887be69888a13571378..add7217598ed0d77f98d86ea02ce2909e142ce92 100644 (file)
@@ -15,7 +15,7 @@ bool bch2_btree_bset_insert_key(struct btree_iter *, struct btree *,
 void bch2_btree_journal_key(struct btree_trans *, struct btree_iter *,
                            struct bkey_i *);
 
-enum {
+enum btree_insert_flags {
        __BTREE_INSERT_NOUNLOCK,
        __BTREE_INSERT_NOFAIL,
        __BTREE_INSERT_NOCHECK_RW,
@@ -24,9 +24,6 @@ enum {
        __BTREE_INSERT_USE_ALLOC_RESERVE,
        __BTREE_INSERT_JOURNAL_REPLAY,
        __BTREE_INSERT_JOURNAL_RESERVED,
-       __BTREE_INSERT_NOMARK_OVERWRITES,
-       __BTREE_INSERT_NOMARK,
-       __BTREE_INSERT_BUCKET_INVALIDATE,
        __BTREE_INSERT_NOWAIT,
        __BTREE_INSERT_GC_LOCK_HELD,
        __BCH_HASH_SET_MUST_CREATE,
@@ -53,14 +50,6 @@ enum {
 
 #define BTREE_INSERT_JOURNAL_RESERVED  (1 << __BTREE_INSERT_JOURNAL_RESERVED)
 
-/* Don't mark overwrites, just new key: */
-#define BTREE_INSERT_NOMARK_OVERWRITES (1 << __BTREE_INSERT_NOMARK_OVERWRITES)
-
-/* Don't call mark new key at all: */
-#define BTREE_INSERT_NOMARK            (1 << __BTREE_INSERT_NOMARK)
-
-#define BTREE_INSERT_BUCKET_INVALIDATE (1 << __BTREE_INSERT_BUCKET_INVALIDATE)
-
 /* Don't block on allocation failure (for new btree nodes: */
 #define BTREE_INSERT_NOWAIT            (1 << __BTREE_INSERT_NOWAIT)
 #define BTREE_INSERT_GC_LOCK_HELD      (1 << __BTREE_INSERT_GC_LOCK_HELD)
@@ -108,15 +97,15 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
 }
 
 static inline void bch2_trans_update(struct btree_trans *trans,
-                                    struct btree_iter *iter,
-                                    struct bkey_i *k)
+                                    struct btree_iter *iter, struct bkey_i *k,
+                                    enum btree_trigger_flags flags)
 {
        EBUG_ON(trans->nr_updates >= trans->nr_iters);
 
        iter->flags |= BTREE_ITER_KEEP_UNTIL_COMMIT;
 
        trans->updates[trans->nr_updates++] = (struct btree_insert_entry) {
-               .iter = iter, .k = k
+               .trigger_flags = flags, .iter = iter, .k = k
        };
 }
 
index 870eb0938c2249bbfde25afa546ed1c51a949c6e..c8fbee82cc562c4976f43109fe117b9252f9d9d7 100644 (file)
@@ -193,8 +193,8 @@ found:
            gc_pos_cmp(c->gc_pos, gc_phase(GC_PHASE_PENDING_DELETE)) < 0)
                bch2_mark_key_locked(c, bkey_i_to_s_c(&d->key),
                              0, 0, NULL, 0,
-                             BCH_BUCKET_MARK_OVERWRITE|
-                             BCH_BUCKET_MARK_GC);
+                             BTREE_TRIGGER_OVERWRITE|
+                             BTREE_TRIGGER_GC);
 }
 
 static void __btree_node_free(struct bch_fs *c, struct btree *b)
@@ -265,13 +265,13 @@ static void bch2_btree_node_free_ondisk(struct bch_fs *c,
        BUG_ON(!pending->index_update_done);
 
        bch2_mark_key(c, bkey_i_to_s_c(&pending->key),
-                     0, 0, NULL, 0, BCH_BUCKET_MARK_OVERWRITE);
+                     0, 0, NULL, 0, BTREE_TRIGGER_OVERWRITE);
 
        if (gc_visited(c, gc_phase(GC_PHASE_PENDING_DELETE)))
                bch2_mark_key(c, bkey_i_to_s_c(&pending->key),
                              0, 0, NULL, 0,
-                             BCH_BUCKET_MARK_OVERWRITE|
-                             BCH_BUCKET_MARK_GC);
+                             BTREE_TRIGGER_OVERWRITE|
+                             BTREE_TRIGGER_GC);
 }
 
 static struct btree *__bch2_btree_node_alloc(struct bch_fs *c,
@@ -1084,12 +1084,12 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b)
 
        bch2_mark_key_locked(c, bkey_i_to_s_c(&b->key),
                      0, 0, &fs_usage->u, 0,
-                     BCH_BUCKET_MARK_INSERT);
+                     BTREE_TRIGGER_INSERT);
        if (gc_visited(c, gc_pos_btree_root(b->c.btree_id)))
                bch2_mark_key_locked(c, bkey_i_to_s_c(&b->key),
                                     0, 0, NULL, 0,
-                                    BCH_BUCKET_MARK_INSERT|
-                                    BCH_BUCKET_MARK_GC);
+                                    BTREE_TRIGGER_INSERT|
+                                    BTREE_TRIGGER_GC);
 
        if (old && !btree_node_fake(old))
                bch2_btree_node_free_index(as, NULL,
@@ -1182,13 +1182,13 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b
 
        bch2_mark_key_locked(c, bkey_i_to_s_c(insert),
                             0, 0, &fs_usage->u, 0,
-                            BCH_BUCKET_MARK_INSERT);
+                            BTREE_TRIGGER_INSERT);
 
        if (gc_visited(c, gc_pos_btree_node(b)))
                bch2_mark_key_locked(c, bkey_i_to_s_c(insert),
                                     0, 0, NULL, 0,
-                                    BCH_BUCKET_MARK_INSERT|
-                                    BCH_BUCKET_MARK_GC);
+                                    BTREE_TRIGGER_INSERT|
+                                    BTREE_TRIGGER_GC);
 
        while ((k = bch2_btree_node_iter_peek_all(node_iter, b)) &&
               bkey_iter_pos_cmp(b, &insert->k.p, k) > 0)
@@ -2031,12 +2031,12 @@ static void __bch2_btree_node_update_key(struct bch_fs *c,
 
                bch2_mark_key_locked(c, bkey_i_to_s_c(&new_key->k_i),
                              0, 0, &fs_usage->u, 0,
-                             BCH_BUCKET_MARK_INSERT);
+                             BTREE_TRIGGER_INSERT);
                if (gc_visited(c, gc_pos_btree_root(b->c.btree_id)))
                        bch2_mark_key_locked(c, bkey_i_to_s_c(&new_key->k_i),
                                             0, 0, NULL, 0,
-                                            BCH_BUCKET_MARK_INSERT||
-                                            BCH_BUCKET_MARK_GC);
+                                            BTREE_TRIGGER_INSERT||
+                                            BTREE_TRIGGER_GC);
 
                bch2_btree_node_free_index(as, NULL,
                                           bkey_i_to_s_c(&b->key),
index abcfd42fc24f77b00d844338957d886b59e8c273..07a6213914f7f8a622a0f536e2be9fca408f6c67 100644 (file)
@@ -395,17 +395,11 @@ static noinline void bch2_trans_mark_gc(struct btree_trans *trans)
 {
        struct bch_fs *c = trans->c;
        struct btree_insert_entry *i;
-       unsigned mark_flags = trans->flags & BTREE_INSERT_BUCKET_INVALIDATE
-               ? BCH_BUCKET_MARK_BUCKET_INVALIDATE
-               : 0;
-
-       if (unlikely(trans->flags & BTREE_INSERT_NOMARK))
-               return;
 
        trans_for_each_update(trans, i)
                if (gc_visited(c, gc_pos_btree_node(i->iter->l[0].b)))
                        bch2_mark_update(trans, i->iter, i->k, NULL,
-                                        mark_flags|BCH_BUCKET_MARK_GC);
+                                        i->trigger_flags|BTREE_TRIGGER_GC);
 }
 
 static inline int
@@ -415,9 +409,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
        struct bch_fs *c = trans->c;
        struct bch_fs_usage_online *fs_usage = NULL;
        struct btree_insert_entry *i;
-       unsigned mark_flags = trans->flags & BTREE_INSERT_BUCKET_INVALIDATE
-               ? BCH_BUCKET_MARK_BUCKET_INVALIDATE
-               : 0;
        unsigned iter, u64s = 0;
        bool marking = false;
        int ret;
@@ -490,10 +481,9 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
        }
 
        trans_for_each_update(trans, i)
-               if (likely(!(trans->flags & BTREE_INSERT_NOMARK)) &&
-                   iter_has_nontrans_triggers(i->iter))
+               if (iter_has_nontrans_triggers(i->iter))
                        bch2_mark_update(trans, i->iter, i->k,
-                                        &fs_usage->u, mark_flags);
+                                        &fs_usage->u, i->trigger_flags);
 
        if (marking)
                bch2_trans_fs_usage_apply(trans, fs_usage);
@@ -753,9 +743,9 @@ int __bch2_trans_commit(struct btree_trans *trans)
                        goto out;
                }
 
-               if (likely(!(trans->flags & BTREE_INSERT_NOMARK)) &&
-                   iter_has_trans_triggers(i->iter)) {
-                       ret = bch2_trans_mark_update(trans, i->iter, i->k);
+               if (iter_has_trans_triggers(i->iter)) {
+                       ret = bch2_trans_mark_update(trans, i->iter, i->k,
+                                                    i->trigger_flags);
                        if (unlikely(ret)) {
                                if (ret == -EINTR)
                                        trace_trans_restart_mark(trans->ip);
@@ -805,7 +795,7 @@ static int __bch2_btree_insert(struct btree_trans *trans,
        if (IS_ERR(iter))
                return PTR_ERR(iter);
 
-       bch2_trans_update(trans, iter, k);
+       bch2_trans_update(trans, iter, k, 0);
        return 0;
 }
 
@@ -867,7 +857,7 @@ retry:
                                break;
                }
 
-               bch2_trans_update(trans, iter, &delete);
+               bch2_trans_update(trans, iter, &delete, 0);
                ret = bch2_trans_commit(trans, NULL, journal_seq,
                                        BTREE_INSERT_NOFAIL);
                if (ret)
@@ -893,7 +883,7 @@ int bch2_btree_delete_at(struct btree_trans *trans,
        bkey_init(&k.k);
        k.k.p = iter->pos;
 
-       bch2_trans_update(trans, iter, &k);
+       bch2_trans_update(trans, iter, &k, 0);
        return bch2_trans_commit(trans, NULL, NULL,
                                 BTREE_INSERT_NOFAIL|
                                 BTREE_INSERT_USE_RESERVE|flags);
index b516b636fbf2122eaa6d65d660abf1c4ea9509ce..d90bcbc0a005e8e7234166694f3f635729d0c79c 100644 (file)
@@ -628,7 +628,7 @@ unwind:
        percpu_rwsem_assert_held(&c->mark_lock);                        \
                                                                        \
        for (gc = 0; gc < 2 && !ret; gc++)                              \
-               if (!gc == !(flags & BCH_BUCKET_MARK_GC) ||             \
+               if (!gc == !(flags & BTREE_TRIGGER_GC) ||               \
                    (gc && gc_visited(c, pos)))                         \
                        ret = fn(c, __VA_ARGS__, gc);                   \
        ret;                                                            \
@@ -710,7 +710,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
                           struct bch_fs_usage *fs_usage,
                           u64 journal_seq, unsigned flags)
 {
-       bool gc = flags & BCH_BUCKET_MARK_GC;
+       bool gc = flags & BTREE_TRIGGER_GC;
        struct bkey_alloc_unpacked u;
        struct bch_dev *ca;
        struct bucket *g;
@@ -719,8 +719,8 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
        /*
         * alloc btree is read in by bch2_alloc_read, not gc:
         */
-       if ((flags & BCH_BUCKET_MARK_GC) &&
-           !(flags & BCH_BUCKET_MARK_BUCKET_INVALIDATE))
+       if ((flags & BTREE_TRIGGER_GC) &&
+           !(flags & BTREE_TRIGGER_BUCKET_INVALIDATE))
                return 0;
 
        ca = bch_dev_bkey_exists(c, k.k->p.inode);
@@ -743,7 +743,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
                }
        }));
 
-       if (!(flags & BCH_BUCKET_MARK_ALLOC_READ))
+       if (!(flags & BTREE_TRIGGER_ALLOC_READ))
                bch2_dev_usage_update(c, ca, fs_usage, old, m, gc);
 
        g->io_time[READ]        = u.read_time;
@@ -756,7 +756,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
         * not:
         */
 
-       if ((flags & BCH_BUCKET_MARK_BUCKET_INVALIDATE) &&
+       if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) &&
            old.cached_sectors) {
                update_cached_sectors(c, fs_usage, ca->dev_idx,
                                      -old.cached_sectors);
@@ -842,13 +842,13 @@ static s64 __ptr_disk_sectors_delta(unsigned old_size,
 {
        BUG_ON(!n || !d);
 
-       if (flags & BCH_BUCKET_MARK_OVERWRITE_SPLIT) {
+       if (flags & BTREE_TRIGGER_OVERWRITE_SPLIT) {
                BUG_ON(offset + -delta > old_size);
 
                return -disk_sectors_scaled(n, d, old_size) +
                        disk_sectors_scaled(n, d, offset) +
                        disk_sectors_scaled(n, d, old_size - offset + delta);
-       } else if (flags & BCH_BUCKET_MARK_OVERWRITE) {
+       } else if (flags & BTREE_TRIGGER_OVERWRITE) {
                BUG_ON(offset + -delta > old_size);
 
                return -disk_sectors_scaled(n, d, old_size) +
@@ -874,8 +874,8 @@ static void bucket_set_stripe(struct bch_fs *c,
                              u64 journal_seq,
                              unsigned flags)
 {
-       bool enabled = !(flags & BCH_BUCKET_MARK_OVERWRITE);
-       bool gc = flags & BCH_BUCKET_MARK_GC;
+       bool enabled = !(flags & BTREE_TRIGGER_OVERWRITE);
+       bool gc = flags & BTREE_TRIGGER_GC;
        unsigned i;
 
        for (i = 0; i < v->nr_blocks; i++) {
@@ -922,7 +922,7 @@ static bool bch2_mark_pointer(struct bch_fs *c,
                              struct bch_fs_usage *fs_usage,
                              u64 journal_seq, unsigned flags)
 {
-       bool gc = flags & BCH_BUCKET_MARK_GC;
+       bool gc = flags & BTREE_TRIGGER_GC;
        struct bucket_mark old, new;
        struct bch_dev *ca = bch_dev_bkey_exists(c, p.ptr.dev);
        struct bucket *g = PTR_BUCKET(ca, &p.ptr, gc);
@@ -970,7 +970,7 @@ static bool bch2_mark_pointer(struct bch_fs *c,
                        new.data_type = data_type;
                }
 
-               if (flags & BCH_BUCKET_MARK_NOATOMIC) {
+               if (flags & BTREE_TRIGGER_NOATOMIC) {
                        g->_mark = new;
                        break;
                }
@@ -1008,7 +1008,7 @@ static int bch2_mark_stripe_ptr(struct bch_fs *c,
                                unsigned *nr_data,
                                unsigned *nr_parity)
 {
-       bool gc = flags & BCH_BUCKET_MARK_GC;
+       bool gc = flags & BTREE_TRIGGER_GC;
        struct stripe *m;
        unsigned old, new;
        int blocks_nonempty_delta;
@@ -1121,7 +1121,7 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k,
                            struct bch_fs_usage *fs_usage,
                            u64 journal_seq, unsigned flags)
 {
-       bool gc = flags & BCH_BUCKET_MARK_GC;
+       bool gc = flags & BTREE_TRIGGER_GC;
        struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k);
        size_t idx = s.k->p.offset;
        struct stripe *m = genradix_ptr(&c->stripes[gc], idx);
@@ -1129,14 +1129,14 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k,
 
        spin_lock(&c->ec_stripes_heap_lock);
 
-       if (!m || ((flags & BCH_BUCKET_MARK_OVERWRITE) && !m->alive)) {
+       if (!m || ((flags & BTREE_TRIGGER_OVERWRITE) && !m->alive)) {
                spin_unlock(&c->ec_stripes_heap_lock);
                bch_err_ratelimited(c, "error marking nonexistent stripe %zu",
                                    idx);
                return -1;
        }
 
-       if (!(flags & BCH_BUCKET_MARK_OVERWRITE)) {
+       if (!(flags & BTREE_TRIGGER_OVERWRITE)) {
                m->sectors      = le16_to_cpu(s.v->sectors);
                m->algorithm    = s.v->algorithm;
                m->nr_blocks    = s.v->nr_blocks;
@@ -1152,7 +1152,7 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k,
 #endif
 
                /* gc recalculates these fields: */
-               if (!(flags & BCH_BUCKET_MARK_GC)) {
+               if (!(flags & BTREE_TRIGGER_GC)) {
                        for (i = 0; i < s.v->nr_blocks; i++) {
                                m->block_sectors[i] =
                                        stripe_blockcount_get(s.v, i);
@@ -1185,16 +1185,16 @@ int bch2_mark_key_locked(struct bch_fs *c,
 
        preempt_disable();
 
-       if (!fs_usage || (flags & BCH_BUCKET_MARK_GC))
+       if (!fs_usage || (flags & BTREE_TRIGGER_GC))
                fs_usage = fs_usage_ptr(c, journal_seq,
-                                       flags & BCH_BUCKET_MARK_GC);
+                                       flags & BTREE_TRIGGER_GC);
 
        switch (k.k->type) {
        case KEY_TYPE_alloc:
                ret = bch2_mark_alloc(c, k, fs_usage, journal_seq, flags);
                break;
        case KEY_TYPE_btree_ptr:
-               sectors = !(flags & BCH_BUCKET_MARK_OVERWRITE)
+               sectors = !(flags & BTREE_TRIGGER_OVERWRITE)
                        ?  c->opts.btree_node_size
                        : -c->opts.btree_node_size;
 
@@ -1210,7 +1210,7 @@ int bch2_mark_key_locked(struct bch_fs *c,
                ret = bch2_mark_stripe(c, k, fs_usage, journal_seq, flags);
                break;
        case KEY_TYPE_inode:
-               if (!(flags & BCH_BUCKET_MARK_OVERWRITE))
+               if (!(flags & BTREE_TRIGGER_OVERWRITE))
                        fs_usage->nr_inodes++;
                else
                        fs_usage->nr_inodes--;
@@ -1260,7 +1260,7 @@ inline int bch2_mark_overwrite(struct btree_trans *trans,
        unsigned                offset = 0;
        s64                     sectors = 0;
 
-       flags |= BCH_BUCKET_MARK_OVERWRITE;
+       flags |= BTREE_TRIGGER_OVERWRITE;
 
        if (btree_node_is_extents(b)
            ? bkey_cmp(new->k.p, bkey_start_pos(old.k)) <= 0
@@ -1288,7 +1288,7 @@ inline int bch2_mark_overwrite(struct btree_trans *trans,
                        offset = bkey_start_offset(&new->k) -
                                bkey_start_offset(old.k);
                        sectors = -((s64) new->k.size);
-                       flags |= BCH_BUCKET_MARK_OVERWRITE_SPLIT;
+                       flags |= BTREE_TRIGGER_OVERWRITE_SPLIT;
                        break;
                }
 
@@ -1311,15 +1311,18 @@ int bch2_mark_update(struct btree_trans *trans,
        struct bkey_packed      *_k;
        int ret = 0;
 
+       if (unlikely(flags & BTREE_TRIGGER_NORUN))
+               return 0;
+
        if (!btree_node_type_needs_gc(iter->btree_id))
                return 0;
 
        bch2_mark_key_locked(c, bkey_i_to_s_c(insert),
                0, insert->k.size,
                fs_usage, trans->journal_res.seq,
-               BCH_BUCKET_MARK_INSERT|flags);
+               BTREE_TRIGGER_INSERT|flags);
 
-       if (unlikely(trans->flags & BTREE_INSERT_NOMARK_OVERWRITES))
+       if (unlikely(flags & BTREE_TRIGGER_NOOVERWRITES))
                return 0;
 
        /*
@@ -1450,7 +1453,7 @@ static void *trans_update_key(struct btree_trans *trans,
                        return new_k;
                }
 
-       bch2_trans_update(trans, iter, new_k);
+       bch2_trans_update(trans, iter, new_k, 0);
        return new_k;
 }
 
@@ -1689,7 +1692,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans,
                goto err;
        }
 
-       if ((flags & BCH_BUCKET_MARK_OVERWRITE) &&
+       if ((flags & BTREE_TRIGGER_OVERWRITE) &&
            (bkey_start_offset(k.k) < idx ||
             k.k->p.offset > idx + sectors))
                goto out;
@@ -1706,7 +1709,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans,
        r_v = bkey_i_to_reflink_v(new_k);
 
        le64_add_cpu(&r_v->v.refcount,
-                    !(flags & BCH_BUCKET_MARK_OVERWRITE) ? 1 : -1);
+                    !(flags & BTREE_TRIGGER_OVERWRITE) ? 1 : -1);
 
        if (!r_v->v.refcount) {
                r_v->k.type = KEY_TYPE_deleted;
@@ -1750,7 +1753,7 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
 
        switch (k.k->type) {
        case KEY_TYPE_btree_ptr:
-               sectors = !(flags & BCH_BUCKET_MARK_OVERWRITE)
+               sectors = !(flags & BTREE_TRIGGER_OVERWRITE)
                        ?  c->opts.btree_node_size
                        : -c->opts.btree_node_size;
 
@@ -1763,7 +1766,7 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
        case KEY_TYPE_inode:
                d = replicas_deltas_realloc(trans, 0);
 
-               if (!(flags & BCH_BUCKET_MARK_OVERWRITE))
+               if (!(flags & BTREE_TRIGGER_OVERWRITE))
                        d->nr_inodes++;
                else
                        d->nr_inodes--;
@@ -1791,22 +1794,26 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
 
 int bch2_trans_mark_update(struct btree_trans *trans,
                           struct btree_iter *iter,
-                          struct bkey_i *insert)
+                          struct bkey_i *insert,
+                          unsigned flags)
 {
        struct btree            *b = iter->l[0].b;
        struct btree_node_iter  node_iter = iter->l[0].iter;
        struct bkey_packed      *_k;
        int ret;
 
+       if (unlikely(flags & BTREE_TRIGGER_NORUN))
+               return 0;
+
        if (!btree_node_type_needs_gc(iter->btree_id))
                return 0;
 
        ret = bch2_trans_mark_key(trans, bkey_i_to_s_c(insert),
-                       0, insert->k.size, BCH_BUCKET_MARK_INSERT);
+                       0, insert->k.size, BTREE_TRIGGER_INSERT);
        if (ret)
                return ret;
 
-       if (unlikely(trans->flags & BTREE_INSERT_NOMARK_OVERWRITES))
+       if (unlikely(flags & BTREE_TRIGGER_NOOVERWRITES))
                return 0;
 
        while ((_k = bch2_btree_node_iter_peek_filter(&node_iter, b,
@@ -1815,7 +1822,7 @@ int bch2_trans_mark_update(struct btree_trans *trans,
                struct bkey_s_c         k;
                unsigned                offset = 0;
                s64                     sectors = 0;
-               unsigned                flags = BCH_BUCKET_MARK_OVERWRITE;
+               unsigned                flags = BTREE_TRIGGER_OVERWRITE;
 
                k = bkey_disassemble(b, _k, &unpacked);
 
@@ -1845,7 +1852,7 @@ int bch2_trans_mark_update(struct btree_trans *trans,
                                offset = bkey_start_offset(&insert->k) -
                                        bkey_start_offset(k.k);
                                sectors = -((s64) insert->k.size);
-                               flags |= BCH_BUCKET_MARK_OVERWRITE_SPLIT;
+                               flags |= BTREE_TRIGGER_OVERWRITE_SPLIT;
                                break;
                        }
 
index 7b1bbe7c931611f2c9a1629716fe86df70565744..2e49f2a8ccd9905b905a187a760698bb3865de81 100644 (file)
@@ -258,14 +258,6 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *,
                               size_t, enum bch_data_type, unsigned,
                               struct gc_pos, unsigned);
 
-#define BCH_BUCKET_MARK_INSERT                 (1 << 0)
-#define BCH_BUCKET_MARK_OVERWRITE              (1 << 1)
-#define BCH_BUCKET_MARK_OVERWRITE_SPLIT                (1 << 2)
-#define BCH_BUCKET_MARK_BUCKET_INVALIDATE      (1 << 3)
-#define BCH_BUCKET_MARK_GC                     (1 << 4)
-#define BCH_BUCKET_MARK_ALLOC_READ             (1 << 5)
-#define BCH_BUCKET_MARK_NOATOMIC               (1 << 6)
-
 int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c, unsigned, s64,
                         struct bch_fs_usage *, u64, unsigned);
 int bch2_mark_key(struct bch_fs *, struct bkey_s_c, unsigned, s64,
@@ -284,9 +276,8 @@ int bch2_replicas_delta_list_apply(struct bch_fs *,
                                   struct replicas_delta_list *);
 int bch2_trans_mark_key(struct btree_trans *, struct bkey_s_c,
                        unsigned, s64, unsigned);
-int bch2_trans_mark_update(struct btree_trans *,
-                          struct btree_iter *iter,
-                          struct bkey_i *insert);
+int bch2_trans_mark_update(struct btree_trans *, struct btree_iter *iter,
+                          struct bkey_i *insert, unsigned);
 void bch2_trans_fs_usage_apply(struct btree_trans *, struct bch_fs_usage_online *);
 
 /* disk reservations: */
index 1bf53c55912d40f572f43afb71cd7b4d2acee7aa..4b4aeaf81d214541a73971c9c431da69df737e46 100644 (file)
@@ -246,7 +246,7 @@ int bch2_dirent_rename(struct btree_trans *trans,
                                 */
                                new_dst->k.p = src_iter->pos;
                                bch2_trans_update(trans, src_iter,
-                                                 &new_dst->k_i);
+                                                 &new_dst->k_i, 0);
                                return 0;
                        } else {
                                /* If we're overwriting, we can't insert new_dst
@@ -268,8 +268,8 @@ int bch2_dirent_rename(struct btree_trans *trans,
                }
        }
 
-       bch2_trans_update(trans, src_iter, &new_src->k_i);
-       bch2_trans_update(trans, dst_iter, &new_dst->k_i);
+       bch2_trans_update(trans, src_iter, &new_src->k_i, 0);
+       bch2_trans_update(trans, dst_iter, &new_dst->k_i, 0);
        return 0;
 }
 
index a6bc9355c7509512962d6f65646b7304ca18ed18..0e2acd4f571292ff867e09d8fd31c9ff9e0d29c2 100644 (file)
@@ -736,7 +736,7 @@ found_slot:
 
        stripe->k.p = iter->pos;
 
-       bch2_trans_update(&trans, iter, &stripe->k_i);
+       bch2_trans_update(&trans, iter, &stripe->k_i, 0);
 
        ret = bch2_trans_commit(&trans, NULL, NULL,
                                BTREE_INSERT_NOFAIL);
@@ -818,7 +818,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
 
                extent_stripe_ptr_add(e, s, ec_ptr, idx);
 
-               bch2_trans_update(&trans, iter, sk.k);
+               bch2_trans_update(&trans, iter, sk.k, 0);
 
                ret = bch2_trans_commit(&trans, NULL, NULL,
                                        BTREE_INSERT_NOFAIL|
@@ -1230,7 +1230,7 @@ static int __bch2_stripe_write_key(struct btree_trans *trans,
 
        spin_unlock(&c->ec_stripes_heap_lock);
 
-       bch2_trans_update(trans, iter, &new_key->k_i);
+       bch2_trans_update(trans, iter, &new_key->k_i, 0);
 
        return bch2_trans_commit(trans, NULL, NULL,
                                 BTREE_INSERT_NOFAIL|flags);
@@ -1316,8 +1316,8 @@ int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys)
 
                bch2_mark_key(c, btree ? btree_k : journal_k,
                              0, 0, NULL, 0,
-                             BCH_BUCKET_MARK_ALLOC_READ|
-                             BCH_BUCKET_MARK_NOATOMIC);
+                             BTREE_TRIGGER_ALLOC_READ|
+                             BTREE_TRIGGER_NOATOMIC);
 
                if (btree)
                        btree_k = bch2_btree_iter_next(btree_iter);
index 15b0d20b2f81eaabe90b10ae3f78dba3abc945ce..25fe9ab0f068046be65bae533492d0609b1197fe 100644 (file)
@@ -2465,7 +2465,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
                struct bpos next_pos;
                struct bpos move_pos = POS(inode->v.i_ino, offset >> 9);
                struct bpos atomic_end;
-               unsigned commit_flags = 0;
+               unsigned trigger_flags = 0;
 
                k = insert
                        ? bch2_btree_iter_peek_prev(src)
@@ -2536,15 +2536,12 @@ reassemble:
                                bkey_start_pos(&delete.k));
                }
 
-               bch2_trans_update(&trans, dst, copy.k);
-               bch2_trans_update(&trans, del ?: src, &delete);
-
                if (copy.k->k.size == k.k->size) {
                        /*
                         * If we're moving the entire extent, we can skip
                         * running triggers:
                         */
-                       commit_flags |= BTREE_INSERT_NOMARK;
+                       trigger_flags |= BTREE_TRIGGER_NORUN;
                } else {
                        /* We might end up splitting compressed extents: */
                        unsigned nr_ptrs =
@@ -2556,10 +2553,12 @@ reassemble:
                        BUG_ON(ret);
                }
 
+               bch2_trans_update(&trans, dst, copy.k, trigger_flags);
+               bch2_trans_update(&trans, del ?: src, &delete, trigger_flags);
+
                ret = bch2_trans_commit(&trans, &disk_res,
                                        &inode->ei_journal_seq,
-                                       BTREE_INSERT_NOFAIL|
-                                       commit_flags);
+                                       BTREE_INSERT_NOFAIL);
                bch2_disk_reservation_put(c, &disk_res);
 bkey_err:
                if (del)
index e25f064706ad431084772ef336a240c0d2945026..9ef532d875e89fbebf9498befaef6f2d5599f870 100644 (file)
@@ -192,7 +192,7 @@ static int hash_redo_key(const struct bch_hash_desc desc,
 
        bkey_init(&delete.k);
        delete.k.p = k_iter->pos;
-       bch2_trans_update(trans, k_iter, &delete);
+       bch2_trans_update(trans, k_iter, &delete, 0);
 
        return  bch2_hash_set(trans, desc, &h->info, k_iter->pos.inode,
                              tmp, BCH_HASH_SET_MUST_CREATE) ?:
@@ -388,7 +388,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h,
                                      BTREE_INSERT_NOFAIL|
                                      BTREE_INSERT_LAZY_RW,
                                      TRANS_RESET_MEM,
-                       (bch2_trans_update(trans, iter, &d->k_i), 0));
+                       (bch2_trans_update(trans, iter, &d->k_i, 0), 0));
                if (ret)
                        goto err;
 
@@ -661,7 +661,7 @@ retry:
                                              BTREE_INSERT_NOFAIL|
                                              BTREE_INSERT_LAZY_RW,
                                              TRANS_RESET_MEM,
-                               (bch2_trans_update(&trans, iter, &n->k_i), 0));
+                               (bch2_trans_update(&trans, iter, &n->k_i, 0), 0));
                        kfree(n);
                        if (ret)
                                goto err;
@@ -1276,7 +1276,7 @@ static int check_inode(struct btree_trans *trans,
                                      BTREE_INSERT_NOFAIL|
                                      BTREE_INSERT_LAZY_RW,
                                      TRANS_RESET_MEM,
-                       (bch2_trans_update(trans, iter, &p.inode.k_i), 0));
+                       (bch2_trans_update(trans, iter, &p.inode.k_i, 0), 0));
                if (ret)
                        bch_err(c, "error in fsck: error %i "
                                "updating inode", ret);
index 77ac9ab7fc572e9c672d47d8f381dc7b58fe8855..bd44ef3842cb26dbb7d2950f4a911dfcb958adba 100644 (file)
@@ -223,7 +223,7 @@ int bch2_inode_write(struct btree_trans *trans,
                return PTR_ERR(inode_p);
 
        bch2_inode_pack(inode_p, inode);
-       bch2_trans_update(trans, iter, &inode_p->inode.k_i);
+       bch2_trans_update(trans, iter, &inode_p->inode.k_i, 0);
        return 0;
 }
 
@@ -411,7 +411,7 @@ again:
                        inode_u->bi_generation  = bkey_generation(k);
 
                        bch2_inode_pack(inode_p, inode_u);
-                       bch2_trans_update(trans, iter, &inode_p->inode.k_i);
+                       bch2_trans_update(trans, iter, &inode_p->inode.k_i, 0);
                        return 0;
                }
        }
@@ -493,7 +493,7 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr)
                        delete.v.bi_generation = cpu_to_le32(bi_generation);
                }
 
-               bch2_trans_update(&trans, iter, &delete.k_i);
+               bch2_trans_update(&trans, iter, &delete.k_i, 0);
 
                ret = bch2_trans_commit(&trans, NULL, NULL,
                                        BTREE_INSERT_NOFAIL);
index ba79b35a130f032969c62593300bde9125630b05..1fab0bdcf9ae64ec5d1fb4a8d9d6a57d21479518 100644 (file)
@@ -302,13 +302,13 @@ int bch2_extent_update(struct btree_trans *trans,
                if (delta || new_i_size) {
                        bch2_inode_pack(&inode_p, &inode_u);
                        bch2_trans_update(trans, inode_iter,
-                                         &inode_p.inode.k_i);
+                                         &inode_p.inode.k_i, 0);
                }
 
                bch2_trans_iter_put(trans, inode_iter);
        }
 
-       bch2_trans_update(trans, iter, k);
+       bch2_trans_update(trans, iter, k, 0);
 
        ret = bch2_trans_commit(trans, disk_res, journal_seq,
                                BTREE_INSERT_NOCHECK_RW|
@@ -1740,7 +1740,7 @@ retry:
        if (!bch2_bkey_narrow_crcs(new.k, new_crc))
                goto out;
 
-       bch2_trans_update(&trans, iter, new.k);
+       bch2_trans_update(&trans, iter, new.k, 0);
        ret = bch2_trans_commit(&trans, NULL, NULL,
                                BTREE_INSERT_NOFAIL|
                                BTREE_INSERT_NOWAIT);
index db86420bd64772457da7ba44b8119e06f7fee9bb..0e3f63c1d65c147578fbf9d6196a5b8f5a23aa01 100644 (file)
@@ -76,7 +76,7 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
 
                bch2_btree_iter_set_pos(iter, bkey_start_pos(&sk.k->k));
 
-               bch2_trans_update(&trans, iter, sk.k);
+               bch2_trans_update(&trans, iter, sk.k, 0);
 
                ret = bch2_trans_commit(&trans, NULL, NULL,
                                        BTREE_INSERT_NOFAIL);
index cb7bb751b7b5aa9c3a6ad7909857cb2ac0899f24..7ed90b0576c095249af3b2fff4cec71c5eb54d1b 100644 (file)
@@ -149,7 +149,7 @@ static int bch2_migrate_index_update(struct bch_write_op *op)
                        goto next;
                }
 
-               bch2_trans_update(&trans, iter, insert);
+               bch2_trans_update(&trans, iter, insert, 0);
 
                ret = bch2_trans_commit(&trans, &op->res,
                                op_journal_seq(op),
index 0fa6f33c049bca2849c803353dabb023820d2056..e7787c5063ce3d7932fe5295702cae12b52ded9f 100644 (file)
@@ -752,7 +752,7 @@ static int bch2_set_quota(struct super_block *sb, struct kqid qid,
        if (qdq->d_fieldmask & QC_INO_HARD)
                new_quota.v.c[Q_INO].hardlimit = cpu_to_le64(qdq->d_ino_hardlimit);
 
-       bch2_trans_update(&trans, iter, &new_quota.k_i);
+       bch2_trans_update(&trans, iter, &new_quota.k_i, 0);
 
        ret = bch2_trans_commit(&trans, NULL, NULL, 0);
 
index c7367a679b22fb2af87f32e0cd9303da306da6a4..8ecd4abc8eebdffdf5ca12154df75c874e7a4df6 100644 (file)
@@ -300,28 +300,24 @@ retry:
                bch2_cut_front(split_iter->pos, split);
                bch2_cut_back(atomic_end, split);
 
-               bch2_trans_update(&trans, split_iter, split);
+               bch2_trans_update(&trans, split_iter, split, !remark
+                                 ? BTREE_TRIGGER_NORUN
+                                 : BTREE_TRIGGER_NOOVERWRITES);
                bch2_btree_iter_set_pos(iter, split->k.p);
        } while (bkey_cmp(iter->pos, k->k.p) < 0);
 
        if (remark) {
                ret = bch2_trans_mark_key(&trans, bkey_i_to_s_c(k),
                                          0, -((s64) k->k.size),
-                                         BCH_BUCKET_MARK_OVERWRITE) ?:
-                     bch2_trans_commit(&trans, &disk_res, NULL,
-                                       BTREE_INSERT_NOFAIL|
-                                       BTREE_INSERT_LAZY_RW|
-                                       BTREE_INSERT_NOMARK_OVERWRITES);
-       } else {
-               ret = bch2_trans_commit(&trans, &disk_res, NULL,
-                                       BTREE_INSERT_NOFAIL|
-                                       BTREE_INSERT_LAZY_RW|
-                                       BTREE_INSERT_JOURNAL_REPLAY|
-                                       BTREE_INSERT_NOMARK);
+                                         BTREE_TRIGGER_OVERWRITE);
+               if (ret)
+                       goto err;
        }
 
-       if (ret)
-               goto err;
+       ret = bch2_trans_commit(&trans, &disk_res, NULL,
+                               BTREE_INSERT_NOFAIL|
+                               BTREE_INSERT_LAZY_RW|
+                               BTREE_INSERT_JOURNAL_REPLAY);
 err:
        if (ret == -EINTR)
                goto retry;
@@ -331,6 +327,30 @@ err:
        return bch2_trans_exit(&trans) ?: ret;
 }
 
+static int __bch2_journal_replay_key(struct btree_trans *trans,
+                                    enum btree_id id, struct bkey_i *k)
+{
+       struct btree_iter *iter;
+
+       iter = bch2_trans_get_iter(trans, id, bkey_start_pos(&k->k),
+                                  BTREE_ITER_INTENT);
+       if (IS_ERR(iter))
+               return PTR_ERR(iter);
+
+       bch2_trans_update(trans, iter, k, BTREE_TRIGGER_NORUN);
+       return 0;
+}
+
+static int bch2_journal_replay_key(struct bch_fs *c, enum btree_id id,
+                                  struct bkey_i *k)
+{
+       return bch2_trans_do(c, NULL, NULL,
+                            BTREE_INSERT_NOFAIL|
+                            BTREE_INSERT_LAZY_RW|
+                            BTREE_INSERT_JOURNAL_REPLAY,
+                            __bch2_journal_replay_key(&trans, id, k));
+}
+
 static int bch2_journal_replay(struct bch_fs *c,
                               struct journal_keys keys)
 {
@@ -348,12 +368,7 @@ static int bch2_journal_replay(struct bch_fs *c,
                else if (btree_node_type_is_extents(i->btree_id))
                        ret = bch2_extent_replay_key(c, i->btree_id, i->k);
                else
-                       ret = bch2_btree_insert(c, i->btree_id, i->k,
-                                               NULL, NULL,
-                                               BTREE_INSERT_NOFAIL|
-                                               BTREE_INSERT_LAZY_RW|
-                                               BTREE_INSERT_JOURNAL_REPLAY|
-                                               BTREE_INSERT_NOMARK);
+                       ret = bch2_journal_replay_key(c, i->btree_id, i->k);
 
                if (ret) {
                        bch_err(c, "journal replay: error %d while replaying key",
index 2bf003ba3bd8b7cb9ae50e537cb9d9b590afb90d..3b8c74ca3725fc1d294c9179bd021e844e6eedd6 100644 (file)
@@ -115,7 +115,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
        r_v->v.refcount = 0;
        memcpy(r_v->v.start, e->v.start, bkey_val_bytes(&e->k));
 
-       bch2_trans_update(trans, reflink_iter, &r_v->k_i);
+       bch2_trans_update(trans, reflink_iter, &r_v->k_i, 0);
 
        r_p = bch2_trans_kmalloc(trans, sizeof(*r_p));
        if (IS_ERR(r_p))
@@ -126,7 +126,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
        set_bkey_val_bytes(&r_p->k, sizeof(r_p->v));
        r_p->v.idx = cpu_to_le64(bkey_start_offset(&r_v->k));
 
-       bch2_trans_update(trans, extent_iter, &r_p->k_i);
+       bch2_trans_update(trans, extent_iter, &r_p->k_i, 0);
 err:
        if (!IS_ERR(reflink_iter)) {
                c->reflink_hint = reflink_iter->pos.offset;
index 3870df2d58ce68041ec40f1bd0e5f792b1a603d5..35f4232d07554e40c6106c096a3f79c6a58f1b42 100644 (file)
@@ -281,7 +281,7 @@ not_found:
                        swap(iter, slot);
 
                insert->k.p = iter->pos;
-               bch2_trans_update(trans, iter, insert);
+               bch2_trans_update(trans, iter, insert, 0);
        }
 
        goto out;
@@ -308,7 +308,7 @@ int bch2_hash_delete_at(struct btree_trans *trans,
        delete->k.p = iter->pos;
        delete->k.type = ret ? KEY_TYPE_whiteout : KEY_TYPE_deleted;
 
-       bch2_trans_update(trans, iter, delete);
+       bch2_trans_update(trans, iter, delete, 0);
        return 0;
 }
 
index a2092bb99095b410320ff82af310e1a3255a043d..8ef7bc8098d741866cb9039cbeb9000933e0a48d 100644 (file)
@@ -43,7 +43,7 @@ static void test_delete(struct bch_fs *c, u64 nr)
        ret = bch2_btree_iter_traverse(iter);
        BUG_ON(ret);
 
-       bch2_trans_update(&trans, iter, &k.k_i);
+       bch2_trans_update(&trans, iter, &k.k_i, 0);
        ret = bch2_trans_commit(&trans, NULL, NULL, 0);
        BUG_ON(ret);
 
@@ -75,7 +75,7 @@ static void test_delete_written(struct bch_fs *c, u64 nr)
        ret = bch2_btree_iter_traverse(iter);
        BUG_ON(ret);
 
-       bch2_trans_update(&trans, iter, &k.k_i);
+       bch2_trans_update(&trans, iter, &k.k_i, 0);
        ret = bch2_trans_commit(&trans, NULL, NULL, 0);
        BUG_ON(ret);
 
@@ -465,7 +465,7 @@ static void rand_mixed(struct bch_fs *c, u64 nr)
                        bkey_cookie_init(&k.k_i);
                        k.k.p = iter->pos;
 
-                       bch2_trans_update(&trans, iter, &k.k_i);
+                       bch2_trans_update(&trans, iter, &k.k_i, 0);
                        ret = bch2_trans_commit(&trans, NULL, NULL, 0);
                        BUG_ON(ret);
                }
@@ -509,7 +509,7 @@ static void seq_insert(struct bch_fs *c, u64 nr)
                           BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
                insert.k.p = iter->pos;
 
-               bch2_trans_update(&trans, iter, &insert.k_i);
+               bch2_trans_update(&trans, iter, &insert.k_i, 0);
                ret = bch2_trans_commit(&trans, NULL, NULL, 0);
                BUG_ON(ret);
 
@@ -548,7 +548,7 @@ static void seq_overwrite(struct bch_fs *c, u64 nr)
 
                bkey_reassemble(&u.k_i, k);
 
-               bch2_trans_update(&trans, iter, &u.k_i);
+               bch2_trans_update(&trans, iter, &u.k_i, 0);
                ret = bch2_trans_commit(&trans, NULL, NULL, 0);
                BUG_ON(ret);
        }