Skip to content

Commit

Permalink
Btrfs: new subvolume oops fix
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason authored and David Woodhouse committed Apr 23, 2007
1 parent 5d0c3e6 commit 5e82849
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,8 @@ static int create_subvol(struct btrfs_root *root, char *name, int namelen)
BUG_ON(!trans);

subvol = btrfs_alloc_free_block(trans, root);
if (subvol == NULL)
return -ENOSPC;
leaf = btrfs_buffer_leaf(subvol);
btrfs_set_header_nritems(&leaf->header, 0);
btrfs_set_header_level(&leaf->header, 0);
Expand All @@ -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,
sizeof(leaf->header.fsid));
mark_buffer_dirty(subvol);
brelse(subvol);
subvol = NULL;

inode_item = &root_item.inode;
memset(inode_item, 0, sizeof(*inode_item));
Expand All @@ -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_refs(&root_item, 1);
brelse(subvol);
subvol = NULL;

ret = btrfs_find_free_objectid(trans, root->fs_info->tree_root,
0, &objectid);
Expand Down

0 comments on commit 5e82849

Please sign in to comment.