Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3148800rdh; Thu, 28 Sep 2023 04:19:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFypUwCsAMn8NR7tz3r+A5eRTmiM+SXhKliD+NvirUn2MRqIcVf6/F85rrW64Fxt3wZIwzb X-Received: by 2002:a05:6870:8320:b0:1dc:bccf:b840 with SMTP id p32-20020a056870832000b001dcbccfb840mr1050453oae.32.1695899982682; Thu, 28 Sep 2023 04:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695899982; cv=none; d=google.com; s=arc-20160816; b=VUBOxCr2HM+syeQhhQq0ojfNEWTRrbXDK5yArpIAuT8FxfzCFTp4XDwRaVJZVXHxTT 3hfPov75Zh3xAGgaafkEzApkG+p6ELSuReJJtksNM8FUIyesqGPm4P6IqGeDv71zHHGy GJg5rVnmkGf/A6iSFCl7ujbVUkWk5EP4P8zgONoUztOi9cl4p0xp9qvCTrA0ZhrPHsWI cPBVKxj6YfmUIqZn92NibGNjdOAKtuC5ucH+bTORwwgmgKr8btbx00wsMNOH7kc0cvOK u9I5bFgxMAHu8ujc+56CauqkuK1yIuUpjb/xyJhk3Ejxs9Xq1QA4QeBzPvsib4bweTA/ M/tA== 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=0hwb/rqhZqRUxpiytPaciEZEx958T5AUFgJmX+PJXmA=; fh=UIStBJvlqOcG0eJXpcE4hrsP5r3uHd8xntseFyzSDLA=; b=B84I44ZTAyMxIoz/88PtX7OWxlwhe2pygKMDYDbk9reb42ZZQCoR7MC1lUJ+OeIMnu MCQrXeVHxGCPLNJTYmHpiyMSbE0lI1ii3rrislblzBwMHYbfqUTfeRscCYW8fp8ie+aN w7ZYDPLg/5YLZ0HouXc9LkO85pY9Q7yZDkmGMXmVrCnjczBkYqb7H0TojXoVeFeylrH4 uFqSZht32zZ5nFBZTENGZtc4asWtt4uKMZK9i0sg87Gl+jYQbI+XBvV3I4r8pWsONDlk lEqoDAUYp/30rF6ZFNVAsPeqLHhNa1mbdGeODmiOI3Unq+LSfzmmsdYblkx8caC49YNu qUnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BiewGpLq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t4-20020a63f344000000b005789e2752e8si2938415pgj.246.2023.09.28.04.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 04:19:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BiewGpLq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 864AE853A924; Thu, 28 Sep 2023 04:06:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbjI1LFs (ORCPT + 99 others); Thu, 28 Sep 2023 07:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231981AbjI1LEl (ORCPT ); Thu, 28 Sep 2023 07:04:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D442F1A4; Thu, 28 Sep 2023 04:04:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FEA5C433C9; Thu, 28 Sep 2023 11:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695899077; bh=ruBVBlbxk43QmbfwYylX+XKh2opy3/NQx5bRlLNo8m8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BiewGpLq2Ju9FF4X5MfXOLjuyzPXKBGx+Dp4rMCgVoZr8X5Nhm8d142DHdibiaZP+ ua5iyJ+YAOv4lHl/ygQTjt2hzLx/vaRiJF6DZHRTju11SbID1WA31rEZHMATOqdYBO IVhB23S3lFZvugNAb0+RfA1TjpI6tiZcc0GefmMD6LOQBof/r2fi5n5x5pyQjIRzs7 S8/dlv8sr4TEBDdj9yuyZAujIM65oX5Sk4W7ybZeYbuAOfSwtjq255CjVmHyo7RO9z 5oonsTrCFKd4T51EiDXSUjpOm61C8IUuUVhumDolbhEEA6PV64+EVnAy1rgrDN/AMj igRYnN5RZgMpw== From: Jeff Layton To: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 22/87] fs/btrfs: convert to new inode {a,m}time accessors Date: Thu, 28 Sep 2023 07:02:31 -0400 Message-ID: <20230928110413.33032-21-jlayton@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928110413.33032-1-jlayton@kernel.org> References: <20230928110300.32891-1-jlayton@kernel.org> <20230928110413.33032-1-jlayton@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 28 Sep 2023 04:06:06 -0700 (PDT) Signed-off-by: Jeff Layton --- fs/btrfs/delayed-inode.c | 16 ++++++++-------- fs/btrfs/file.c | 18 ++++++++++-------- fs/btrfs/inode.c | 39 ++++++++++++++++++++------------------- fs/btrfs/reflink.c | 2 +- fs/btrfs/transaction.c | 3 ++- fs/btrfs/tree-log.c | 8 ++++---- 6 files changed, 45 insertions(+), 41 deletions(-) diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index caf0bbd028d1..c578a6fc796c 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -1834,14 +1834,14 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans, btrfs_set_stack_inode_block_group(inode_item, 0); btrfs_set_stack_timespec_sec(&inode_item->atime, - inode->i_atime.tv_sec); + inode_get_atime(inode).tv_sec); btrfs_set_stack_timespec_nsec(&inode_item->atime, - inode->i_atime.tv_nsec); + inode_get_atime(inode).tv_nsec); btrfs_set_stack_timespec_sec(&inode_item->mtime, - inode->i_mtime.tv_sec); + inode_get_mtime(inode).tv_sec); btrfs_set_stack_timespec_nsec(&inode_item->mtime, - inode->i_mtime.tv_nsec); + inode_get_mtime(inode).tv_nsec); btrfs_set_stack_timespec_sec(&inode_item->ctime, inode_get_ctime(inode).tv_sec); @@ -1891,11 +1891,11 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev) btrfs_inode_split_flags(btrfs_stack_inode_flags(inode_item), &BTRFS_I(inode)->flags, &BTRFS_I(inode)->ro_flags); - inode->i_atime.tv_sec = btrfs_stack_timespec_sec(&inode_item->atime); - inode->i_atime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->atime); + inode_set_atime(inode, btrfs_stack_timespec_sec(&inode_item->atime), + btrfs_stack_timespec_nsec(&inode_item->atime)); - inode->i_mtime.tv_sec = btrfs_stack_timespec_sec(&inode_item->mtime); - inode->i_mtime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->mtime); + inode_set_mtime(inode, btrfs_stack_timespec_sec(&inode_item->mtime), + btrfs_stack_timespec_nsec(&inode_item->mtime)); inode_set_ctime(inode, btrfs_stack_timespec_sec(&inode_item->ctime), btrfs_stack_timespec_nsec(&inode_item->ctime)); diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 361535c71c0f..278a4ea651e1 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1108,17 +1108,18 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode) static void update_time_for_write(struct inode *inode) { - struct timespec64 now, ctime; + struct timespec64 now, ts; if (IS_NOCMTIME(inode)) return; now = current_time(inode); - if (!timespec64_equal(&inode->i_mtime, &now)) - inode->i_mtime = now; + ts = inode_get_mtime(inode); + if (!timespec64_equal(&ts, &now)) + inode_set_mtime_to_ts(inode, now); - ctime = inode_get_ctime(inode); - if (!timespec64_equal(&ctime, &now)) + ts = inode_get_ctime(inode); + if (!timespec64_equal(&ts, &now)) inode_set_ctime_to_ts(inode, now); if (IS_I_VERSION(inode)) @@ -2473,7 +2474,8 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode, inode_inc_iversion(&inode->vfs_inode); if (!extent_info || extent_info->update_times) - inode->vfs_inode.i_mtime = inode_set_ctime_current(&inode->vfs_inode); + inode_set_mtime_to_ts(&inode->vfs_inode, + inode_set_ctime_current(&inode->vfs_inode)); ret = btrfs_update_inode(trans, root, inode); if (ret) @@ -2714,7 +2716,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len) ASSERT(trans != NULL); inode_inc_iversion(inode); - inode->i_mtime = inode_set_ctime_current(inode); + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); ret = btrfs_update_inode(trans, root, BTRFS_I(inode)); updated_inode = true; btrfs_end_transaction(trans); @@ -2734,7 +2736,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len) struct timespec64 now = inode_set_ctime_current(inode); inode_inc_iversion(inode); - inode->i_mtime = now; + inode_set_mtime_to_ts(inode, now); trans = btrfs_start_transaction(root, 1); if (IS_ERR(trans)) { ret = PTR_ERR(trans); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7814b9d654ce..e35939e68fc5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3754,11 +3754,11 @@ static int btrfs_read_locked_inode(struct inode *inode, btrfs_inode_set_file_extent_range(BTRFS_I(inode), 0, round_up(i_size_read(inode), fs_info->sectorsize)); - inode->i_atime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->atime); - inode->i_atime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->atime); + inode_set_atime(inode, btrfs_timespec_sec(leaf, &inode_item->atime), + btrfs_timespec_nsec(leaf, &inode_item->atime)); - inode->i_mtime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->mtime); - inode->i_mtime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->mtime); + inode_set_mtime(inode, btrfs_timespec_sec(leaf, &inode_item->mtime), + btrfs_timespec_nsec(leaf, &inode_item->mtime)); inode_set_ctime(inode, btrfs_timespec_sec(leaf, &inode_item->ctime), btrfs_timespec_nsec(leaf, &inode_item->ctime)); @@ -3922,14 +3922,14 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, btrfs_set_token_inode_nlink(&token, item, inode->i_nlink); btrfs_set_token_timespec_sec(&token, &item->atime, - inode->i_atime.tv_sec); + inode_get_atime(inode).tv_sec); btrfs_set_token_timespec_nsec(&token, &item->atime, - inode->i_atime.tv_nsec); + inode_get_atime(inode).tv_nsec); btrfs_set_token_timespec_sec(&token, &item->mtime, - inode->i_mtime.tv_sec); + inode_get_mtime(inode).tv_sec); btrfs_set_token_timespec_nsec(&token, &item->mtime, - inode->i_mtime.tv_nsec); + inode_get_mtime(inode).tv_nsec); btrfs_set_token_timespec_sec(&token, &item->ctime, inode_get_ctime(inode).tv_sec); @@ -4133,7 +4133,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, inode_inc_iversion(&inode->vfs_inode); inode_inc_iversion(&dir->vfs_inode); inode_set_ctime_current(&inode->vfs_inode); - dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode); + inode_set_mtime_to_ts(&dir->vfs_inode, inode_set_ctime_current(&dir->vfs_inode)); ret = btrfs_update_inode(trans, root, dir); out: return ret; @@ -4306,7 +4306,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, btrfs_i_size_write(dir, dir->vfs_inode.i_size - fname.disk_name.len * 2); inode_inc_iversion(&dir->vfs_inode); - dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode); + inode_set_mtime_to_ts(&dir->vfs_inode, inode_set_ctime_current(&dir->vfs_inode)); ret = btrfs_update_inode_fallback(trans, root, dir); if (ret) btrfs_abort_transaction(trans, ret); @@ -4956,7 +4956,8 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) if (newsize != oldsize) { inode_inc_iversion(inode); if (!(mask & (ATTR_CTIME | ATTR_MTIME))) { - inode->i_mtime = inode_set_ctime_current(inode); + inode_set_mtime_to_ts(inode, + inode_set_ctime_current(inode)); } } @@ -5600,9 +5601,9 @@ static struct inode *new_simple_dir(struct inode *dir, inode->i_opflags &= ~IOP_XATTR; inode->i_fop = &simple_dir_operations; inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; - inode->i_mtime = inode_set_ctime_current(inode); - inode->i_atime = dir->i_atime; - BTRFS_I(inode)->i_otime = inode->i_mtime; + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); + inode_set_atime_to_ts(inode, inode_get_atime(dir)); + BTRFS_I(inode)->i_otime = inode_get_mtime(inode); inode->i_uid = dir->i_uid; inode->i_gid = dir->i_gid; @@ -6277,9 +6278,9 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans, goto discard; } - inode->i_mtime = inode_set_ctime_current(inode); - inode->i_atime = inode->i_mtime; - BTRFS_I(inode)->i_otime = inode->i_mtime; + simple_inode_init_ts(inode); + + BTRFS_I(inode)->i_otime = inode_get_mtime(inode); /* * We're going to fill the inode item now, so at this point the inode @@ -6444,8 +6445,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, * values (the ones it had when the fsync was done). */ if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) - parent_inode->vfs_inode.i_mtime = - inode_set_ctime_current(&parent_inode->vfs_inode); + inode_set_mtime_to_ts(&parent_inode->vfs_inode, + inode_set_ctime_current(&parent_inode->vfs_inode)); ret = btrfs_update_inode(trans, root, parent_inode); if (ret) diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c index 65d2bd6910f2..13ecb4f85941 100644 --- a/fs/btrfs/reflink.c +++ b/fs/btrfs/reflink.c @@ -30,7 +30,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans, inode_inc_iversion(inode); if (!no_time_update) { - inode->i_mtime = inode_set_ctime_current(inode); + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); } /* * We round up to the block size at eof when determining which diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index c780d3729463..38a2775c5c7b 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1860,7 +1860,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size + fname.disk_name.len * 2); - parent_inode->i_mtime = inode_set_ctime_current(parent_inode); + inode_set_mtime_to_ts(parent_inode, + inode_set_ctime_current(parent_inode)); ret = btrfs_update_inode_fallback(trans, parent_root, BTRFS_I(parent_inode)); if (ret) { btrfs_abort_transaction(trans, ret); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index cbb17b542131..3f33e18f6d3e 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -4138,14 +4138,14 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, btrfs_set_token_inode_nlink(&token, item, inode->i_nlink); btrfs_set_token_timespec_sec(&token, &item->atime, - inode->i_atime.tv_sec); + inode_get_atime(inode).tv_sec); btrfs_set_token_timespec_nsec(&token, &item->atime, - inode->i_atime.tv_nsec); + inode_get_atime(inode).tv_nsec); btrfs_set_token_timespec_sec(&token, &item->mtime, - inode->i_mtime.tv_sec); + inode_get_mtime(inode).tv_sec); btrfs_set_token_timespec_nsec(&token, &item->mtime, - inode->i_mtime.tv_nsec); + inode_get_mtime(inode).tv_nsec); btrfs_set_token_timespec_sec(&token, &item->ctime, inode_get_ctime(inode).tv_sec); -- 2.41.0