Re: [PATCH] btrfs-progs: rescue-zero-log: Modify super block directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 26, 2019 at 06:11:27PM +0800, Qu Wenruo wrote:
> +	/*
> +	 * Log tree only exists in the primary super block, so SBREAD_DEFAULT
> +	 * is enough.

For read it should be enough to read the default one, but do you mean
that 1st and 2nd copy don't have the log_root values set? They're
written from the same buffer so I'd expect the contents to be the same.

> +	ret = btrfs_read_dev_super(fd, sb, BTRFS_SUPER_INFO_OFFSET,
> +				   SBREAD_DEFAULT);
> +	if (ret < 0) {
> +		errno = -ret;
> +		error("failed to read super block on '%s': %m", devname);
> +		goto close_fd;
>  	}
>  
> -	sb = root->fs_info->super_copy;
>  	printf("Clearing log on %s, previous log_root %llu, level %u\n",
>  			devname,
>  			(unsigned long long)btrfs_super_log_root(sb),
>  			(unsigned)btrfs_super_log_root_level(sb));
> -	trans = btrfs_start_transaction(root, 1);
> -	BUG_ON(IS_ERR(trans));
>  	btrfs_set_super_log_root(sb, 0);
>  	btrfs_set_super_log_root_level(sb, 0);
> -	btrfs_commit_transaction(trans, root);
> -	close_ctree(root);
> +	btrfs_csum_data(btrfs_super_csum_type(sb), (u8 *)sb + BTRFS_CSUM_SIZE,
> +			result, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
> +	memcpy(&sb->csum[0], result, BTRFS_CSUM_SIZE);
> +	ret = pwrite64(fd, sb, BTRFS_SUPER_INFO_SIZE, BTRFS_SUPER_INFO_OFFSET);

So this only writes on the one device that's passed to the command.
Previously it would update superblocks on all devices.



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux