[RFC,1/2] errno.h: Export EFSCORRUPTED error number
diff mbox series

Message ID 20190410083508.21091-1-wqu@suse.com
State New
Headers show
Series
  • [RFC,1/2] errno.h: Export EFSCORRUPTED error number
Related show

Commit Message

Qu Wenruo April 10, 2019, 8:35 a.m. UTC
Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
They both map EFSCORRUPTED to EUCLEAN.

Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
corruption.

And block layer is going to distinguish filesystem corruption with
oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
declaration to <linux/errno.h> so all filesystems and block layer can
take advantage of this easier-to-read error number.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/ext2/ext2.h                   | 1 -
 fs/ext4/ext4.h                   | 1 -
 fs/xfs/xfs_linux.h               | 1 -
 include/uapi/asm-generic/errno.h | 3 +++
 4 files changed, 3 insertions(+), 3 deletions(-)

Comments

Darrick J. Wong April 10, 2019, 3:11 p.m. UTC | #1
On Wed, Apr 10, 2019 at 04:35:07PM +0800, Qu Wenruo wrote:
> Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
> They both map EFSCORRUPTED to EUCLEAN.
> 
> Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
> corruption.

I don't know if you (btrfs folks specifically) care but ext* and xfs
also use EFSBADCRC to signal unrecovered checksum validation failures.
Can we promote both of them to asm-generic/errno.h at the same time?

#define EFSBADCRC   EBADMSG

--D

> And block layer is going to distinguish filesystem corruption with
> oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
> declaration to <linux/errno.h> so all filesystems and block layer can
> take advantage of this easier-to-read error number.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/ext2/ext2.h                   | 1 -
>  fs/ext4/ext4.h                   | 1 -
>  fs/xfs/xfs_linux.h               | 1 -
>  include/uapi/asm-generic/errno.h | 3 +++
>  4 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 10ab238de9a6..03d0ca8fae42 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -369,7 +369,6 @@ struct ext2_inode {
>   */
>  #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
>  #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
> -#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
>  
>  /*
>   * Mount flags
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 82ffdacdc7fa..f906b5cbf96d 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3248,6 +3248,5 @@ extern const struct iomap_ops ext4_iomap_ops;
>  #endif	/* __KERNEL__ */
>  
>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>  
>  #endif	/* _EXT4_H */
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index edbd5a210df2..36e5c6549f15 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -125,7 +125,6 @@ typedef __u32			xfs_nlink_t;
>  
>  #define ENOATTR		ENODATA		/* Attribute not found */
>  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>  
>  #define SYNCHRONIZE()	barrier()
> diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
> index cf9c51ac49f9..ebd6e7e76a98 100644
> --- a/include/uapi/asm-generic/errno.h
> +++ b/include/uapi/asm-generic/errno.h
> @@ -98,6 +98,9 @@
>  #define	EINPROGRESS	115	/* Operation now in progress */
>  #define	ESTALE		116	/* Stale file handle */
>  #define	EUCLEAN		117	/* Structure needs cleaning */
> +
> +#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
> +
>  #define	ENOTNAM		118	/* Not a XENIX named type file */
>  #define	ENAVAIL		119	/* No XENIX semaphores available */
>  #define	EISNAM		120	/* Is a named type file */
> -- 
> 2.21.0
>
Nikolay Borisov April 10, 2019, 3:28 p.m. UTC | #2
On 10.04.19 г. 18:11 ч., Darrick J. Wong wrote:
> On Wed, Apr 10, 2019 at 04:35:07PM +0800, Qu Wenruo wrote:
>> Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
>> They both map EFSCORRUPTED to EUCLEAN.
>>
>> Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
>> corruption.
> 
> I don't know if you (btrfs folks specifically) care but ext* and xfs
> also use EFSBADCRC to signal unrecovered checksum validation failures.
> Can we promote both of them to asm-generic/errno.h at the same time?
> 
> #define EFSBADCRC   EBADMSG

No we don't but I think we ought to start since this is more precise
than simple -EUCLEAN. So I agree with your suggestion

> 
> --D
> 
>> And block layer is going to distinguish filesystem corruption with
>> oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
>> declaration to <linux/errno.h> so all filesystems and block layer can
>> take advantage of this easier-to-read error number.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  fs/ext2/ext2.h                   | 1 -
>>  fs/ext4/ext4.h                   | 1 -
>>  fs/xfs/xfs_linux.h               | 1 -
>>  include/uapi/asm-generic/errno.h | 3 +++
>>  4 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
>> index 10ab238de9a6..03d0ca8fae42 100644
>> --- a/fs/ext2/ext2.h
>> +++ b/fs/ext2/ext2.h
>> @@ -369,7 +369,6 @@ struct ext2_inode {
>>   */
>>  #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
>>  #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
>> -#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
>>  
>>  /*
>>   * Mount flags
>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
>> index 82ffdacdc7fa..f906b5cbf96d 100644
>> --- a/fs/ext4/ext4.h
>> +++ b/fs/ext4/ext4.h
>> @@ -3248,6 +3248,5 @@ extern const struct iomap_ops ext4_iomap_ops;
>>  #endif	/* __KERNEL__ */
>>  
>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>>  
>>  #endif	/* _EXT4_H */
>> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
>> index edbd5a210df2..36e5c6549f15 100644
>> --- a/fs/xfs/xfs_linux.h
>> +++ b/fs/xfs/xfs_linux.h
>> @@ -125,7 +125,6 @@ typedef __u32			xfs_nlink_t;
>>  
>>  #define ENOATTR		ENODATA		/* Attribute not found */
>>  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>>  
>>  #define SYNCHRONIZE()	barrier()
>> diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
>> index cf9c51ac49f9..ebd6e7e76a98 100644
>> --- a/include/uapi/asm-generic/errno.h
>> +++ b/include/uapi/asm-generic/errno.h
>> @@ -98,6 +98,9 @@
>>  #define	EINPROGRESS	115	/* Operation now in progress */
>>  #define	ESTALE		116	/* Stale file handle */
>>  #define	EUCLEAN		117	/* Structure needs cleaning */
>> +
>> +#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
>> +
>>  #define	ENOTNAM		118	/* Not a XENIX named type file */
>>  #define	ENAVAIL		119	/* No XENIX semaphores available */
>>  #define	EISNAM		120	/* Is a named type file */
>> -- 
>> 2.21.0
>>
>
Qu Wenruo April 11, 2019, 12:28 a.m. UTC | #3
On 2019/4/10 下午11:11,  Darrick J. Wong  wrote:
> On Wed, Apr 10, 2019 at 04:35:07PM +0800, Qu Wenruo wrote:
>> Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
>> They both map EFSCORRUPTED to EUCLEAN.
>>
>> Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
>> corruption.
> 
> I don't know if you (btrfs folks specifically) care but ext* and xfs
> also use EFSBADCRC to signal unrecovered checksum validation failures.
> Can we promote both of them to asm-generic/errno.h at the same time?

It looks pretty good to me in fact.

I'm really tired of using -EIO for csum mismatch/any other higher level
mismatch.

The only concern is the "CRC" part. Yes, btrfs uses and only supports
CRC32 so far, but I'm sure btrfs will support cryptographic hash.

So what about renaming it to EFSBADCSUM?

Thanks,
Qu

> 
> #define EFSBADCRC   EBADMSG
> 
> --D
> 
>> And block layer is going to distinguish filesystem corruption with
>> oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
>> declaration to <linux/errno.h> so all filesystems and block layer can
>> take advantage of this easier-to-read error number.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  fs/ext2/ext2.h                   | 1 -
>>  fs/ext4/ext4.h                   | 1 -
>>  fs/xfs/xfs_linux.h               | 1 -
>>  include/uapi/asm-generic/errno.h | 3 +++
>>  4 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
>> index 10ab238de9a6..03d0ca8fae42 100644
>> --- a/fs/ext2/ext2.h
>> +++ b/fs/ext2/ext2.h
>> @@ -369,7 +369,6 @@ struct ext2_inode {
>>   */
>>  #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
>>  #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
>> -#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
>>  
>>  /*
>>   * Mount flags
>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
>> index 82ffdacdc7fa..f906b5cbf96d 100644
>> --- a/fs/ext4/ext4.h
>> +++ b/fs/ext4/ext4.h
>> @@ -3248,6 +3248,5 @@ extern const struct iomap_ops ext4_iomap_ops;
>>  #endif	/* __KERNEL__ */
>>  
>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>>  
>>  #endif	/* _EXT4_H */
>> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
>> index edbd5a210df2..36e5c6549f15 100644
>> --- a/fs/xfs/xfs_linux.h
>> +++ b/fs/xfs/xfs_linux.h
>> @@ -125,7 +125,6 @@ typedef __u32			xfs_nlink_t;
>>  
>>  #define ENOATTR		ENODATA		/* Attribute not found */
>>  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>>  
>>  #define SYNCHRONIZE()	barrier()
>> diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
>> index cf9c51ac49f9..ebd6e7e76a98 100644
>> --- a/include/uapi/asm-generic/errno.h
>> +++ b/include/uapi/asm-generic/errno.h
>> @@ -98,6 +98,9 @@
>>  #define	EINPROGRESS	115	/* Operation now in progress */
>>  #define	ESTALE		116	/* Stale file handle */
>>  #define	EUCLEAN		117	/* Structure needs cleaning */
>> +
>> +#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
>> +
>>  #define	ENOTNAM		118	/* Not a XENIX named type file */
>>  #define	ENAVAIL		119	/* No XENIX semaphores available */
>>  #define	EISNAM		120	/* Is a named type file */
>> -- 
>> 2.21.0
>>
>
Darrick J. Wong April 11, 2019, 1:06 a.m. UTC | #4
On Thu, Apr 11, 2019 at 08:28:44AM +0800, Qu Wenruo wrote:
> 
> 
> On 2019/4/10 下午11:11,  Darrick J. Wong  wrote:
> > On Wed, Apr 10, 2019 at 04:35:07PM +0800, Qu Wenruo wrote:
> >> Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
> >> They both map EFSCORRUPTED to EUCLEAN.
> >>
> >> Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
> >> corruption.
> > 
> > I don't know if you (btrfs folks specifically) care but ext* and xfs
> > also use EFSBADCRC to signal unrecovered checksum validation failures.
> > Can we promote both of them to asm-generic/errno.h at the same time?
> 
> It looks pretty good to me in fact.
> 
> I'm really tired of using -EIO for csum mismatch/any other higher level
> mismatch.
> 
> The only concern is the "CRC" part. Yes, btrfs uses and only supports
> CRC32 so far, but I'm sure btrfs will support cryptographic hash.
> 
> So what about renaming it to EFSBADCSUM?

We've been shipping EFSBADCRC in xfslibs-dev userspace libraries for
years now, so we can't change the symbol name.

--D

> Thanks,
> Qu
> 
> > 
> > #define EFSBADCRC   EBADMSG
> > 
> > --D
> > 
> >> And block layer is going to distinguish filesystem corruption with
> >> oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
> >> declaration to <linux/errno.h> so all filesystems and block layer can
> >> take advantage of this easier-to-read error number.
> >>
> >> Signed-off-by: Qu Wenruo <wqu@suse.com>
> >> ---
> >>  fs/ext2/ext2.h                   | 1 -
> >>  fs/ext4/ext4.h                   | 1 -
> >>  fs/xfs/xfs_linux.h               | 1 -
> >>  include/uapi/asm-generic/errno.h | 3 +++
> >>  4 files changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> >> index 10ab238de9a6..03d0ca8fae42 100644
> >> --- a/fs/ext2/ext2.h
> >> +++ b/fs/ext2/ext2.h
> >> @@ -369,7 +369,6 @@ struct ext2_inode {
> >>   */
> >>  #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
> >>  #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
> >> -#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
> >>  
> >>  /*
> >>   * Mount flags
> >> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> >> index 82ffdacdc7fa..f906b5cbf96d 100644
> >> --- a/fs/ext4/ext4.h
> >> +++ b/fs/ext4/ext4.h
> >> @@ -3248,6 +3248,5 @@ extern const struct iomap_ops ext4_iomap_ops;
> >>  #endif	/* __KERNEL__ */
> >>  
> >>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
> >> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
> >>  
> >>  #endif	/* _EXT4_H */
> >> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> >> index edbd5a210df2..36e5c6549f15 100644
> >> --- a/fs/xfs/xfs_linux.h
> >> +++ b/fs/xfs/xfs_linux.h
> >> @@ -125,7 +125,6 @@ typedef __u32			xfs_nlink_t;
> >>  
> >>  #define ENOATTR		ENODATA		/* Attribute not found */
> >>  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
> >> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
> >>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
> >>  
> >>  #define SYNCHRONIZE()	barrier()
> >> diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
> >> index cf9c51ac49f9..ebd6e7e76a98 100644
> >> --- a/include/uapi/asm-generic/errno.h
> >> +++ b/include/uapi/asm-generic/errno.h
> >> @@ -98,6 +98,9 @@
> >>  #define	EINPROGRESS	115	/* Operation now in progress */
> >>  #define	ESTALE		116	/* Stale file handle */
> >>  #define	EUCLEAN		117	/* Structure needs cleaning */
> >> +
> >> +#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
> >> +
> >>  #define	ENOTNAM		118	/* Not a XENIX named type file */
> >>  #define	ENAVAIL		119	/* No XENIX semaphores available */
> >>  #define	EISNAM		120	/* Is a named type file */
> >> -- 
> >> 2.21.0
> >>
> > 
>
Qu Wenruo April 11, 2019, 1:43 a.m. UTC | #5
On 2019/4/11 上午9:06, Darrick J. Wong wrote:
> On Thu, Apr 11, 2019 at 08:28:44AM +0800, Qu Wenruo wrote:
>>
>>
>> On 2019/4/10 下午11:11,  Darrick J. Wong  wrote:
>>> On Wed, Apr 10, 2019 at 04:35:07PM +0800, Qu Wenruo wrote:
>>>> Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
>>>> They both map EFSCORRUPTED to EUCLEAN.
>>>>
>>>> Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
>>>> corruption.
>>>
>>> I don't know if you (btrfs folks specifically) care but ext* and xfs
>>> also use EFSBADCRC to signal unrecovered checksum validation failures.
>>> Can we promote both of them to asm-generic/errno.h at the same time?
>>
>> It looks pretty good to me in fact.
>>
>> I'm really tired of using -EIO for csum mismatch/any other higher level
>> mismatch.
>>
>> The only concern is the "CRC" part. Yes, btrfs uses and only supports
>> CRC32 so far, but I'm sure btrfs will support cryptographic hash.
>>
>> So what about renaming it to EFSBADCSUM?
> 
> We've been shipping EFSBADCRC in xfslibs-dev userspace libraries for
> years now, so we can't change the symbol name.

Fair enough.

Any extra error number worthy export?

Thanks,
Qu

> 
> --D
> 
>> Thanks,
>> Qu
>>
>>>
>>> #define EFSBADCRC   EBADMSG
>>>
>>> --D
>>>
>>>> And block layer is going to distinguish filesystem corruption with
>>>> oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
>>>> declaration to <linux/errno.h> so all filesystems and block layer can
>>>> take advantage of this easier-to-read error number.
>>>>
>>>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>>>> ---
>>>>  fs/ext2/ext2.h                   | 1 -
>>>>  fs/ext4/ext4.h                   | 1 -
>>>>  fs/xfs/xfs_linux.h               | 1 -
>>>>  include/uapi/asm-generic/errno.h | 3 +++
>>>>  4 files changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
>>>> index 10ab238de9a6..03d0ca8fae42 100644
>>>> --- a/fs/ext2/ext2.h
>>>> +++ b/fs/ext2/ext2.h
>>>> @@ -369,7 +369,6 @@ struct ext2_inode {
>>>>   */
>>>>  #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
>>>>  #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
>>>> -#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
>>>>  
>>>>  /*
>>>>   * Mount flags
>>>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
>>>> index 82ffdacdc7fa..f906b5cbf96d 100644
>>>> --- a/fs/ext4/ext4.h
>>>> +++ b/fs/ext4/ext4.h
>>>> @@ -3248,6 +3248,5 @@ extern const struct iomap_ops ext4_iomap_ops;
>>>>  #endif	/* __KERNEL__ */
>>>>  
>>>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>>>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>>>>  
>>>>  #endif	/* _EXT4_H */
>>>> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
>>>> index edbd5a210df2..36e5c6549f15 100644
>>>> --- a/fs/xfs/xfs_linux.h
>>>> +++ b/fs/xfs/xfs_linux.h
>>>> @@ -125,7 +125,6 @@ typedef __u32			xfs_nlink_t;
>>>>  
>>>>  #define ENOATTR		ENODATA		/* Attribute not found */
>>>>  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
>>>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>>>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>>>>  
>>>>  #define SYNCHRONIZE()	barrier()
>>>> diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
>>>> index cf9c51ac49f9..ebd6e7e76a98 100644
>>>> --- a/include/uapi/asm-generic/errno.h
>>>> +++ b/include/uapi/asm-generic/errno.h
>>>> @@ -98,6 +98,9 @@
>>>>  #define	EINPROGRESS	115	/* Operation now in progress */
>>>>  #define	ESTALE		116	/* Stale file handle */
>>>>  #define	EUCLEAN		117	/* Structure needs cleaning */
>>>> +
>>>> +#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
>>>> +
>>>>  #define	ENOTNAM		118	/* Not a XENIX named type file */
>>>>  #define	ENAVAIL		119	/* No XENIX semaphores available */
>>>>  #define	EISNAM		120	/* Is a named type file */
>>>> -- 
>>>> 2.21.0
>>>>
>>>
>>
> 
> 
>
Darrick J. Wong April 11, 2019, 1:47 a.m. UTC | #6
On Thu, Apr 11, 2019 at 09:43:05AM +0800, Qu Wenruo wrote:
> 
> 
> On 2019/4/11 上午9:06, Darrick J. Wong wrote:
> > On Thu, Apr 11, 2019 at 08:28:44AM +0800, Qu Wenruo wrote:
> >>
> >>
> >> On 2019/4/10 下午11:11,  Darrick J. Wong  wrote:
> >>> On Wed, Apr 10, 2019 at 04:35:07PM +0800, Qu Wenruo wrote:
> >>>> Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption.
> >>>> They both map EFSCORRUPTED to EUCLEAN.
> >>>>
> >>>> Btrfs/Ubifs/fscrypto all use EUCLEAN directly to indicate filesystem
> >>>> corruption.
> >>>
> >>> I don't know if you (btrfs folks specifically) care but ext* and xfs
> >>> also use EFSBADCRC to signal unrecovered checksum validation failures.
> >>> Can we promote both of them to asm-generic/errno.h at the same time?
> >>
> >> It looks pretty good to me in fact.
> >>
> >> I'm really tired of using -EIO for csum mismatch/any other higher level
> >> mismatch.
> >>
> >> The only concern is the "CRC" part. Yes, btrfs uses and only supports
> >> CRC32 so far, but I'm sure btrfs will support cryptographic hash.
> >>
> >> So what about renaming it to EFSBADCSUM?
> > 
> > We've been shipping EFSBADCRC in xfslibs-dev userspace libraries for
> > years now, so we can't change the symbol name.
> 
> Fair enough.
> 
> Any extra error number worthy export?

None that I can think of...

--D

> Thanks,
> Qu
> 
> > 
> > --D
> > 
> >> Thanks,
> >> Qu
> >>
> >>>
> >>> #define EFSBADCRC   EBADMSG
> >>>
> >>> --D
> >>>
> >>>> And block layer is going to distinguish filesystem corruption with
> >>>> oridinary EIO error, it's a good idea to export the initial EFSCORRUPTED
> >>>> declaration to <linux/errno.h> so all filesystems and block layer can
> >>>> take advantage of this easier-to-read error number.
> >>>>
> >>>> Signed-off-by: Qu Wenruo <wqu@suse.com>
> >>>> ---
> >>>>  fs/ext2/ext2.h                   | 1 -
> >>>>  fs/ext4/ext4.h                   | 1 -
> >>>>  fs/xfs/xfs_linux.h               | 1 -
> >>>>  include/uapi/asm-generic/errno.h | 3 +++
> >>>>  4 files changed, 3 insertions(+), 3 deletions(-)
> >>>>
> >>>> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> >>>> index 10ab238de9a6..03d0ca8fae42 100644
> >>>> --- a/fs/ext2/ext2.h
> >>>> +++ b/fs/ext2/ext2.h
> >>>> @@ -369,7 +369,6 @@ struct ext2_inode {
> >>>>   */
> >>>>  #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
> >>>>  #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
> >>>> -#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
> >>>>  
> >>>>  /*
> >>>>   * Mount flags
> >>>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> >>>> index 82ffdacdc7fa..f906b5cbf96d 100644
> >>>> --- a/fs/ext4/ext4.h
> >>>> +++ b/fs/ext4/ext4.h
> >>>> @@ -3248,6 +3248,5 @@ extern const struct iomap_ops ext4_iomap_ops;
> >>>>  #endif	/* __KERNEL__ */
> >>>>  
> >>>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
> >>>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
> >>>>  
> >>>>  #endif	/* _EXT4_H */
> >>>> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> >>>> index edbd5a210df2..36e5c6549f15 100644
> >>>> --- a/fs/xfs/xfs_linux.h
> >>>> +++ b/fs/xfs/xfs_linux.h
> >>>> @@ -125,7 +125,6 @@ typedef __u32			xfs_nlink_t;
> >>>>  
> >>>>  #define ENOATTR		ENODATA		/* Attribute not found */
> >>>>  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
> >>>> -#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
> >>>>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
> >>>>  
> >>>>  #define SYNCHRONIZE()	barrier()
> >>>> diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
> >>>> index cf9c51ac49f9..ebd6e7e76a98 100644
> >>>> --- a/include/uapi/asm-generic/errno.h
> >>>> +++ b/include/uapi/asm-generic/errno.h
> >>>> @@ -98,6 +98,9 @@
> >>>>  #define	EINPROGRESS	115	/* Operation now in progress */
> >>>>  #define	ESTALE		116	/* Stale file handle */
> >>>>  #define	EUCLEAN		117	/* Structure needs cleaning */
> >>>> +
> >>>> +#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
> >>>> +
> >>>>  #define	ENOTNAM		118	/* Not a XENIX named type file */
> >>>>  #define	ENAVAIL		119	/* No XENIX semaphores available */
> >>>>  #define	EISNAM		120	/* Is a named type file */
> >>>> -- 
> >>>> 2.21.0
> >>>>
> >>>
> >>
> > 
> > 
> > 
>

Patch
diff mbox series

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 10ab238de9a6..03d0ca8fae42 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -369,7 +369,6 @@  struct ext2_inode {
  */
 #define	EXT2_VALID_FS			0x0001	/* Unmounted cleanly */
 #define	EXT2_ERROR_FS			0x0002	/* Errors detected */
-#define	EFSCORRUPTED			EUCLEAN	/* Filesystem is corrupted */
 
 /*
  * Mount flags
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 82ffdacdc7fa..f906b5cbf96d 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3248,6 +3248,5 @@  extern const struct iomap_ops ext4_iomap_ops;
 #endif	/* __KERNEL__ */
 
 #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
-#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
 
 #endif	/* _EXT4_H */
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index edbd5a210df2..36e5c6549f15 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -125,7 +125,6 @@  typedef __u32			xfs_nlink_t;
 
 #define ENOATTR		ENODATA		/* Attribute not found */
 #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
-#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
 #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
 
 #define SYNCHRONIZE()	barrier()
diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
index cf9c51ac49f9..ebd6e7e76a98 100644
--- a/include/uapi/asm-generic/errno.h
+++ b/include/uapi/asm-generic/errno.h
@@ -98,6 +98,9 @@ 
 #define	EINPROGRESS	115	/* Operation now in progress */
 #define	ESTALE		116	/* Stale file handle */
 #define	EUCLEAN		117	/* Structure needs cleaning */
+
+#define EFSCORRUPTED	EUCLEAN	/* Filesystem is corrupted */
+
 #define	ENOTNAM		118	/* Not a XENIX named type file */
 #define	ENAVAIL		119	/* No XENIX semaphores available */
 #define	EISNAM		120	/* Is a named type file */