Skip to contentSkip to conversation

errno.h: Export EFSCORRUPTED error number

RFC PATCH In review Qu Wenruo 6 participants 10 messages Apr 10, 2019 – Apr 11, 2019

Subsystems (7)
lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

RFC PATCH 1/2 errno.h: Export EFSCORRUPTED error number

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0
author
#1 lore raw

PATCH 2/2 block: Add new BLK_STS_FSCORRUPTED status

There are quite a lot of filesystems doing their verification work done at endio hook or hook before submitting bio.

Normally such verification returns -EUCLEAN/-EFSCORRUPTED to indicate something unexpected, and some of such verification either use bio->bi_status or users bio->bi_endio to return their value.

In such case, the missing of corresponding BLK_STS_ bit can lower the severity just like:

In endio function:

	return errno_to_blk_status(-EFSCORRUPTED);

^^^ -EFSCORRUPTED gets interpreted to BLK_STS_IOERR

In the filesystem code:

	ret = blk_status_to_errno(bi->bi_status);
	^^^ BLK_STS_IOERR gets interpreted to -EIO;

This lowers the severity, making the filesystem layer to believe it's just an ordinary error.

This patch will add a new BLK_STS_FSCORRUPTED, to allow -EFSCORRUPTED to be converted to BLK_STS_FSCORRUPTED, and then converted back to -EFSCORRUPTED without losing info.

---
 block/blk-core.c          | 1 +
 include/linux/blk_types.h | 3 +++
 2 files changed, 4 insertions(+)
block/blk-core.c +1 -0
index a55389ba8779..ba7acfc3d8e0 100644
@@ -135,6 +135,7 @@ static const struct {
 	[BLK_STS_RESOURCE]	= { -ENOMEM,	"kernel resource" },
 	[BLK_STS_DEV_RESOURCE]	= { -EBUSY,	"device resource" },
 	[BLK_STS_AGAIN]		= { -EAGAIN,	"nonblocking retry" },
+	[BLK_STS_FSCORRUPTED]	= { -EFSCORRUPTED, "filesystem is corrupted" },
 
 	/* device mapper special case, should not leak out: */
 	[BLK_STS_DM_REQUEUE]	= { -EREMCHG, "dm internal retry" },
include/linux/blk_types.h +3 -0
index 791fee35df88..8f70bbec6c83 100644
@@ -63,6 +63,9 @@ typedef u8 __bitwise blk_status_t;
  */
 #define BLK_STS_DEV_RESOURCE	((__force blk_status_t)13)
 
+/* Normally filesystem layer generated error */
+#define BLK_STS_FSCORRUPTED	((__force blk_status_t)14)
+
 /**
  * blk_path_error - returns true if error may be path related
  * @error: status the request was completed with
Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH 2/2] block: Add new BLK_STS_FSCORRUPTED status

Quoted 5 lines · Qu Wenruo

There are quite a lot of filesystems doing their verification work done at endio hook or hook before submitting bio.

Normally such verification returns -EUCLEAN/-EFSCORRUPTED to indicate
something unexpected, and some of such verification either use> bio->bi_status or users bio->bi_endio to return their value.

Usually filesystems return -EUCLEAN/-EFSCORRUPTED to indicate failed verification. Currently there is no strict way how this information is communicated - either via bio->bi_status or through the bio's endio return value.

Quoted 12 lines

In such case, the missing of corresponding BLK_STS_ bit can lower the severity just like:

In endio function:

	return errno_to_blk_status(-EFSCORRUPTED);

^^^ -EFSCORRUPTED gets interpreted to BLK_STS_IOERR

In the filesystem code:

	ret = blk_status_to_errno(bi->bi_status);
	^^^ BLK_STS_IOERR gets interpreted to -EIO;
Quoted 6 lines

This lowers the severity, making the filesystem layer to believe it's just an ordinary error.

This patch will add a new BLK_STS_FSCORRUPTED, to allow -EFSCORRUPTED to be converted to BLK_STS_FSCORRUPTED, and then converted back to -EFSCORRUPTED without losing info.

This patch will add a new BLK_STS_FSCORRUPTED block status code, allowing filesystem corruptions to be properly communicated to upper layers.

Quoted 34 lines
---
 block/blk-core.c          | 1 +
 include/linux/blk_types.h | 3 +++
 2 files changed, 4 insertions(+)
block/blk-core.c +1 -0
index a55389ba8779..ba7acfc3d8e0 100644
@@ -135,6 +135,7 @@ static const struct {
 	[BLK_STS_RESOURCE]	= { -ENOMEM,	"kernel resource" },
 	[BLK_STS_DEV_RESOURCE]	= { -EBUSY,	"device resource" },
 	[BLK_STS_AGAIN]		= { -EAGAIN,	"nonblocking retry" },
+	[BLK_STS_FSCORRUPTED]	= { -EFSCORRUPTED, "filesystem is corrupted" },
 
 	/* device mapper special case, should not leak out: */
 	[BLK_STS_DM_REQUEUE]	= { -EREMCHG, "dm internal retry" },
include/linux/blk_types.h +3 -0
index 791fee35df88..8f70bbec6c83 100644
@@ -63,6 +63,9 @@ typedef u8 __bitwise blk_status_t;
  */
 #define BLK_STS_DEV_RESOURCE	((__force blk_status_t)13)
 
+/* Normally filesystem layer generated error */
+#define BLK_STS_FSCORRUPTED	((__force blk_status_t)14)
+
 /**
  * blk_path_error - returns true if error may be path related
  * @error: status the request was completed with
#3 lore raw

Re: [PATCH 2/2] block: Add new BLK_STS_FSCORRUPTED status

In reply to Qu Wenruo
Thank you for the patch! Yet something to improve:

Hi Qu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.1-rc4 next-20190410]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Qu-Wenruo/errno-h-Export-EFSCORRUPTED-error-number/20190410-183556
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=sparc64

All errors (new ones prefixed by >>):

>> block/blk-core.c:138:29: error: 'EFSCORRUPTED' undeclared here (not in a function); did you mean 'FS_NRSUPER'?

[BLK_STS_FSCORRUPTED] = { -EFSCORRUPTED, "filesystem is corrupted" },
^~~~~~~~~~~~
FS_NRSUPER

vim +138 block/blk-core.c

121
122 static const struct {
123 int errno;
124 const char *name;
125 } blk_errors[] = {
126 [BLK_STS_OK] = { 0, "" },
127 [BLK_STS_NOTSUPP] = { -EOPNOTSUPP, "operation not supported" },
128 [BLK_STS_TIMEOUT] = { -ETIMEDOUT, "timeout" },
129 [BLK_STS_NOSPC] = { -ENOSPC, "critical space allocation" },
130 [BLK_STS_TRANSPORT] = { -ENOLINK, "recoverable transport" },
131 [BLK_STS_TARGET] = { -EREMOTEIO, "critical target" },
132 [BLK_STS_NEXUS] = { -EBADE, "critical nexus" },
133 [BLK_STS_MEDIUM] = { -ENODATA, "critical medium" },
134 [BLK_STS_PROTECTION] = { -EILSEQ, "protection" },
135 [BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" },
136 [BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" },
137 [BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" },

 > 138		[BLK_STS_FSCORRUPTED]	= { -EFSCORRUPTED, "filesystem is corrupted" },

139
140 /* device mapper special case, should not leak out: */
141 [BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },
142
143 /* everything else not covered above: */
144 [BLK_STS_IOERR] = { -EIO, "I/O" },
145 };
146

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw
In reply to Qu Wenruo
Quoted 5 lines · Qu Wenruo

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

Quoted 65 lines

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0
#5 lore raw
Quoted 4 lines · Darrick J. Wong
Quoted 3 lines · Qu Wenruo

Xfs and Ext* uses EFSCORRUPTED to indicate filesystem corruption. They both map EFSCORRUPTED to EUCLEAN.

Quoted 8 lines
Quoted 2 lines

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

Quoted 69 lines

--D

Quoted 65 lines

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0
#6 lore raw
In reply to Darrick J. Wong
Quoted 10 lines · Darrick J. Wong
Quoted 5 lines · Qu Wenruo

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

Quoted 71 lines

#define EFSBADCRC EBADMSG

--D

Quoted 65 lines

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0
#7 lore raw
Quoted 16 lines · Qu Wenruo
Quoted 10 lines · Darrick J. Wong
Quoted 5 lines · Qu Wenruo

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.

Quoted 7 lines

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

Quoted 75 lines

Thanks,
Qu

Quoted 71 lines

#define EFSBADCRC EBADMSG

--D

Quoted 65 lines

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0
#8 lore raw
Quoted 20 lines · Darrick J. Wong
Quoted 19 lines · Qu Wenruo
Quoted 10 lines · Darrick J. Wong
Quoted 5 lines · Qu Wenruo

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.

Quoted 7 lines
Quoted 4 lines

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

Quoted 81 lines

--D

Quoted 75 lines

Thanks,
Qu

Quoted 71 lines

#define EFSBADCRC EBADMSG

--D

Quoted 65 lines

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0
#9 lore raw
Quoted 26 lines · Qu Wenruo
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · Qu Wenruo
Quoted 10 lines · Darrick J. Wong
Quoted 5 lines · Qu Wenruo

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.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

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

Quoted 85 lines

Thanks,
Qu

Quoted 81 lines

--D

Quoted 75 lines

Thanks,
Qu

Quoted 71 lines

#define EFSBADCRC EBADMSG

--D

Quoted 65 lines

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.

---
 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(-)
fs/ext2/ext2.h +0 -1
index 10ab238de9a6..03d0ca8fae42 100644
@@ -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
fs/ext4/ext4.h +0 -1
index 82ffdacdc7fa..f906b5cbf96d 100644
@@ -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 */
fs/xfs/xfs_linux.h +0 -1
index edbd5a210df2..36e5c6549f15 100644
@@ -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()
include/uapi/asm-generic/errno.h +3 -0
index cf9c51ac49f9..ebd6e7e76a98 100644
@@ -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 */
Signature · 1 line
2.21.0