From patchwork Thu May 18 11:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13246636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A62B0C7EE22 for ; Thu, 18 May 2023 11:48:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F91D900003; Thu, 18 May 2023 07:48:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A819280001; Thu, 18 May 2023 07:48:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27020900006; Thu, 18 May 2023 07:48:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1A160900003 for ; Thu, 18 May 2023 07:48:11 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CA2C71A07B8 for ; Thu, 18 May 2023 11:48:10 +0000 (UTC) X-FDA: 80803202340.25.4BC58D3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 086B1C0009 for ; Thu, 18 May 2023 11:48:08 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bzkIxbhD; spf=pass (imf22.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684410489; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7p7H57m5EvrexIaZAfkDWNQhr9XBbFKJmNws5e2gM/o=; b=ckUy2IyVzFJAqVWBxeGImsAhZbNv9TFBhmbntvam+Y0pnIqPYhLWrrsdCNubMdOXO9sczj QBelsPwD5QlHu3D8/fhmHmYw0q5EjPaknQgWf0SUegOy1OD+L1O0c5PihCSYmvrreMh6cS l5OndRJGJXaJC6ssNaqcyfvUGvirB30= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684410489; a=rsa-sha256; cv=none; b=lnqHfV7CJfZka9wC5dF0zFVKbKHfjcIUCMtBYe5eI0KGFKUdgEbfSj2Ead+FzjQPZ6LoRf GKRWmb8jlDjfWN8YAHuGoTjIYv5xBrNgNskmJBA8/kWZ4gYouu84ceq7i8ZGN3g7OmS7A+ THD3/nTtiw2/QTI7Yf/ggz0kA9R/3ME= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bzkIxbhD; spf=pass (imf22.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org 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 dfw.source.kernel.org (Postfix) with ESMTPS id 391EF60C28; Thu, 18 May 2023 11:48:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48507C433A8; Thu, 18 May 2023 11:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684410487; bh=kquwxLu1RihR3+XLA7F476KPp9MVAZdnWUNISapvPR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bzkIxbhDHURav3gjTbQ2xFZrLyGJSG3Hn9dS+SsLaBnRDDKBLvLERckzR526obwYW lvXvMK+Y2sH7weoCTR0SukIJ2OvUY3CI0eOdclclvgDj72X+zOY63Q1hrRGfWK2LP8 /t1DNOWaVGkaw36xyXe+sbetbfybu6C0m9TJvGHp6CBQLRrPHNGG5JM3sOp6DvxWZy SYax8PXtJ+sObAy4nFE0sXQrPOF84NN6/5SMCv89EUxLnC0OPfj6a4X8OnPVNcGta2 76mu7+on+K28VJdnqfF/QI1nAzBiR/LWfq6xVgGEb9QEPjDQdB18JUg5KlahtUxFP4 RDVUQQzgybvTw== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: Jan Kara , Amir Goldstein , David Howells , Neil Brown , Matthew Wilcox , Andreas Dilger , Theodore T'so , Chris Mason , Josef Bacik , David Sterba , Namjae Jeon , Steve French , Sergey Senozhatsky , Tom Talpey , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org Subject: [PATCH v4 8/9] ext4: convert to multigrain timestamps Date: Thu, 18 May 2023 07:47:41 -0400 Message-Id: <20230518114742.128950-9-jlayton@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518114742.128950-1-jlayton@kernel.org> References: <20230518114742.128950-1-jlayton@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 086B1C0009 X-Stat-Signature: pj9xr4saa83ncraisqqcmco79znz8wzg X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1684410488-42638 X-HE-Meta: U2FsdGVkX181MeLGpos6IEo66Cq224pgAjZ0144bPXkaLM4KrbLqJ66IWzdja8Zq3D0+ZCWcJuANCwJlFvup1Pdj7HsPMIkAELW+t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T9Zv4/wYjbkdUeujgdEcNGnqmMqVWp2g1rL2Dro2vH1wAvdXbBVYZAi39+EiENpC4KDCEqSHDHPfIj+KOlmdR9jjxoJhW1ueQzMj1nOJBEUD4AmPdVBcCBLH9hmS8WVt50+FVU8pSF85fJih/OtK48p8SKTwhxUtwvnieeg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Signed-off-by: Jeff Layton Acked-by: Theodore Ts'o --- fs/ext4/inode.c | 17 +++++++++++++++-- fs/ext4/super.c | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e0bbcf7a07b5..37840aeb7ff9 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4235,6 +4235,19 @@ static int ext4_inode_blocks_set(struct ext4_inode *raw_inode, return 0; } +static void ext4_inode_set_ctime(struct inode *inode, struct ext4_inode *raw_inode) +{ + struct timespec64 ctime = ctime_peek(inode); + + if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra)) { + raw_inode->i_ctime = cpu_to_le32(ctime.tv_sec); + raw_inode->i_ctime_extra = ext4_encode_extra_time(&ctime); + } else { + raw_inode->i_ctime = cpu_to_le32(clamp_t(int32_t, + ctime.tv_sec, S32_MIN, S32_MAX)); + } +} + static int ext4_fill_raw_inode(struct inode *inode, struct ext4_inode *raw_inode) { struct ext4_inode_info *ei = EXT4_I(inode); @@ -4275,7 +4288,7 @@ static int ext4_fill_raw_inode(struct inode *inode, struct ext4_inode *raw_inode } raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); - EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode); + ext4_inode_set_ctime(inode, raw_inode); EXT4_INODE_SET_XTIME(i_mtime, inode, raw_inode); EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode); EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode); @@ -4983,7 +4996,7 @@ static void __ext4_update_other_inode_time(struct super_block *sb, spin_unlock(&inode->i_lock); spin_lock(&ei->i_raw_lock); - EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode); + ext4_inode_set_ctime(inode, raw_inode); EXT4_INODE_SET_XTIME(i_mtime, inode, raw_inode); EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode); ext4_inode_csum_set(inode, raw_inode, ei); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9680fe753e59..4de4977dcb21 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -7258,7 +7258,7 @@ static struct file_system_type ext4_fs_type = { .init_fs_context = ext4_init_fs_context, .parameters = ext4_param_specs, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MULTIGRAIN_TS, }; MODULE_ALIAS_FS("ext4");