From patchwork Tue Apr 11 14:27:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13207680 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 A76DCC77B73 for ; Tue, 11 Apr 2023 14:27:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E54BB28000C; Tue, 11 Apr 2023 10:27:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDB2D280001; Tue, 11 Apr 2023 10:27:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7BB828000C; Tue, 11 Apr 2023 10:27:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B16B0280001 for ; Tue, 11 Apr 2023 10:27:17 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5F8251A0D15 for ; Tue, 11 Apr 2023 14:27:17 +0000 (UTC) X-FDA: 80669337714.16.B1CFF82 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 9DAEB100003 for ; Tue, 11 Apr 2023 14:27:15 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IymI7Pv0; spf=pass (imf05.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=1681223235; 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=VVCfke3ZCxYsghQLpATwfwjekyzkEVZd5h7+Voop3jo=; b=ZkSSuFha+kxKUMKrj15RTpM6kGz8sXqN+8Ykq+IU32+dXbpmuNgUoXN+PlYvJ6fKhE0iJN NDVIU2kc9oRdy7DZgQ/8mYGRGYvS0CHiZsE2z7OBkIQXQvgDG+jEKH/pbP796iKfozUdqg JIdBm+Txt0nNJwF7odXryPB8zqyWlK8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IymI7Pv0; spf=pass (imf05.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=1681223235; a=rsa-sha256; cv=none; b=vLxVsobF2VQ/lUzBdCEXcYKd+/EF5lVpWd+65lmu9y2djtpbsnab96V5PRZzww2CFtDBMJ GveZgebDXiDOzz1AU8QjHZXFdvyFVImgpfG+HIg6EM9akOizx0jGhE+z+kYc0M072YF3G1 TdVFs7HQd0UJw3S1zCoXbhuzQQxFcnM= 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 B81A362769; Tue, 11 Apr 2023 14:27:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C100C433D2; Tue, 11 Apr 2023 14:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681223234; bh=6y1YeGPH/VDzbluu556WvHbrgod71MAnILEUbvu4oy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IymI7Pv0rtcsh15nq7onOJEP+gWsO4qna8uXbEuQwaEVOvwsKzPwh2hcFyUaF4Lrx XdYZai9OWXt7UKRbAg3BTWw/42rJ4yWtC+dwFzLLGNkVahk09bUFcduCvRM1PtXiLw m002LBg/IFOgaiQgOCspNScOrKbSzHygYmekp4HClAirdjNF3Mjta7Br3SMRvZ1Rs8 HM61/lARWL0KAgsdQWzwTlXzaSZNHX9lmToIXAubJkrWLNqd+vMAe3mM1m2rG32YBI zDM8U6NpOEBIgE7Bl5vD5FaLjbFdKLB2ciLTdgD7mHHnnRJDt6pdJ3S+AA+P2K6IHv ChJgZLWcjeELQ== 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 3/3] xfs: mark the inode for high-res timestamp update in getattr Date: Tue, 11 Apr 2023 10:27:08 -0400 Message-Id: <20230411142708.62475-4-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-Server: rspam07 X-Rspamd-Queue-Id: 9DAEB100003 X-Rspam-User: X-Stat-Signature: ecjwgdnc1cprxcccj9fm5yz3634rzmwg X-HE-Tag: 1681223235-765265 X-HE-Meta: U2FsdGVkX1+lA39EXV7wluNq3fci2Acv/3wgfBgEqOnDi/Ec0ksVN5ri//lmtfEUJkT8DQjmWrO8ni5VebzAG/wRZ4X7fqQcUciryML9wk0m1ntrQU/iS/VGJ43T6Ag1R56fAUn0NLl9SWnTTTF9JgMYvxbGALKuzhI1cIrGeIHwLDLxxF7+XxNUNKu+FHsoh7QSw3gcuYHNoI9+HqL+J1w0llR+V3kUcLc3U5bg41Jb9bLjvZ3Znv0CgniakKJ8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=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. With this change, we're better off having the NFS server just ignore the i_version field and have it use the ctime instead, so clear the STATX_CHANGE_COOKIE flag in the result mask in ->getattr. Signed-off-by: Jeff Layton --- fs/xfs/libxfs/xfs_trans_inode.c | 2 +- fs/xfs/xfs_acl.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iops.c | 15 ++++++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index 8b5547073379..9ad7c229c617 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -63,7 +63,7 @@ xfs_trans_ichgtime( ASSERT(tp); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - tv = current_time(inode); + tv = current_cmtime(inode); if (flags & XFS_ICHGTIME_MOD) inode->i_mtime = tv; diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 791db7d9c849..461adc58cf8c 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c @@ -233,7 +233,7 @@ xfs_acl_set_mode( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); inode->i_mode = mode; - inode->i_ctime = current_time(inode); + inode->i_ctime = current_cmtime(inode); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); if (xfs_has_wsync(mp)) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5808abab786c..80f9d731e261 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -843,7 +843,7 @@ xfs_init_new_inode( ip->i_df.if_nextents = 0; ASSERT(ip->i_nblocks == 0); - tv = current_time(inode); + tv = current_cmtime(inode); inode->i_mtime = tv; inode->i_atime = tv; inode->i_ctime = tv; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 24718adb3c16..a0b07f90e16c 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -565,6 +565,15 @@ xfs_vn_getattr( if (xfs_is_shutdown(mp)) return -EIO; + /* + * XFS uses the i_version infrastructure to track any change to + * the inode, including atime updates. This means that the i_version + * returned by getattr doesn't conform to what the callers expect. + * Clear it here so that nfsd will fake up a change cookie from the + * ctime instead. + */ + stat->result_mask &= ~STATX_CHANGE_COOKIE; + stat->size = XFS_ISIZE(ip); stat->dev = inode->i_sb->s_dev; stat->mode = inode->i_mode; @@ -573,8 +582,8 @@ xfs_vn_getattr( stat->gid = vfsgid_into_kgid(vfsgid); stat->ino = ip->i_ino; stat->atime = inode->i_atime; - stat->mtime = inode->i_mtime; - stat->ctime = inode->i_ctime; + if (request_mask & (STATX_CTIME|STATX_MTIME)) + fill_cmtime_and_mark(inode, stat); stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks); if (xfs_has_v3inodes(mp)) { @@ -917,7 +926,7 @@ xfs_setattr_size( if (newsize != oldsize && !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) { iattr->ia_ctime = iattr->ia_mtime = - current_time(inode); + current_cmtime(inode); iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; }