/* checks if a valid root backup is present. considers the case when all root backups empty valid. returns -1 in case of invalid root backup and 0 for valid.  */
static int btrfs_check_super_roots(struct btrfs_super_block *sb)
/* checks if a valid root backup is present. considers the case when all root backups empty valid. returns -1 in case of invalid root backup and 0 for valid.  */
static int btrfs_check_super_roots(struct btrfs_super_block *sb)
{
	struct btrfs_root_backup *root_backup;
	int i, newest = -1;
	int num_empty = 0;
	for (i = 0; i < BTRFS_NUM_BACKUP_ROOTS; ++i) {
		root_backup = sb->super_roots + i;
		if (root_backup->tree_root == 0 && root_backup->tree_root_gen == 0)
			num_empty++;
		if (root_backup->tree_root_gen == sb->generation)
			newest = i;
	}
	if (num_empty == BTRFS_NUM_BACKUP_ROOTS) {
		return 0;
	} else if (newest >= 0) {
		return 0;
	}
	return -1;
}