From patchwork Wed Apr 10 08:35:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10893475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1449139A for ; Wed, 10 Apr 2019 08:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D32D2286BE for ; Wed, 10 Apr 2019 08:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C798A28A15; Wed, 10 Apr 2019 08:35:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C499286BE for ; Wed, 10 Apr 2019 08:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729544AbfDJIfO (ORCPT ); Wed, 10 Apr 2019 04:35:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:54008 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726630AbfDJIfO (ORCPT ); Wed, 10 Apr 2019 04:35:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18CF7AE64; Wed, 10 Apr 2019 08:35:13 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH RFC 1/2] errno.h: Export EFSCORRUPTED error number Date: Wed, 10 Apr 2019 16:35:07 +0800 Message-Id: <20190410083508.21091-1-wqu@suse.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 so all filesystems and block layer can take advantage of this easier-to-read error number. Signed-off-by: Qu Wenruo --- 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 */ From patchwork Wed Apr 10 08:35:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10893481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 691851708 for ; Wed, 10 Apr 2019 08:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BCF828A15 for ; Wed, 10 Apr 2019 08:35:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5099B28A20; Wed, 10 Apr 2019 08:35:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE3EB28A1B for ; Wed, 10 Apr 2019 08:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729614AbfDJIfS (ORCPT ); Wed, 10 Apr 2019 04:35:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:54024 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726630AbfDJIfR (ORCPT ); Wed, 10 Apr 2019 04:35:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A9B74AE64; Wed, 10 Apr 2019 08:35:15 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] block: Add new BLK_STS_FSCORRUPTED status Date: Wed, 10 Apr 2019 16:35:08 +0800 Message-Id: <20190410083508.21091-2-wqu@suse.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190410083508.21091-1-wqu@suse.com> References: <20190410083508.21091-1-wqu@suse.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Qu Wenruo --- block/blk-core.c | 1 + include/linux/blk_types.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index a55389ba8779..ba7acfc3d8e0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -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" }, diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 791fee35df88..8f70bbec6c83 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -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