Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5601783rwl; Tue, 11 Apr 2023 07:39:08 -0700 (PDT) X-Google-Smtp-Source: AKy350bPn9qSu644tpmthCpjtlYUwwv6shssXeZeUGWwkc21aFKYY/4ZsjJF9qV/n8pKyF/8nK72 X-Received: by 2002:a17:906:8e8e:b0:94a:8661:162a with SMTP id ru14-20020a1709068e8e00b0094a8661162amr6298848ejc.36.1681223948595; Tue, 11 Apr 2023 07:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681223948; cv=none; d=google.com; s=arc-20160816; b=bggPgsAThLix5HI5WdQDVIwssbvCSMjGdK7lT0+RlHDCYk1TmO4kNHCFYyMpgVqdOF Dd6CXFFDdzumYTaav4gDkVghY7dVpQcbb8mf17arI3caqIJmI/c71DzO8ZJRErvngBCH v8Qr0IOyJx5JMw6HecyQnxRt2Vm3D3bB2xVle73VLNVrWMKXxjMyEVb+1QDJYQHVyYpW 2G2mDxl0eIS1Q83g5yF3+JCYijx8hb0EjYkHFpjRC71QwAbfLt+GZXNDIefDxIzGdYX1 rBXi5R2/20AMu+D6NC75yCBvcnQ4FGjsqvSGc6YQ/6Oab+TeLYi8NgAoQbCmYvC3IsK8 C5fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cmsV/BNDrmF6zQdi+rsdgHY9rce/ydYxUGcPmL06UuA=; b=EjvcBq/1IDjD0j4lGTbdvnu8vDznYnl2wKdkk+H3vMUJaJHiNuqyog+m+HAMJJUzHX 7bU9fb6xqLf4/TqG1OWf+btYsO++/gsijlRy6yS9/BWiS/QF5pimQpduAXBLOCX6xWmY OOZRsQ45YmbnyPu7pTzexkXiUPriFdsyN7WES/YXnGZSemdEYYkZFo8UvEteErE6Q5CV +tIkKThmeJk17RtWTYmN1j8m75jYOooRRRa527pfofahu8qpgaAuQ8yjJUUoPVIatHoD yTvMQneY1Msq1ksnQbmFNyqlU8Xt4PUN3iZjr+kGqTqCx2OoFCp32owMK68arXiLg4Po sstw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lntjKiiq; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 jy26-20020a170907763a00b0094a9e90995bsi1307787ejc.268.2023.04.11.07.38.43; Tue, 11 Apr 2023 07:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=lntjKiiq; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S230268AbjDKOhR (ORCPT + 99 others); Tue, 11 Apr 2023 10:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230148AbjDKOhM (ORCPT ); Tue, 11 Apr 2023 10:37:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EDE244A5; Tue, 11 Apr 2023 07:37:09 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C152B627D5; 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-nfs@vger.kernel.org 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; -- 2.39.2