From patchwork Wed Jul 5 19:01:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 116340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2094548vqx; Wed, 5 Jul 2023 12:38:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49gZL6gEYhQ+pzYhL0TegUAdvtPm1ADkDSpKWSK+ueYRA7b3wlH+u11MhlwYoksNBP4dd6 X-Received: by 2002:a05:6830:138a:b0:6b8:7d21:3721 with SMTP id d10-20020a056830138a00b006b87d213721mr15064287otq.33.1688585906231; Wed, 05 Jul 2023 12:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688585906; cv=none; d=google.com; s=arc-20160816; b=MPrkMRSX8Ywz+dijhxJFXZaratgFqlGqliGFK0Qb60/sdmGIWwdvIrT1HMU9WeUTDv 8SRAE7DUY6yd8TLgLSW7DOtZRRp3l++q2ZnoFYM+s/iqh8n9fpS+EOlwlylt8d9VTa+v pqF5k6K8U0nzE7ecT37gquA0RaElINiSQATMw7ENGrCHm5VudMBzO4mG3mFgFflPqK4a fCC+6SSL+yY0QKQpN1OfILgf9d91Bggn4O8ih1tk5kyiqTEM1C72oC1xcEzZQbPbl2A5 4+ySUCgGm7eNU6oK/n76NKSXhRVbL+P8Pj73oL+yj6HR33WtprIFgaCW8wgg/Xr3iz5d euKw== 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=6p/jD2qgu3Ta8+OfCkVGYmt0yytFObZ0xAYF5VRvddo=; fh=m1GEco3WzxljGGiRBVBES01Us7aWsb1sAN0xHUrBisQ=; b=gRU3q8VU+J9Vnep7Scik83FVqtCsUWKtXfJMz6S4Jp+CfX3JcHlxqKsOTadGy9WZ7+ C0JivqoQMF8n31rK67z1CnueLW4jdTsrZvj5UZnjJmYD5Aac1FIM9KAW8iWyRrnNU623 tAWWXRgpBLSmI7AsE+0whcDAPyl78R/3TeN9/3AIBZaSXvMPHYHvAKFSx0vAuabhFyqo MqSarfvP42tFDf/c7jHv+V8YnaG12YUklQWQRwEzsYwUIg3lxG8zsTtJrFZstFnN1eup 45mIjvHBHGhfm5WhRRoK78OarjZZ1LUaBG9ziDTxMIbs56fAzk8mcHv0s5oRjYpqlTxF SiTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g1xtWtER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y64-20020a638a43000000b0054fd4d7d642si22995043pgd.4.2023.07.05.12.38.13; Wed, 05 Jul 2023 12:38:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=g1xtWtER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S233918AbjGETIx (ORCPT + 99 others); Wed, 5 Jul 2023 15:08:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234006AbjGETIP (ORCPT ); Wed, 5 Jul 2023 15:08:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 329C930FD; Wed, 5 Jul 2023 12:04:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA967616D1; Wed, 5 Jul 2023 19:04:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99645C433C7; Wed, 5 Jul 2023 19:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688583892; bh=jvaW2KRmybks7mvs3yOwXVr/qAGA1M2OOs0qv92r5E8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1xtWtERR9DQpMMBKqDExHVrFEjpaDxc4hzZ3Y7fdDV2lCxsUP6+Ed5TSxXK4taET ttP2JTp9wZ6FOXip1TYDrYEdcSq0M8GJ+UqIiDUZLN3UMqVZUEMn0SU+ifk7M3GR4f Ehvrkqw8+sKz+uxAFmV+9Isjs7Y1SiYrqcNfxVFKiFT1h9hc8J6Utbpl/CCrewFVgX tV7x2ReErdrhiIKM+VucEI9tsu4Gf1oIxbCnkoOt9BMmGg4cQR42vmDeBoweJwAuBr u/VeLLD9+TEUqc8/gefyIln5ueL8vAh3LcJ/cgYls9OG9Duts/iqGX4a+7ZUUhrppQ OfJ5s89rA1viw== From: Jeff Layton To: Christian Brauner , Anton Altaparmakov , Namjae Jeon Cc: Al Viro , Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH v2 60/92] ntfs: convert to ctime accessor functions Date: Wed, 5 Jul 2023 15:01:25 -0400 Message-ID: <20230705190309.579783-58-jlayton@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705190309.579783-1-jlayton@kernel.org> References: <20230705185755.579053-1-jlayton@kernel.org> <20230705190309.579783-1-jlayton@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770610655456143094?= X-GMAIL-MSGID: =?utf-8?q?1770610655456143094?= In later patches, we're going to change how the inode's ctime field is used. Switch to using accessor functions instead of raw accesses of inode->i_ctime. Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- fs/ntfs/inode.c | 15 ++++++++------- fs/ntfs/mft.c | 3 +-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 6c3f38d66579..99ac6ea277c4 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -654,7 +654,7 @@ static int ntfs_read_locked_inode(struct inode *vi) * always changes, when mtime is changed. ctime can be changed on its * own, mtime is then not changed, e.g. when a file is renamed. */ - vi->i_ctime = ntfs2utc(si->last_mft_change_time); + inode_set_ctime_to_ts(vi, ntfs2utc(si->last_mft_change_time)); /* * Last access to the data within the file. Not changed during a rename * for example but changed whenever the file is written to. @@ -1218,7 +1218,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) vi->i_gid = base_vi->i_gid; set_nlink(vi, base_vi->i_nlink); vi->i_mtime = base_vi->i_mtime; - vi->i_ctime = base_vi->i_ctime; + inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi)); vi->i_atime = base_vi->i_atime; vi->i_generation = ni->seq_no = base_ni->seq_no; @@ -1484,7 +1484,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) vi->i_gid = base_vi->i_gid; set_nlink(vi, base_vi->i_nlink); vi->i_mtime = base_vi->i_mtime; - vi->i_ctime = base_vi->i_ctime; + inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi)); vi->i_atime = base_vi->i_atime; vi->i_generation = ni->seq_no = base_ni->seq_no; /* Set inode type to zero but preserve permissions. */ @@ -2804,13 +2804,14 @@ int ntfs_truncate(struct inode *vi) */ if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) { struct timespec64 now = current_time(VFS_I(base_ni)); + struct timespec64 ctime = inode_get_ctime(VFS_I(base_ni)); int sync_it = 0; if (!timespec64_equal(&VFS_I(base_ni)->i_mtime, &now) || - !timespec64_equal(&VFS_I(base_ni)->i_ctime, &now)) + !timespec64_equal(&ctime, &now)) sync_it = 1; + inode_set_ctime_to_ts(VFS_I(base_ni), now); VFS_I(base_ni)->i_mtime = now; - VFS_I(base_ni)->i_ctime = now; if (sync_it) mark_inode_dirty_sync(VFS_I(base_ni)); @@ -2928,7 +2929,7 @@ int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (ia_valid & ATTR_MTIME) vi->i_mtime = attr->ia_mtime; if (ia_valid & ATTR_CTIME) - vi->i_ctime = attr->ia_ctime; + inode_set_ctime_to_ts(vi, attr->ia_ctime); mark_inode_dirty(vi); out: return err; @@ -3004,7 +3005,7 @@ int __ntfs_write_inode(struct inode *vi, int sync) si->last_data_change_time = nt; modified = true; } - nt = utc2ntfs(vi->i_ctime); + nt = utc2ntfs(inode_get_ctime(vi)); if (si->last_mft_change_time != nt) { ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, " "new = 0x%llx", vi->i_ino, (long long) diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 0155f106ec34..ad1a8f72da22 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -2682,8 +2682,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode, vi->i_mode &= ~S_IWUGO; /* Set the inode times to the current time. */ - vi->i_atime = vi->i_mtime = vi->i_ctime = - current_time(vi); + vi->i_atime = vi->i_mtime = inode_set_ctime_current(vi); /* * Set the file size to 0, the ntfs inode sizes are set to 0 by * the call to ntfs_init_big_inode() below.