From patchwork Tue Apr 11 14:27:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13207678 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 C6309C77B6F for ; Tue, 11 Apr 2023 14:27:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63BBA28000A; Tue, 11 Apr 2023 10:27:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EC06280001; Tue, 11 Apr 2023 10:27:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43F3128000A; Tue, 11 Apr 2023 10:27:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2B223280001 for ; Tue, 11 Apr 2023 10:27:16 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EC111120CB9 for ; Tue, 11 Apr 2023 14:27:15 +0000 (UTC) X-FDA: 80669337630.29.1ACCCF3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 17D3020028 for ; Tue, 11 Apr 2023 14:27:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DS4Rz6ur; spf=pass (imf03.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=1681223234; 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=WAoi51A1ZfCExn/x0VKiZealZSw8UmnMbzAHHTuCNKegYhfMTkJjyZb4vPC/876y7sQ9pj PK988j7AX8e9BMyywyJh01gDj3xyRaVUJVHzgdKd/V61gj63NfGfznjnQtjrj92UF7cW5f T+42JsGL83rpq0k/WbBuPVMTa55rfWA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DS4Rz6ur; spf=pass (imf03.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=1681223234; a=rsa-sha256; cv=none; b=baLyD/HTv9xAgnH8ybMOp5CR342bibm+W7Qvz6zzGuaKOa8gxETYF3IXivTz1Kw3XLTWkd u8qJqn+39vvi7mPiQqulsOgPhdy5UMtE0YGHHKe3j/hd1GCRP5dcfQKzH6u+d3E5Gbukmk SUynqcv3GednuxItt0zIs3LbzwWMOqY= 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 3DE45627CC; Tue, 11 Apr 2023 14:27:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31189C4331F; Tue, 11 Apr 2023 14:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681223233; bh=0tABut1wgcVqOORC6SjkhEn9chzMnRxYPBvizenz41c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DS4Rz6ur+uD+K6rkXA92so5T/79mNn9H+8znTY8wB7jXea7DFFL2hylu15eAboI8U +NwNnnDUpM0JkKdjFtiVhLxydSgQP9/MkwjC5IgmD9qA1WElWwCnf2kJSjDoBf4N0C 7mmobbjHwcugmS66AbgRFw3DcEJaAIV8DegHfzh44DwPA7X8xHn+m4kcyLDRjNWNBo Xwz/V7r+7W+/Fya6R9kn7D0lRo99+0Aogd2YXcSnfxhX/o8IaoXGZF9gZLHuPvstsq catZYcZ9OryZNJyGG7evnrJybTfo32CYs/9Go5Qo4yIavZZHXp9+WXuiMCGiCC8KnS X8Uw8Yf4lfLsw== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 2/3] shmem: mark for high-res timestamps on next update after getattr Date: Tue, 11 Apr 2023 10:27:07 -0400 Message-Id: <20230411142708.62475-3-jlayton@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411142708.62475-1-jlayton@kernel.org> References: <20230411142708.62475-1-jlayton@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 17D3020028 X-Stat-Signature: xqtd4qm7utrf3o5ks76jfhw9q85yg9et X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681223233-670888 X-HE-Meta: U2FsdGVkX19I5MFBz3rBOW7THNbtWE6AMhJBj3PdF08eHimXJ/wDsiLSQ5vhStkd9uaJkzXUovSvBaWcN6DqotW7V7FlL2ndcG9S50tgdOu3InSK6kRQvuFtDYY95lVpyRjEXvM5J5slPobK5mwIXCTZwbns4IR0OzQWjtDFKJB4WjT067Sa7jQ0e3tsnZgQlbvR53eK1zOUqE3SI3imfPOlF8gcW1SToVufk6RQ03DcTx3u29rpiyuWspmG2Y++9d1kTiKTqAHyR/dBXo66ZDw6V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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;