aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2011-11-06 18:50:56 -0500
committerChris Mason <chris.mason@oracle.com>2011-11-06 18:50:56 -0500
commit7c7e82a77fe3d89ae50824aa7c897454675eb4c4 (patch)
treede7ac71aa9fa00d3ce2b1849c97733f37799900c
parentd43317dcd074818d4bd12ddd4184a29aff98907b (diff)
Btrfs: check for a null fs root when writing to the backup root log
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>
-rw-r--r--fs/btrfs/disk-io.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e532892431f4..e53a5bb85670 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1754,11 +1754,18 @@ static void backup_super_roots(struct btrfs_fs_info *info)
1754 btrfs_set_backup_extent_root_level(root_backup, 1754 btrfs_set_backup_extent_root_level(root_backup,
1755 btrfs_header_level(info->extent_root->node)); 1755 btrfs_header_level(info->extent_root->node));
1756 1756
1757 btrfs_set_backup_fs_root(root_backup, info->fs_root->node->start); 1757 /*
1758 btrfs_set_backup_fs_root_gen(root_backup, 1758 * we might commit during log recovery, which happens before we set
1759 * the fs_root. Make sure it is valid before we fill it in.
1760 */
1761 if (info->fs_root && info->fs_root->node) {
1762 btrfs_set_backup_fs_root(root_backup,
1763 info->fs_root->node->start);
1764 btrfs_set_backup_fs_root_gen(root_backup,
1759 btrfs_header_generation(info->fs_root->node)); 1765 btrfs_header_generation(info->fs_root->node));
1760 btrfs_set_backup_fs_root_level(root_backup, 1766 btrfs_set_backup_fs_root_level(root_backup,
1761 btrfs_header_level(info->fs_root->node)); 1767 btrfs_header_level(info->fs_root->node));
1768 }
1762 1769
1763 btrfs_set_backup_dev_root(root_backup, info->dev_root->node->start); 1770 btrfs_set_backup_dev_root(root_backup, info->dev_root->node->start);
1764 btrfs_set_backup_dev_root_gen(root_backup, 1771 btrfs_set_backup_dev_root_gen(root_backup,