Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp54968rwl; Tue, 28 Mar 2023 20:47:48 -0700 (PDT) X-Google-Smtp-Source: AKy350aFDoiWxKt+tBv3Bh9p21vvpv04lHhf8pFv0lhkoXc3xFZhWfCi0PEF6j/j0Guz8fEJlalx X-Received: by 2002:a17:906:6851:b0:930:7324:2766 with SMTP id a17-20020a170906685100b0093073242766mr687643ejs.35.1680061668173; Tue, 28 Mar 2023 20:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680061668; cv=none; d=google.com; s=arc-20160816; b=Szl1Oc+S5FtMBu6XA7mIviZq7Jckgoo53m7G780jxqo1w+QItC+JCS9K42HcEFcKlz Sc4oX/D0z42xtbISEI2L77e3vuX334b866Ws9NXUYmh61QivBNOXCHx3z4YkNmQ+/F+1 CSldo9T8KneX8DsDkdup9eJIo7lNZuG0+88ZyESzo8vpN8hNEdwloj46r4CNpkJyP9Yg 8MJc0Rfn/kxnQ0gKxilfvOvnwRYLGv6qFRBoREtCvmBqB+A6Tx4qon11HymZ1slmqiSb lxZipT2vFnuHjySr2lKLcLJch/EQ9uKdc9yT2lf/shFsF34Y9zh2CSB3gIE3fhvn3gnY +spw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tKPA/fEp6Y8GE/rfc/c4zMqFp4+yZmBO+tg+7Y+LKB8=; b=vWv5Iz5mPqOoVAMbw1b5b7w7tFQFE7EHHgyoIDDMk+TzRGrvUE+4AYtnKe5SndyCpS 9ctXfXEDzMUNMC53wU0DuIKX1l5FRyqrWFFAHQOE42Ud9YrkZX4Dabsei8qarpH6x5yG WUHXOqNHF9p5g8507XERhBxGJ6vmmgQjMXFzRYU3CXjh2jkZ6dTIn8c/cQnE0pHCW331 8kTJBaIIh1yQ4rvxN8atYyb31EY1nNgR5azPwurU3CKPSv2E+9bFMSGAGNax2iML+cUO ngqj9lPMaBs2FPZLCiDSoS7i+8Q+nA2kSzetvFP4I94ST6napRMT4ilOu9m5DIqrai/J pSIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lskYP87V; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv19-20020a170906f11300b009282419de75si26678743ejb.86.2023.03.28.20.47.20; Tue, 28 Mar 2023 20:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@gmail.com header.s=20210112 header.b=lskYP87V; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjC2DhG (ORCPT + 99 others); Tue, 28 Mar 2023 23:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbjC2DhC (ORCPT ); Tue, 28 Mar 2023 23:37:02 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FC4C35AD for ; Tue, 28 Mar 2023 20:36:59 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id e18so14211193wra.9 for ; Tue, 28 Mar 2023 20:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680061017; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tKPA/fEp6Y8GE/rfc/c4zMqFp4+yZmBO+tg+7Y+LKB8=; b=lskYP87VnQMRxzjh5kLVoPj2E2LbdMp0gcoZC8kpa51niCTQzJH/rvPohG4T51LvH+ 1ogSxPR3h0wTdZwZO/VfBsS9WooONeskTN242P95JWwJxK06ETrMo9l/u5ZAKMITN5ZM hjxYE2JsGcJTia1XGk2bXBnZApLo2C+2lo8vxyr/aLWWvEL7ACqhr8qwjTXxJVyqW8WO 1HC0RLfr+fllYveWsj08WGMYFi6yKuQXjGX6sl9QRYatjOAhkYvxogNbL+iMyxeo7p8X bfVvhO3qGe8nT8u8XVrCfWpB92PhoeFrDHsDGSd/NJiEXesXEC9hsEpDpAWl74++Dl1d yGmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680061017; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tKPA/fEp6Y8GE/rfc/c4zMqFp4+yZmBO+tg+7Y+LKB8=; b=G+9xfNtBEaoBbWT8tzdw4bMbcqLxROmd89xpwduWFL/wYN+5v0P3wF2ygwBZU1NtlR EdpwRnWZiW6uTNd/sD2raFqmkB6x+cZAev3l/T2kwhhLOg4B+t40lI0XrKP/cH9EUK6X fCA4SMd26nLhh3RFvQU6KH32Cz/7mZ/1QrXhd9/cCfAKAvPIXsrWzpvlGndHhYSoE12I pcIgRtpkklAIF85BV7oCaXklC+gPlcDmRU+wSG3kSsYiFdhI8hAegoIhn/zh/f7r1h9o th66ruFaPC3hfWg/JDNxFuUUgO765v5JomFxfs0i9r/1zM+U6y5JkTgZ6kiAWmYzuOmo nNzw== X-Gm-Message-State: AAQBX9eTFWPeuYfDF0dhz7dJ0gl0HlSiOw95eSYtiy3vteA2oqkSfcgz M8S1sQjmXRP7+zDlzpXpYH/EBTGVogQACsxqfeo= X-Received: by 2002:adf:e4d1:0:b0:2cf:e995:afef with SMTP id v17-20020adfe4d1000000b002cfe995afefmr3598450wrm.13.1680061017438; Tue, 28 Mar 2023 20:36:57 -0700 (PDT) MIME-Version: 1.0 References: <20230324092907.1341457-1-cccheng@synology.com> <20230327092914.mzizhh52izbvjhhv@quack3> <08c67287-53d8-58ce-e4bb-b1656bc6013e@huawei.com> In-Reply-To: <08c67287-53d8-58ce-e4bb-b1656bc6013e@huawei.com> From: Chung-Chiang Cheng Date: Wed, 29 Mar 2023 11:36:46 +0800 Message-ID: Subject: Re: [PATCH] ext4: defer updating i_disksize until endio To: Zhang Yi , Jan Kara Cc: Chung-Chiang Cheng , linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, kernel@cccheng.net, Robbie Ko Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Mon, Mar 27, 2023 at 7:17=E2=80=AFPM Zhang Yi wrot= e: > > On 2023/3/27 18:28, Chung-Chiang Cheng wrote: > > It's a pity that this issue also occurs with data=3Dordered due to dela= yed > > allocation being enabled by default. If delayed allocation were disable= d, > > it would not be as easy to reproduce. > > > > This is because if data is written to the end of a file and the block i= s > > allocated, the new i_disksize will be immediately committed to the jour= nal > > at ext4_da_write_end(), but the writeback procedure is not yet triggere= d. > > By default, ext4 commits the journal every 5 seconds, but a dirty page = may > > not be written back until 30 seconds later. This is not a short time wi= ndow, > > and any improper shutdown during this time may lead to the issue :( > > Thank you for the explanation from you and Jan. I agree that it is not the responsibility of ext4 to provide application consistency, but this case is not even crash consistent, although no sensitive data were revealed after crash. > It seems that the case you've mentioned is intra-block append write (no?)= , > current data=3Dordered mount option doesn't work in this case because > ext4_map_blocks() doesn't attach inode to the t_inode_list of the running > transaction. If delayed allocation were disabled, the lose data window is= still > there, because ext4_write_end()->ext4_update_inode_size() is also updatin= g > i_disksize before writing data back. This is at least guarantee no store = data. > We had discussed this in [1]. Yes, you're right. I've reconfirmed my experiment and determined that this issue can be reproduced with or without delayed allocation. I've tried your previous solution of adding the required inode to the curre= nt transaction's ordered data list. It seems to work perfectly for me and simp= ly solves the issue, but the journal handling needs to be added back to the delayed allocation write. Does it really have an obvious performance impact= ? > > [1]. https://lore.kernel.org/linux-ext4/1554370192-113254-1-git-send-emai= l-yi.zhang@huawei.com/ > > Thanks, > Yi.