]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Dont't call bch2_trans_begin_updates() in bch2_extent_update()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 18 Jul 2019 21:11:35 +0000 (17:11 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:24 +0000 (17:08 -0400)
Prep work for reflink - for reflink, we're going to be using
bch2_extent_update() with other updates in the same transaction.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io.c

index def470b5b9594988239f451958c110921f1ccfc7..55fee053337f9bc86741dc23adcd9639c0e748ce 100644 (file)
@@ -276,16 +276,16 @@ static int sum_sector_overwrites(struct btree_trans *trans,
        return 0;
 }
 
-static int bch2_extent_update(struct btree_trans *trans,
-                             struct bch_inode_info *inode,
-                             struct disk_reservation *disk_res,
-                             struct quota_res *quota_res,
-                             struct btree_iter *extent_iter,
-                             struct bkey_i *k,
-                             u64 new_i_size,
-                             bool may_allocate,
-                             bool direct,
-                             s64 *total_delta)
+int bch2_extent_update(struct btree_trans *trans,
+                      struct bch_inode_info *inode,
+                      struct disk_reservation *disk_res,
+                      struct quota_res *quota_res,
+                      struct btree_iter *extent_iter,
+                      struct bkey_i *k,
+                      u64 new_i_size,
+                      bool may_allocate,
+                      bool direct,
+                      s64 *total_delta)
 {
        struct bch_fs *c = trans->c;
        struct btree_iter *inode_iter = NULL;
@@ -297,8 +297,6 @@ static int bch2_extent_update(struct btree_trans *trans,
        s64 i_sectors_delta;
        int ret;
 
-       bch2_trans_begin_updates(trans);
-
        ret = bch2_btree_iter_traverse(extent_iter);
        if (ret)
                return ret;
@@ -447,6 +445,8 @@ static int bchfs_write_index_update(struct bch_write_op *wop)
 
                bkey_copy(&tmp.k, bch2_keylist_front(keys));
 
+               bch2_trans_begin_updates(&trans);
+
                ret = bch2_extent_update(&trans, inode,
                                &wop->res, quota_res,
                                iter, &tmp.k,
@@ -2198,6 +2198,8 @@ static int __bch2_fpunch(struct bch_fs *c, struct bch_inode_info *inode,
                bch2_key_resize(&delete.k, max_sectors);
                bch2_cut_back(end, &delete.k);
 
+               bch2_trans_begin_updates(&trans);
+
                ret = bch2_extent_update(&trans, inode,
                                &disk_res, NULL, iter, &delete,
                                0, true, true, NULL);
@@ -2546,6 +2548,8 @@ static long bch2_fcollapse(struct bch_inode_info *inode,
                                BCH_DISK_RESERVATION_NOFAIL);
                BUG_ON(ret);
 
+               bch2_trans_begin_updates(&trans);
+
                ret = bch2_extent_update(&trans, inode,
                                &disk_res, NULL,
                                dst, &copy.k,
@@ -2689,6 +2693,8 @@ static long bch2_fallocate(struct bch_inode_info *inode, int mode,
                        reservation.v.nr_replicas = disk_res.nr_replicas;
                }
 
+               bch2_trans_begin_updates(&trans);
+
                ret = bch2_extent_update(&trans, inode,
                                &disk_res, &quota_res,
                                iter, &reservation.k_i,