Commit cb1b69f4 authored by Tsutomu Itoh's avatar Tsutomu Itoh Committed by Chris Mason

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: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent cdcb725c
...@@ -2367,8 +2367,8 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, ...@@ -2367,8 +2367,8 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans,
int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
int btrfs_drop_snapshot(struct btrfs_root *root, void btrfs_drop_snapshot(struct btrfs_root *root,
struct btrfs_block_rsv *block_rsv, int update_ref); struct btrfs_block_rsv *block_rsv, int update_ref);
int btrfs_drop_subtree(struct btrfs_trans_handle *trans, int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct extent_buffer *node, struct extent_buffer *node,
......
...@@ -6277,8 +6277,8 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans, ...@@ -6277,8 +6277,8 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
* also make sure backrefs for the shared block and all lower level * also make sure backrefs for the shared block and all lower level
* blocks are properly updated. * blocks are properly updated.
*/ */
int btrfs_drop_snapshot(struct btrfs_root *root, void btrfs_drop_snapshot(struct btrfs_root *root,
struct btrfs_block_rsv *block_rsv, int update_ref) struct btrfs_block_rsv *block_rsv, int update_ref)
{ {
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
...@@ -6291,13 +6291,16 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -6291,13 +6291,16 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
int level; int level;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path) {
return -ENOMEM; err = -ENOMEM;
goto out;
}
wc = kzalloc(sizeof(*wc), GFP_NOFS); wc = kzalloc(sizeof(*wc), GFP_NOFS);
if (!wc) { if (!wc) {
btrfs_free_path(path); btrfs_free_path(path);
return -ENOMEM; err = -ENOMEM;
goto out;
} }
trans = btrfs_start_transaction(tree_root, 0); trans = btrfs_start_transaction(tree_root, 0);
...@@ -6326,7 +6329,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -6326,7 +6329,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
path->lowest_level = 0; path->lowest_level = 0;
if (ret < 0) { if (ret < 0) {
err = ret; err = ret;
goto out; goto out_free;
} }
WARN_ON(ret > 0); WARN_ON(ret > 0);
...@@ -6433,11 +6436,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -6433,11 +6436,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
free_extent_buffer(root->commit_root); free_extent_buffer(root->commit_root);
kfree(root); kfree(root);
} }
out: out_free:
btrfs_end_transaction_throttle(trans, tree_root); btrfs_end_transaction_throttle(trans, tree_root);
kfree(wc); kfree(wc);
btrfs_free_path(path); btrfs_free_path(path);
return err; out:
if (err)
btrfs_std_error(root->fs_info, err);
return;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment