Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11E38C761AF for ; Thu, 30 Mar 2023 06:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbjC3G5n (ORCPT ); Thu, 30 Mar 2023 02:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjC3G5m (ORCPT ); Thu, 30 Mar 2023 02:57:42 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C37C469A for ; Wed, 29 Mar 2023 23:57:37 -0700 (PDT) Received: from dggpeml500016.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PnDfZ5Y17zSqZM; Thu, 30 Mar 2023 14:53:58 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggpeml500016.china.huawei.com (7.185.36.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 30 Mar 2023 14:57:35 +0800 From: zhanchengbin To: , CC: , , , , zhanchengbin Subject: [PATCH v2 2/2] e2fsck: add sync error handle to e2fsck. Date: Thu, 30 Mar 2023 14:56:56 +0800 Message-ID: <20230330065656.3275785-3-zhanchengbin1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230330065656.3275785-1-zhanchengbin1@huawei.com> References: <20230330065656.3275785-1-zhanchengbin1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500016.china.huawei.com (7.185.36.70) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If fsync fails during fsck, it is silent and users will not perceive it, so a function to handle fsync failure should be added to fsck. Signed-off-by: zhanchengbin --- e2fsck/ehandler.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c index 71ca301c..1d95a89d 100644 --- a/e2fsck/ehandler.c +++ b/e2fsck/ehandler.c @@ -118,6 +118,27 @@ static errcode_t e2fsck_handle_write_error(io_channel channel, return error; } +static errcode_t e2fsck_handle_sync_error(io_channel channel, + errcode_t error) +{ + ext2_filsys fs = (ext2_filsys) channel->app_data; + e2fsck_t ctx; + + ctx = (e2fsck_t) fs->priv_data; + if (ctx->flags & E2F_FLAG_EXITING) + return 0; + + if (operation) + printf(_("Error during fsync of dirty metadata while %s: %s "), + operation, error_message(error)); + else + printf(_("Error during fsync of dirty metadata: %s "), + error_message(error)); + preenhalt(ctx); + + return error; +} + const char *ehandler_operation(const char *op) { const char *ret = operation; @@ -130,4 +151,5 @@ void ehandler_init(io_channel channel) { channel->read_error = e2fsck_handle_read_error; channel->write_error = e2fsck_handle_write_error; + channel->sync_error = e2fsck_handle_sync_error; } -- 2.31.1