Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3981684ioa; Tue, 26 Apr 2022 14:02:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrM6aWycLmvshY0S6E6x52cqaQUlcHk00/W55hxWxB8hS553Aq4VOX8ijZvhDG59aoZfPB X-Received: by 2002:a17:907:7e96:b0:6f3:7cb4:ac4e with SMTP id qb22-20020a1709077e9600b006f37cb4ac4emr16383271ejc.159.1651006921322; Tue, 26 Apr 2022 14:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651006921; cv=none; d=google.com; s=arc-20160816; b=wTH1gs7F8rrUt6bFMnpa6wv3WoR4uiE/60B9JGH3FHcS+i3j+IJ8m85elejUFXyKkh gD7/kILvpxFiipjeC/3uZK5LxWSyXU5VpedD9BWMVW5wrQPuLvp1q8al3WogqXCXtMLS UhgbUvTo8JlR/Gmyg+Ya52cySkRMk0Maf+p0yQTLgzdXfB3bH2glNhkeQrhzV+w2Xibk Sl0yExRFKmsPwZA87Z2XDJE1cfqeVUrSB4N+o0mHQm0RJbgh5V7fak5YxN/hdHYvzIyO i6H4HZSVRKUSZvObwJUh6auDmE4rgB4xo9h4MzK9tf9vRBMBui5wFh2KuIhCke0WwOe0 jjpw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ubcudZpDeqwZibFGeky2iiMKZkGb2d3U/DfC4z0F6PA=; b=pCEcv9u6s0VLjtzNbeWC8SoT0ps7aw0xFYIy5bnDxPqB0hRrxm8N1Gtk3jdLg7ZldZ TjfIbKa5ur6tXw0ll9Zz5GrqDew3UPg9ntE0znx+Pd5MM7fTt1HTeU/cBQXCmnMO0gf6 YR8PXQX7UYmSsFCHWPrXGSHuLu7+P9Nd6aNrfSfKwwK/ncbojZHJv5NVzSJkET5EKLXu SIO8DwB7nHESyj2MWkSbw/GC8+h/6DFeeW4mG7BLKwSvU4uD1N0CpRkoPotl3h69Yd3q z1fZPFAxI+lPvnNmriHHfaUvnQ6dHdlEKm/LxQaU2dCEEzI+FWnyjJq6w09QU3z3EijM 9JUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xo+38FwC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a1709060d9200b006f38a65b1c2si6506754eji.848.2022.04.26.14.01.35; Tue, 26 Apr 2022 14:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xo+38FwC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346178AbiDZIyU (ORCPT + 99 others); Tue, 26 Apr 2022 04:54:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345816AbiDZIje (ORCPT ); Tue, 26 Apr 2022 04:39:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC99E78FF7; Tue, 26 Apr 2022 01:31:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A4E58B81CF3; Tue, 26 Apr 2022 08:31:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAE36C385A0; Tue, 26 Apr 2022 08:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961903; bh=+7W/z/NXq+al8Bfg6I1o93fhJ8rD0L8br9mElJvBpog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xo+38FwCX+Jz9v8TL8/R/qMLZqBVkyAFhrklOMx1hnRpYS2N5d0zmoo7KksnEs8Qk ayzFeO1hPLrS48da+UFP9kLVSO/ItpYE82EKQqQQGSoN6VMr9ZrTpX63wFXA+vu7wc h3cvUkQ+48NXwDL8x1QEwo6Lv3Dcrf16vfW3Ku3k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Ye Bin , Jan Kara , Theodore Tso Subject: [PATCH 5.4 52/62] ext4: fix symlink file size not match to file content Date: Tue, 26 Apr 2022 10:21:32 +0200 Message-Id: <20220426081738.713722480@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081737.209637816@linuxfoundation.org> References: <20220426081737.209637816@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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-kernel@vger.kernel.org From: Ye Bin commit a2b0b205d125f27cddfb4f7280e39affdaf46686 upstream. 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(). Cc: stable@kernel.org Signed-off-by: Ye Bin Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20220321144438.201685-1-yebin10@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/page-io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -100,8 +100,10 @@ static void ext4_finish_bio(struct 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); bit_spin_unlock(BH_Uptodate_Lock, &head->b_state); local_irq_restore(flags);