Skip to content

Commit

Permalink
Btrfs: check for a null fs root when writing to the backup root log
Browse files Browse the repository at this point in the history
During log replay, can commit the transaction before the fs_root
pointers are setup, so we have to make sure they are not null before
trying to use them.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Nov 6, 2011
1 parent d43317d commit 7c7e82a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,11 +1754,18 @@ static void backup_super_roots(struct btrfs_fs_info *info)
btrfs_set_backup_extent_root_level(root_backup,
btrfs_header_level(info->extent_root->node));

btrfs_set_backup_fs_root(root_backup, info->fs_root->node->start);
btrfs_set_backup_fs_root_gen(root_backup,
/*
* we might commit during log recovery, which happens before we set
* the fs_root. Make sure it is valid before we fill it in.
*/
if (info->fs_root && info->fs_root->node) {
btrfs_set_backup_fs_root(root_backup,
info->fs_root->node->start);
btrfs_set_backup_fs_root_gen(root_backup,
btrfs_header_generation(info->fs_root->node));
btrfs_set_backup_fs_root_level(root_backup,
btrfs_set_backup_fs_root_level(root_backup,
btrfs_header_level(info->fs_root->node));
}

btrfs_set_backup_dev_root(root_backup, info->dev_root->node->start);
btrfs_set_backup_dev_root_gen(root_backup,
Expand Down

0 comments on commit 7c7e82a

Please sign in to comment.