From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BDEEC433E0 for ; Sat, 9 Jan 2021 08:00:06 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3397C23A9C; Sat, 9 Jan 2021 08:00:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3397C23A9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1ky9AL-0002Hn-QY; Sat, 09 Jan 2021 08:00:05 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ky9AK-0002HV-4b for linux-f2fs-devel@lists.sourceforge.net; Sat, 09 Jan 2021 08:00:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lqtMUSMHjA+QOZ916Gt3rDOwy86ZDbjkYjpTDTpGArE=; b=Txi3W17dBFJF74ApHD9nSLcb45 3hd+pwAqROL/D3Zwrpo3L1WqB3MOAylXqb0sWujLTxt1L4WnESYJ118ZnweRwy5LzT3JboxctZ9/r 08ieIZ2TeYgbOppo4tpoXOs8CZ8azpPE0M1iePAclD5XMJ0fDVbpdGgjJUXoUJbm3wJI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lqtMUSMHjA+QOZ916Gt3rDOwy86ZDbjkYjpTDTpGArE=; b=JjOq+oLe2Qz3CYbb25sedR/RLZ 5Xys2XX14mbRf6r1GqTyyWcZZY0qgXvTuzoPaCMrvYD6cMnSVs+mJb+GxY0oDMdXTgf22rDcgNDhR B3hpZw1gwAtukykK6JGfP4FcTGJpqJXUoEjS6cW8uB6nq5rSVhmP3EL7Doj7q6x9RnwY=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1ky9AA-00Dmpn-MW for linux-f2fs-devel@lists.sourceforge.net; Sat, 09 Jan 2021 08:00:04 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A956023A60; Sat, 9 Jan 2021 07:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610179184; bh=UAs5pZYbnHEbB32I8gYpVHYl5ps5DskVBX1/zJ7HEQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoT+M+0x7oiHSACHnRZzbGNiIWW5upkwVfH5++ixOztpM5YOvybegB3g8nXEEicEj hl9mqWdNzhULeIjdHYsBv+IIOy70YPKx+OnBYbIlw3VzIfSrtA9C5muhIc968rY8KL psdI6/oG5oFnHsmSOi3lhhQEnSxSHHuKFZ2BFmrDsb/dQN8dkJXZjy2zvQwHBiyFzs j8DRYBIyioPgHaWnWsWd5nzp8XorZgiGmYdvIabwlvn12r8nXbaYTj/qwxn2S2Hpgd PSWWYIA2IDr1UMOe5W3Z1b80Sp9fXxraUFqynwAjlDyfYatd1Rdx8WS8DbSy+rjXRV jReLDxw0TkFXw== From: Eric Biggers To: linux-fsdevel@vger.kernel.org Date: Fri, 8 Jan 2021 23:58:54 -0800 Message-Id: <20210109075903.208222-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210109075903.208222-1-ebiggers@kernel.org> References: <20210109075903.208222-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ky9AA-00Dmpn-MW Subject: [f2fs-dev] [PATCH v2 03/12] fs: only specify I_DIRTY_TIME when needed in generic_update_time() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, Theodore Ts'o , Christoph Hellwig , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Eric Biggers generic_update_time() always passes I_DIRTY_TIME to __mark_inode_dirty(), which doesn't really make sense because (a) generic_update_time() might be asked to do only an i_version update, not also a timestamps update; and (b) I_DIRTY_TIME is only supposed to be set in i_state if the filesystem has lazytime enabled, so using it unconditionally in generic_update_time() is inconsistent. As a result there is a weird edge case where if only an i_version update was requested (not also a timestamps update) but it is no longer needed (i.e. inode_maybe_inc_iversion() returns false), then I_DIRTY_TIME will be set in i_state even if the filesystem isn't mounted with lazytime. Fix this by only passing I_DIRTY_TIME to __mark_inode_dirty() if the timestamps were updated and the filesystem has lazytime enabled. Reviewed-by: Christoph Hellwig Signed-off-by: Eric Biggers --- fs/inode.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 6442d97d9a4ab..d0fa43d8e9d5c 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1743,24 +1743,26 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, int generic_update_time(struct inode *inode, struct timespec64 *time, int flags) { - int iflags = I_DIRTY_TIME; - bool dirty = false; - - if (flags & S_ATIME) - inode->i_atime = *time; - if (flags & S_VERSION) - dirty = inode_maybe_inc_iversion(inode, false); - if (flags & S_CTIME) - inode->i_ctime = *time; - if (flags & S_MTIME) - inode->i_mtime = *time; - if ((flags & (S_ATIME | S_CTIME | S_MTIME)) && - !(inode->i_sb->s_flags & SB_LAZYTIME)) - dirty = true; - - if (dirty) - iflags |= I_DIRTY_SYNC; - __mark_inode_dirty(inode, iflags); + int dirty_flags = 0; + + if (flags & (S_ATIME | S_CTIME | S_MTIME)) { + if (flags & S_ATIME) + inode->i_atime = *time; + if (flags & S_CTIME) + inode->i_ctime = *time; + if (flags & S_MTIME) + inode->i_mtime = *time; + + if (inode->i_sb->s_flags & SB_LAZYTIME) + dirty_flags |= I_DIRTY_TIME; + else + dirty_flags |= I_DIRTY_SYNC; + } + + if ((flags & S_VERSION) && inode_maybe_inc_iversion(inode, false)) + dirty_flags |= I_DIRTY_SYNC; + + __mark_inode_dirty(inode, dirty_flags); return 0; } EXPORT_SYMBOL(generic_update_time); -- 2.30.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel