Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2087217rwb; Fri, 12 Aug 2022 11:46:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR6yd+Ezwnr4jKXvGc0WuPpwQ17MNRCfXU4MrkIKmg2BjXHLgbUqSk27f1KLA6agSWvsfrM+ X-Received: by 2002:a05:6402:27ca:b0:43e:ce64:ca07 with SMTP id c10-20020a05640227ca00b0043ece64ca07mr4849519ede.66.1660329979722; Fri, 12 Aug 2022 11:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660329979; cv=none; d=google.com; s=arc-20160816; b=koHv+D1PNXshxdVQXzlRCoH1CtIFXRfaDhiuAOVnlwtSMkUsYjxpQOXqIZPsLXfWeR Tzbgvw/UAHrKn0fODKt5hK46XWlc/1nPKPzM0adaCJRhTh8uXOF1BgFWtEsrFfpBIDf4 Q8Ag4pq5TCQPLtSNUdg0IZZGeaSK5i8xYkgwWDRqCGqd/IDA0hT8Re2q74AShSyx3z3c XqrFx/6bzG88m1fRfkAnCHYEAMuFGrYywByBvvjluFt+hxBywLEzozGEEMFujdX/KcGb lchuTJ7bYkVd8wpdGqnL+WwfBmkPBIJFNhbzomXiVeeRTUflZp7jpfC5eLafUoSC3k5o 7OVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wrWw8hfSyRF5CzvmPt8cW6LWL+EAnTk8/M0xzVTiLoA=; b=gt1J/tkrHUsZDXVBuF+JAqGkNc5eLPFUGJAqykSzk/KOmEO4pG/WROCp/SdaKKrQsK rmhDI1NY5uygrFqyndLJoAdE2bEIg9hZWguOsasxaqXPDssHs+KE1IkJLi5/Xi8DjRwC UU09htxtJtqQKrTiquMty0OVvcBPD2ffFRC8bZqm5w3Pv7b94pifXGN134xYtends4WH UGD0QgOHS19pPw948nu5rKZvASeMpuvAl8qAIdeqYbznTEO607CloP5S28GLn6ePxUxV y7J9UjVsSrpBsMX9mC2lXWdBzoWs4ZFVqpPGtUTS1Ni1wbeu+fNiOykOXUttuMzYhJMA Xv8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RdQQOP92; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a056402439500b0043d651cf5acsi3197464edc.99.2022.08.12.11.45.49; Fri, 12 Aug 2022 11:46:19 -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=@kernel.org header.s=k20201202 header.b=RdQQOP92; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236246AbiHLSm2 (ORCPT + 99 others); Fri, 12 Aug 2022 14:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbiHLSm1 (ORCPT ); Fri, 12 Aug 2022 14:42:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD31EAE9D1; Fri, 12 Aug 2022 11:42:26 -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 3063FB8233E; Fri, 12 Aug 2022 18:42:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D397C433C1; Fri, 12 Aug 2022 18:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660329743; bh=o3ElHzRdSZcCSXwS1Nf8yiNyuMgIgtGAtTgoix6Cnpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RdQQOP92JQJoO/K+b+Zrcm3aFdiaW1IMd8giHFNgFNhUVhqaMwV3K/gmSxAerry3F 2V9NKEJVxRIGm5ebIQ5/0Dw0gDJazJ2s8h1LsepnMTlegOtK3Bxdu4w81W/rdWgjQC bsIJbqEyzuxPR2eOskZqPY5AgsCXdaXiE+czFIfKU9+EMv1f0axyiQ2sH8ZYkywn9Y abbCNppx1ycWy+TRIn8T63UxvQuBeirNZZ+1UtEb/3ZXlkia8jLZa5asbfrUlMfM6d Q8F3OmWL6gPbyAYaoj4w97OkPA3kglx5eXfjFdE5YTZStvv13NHgBLZhznNrF6ESz5 kF8KsuqrjFQPg== Date: Fri, 12 Aug 2022 11:42:21 -0700 From: Eric Biggers To: Lukas Czerner Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, jlayton@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, david@fromorbit.com, Christoph Hellwig Subject: Re: [PATCH v3 2/3] fs: record I_DIRTY_TIME even if inode already has I_DIRTY_INODE Message-ID: References: <20220812123727.46397-1-lczerner@redhat.com> <20220812123727.46397-2-lczerner@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220812123727.46397-2-lczerner@redhat.com> 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,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org On Fri, Aug 12, 2022 at 02:37:26PM +0200, Lukas Czerner wrote: > Currently the I_DIRTY_TIME will never get set if the inode already has > I_DIRTY_INODE with assumption that it supersedes I_DIRTY_TIME. That's > true, however ext4 will only update the on-disk inode in > ->dirty_inode(), not on actual writeback. As a result if the inode > already has I_DIRTY_INODE state by the time we get to > __mark_inode_dirty() only with I_DIRTY_TIME, the time was already filled > into on-disk inode and will not get updated until the next I_DIRTY_INODE > update, which might never come if we crash or get a power failure. > > The problem can be reproduced on ext4 by running xfstest generic/622 > with -o iversion mount option. > > Fix it by allowing I_DIRTY_TIME to be set even if the inode already has > I_DIRTY_INODE. Also make sure that the case is properly handled in > writeback_single_inode() as well. Additionally changes in > xfs_fs_dirty_inode() was made to accommodate for I_DIRTY_TIME in flag. > > Thanks Jan Kara for suggestions on how to make this work properly. > > Cc: Dave Chinner > Cc: Christoph Hellwig > Signed-off-by: Lukas Czerner > Suggested-by: Jan Kara Sorry for so many separate emails. One more thought: isn't there a much more straightforward fix to this bug that wouldn't require changing the semantics of the inode flags: on __mark_inode_dirty(I_DIRTY_TIME), if the inode already has i_state & I_DIRTY_INODE, just call ->dirty_inode with i_state & I_DIRTY_INODE? That would fix the bug by making the filesystem update the on-disk inode. Perhaps you aren't doing that in order to strictly maintain the semantics of 'lazytime', where timestamp updates are only persisted at certain times? Is this useful even in the short window of time that an inode is dirty? - Eric