From patchwork Tue Apr 11 14:37:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13207694 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 EFB94C77B70 for ; Tue, 11 Apr 2023 14:37:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D06628000A; Tue, 11 Apr 2023 10:37:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88041280001; Tue, 11 Apr 2023 10:37:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 748BC28000A; Tue, 11 Apr 2023 10:37:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 65B0F280001 for ; Tue, 11 Apr 2023 10:37:11 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 412E8160DE0 for ; Tue, 11 Apr 2023 14:37:11 +0000 (UTC) X-FDA: 80669362662.05.991FA1E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 86336140019 for ; Tue, 11 Apr 2023 14:37:09 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lntjKiiq; spf=pass (imf26.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=1681223829; 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=cmsV/BNDrmF6zQdi+rsdgHY9rce/ydYxUGcPmL06UuA=; b=k4/qpr+3m58vfdGguNY8f4uuO0Rv47dpjuOmfnVXzXQOLP4YmmXq3YkOh+co3+xqFivqaO VPPOlVAF38h1I5lqVRLN0a90d8fY73wMbac33Ru1qlPBUi9+Weg11cjHk6gKLhLxc79K2+ PwIV5i9vmVI5rTepF1ZAa1+nXn8a7UE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lntjKiiq; spf=pass (imf26.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681223829; a=rsa-sha256; cv=none; b=m/AYnJ+CfQ41sxLUI2ROQ72gnqQpnl7IpnYaRA/4eCfh621ONyKYJEZ74xO10OYpDVHYpS YnfYOfmZHptc3bidw9qE4/D5wp7GNhmMSgvjTpRyI+D9FFxsOaymUCXtENCLI8Op5naqve cnPbI+7KoHLNgfP+Y4AHdLrDmhRGB+s= 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 C150E627D3; Tue, 11 Apr 2023 14:37:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11462C433D2; Tue, 11 Apr 2023 14:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681223828; bh=0tABut1wgcVqOORC6SjkhEn9chzMnRxYPBvizenz41c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lntjKiiqZL6UbCt/BYubnJScSkK71phIse7M0U/lbZ0038OMjKxYZ86HeesTUNRiW 6on5MlC3P7XAYgkRSTqi+5y4jfRKmMERr9fmB5rmT2g2nxB1OyYiqsFg07Fbjp7SaJ pxLUkZoPVRLV3lesysLW9ycHuy2mc0iJ2vqpsCcvIgg6TVIJcEW9FYcPzyLsIz4Q0c t18Z5idZUpbhweCcB5aHNZP3jJl4/NXMWsMrQI7f2lvwoKivfceipbq+9TywahTo+i mqrgqNEYWK1vf+bEmSZSLnC3n2tgkSZpsbghL49bnexSbyv0nAYLmKmEwJYMUkmnew 3esCI9rV5pXUw== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Subject: [RFC PATCH 2/3][RESEND] shmem: mark for high-res timestamps on next update after getattr Date: Tue, 11 Apr 2023 10:37:01 -0400 Message-Id: <20230411143702.64495-3-jlayton@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411143702.64495-1-jlayton@kernel.org> References: <20230411143702.64495-1-jlayton@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 86336140019 X-Rspam-User: X-Stat-Signature: wtt1oih34czffmea1kuceo7ihdtxedko X-HE-Tag: 1681223829-173648 X-HE-Meta: U2FsdGVkX1//i4Un1zEhxdPWL30icEEhC4G2pmq6sMeU+GEKzAfUvzmxgbHM0KmdeKu2pdLmJVLbrSd2ALie6ZNmod/MK9MKXn7SVCpXybXN5xuVX+Z6+G/aax60u/TkqsfOp7FJX+IzHB7ctKviY62GxfJ/42X50Pw9IRBsaRDL9NmzEkJ1f12vsbC3CNuA0+F9vd1pIHvZAJwhzBBpLZGO0831iS8YiKEtMzpkY8Dy3V+Mnays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2BeuggZyIcqtP4c3kad9RDc8= 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: When the mtime or ctime is being queried via getattr, ensure that we mark the inode for a high-res timestamp update on the next pass. Also, switch to current_cmtime for other c/mtime updates. Signed-off-by: Jeff Layton --- mm/shmem.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 448f393d8ab2..75dd09492c36 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1039,7 +1039,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) { shmem_undo_range(inode, lstart, lend, false); - inode->i_ctime = inode->i_mtime = current_time(inode); + inode->i_ctime = inode->i_mtime = current_cmtime(inode); inode_inc_iversion(inode); } EXPORT_SYMBOL_GPL(shmem_truncate_range); @@ -1065,7 +1065,10 @@ static int shmem_getattr(struct mnt_idmap *idmap, stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_IMMUTABLE | STATX_ATTR_NODUMP); + generic_fillattr(idmap, inode, stat); + if (request_mask & (STATX_CTIME|STATX_MTIME)) + fill_cmtime_and_mark(inode, stat); if (shmem_is_huge(inode, 0, false, NULL, 0)) stat->blksize = HPAGE_PMD_SIZE; @@ -1136,7 +1139,7 @@ static int shmem_setattr(struct mnt_idmap *idmap, if (attr->ia_valid & ATTR_MODE) error = posix_acl_chmod(idmap, dentry, inode->i_mode); if (!error && update_ctime) { - inode->i_ctime = current_time(inode); + inode->i_ctime = current_cmtime(inode); if (update_mtime) inode->i_mtime = inode->i_ctime; inode_inc_iversion(inode); @@ -2361,7 +2364,7 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap, struct super_block inode->i_ino = ino; inode_init_owner(idmap, inode, dir, mode); inode->i_blocks = 0; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); + inode->i_atime = inode->i_mtime = inode->i_ctime = current_cmtime(inode); inode->i_generation = get_random_u32(); info = SHMEM_I(inode); memset(info, 0, (char *)inode - (char *)info); @@ -2940,7 +2943,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, error = 0; dir->i_size += BOGO_DIRENT_SIZE; - dir->i_ctime = dir->i_mtime = current_time(dir); + dir->i_ctime = dir->i_mtime = current_cmtime(dir); inode_inc_iversion(dir); d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ @@ -3016,7 +3019,7 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr } dir->i_size += BOGO_DIRENT_SIZE; - inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); + inode->i_ctime = dir->i_ctime = dir->i_mtime = current_cmtime(inode); inode_inc_iversion(dir); inc_nlink(inode); ihold(inode); /* New dentry reference */ @@ -3034,7 +3037,7 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) shmem_free_inode(inode->i_sb); dir->i_size -= BOGO_DIRENT_SIZE; - inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); + inode->i_ctime = dir->i_ctime = dir->i_mtime = current_cmtime(inode); inode_inc_iversion(dir); drop_nlink(inode); dput(dentry); /* Undo the count from "create" - this does all the work */ @@ -3124,7 +3127,7 @@ static int shmem_rename2(struct mnt_idmap *idmap, new_dir->i_size += BOGO_DIRENT_SIZE; old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = new_dir->i_mtime = - inode->i_ctime = current_time(old_dir); + inode->i_ctime = current_cmtime(old_dir); inode_inc_iversion(old_dir); inode_inc_iversion(new_dir); return 0; @@ -3178,7 +3181,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, folio_put(folio); } dir->i_size += BOGO_DIRENT_SIZE; - dir->i_ctime = dir->i_mtime = current_time(dir); + dir->i_ctime = dir->i_mtime = current_cmtime(dir); inode_inc_iversion(dir); d_instantiate(dentry, inode); dget(dentry); @@ -3250,7 +3253,7 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap, (fa->flags & SHMEM_FL_USER_MODIFIABLE); shmem_set_inode_flags(inode, info->fsflags); - inode->i_ctime = current_time(inode); + inode->i_ctime = current_cmtime(inode); inode_inc_iversion(inode); return 0; } @@ -3320,7 +3323,7 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler, name = xattr_full_name(handler, name); err = simple_xattr_set(&info->xattrs, name, value, size, flags, NULL); if (!err) { - inode->i_ctime = current_time(inode); + inode->i_ctime = current_cmtime(inode); inode_inc_iversion(inode); } return err;