Re: [PATCH URGENT v1.1 1/2] btrfs-progs: disk-io: Make super block write error easier to read

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

 




On 27.03.19 г. 11:46 ч., Qu Wenruo wrote:
> When we failed to write super blocks, we just output something like:
>   WARNING: failed to write sb: I/O error
> Or
>   WARNING: failed to write all sb data
> 
> There is no info about which device failed and there are two different
> error message for the same write error.
> 
> This patch will change it to something more detailed:
> ERROR: failed to write super block for devid 1: write error: I/O error
> 
> This provides the basis for later super block flush error handling.
> 
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>

Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>

> ---
>  disk-io.c | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/disk-io.c b/disk-io.c
> index 797b9b79ea3c..f7fb7026cd94 100644
> --- a/disk-io.c
> +++ b/disk-io.c
> @@ -1599,8 +1599,13 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
>  		ret = pwrite64(device->fd, fs_info->super_copy,
>  				BTRFS_SUPER_INFO_SIZE,
>  				fs_info->super_bytenr);
> -		if (ret != BTRFS_SUPER_INFO_SIZE)
> -			goto write_err;
> +		if (ret != BTRFS_SUPER_INFO_SIZE) {
> +			errno = EIO;
> +			error(
> +		"failed to write super block for devid %llu: write error: %m",
> +				device->devid);
> +			return -EIO;
> +		}
>  		return 0;
>  	}
>  
> @@ -1622,18 +1627,16 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
>  		 */
>  		ret = pwrite64(device->fd, fs_info->super_copy,
>  				BTRFS_SUPER_INFO_SIZE, bytenr);
> -		if (ret != BTRFS_SUPER_INFO_SIZE)
> -			goto write_err;
> +		if (ret != BTRFS_SUPER_INFO_SIZE) {
> +			errno = EIO;
> +			error(
> +		"failed to write super block for devid %llu: write error: %m",
> +				device->devid);
> +			return -errno;
> +		}
>  	}
>  
>  	return 0;
> -
> -write_err:
> -	if (ret > 0)
> -		fprintf(stderr, "WARNING: failed to write all sb data\n");
> -	else
> -		fprintf(stderr, "WARNING: failed to write sb: %m\n");
> -	return ret;
>  }
>  
>  int write_all_supers(struct btrfs_fs_info *fs_info)
> 



[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