Re: [RFC PATCH] btrfs: Introduce developer-oriented check to ensure all tree blocks are written back before writing super blocks

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

 




On 2019/2/21 下午4:22, Qu Wenruo wrote:
> There are a lot of error reports complaining about transid error in the
> mail list.
> 
> Under most case, the on-disk transid is lower than expected transid.
> This may indicate that some tree blocks are not written back to disk
> before writing super blocks.
> 
> This patch will add a safe net for developers, by calling
> btrfs_write_and_wait_transaction() before setting transaction unblocked
> and double check btree_inode and dirty_pages io_tree, to ensure no tree
> blocks are still dirty or under writeback.
> 
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>

Please discard this patch.

As Nikolay suggested, the check doesn't make much sense.

>  
> +	/* Last safenet or developer to catch any unwritten tree blocks */
> +	if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) {
> +		u64 found_start = 0;
> +		u64 found_end = 0;
> +
> +		ret = btrfs_write_and_wait_transaction(trans);
> +		if (ret) {
> +			btrfs_handle_fs_error(fs_info, ret,
> +					      "Error while writing out transaction");
> +			mutex_unlock(&fs_info->tree_log_mutex);
> +			goto scrub_continue;
> +		}
> +
> +		/* No dirty extent should exist in btree inode */
> +		ret = test_range_bit(&trans->transaction->dirty_pages, 0,
> +				(u64)-1, EXTENT_DIRTY | EXTENT_WRITEBACK,
> +				0, NULL);

For dirty_pages, btrfs_write_and_wait_transaction() will clear all bits.
So the check will always return 0.

> +		if (ret > 0) {
> +			WARN(1,
> +		"dirty_pages not fully written back, start=%llu len=%llu\n",
> +			     found_start, found_end + 1 - found_start);
> +			ret = -EUCLEAN;
> +			mutex_unlock(&fs_info->tree_log_mutex);
> +			goto scrub_continue;
> +		}
> +		ret = test_range_bit(&BTRFS_I(fs_info->btree_inode)->io_tree, 0,
> +				     (u64)-1, EXTENT_DIRTY | EXTENT_WRITEBACK,
> +				     0, NULL);

btree_inode doesn't really carry EXTENT_DIRTY bit.
It only carries EXTENT_LOCK, and are mostly for tree read locking.

So this check doesn't make much sense either.

Thanks,
Qu

> +		if (ret > 0) {
> +			WARN(1,
> +		"btree io_tree not fully written back, start=%llu len=%llu\n",
> +			     found_start, found_end + 1 - found_start);
> +			ret = -EUCLEAN;
> +			mutex_unlock(&fs_info->tree_log_mutex);
> +			goto scrub_continue;
> +		}
> +	}
> +
>  	spin_lock(&fs_info->trans_lock);
>  	cur_trans->state = TRANS_STATE_UNBLOCKED;
>  	fs_info->running_transaction = NULL;
> 

Attachment: signature.asc
Description: OpenPGP digital signature


[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