Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2241333pxp; Mon, 21 Mar 2022 14:44:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD3n+Z6wxtJgvbnaVd56tQ5M8dNRxPgbJy9l2xbbeTZJfKUwbsPUFfEEhipH+oXhPv/ixT X-Received: by 2002:a17:902:8f94:b0:14f:d9b3:52c2 with SMTP id z20-20020a1709028f9400b0014fd9b352c2mr14751228plo.103.1647899082747; Mon, 21 Mar 2022 14:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647899082; cv=none; d=google.com; s=arc-20160816; b=TG/8zKRl48kH5PjJTi6TE7/1IHDv50Rzd+bOtGyHHwH0X3xSufsQnC9AYpQsu504Zs U4JmVjyPTyau68bzI5yvb1dygZzgf73p7DFY8xj/OcoxiMxyaW+HnjMyA5QgSLmSCSll lWkMMPeJsSUY1l79eNo4Ffekq1QQGBRMMK0Rv6mzggEAGG4kDGmQ/w87xQOHveskGhb5 3gDEFLfr/6ShjcWWL2v0rz+JXz2q0rrw12CFzNCOPMagyjicj7LnjA+9yLpOekJH17dK 6hJ/SVMsuwmgQ9i1pHBHrIKcDd6lbEzhv5vwf/JqxVggWwLoMhAbQ3m0nouHfr3xYm/7 Pa5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cCL1FlTegtkwOaOa57r/Jk86Yqs6V52GDwuQeNGCH9g=; b=dMK5I1mKHSVzh3ZBPtvXD+ypcFz2SAN8E9CP3VBMMGAtEuB6CbcRJ+JzCPCYs9VMab FS/ve3d/Gx+o8CXZnj/tuyRgRR0Cyle5xc1XUhJv/hsKGxBPbRIln6+cgEcwL3IRf41r dgeiWsnWl6Gg+vB41jWb3vyfRcdq4zOcRTWC+mFw0J++mrtM+cSPdpwFkICg9c79riKz RDFTepoL/lS2DMYpiJxh3WPherVCCgctTgbXabPaMJjJ0ImHxi9eHfHQiPkH2cj+6ZpH 3vnvFd/jSslG9HMg1k6sLqYlbxIBWbLoKmAKWC82cK0SPGnVghotdsSeAGpCKSxSfEkw s6Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l1-20020a170902ec0100b00153b2d164e1si11151070pld.233.2022.03.21.14.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 14:44:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8076F2AFA00; Mon, 21 Mar 2022 14:17:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349111AbiCUOeQ (ORCPT + 99 others); Mon, 21 Mar 2022 10:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349562AbiCUOct (ORCPT ); Mon, 21 Mar 2022 10:32:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1195D67C; Mon, 21 Mar 2022 07:29:38 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KMcQW1Kb8zCr5Z; Mon, 21 Mar 2022 22:27:31 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 21 Mar 2022 22:29:36 +0800 From: Ye Bin To: , , CC: , , , Ye Bin Subject: [PATCH -next v2] ext4: Fix symlink file size not match to file content Date: Mon, 21 Mar 2022 22:44:38 +0800 Message-ID: <20220321144438.201685-1-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 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 canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org We got issue as follows: [home]# fsck.ext4 -fn ram0yb e2fsck 1.45.6 (20-Mar-2020) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Symlink /p3/d14/d1a/l3d (inode #3494) is invalid. Clear? no Entry 'l3d' in /p3/d14/d1a (3383) has an incorrect filetype (was 7, should be 0). Fix? no As the symlink file size does not match the file content. If the writeback of the symlink data block failed, ext4_finish_bio() handles the end of IO. However this function fails to mark the buffer with BH_write_io_error and so when unmount does journal checkpoint it cannot detect the writeback error and will cleanup the journal. Thus we've lost the correct data in the journal area. To solve this issue, mark the buffer as BH_write_io_error in ext4_finish_bio(). Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/page-io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 495ce59fb4ad..14695e2b5042 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -134,8 +134,10 @@ static void ext4_finish_bio(struct bio *bio) continue; } clear_buffer_async_write(bh); - if (bio->bi_status) + if (bio->bi_status) { + set_buffer_write_io_error(bh); buffer_io_error(bh); + } } while ((bh = bh->b_this_page) != head); spin_unlock_irqrestore(&head->b_uptodate_lock, flags); if (!under_io) { -- 2.31.1