Skip to content

Commit cb1b69f

Browse files
Tsutomu Itohchrismason-xx
authored andcommitted
Btrfs: forced readonly when btrfs_drop_snapshot() fails
The filesystem turns readonly instead of returning the error to the caller when detected error in btrfs_drop_snapshot(). and, because the caller doesn't check the error, the function type is changed to 'void'. Signed-off-by: Tsutomu Itoh <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent cdcb725 commit cb1b69f

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

fs/btrfs/ctree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,8 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans,
23672367
int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
23682368
int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
23692369
int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
2370-
int btrfs_drop_snapshot(struct btrfs_root *root,
2371-
struct btrfs_block_rsv *block_rsv, int update_ref);
2370+
void btrfs_drop_snapshot(struct btrfs_root *root,
2371+
struct btrfs_block_rsv *block_rsv, int update_ref);
23722372
int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
23732373
struct btrfs_root *root,
23742374
struct extent_buffer *node,

fs/btrfs/extent-tree.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6277,8 +6277,8 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
62776277
* also make sure backrefs for the shared block and all lower level
62786278
* blocks are properly updated.
62796279
*/
6280-
int btrfs_drop_snapshot(struct btrfs_root *root,
6281-
struct btrfs_block_rsv *block_rsv, int update_ref)
6280+
void btrfs_drop_snapshot(struct btrfs_root *root,
6281+
struct btrfs_block_rsv *block_rsv, int update_ref)
62826282
{
62836283
struct btrfs_path *path;
62846284
struct btrfs_trans_handle *trans;
@@ -6291,13 +6291,16 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
62916291
int level;
62926292

62936293
path = btrfs_alloc_path();
6294-
if (!path)
6295-
return -ENOMEM;
6294+
if (!path) {
6295+
err = -ENOMEM;
6296+
goto out;
6297+
}
62966298

62976299
wc = kzalloc(sizeof(*wc), GFP_NOFS);
62986300
if (!wc) {
62996301
btrfs_free_path(path);
6300-
return -ENOMEM;
6302+
err = -ENOMEM;
6303+
goto out;
63016304
}
63026305

63036306
trans = btrfs_start_transaction(tree_root, 0);
@@ -6326,7 +6329,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
63266329
path->lowest_level = 0;
63276330
if (ret < 0) {
63286331
err = ret;
6329-
goto out;
6332+
goto out_free;
63306333
}
63316334
WARN_ON(ret > 0);
63326335

@@ -6433,11 +6436,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
64336436
free_extent_buffer(root->commit_root);
64346437
kfree(root);
64356438
}
6436-
out:
6439+
out_free:
64376440
btrfs_end_transaction_throttle(trans, tree_root);
64386441
kfree(wc);
64396442
btrfs_free_path(path);
6440-
return err;
6443+
out:
6444+
if (err)
6445+
btrfs_std_error(root->fs_info, err);
6446+
return;
64416447
}
64426448

64436449
/*

0 commit comments

Comments
 (0)