Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2297342pxp; Mon, 21 Mar 2022 16:12:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYpdbRbVZig9t0aE0FCkqwFwtrpCGcilKNWG03798temC1Pz/YQp5k+0C4zRYa8BmRgtpF X-Received: by 2002:a17:902:70cc:b0:154:1cc8:9df8 with SMTP id l12-20020a17090270cc00b001541cc89df8mr15430081plt.32.1647904343503; Mon, 21 Mar 2022 16:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647904343; cv=none; d=google.com; s=arc-20160816; b=kjY0SBbelDSlxnQqFP0HSV0zAmdZDZiOqp33fzrHulwG5+faqHlTun16yzBhi17LiI TPmh92/Odu+LdljOYqal1OM85Z48L3MXcHSf177foIXCTxFTtM37s+zE0yP4EcQ1q2Mp +H2It7G8TBZsFOkJ7e9w4bR3RPnyregk8F8Q/0rYMdtsZSr6440zEX7zOOVZG+RRnkmL SGLPiGrWIfIJW1wZzsadEbrmT73/I7xdRTsCcvV15HH6nJfDjy2gUVJDYJYkCAH0sOC3 jlrqAV9MftAR6nGfxH+oLPeQ2eNUggr/jM0OpnjG4yx+KvIfc4wOB+YfOgEicA2uqE7n QG6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=0Y7cvZdjxSBUFal+lboGUBcHq3LvFZvO6ScQ5UYNRHY=; b=Ap3SU7g1E8x+PYGwoiuylqqzPgCsFkNyngm65wx29rOkoIpK9RX2hUyKR9ucXc8A/N s3jNjl6y6dcL+3XML79k5nOrdo3E1ZYczF5qxoyT2LBedVH+1OZYmpZMmPxHJR/0CeZI PwHUHAdRcK+W8Z9ZzAocvq59IW/0cfWTTjivi6rSi+QDn3mKjANv5D9+qWWvJdabii/J ng6cIIWosimai2+2OlADQwblswf3pJh/Cxg8BXLGEYqvLD/6mlJJ9fUd8kANTupcE7Rh CMoiSTCOlY/vHtI8J5O8Otp5iZ2aHVM7C2Y1AR3/dWfoY8SegLMwTw9w72WiChf8umSK YoOw== 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 q13-20020a170902b10d00b00153b691f326si11552129plr.364.2022.03.21.16.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:12:23 -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 937F04384B6; Mon, 21 Mar 2022 15:10:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348000AbiCUNgw (ORCPT + 99 others); Mon, 21 Mar 2022 09:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235400AbiCUNgb (ORCPT ); Mon, 21 Mar 2022 09:36:31 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2294474B; Mon, 21 Mar 2022 06:35:05 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KMbDB4F2FzfZMc; Mon, 21 Mar 2022 21:33:30 +0800 (CST) Received: from [10.174.178.185] (10.174.178.185) 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 21:35:02 +0800 Subject: Re: [PATCH -next] ext4: Fix symlink file size not match to file content To: Jan Kara References: <20220321113408.4112428-1-yebin10@huawei.com> <20220321113703.cibgeac5ipslg3df@quack3.lan> CC: , , , , From: yebin Message-ID: <62387F05.2090408@huawei.com> Date: Mon, 21 Mar 2022 21:35:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20220321113703.cibgeac5ipslg3df@quack3.lan> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.185] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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,NICE_REPLY_A, 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 On 2022/3/21 19:37, Jan Kara wrote: > On Mon 21-03-22 19:34:08, Ye Bin wrote: >> 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 symlink file size not match to file content. If symlink data block >> writback failed, will call ext4_finish_bio to end io. In this path don't >> mark buffer error. When umount do checkpoint can't detect buffer error, >> then will cleanup jounral. Actually, correct data maybe in journal area. >> To solve this issue, mark buffer error when detect bio error in >> ext4_finish_bio. > Thanks for the patch! Let me rephrase the text a bit: > > 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 >> --- >> 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); > Why don't you use mark_buffer_write_io_error()? It will also update other IO > error counters properly so that e.g. fsync(2) or sync_filesystem() can properly > report IO error etc. Granted we'll abort the journal in response to > checkpointing error so the failure will be hard to miss anyway but still > :). > > Honza 'ext4_finish_bio' already call 'mapping_set_error' set mapping error , I think fsync and sync_filesystem can report IO error. static inline void mapping_set_error(struct address_space *mapping, int error) { if (likely(!error)) return; /* Record in wb_err for checkers using errseq_t based tracking */ __filemap_set_wb_err(mapping, error); /* Record it in superblock */ if (mapping->host) errseq_set(&mapping->host->i_sb->s_wb_err, error); /* Record it in flags for now, for legacy callers */ if (error == -ENOSPC) set_bit(AS_ENOSPC, &mapping->flags); else set_bit(AS_EIO, &mapping->flags); }