From: Zygo Blaxell Date: Fri, 6 Dec 2019 20:16:08 +0000 (-0500) Subject: Revert "Btrfs: do not start a transaction at iterate_extent_inodes()" X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef69ca517bc33d364090c080b618a1be7acfcfe5;p=linux Revert "Btrfs: do not start a transaction at iterate_extent_inodes()" This reverts commit bfc61c36260ca990937539cd648ede3cd749bc10. (cherry picked from commit 9ad6e14f3f1ad6a90c8530b8c8f925e99dd4062f) --- diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index ded46efac27d..c854f74ab772 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1913,19 +1913,13 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, extent_item_objectid); if (!search_commit_root) { - 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) + trans = btrfs_join_transaction(fs_info->extent_root); + if (IS_ERR(trans)) + return PTR_ERR(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, @@ -1958,7 +1952,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, free_leaf_list(refs); out: - if (trans) { + if (!search_commit_root) { btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem); btrfs_end_transaction(trans); } else {