Skip to content

Commit 2c53679

Browse files
jeffmahoneykdave
authored andcommitted
btrfs: btrfs_drop_snapshot should return int
Commit cb1b69f (Btrfs: forced readonly when btrfs_drop_snapshot() fails) made btrfs_drop_snapshot return void because there were no callers checking the return value. That is the wrong order to handle error propogation since the caller will have no idea that an error has occured and continue on as if nothing went wrong. Signed-off-by: Jeff Mahoney <[email protected]>
1 parent 3fbe5c0 commit 2c53679

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

fs/btrfs/ctree.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,9 +2661,9 @@ static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p)
26612661
}
26622662
int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
26632663
int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
2664-
void btrfs_drop_snapshot(struct btrfs_root *root,
2665-
struct btrfs_block_rsv *block_rsv, int update_ref,
2666-
int for_reloc);
2664+
int __must_check btrfs_drop_snapshot(struct btrfs_root *root,
2665+
struct btrfs_block_rsv *block_rsv,
2666+
int update_ref, int for_reloc);
26672667
int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
26682668
struct btrfs_root *root,
26692669
struct extent_buffer *node,

fs/btrfs/extent-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6734,7 +6734,7 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
67346734
* also make sure backrefs for the shared block and all lower level
67356735
* blocks are properly updated.
67366736
*/
6737-
void btrfs_drop_snapshot(struct btrfs_root *root,
6737+
int btrfs_drop_snapshot(struct btrfs_root *root,
67386738
struct btrfs_block_rsv *block_rsv, int update_ref,
67396739
int for_reloc)
67406740
{
@@ -6902,7 +6902,7 @@ void btrfs_drop_snapshot(struct btrfs_root *root,
69026902
out:
69036903
if (err)
69046904
btrfs_std_error(root->fs_info, err);
6905-
return;
6905+
return err;
69066906
}
69076907

69086908
/*

fs/btrfs/relocation.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,8 @@ int merge_reloc_roots(struct reloc_control *rc)
22722272
} else {
22732273
list_del_init(&reloc_root->root_list);
22742274
}
2275-
btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0, 1);
2275+
ret = btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0, 1);
2276+
BUG_ON(ret < 0);
22762277
}
22772278

22782279
if (found) {

fs/btrfs/transaction.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,16 +1387,19 @@ int btrfs_clean_old_snapshots(struct btrfs_root *root)
13871387
spin_unlock(&fs_info->trans_lock);
13881388

13891389
while (!list_empty(&list)) {
1390+
int ret;
1391+
13901392
root = list_entry(list.next, struct btrfs_root, root_list);
13911393
list_del(&root->root_list);
13921394

13931395
btrfs_kill_all_delayed_nodes(root);
13941396

13951397
if (btrfs_header_backref_rev(root->node) <
13961398
BTRFS_MIXED_BACKREF_REV)
1397-
btrfs_drop_snapshot(root, NULL, 0, 0);
1399+
ret = btrfs_drop_snapshot(root, NULL, 0, 0);
13981400
else
1399-
btrfs_drop_snapshot(root, NULL, 1, 0);
1401+
ret =btrfs_drop_snapshot(root, NULL, 1, 0);
1402+
BUG_ON(ret < 0);
14001403
}
14011404
return 0;
14021405
}

0 commit comments

Comments
 (0)