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

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

 




On 2019/11/1 下午6:52, David Sterba wrote:
> 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.

Log tree update only happens for primary sb.

The kernel code has this:

btrfs_sync_log()
|- ret = write_all_supers(fs_info, 1)
   |- write_dev_supers(max_mirrors); # max_mirrors == 1
      |- for (i = 0; i < max_mirrors; i++)

> 
>> +	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.

Oh, you got me.

That's indeed the case. I guess we need to do the same skip_bg behavior
just like kernel to handle multiple devices.

Thanks,
Qu




[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