Commit 5e82849e authored by Chris Mason's avatar Chris Mason Committed by David Woodhouse

Btrfs: new subvolume oops fix

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 5d0c3e60
...@@ -2013,6 +2013,8 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen) ...@@ -2013,6 +2013,8 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen)
BUG_ON(!trans); BUG_ON(!trans);
subvol = btrfs_alloc_free_block(trans, root); subvol = btrfs_alloc_free_block(trans, root);
if (subvol == NULL)
return -ENOSPC;
leaf = btrfs_buffer_leaf(subvol); leaf = btrfs_buffer_leaf(subvol);
btrfs_set_header_nritems(&leaf->header, 0); btrfs_set_header_nritems(&leaf->header, 0);
btrfs_set_header_level(&leaf->header, 0); btrfs_set_header_level(&leaf->header, 0);
...@@ -2022,8 +2024,6 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen) ...@@ -2022,8 +2024,6 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen)
memcpy(leaf->header.fsid, root->fs_info->disk_super->fsid, memcpy(leaf->header.fsid, root->fs_info->disk_super->fsid,
sizeof(leaf->header.fsid)); sizeof(leaf->header.fsid));
mark_buffer_dirty(subvol); mark_buffer_dirty(subvol);
brelse(subvol);
subvol = NULL;
inode_item = &root_item.inode; inode_item = &root_item.inode;
memset(inode_item, 0, sizeof(*inode_item)); memset(inode_item, 0, sizeof(*inode_item));
...@@ -2035,6 +2035,8 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen) ...@@ -2035,6 +2035,8 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen)
btrfs_set_root_blocknr(&root_item, bh_blocknr(subvol)); btrfs_set_root_blocknr(&root_item, bh_blocknr(subvol));
btrfs_set_root_refs(&root_item, 1); btrfs_set_root_refs(&root_item, 1);
brelse(subvol);
subvol = NULL;
ret = btrfs_find_free_objectid(trans, root->fs_info->tree_root, ret = btrfs_find_free_objectid(trans, root->fs_info->tree_root,
0, &objectid); 0, &objectid);
......
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