Re: [PATCH 1/2] btrfs-progs: Return more meaningful value for btrfs_read_dev_super

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

 



On Tue, Sep 20, 2016 at 10:19:01AM +0800, Qu Wenruo wrote:
> btrfs_read_dev_super() only returns 0 or -1, which doesn't really help,
> caller won't know if it's caused by bad superblock or superblock out of
> range.
> 
> Change it to return -ENOENT for superblock which is out of range, and
> return -EIO for bad superblocks.
> 
> Signed-off-by: Qu Wenruo <quwenruo@xxxxxxxxxxxxxx>
> ---
>  disk-io.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/disk-io.c b/disk-io.c
> index 854c285..26852ee 100644
> --- a/disk-io.c
> +++ b/disk-io.c
> @@ -1590,14 +1590,15 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr,
>  
>  	if (sb_bytenr != BTRFS_SUPER_INFO_OFFSET) {
>  		ret = pread64(fd, buf, BTRFS_SUPER_INFO_SIZE, sb_bytenr);

pread64 sets errno, should be returned

> +		/* Special return value for out of dev/file range */
>  		if (ret < BTRFS_SUPER_INFO_SIZE)
> -			return -1;
> +			return -ENOENT;
>  
>  		if (btrfs_super_bytenr(buf) != sb_bytenr)
> -			return -1;
> +			return -EIO;
>  
>  		if (check_super(buf, sbflags))
> -			return -1;
> +			return -EIO;

and we should return what check_super returns, though it's -EIO in most
cases.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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