]> git.hungrycats.org Git - linux/commitdiff
Revert "Revert "Btrfs: do not start a transaction at iterate_extent_inodes()""
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 10 Dec 2019 17:26:54 +0000 (12:26 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 14 Dec 2019 04:53:10 +0000 (23:53 -0500)
This reverts commit 9ad6e14f3f1ad6a90c8530b8c8f925e99dd4062f.

(cherry picked from commit 87853d040f5785fe1a8707210d0ce3a4d355b01f)

fs/btrfs/backref.c

index 488deb6ef09ab8059e814bb1d65b8a179681e4fe..e5d85311d5d5d4eadd857fda99a99bd881074b38 100644 (file)
@@ -1911,13 +1911,19 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
                        extent_item_objectid);
 
        if (!search_commit_root) {
-               trans = btrfs_join_transaction(fs_info->extent_root);
-               if (IS_ERR(trans))
-                       return PTR_ERR(trans);
+               trans = btrfs_attach_transaction(fs_info->extent_root);
+               if (IS_ERR(trans)) {
+                       if (PTR_ERR(trans) != -ENOENT &&
+                           PTR_ERR(trans) != -EROFS)
+                               return PTR_ERR(trans);
+                       trans = NULL;
+               }
+       }
+
+       if (trans)
                btrfs_get_tree_mod_seq(fs_info, &tree_mod_seq_elem);
-       } else {
+       else
                down_read(&fs_info->commit_root_sem);
-       }
 
        ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid,
                                   tree_mod_seq_elem.seq, &refs,
@@ -1950,7 +1956,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
 
        free_leaf_list(refs);
 out:
-       if (!search_commit_root) {
+       if (trans) {
                btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
                btrfs_end_transaction(trans);
        } else {