From: Jeff Layton <jlayton@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: ceph-devel@vger.kernel.org
Subject: [PATCH 23/87] fs/ceph: convert to new inode {a,m}time accessors
Date: Thu, 28 Sep 2023 07:02:32 -0400 [thread overview]
Message-ID: <20230928110413.33032-22-jlayton@kernel.org> (raw)
In-Reply-To: <20230928110413.33032-1-jlayton@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/ceph/addr.c | 10 ++++----
fs/ceph/caps.c | 4 +--
fs/ceph/file.c | 2 +-
fs/ceph/inode.c | 60 ++++++++++++++++++++++++--------------------
fs/ceph/mds_client.c | 8 ++++--
fs/ceph/snap.c | 4 +--
6 files changed, 49 insertions(+), 39 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index f4863078f7fe..936b9e0b351d 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -750,7 +750,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
dout("writepage %llu~%llu (%llu bytes, %sencrypted)\n",
page_off, len, wlen, IS_ENCRYPTED(inode) ? "" : "not ");
- req->r_mtime = inode->i_mtime;
+ req->r_mtime = inode_get_mtime(inode);
ceph_osdc_start_request(osdc, req);
err = ceph_osdc_wait_request(osdc, req);
@@ -1327,7 +1327,7 @@ static int ceph_writepages_start(struct address_space *mapping,
pages = NULL;
}
- req->r_mtime = inode->i_mtime;
+ req->r_mtime = inode_get_mtime(inode);
ceph_osdc_start_request(&fsc->client->osdc, req);
req = NULL;
@@ -1875,7 +1875,7 @@ int ceph_uninline_data(struct file *file)
goto out_unlock;
}
- req->r_mtime = inode->i_mtime;
+ req->r_mtime = inode_get_mtime(inode);
ceph_osdc_start_request(&fsc->client->osdc, req);
err = ceph_osdc_wait_request(&fsc->client->osdc, req);
ceph_osdc_put_request(req);
@@ -1917,7 +1917,7 @@ int ceph_uninline_data(struct file *file)
goto out_put_req;
}
- req->r_mtime = inode->i_mtime;
+ req->r_mtime = inode_get_mtime(inode);
ceph_osdc_start_request(&fsc->client->osdc, req);
err = ceph_osdc_wait_request(&fsc->client->osdc, req);
@@ -2092,7 +2092,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
0, false, true);
ceph_osdc_start_request(&fsc->client->osdc, rd_req);
- wr_req->r_mtime = ci->netfs.inode.i_mtime;
+ wr_req->r_mtime = inode_get_mtime(&ci->netfs.inode);
ceph_osdc_start_request(&fsc->client->osdc, wr_req);
err = ceph_osdc_wait_request(&fsc->client->osdc, rd_req);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 14215ec646f7..a104669fcf4c 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1421,8 +1421,8 @@ static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap,
arg->old_xattr_buf = NULL;
}
- arg->mtime = inode->i_mtime;
- arg->atime = inode->i_atime;
+ arg->mtime = inode_get_mtime(inode);
+ arg->atime = inode_get_atime(inode);
arg->ctime = inode_get_ctime(inode);
arg->btime = ci->i_btime;
arg->change_attr = inode_peek_iversion_raw(inode);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index b1da02f5dbe3..b96d4e74ae99 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -2489,7 +2489,7 @@ static int ceph_zero_partial_object(struct inode *inode,
goto out;
}
- req->r_mtime = inode->i_mtime;
+ req->r_mtime = inode_get_mtime(inode);
ceph_osdc_start_request(&fsc->client->osdc, req);
ret = ceph_osdc_wait_request(&fsc->client->osdc, req);
if (ret == -ENOENT)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 800ab7920513..6a51db29ed57 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -185,9 +185,9 @@ struct inode *ceph_get_snapdir(struct inode *parent)
inode->i_mode = parent->i_mode;
inode->i_uid = parent->i_uid;
inode->i_gid = parent->i_gid;
- inode->i_mtime = parent->i_mtime;
+ inode_set_mtime_to_ts(inode, inode_get_mtime(parent));
inode_set_ctime_to_ts(inode, inode_get_ctime(parent));
- inode->i_atime = parent->i_atime;
+ inode_set_atime_to_ts(inode, inode_get_atime(parent));
ci->i_rbytes = 0;
ci->i_btime = ceph_inode(parent)->i_btime;
@@ -837,28 +837,31 @@ void ceph_fill_file_time(struct inode *inode, int issued,
/* the MDS did a utimes() */
dout("mtime %lld.%09ld -> %lld.%09ld "
"tw %d -> %d\n",
- inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+ inode_get_mtime(inode).tv_sec,
+ inode_get_mtime(inode).tv_nsec,
mtime->tv_sec, mtime->tv_nsec,
ci->i_time_warp_seq, (int)time_warp_seq);
- inode->i_mtime = *mtime;
- inode->i_atime = *atime;
+ inode_set_mtime_to_ts(inode, *mtime);
+ inode_set_atime_to_ts(inode, *atime);
ci->i_time_warp_seq = time_warp_seq;
} else if (time_warp_seq == ci->i_time_warp_seq) {
+ struct timespec64 ts;
+
/* nobody did utimes(); take the max */
- if (timespec64_compare(mtime, &inode->i_mtime) > 0) {
+ ts = inode_get_mtime(inode);
+ if (timespec64_compare(mtime, &ts) > 0) {
dout("mtime %lld.%09ld -> %lld.%09ld inc\n",
- inode->i_mtime.tv_sec,
- inode->i_mtime.tv_nsec,
+ ts.tv_sec, ts.tv_nsec,
mtime->tv_sec, mtime->tv_nsec);
- inode->i_mtime = *mtime;
+ inode_set_mtime_to_ts(inode, *mtime);
}
- if (timespec64_compare(atime, &inode->i_atime) > 0) {
+ ts = inode_get_atime(inode);
+ if (timespec64_compare(atime, &ts) > 0) {
dout("atime %lld.%09ld -> %lld.%09ld inc\n",
- inode->i_atime.tv_sec,
- inode->i_atime.tv_nsec,
+ ts.tv_sec, ts.tv_nsec,
atime->tv_sec, atime->tv_nsec);
- inode->i_atime = *atime;
+ inode_set_atime_to_ts(inode, *atime);
}
} else if (issued & CEPH_CAP_FILE_EXCL) {
/* we did a utimes(); ignore mds values */
@@ -869,8 +872,8 @@ void ceph_fill_file_time(struct inode *inode, int issued,
/* we have no write|excl caps; whatever the MDS says is true */
if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) {
inode_set_ctime_to_ts(inode, *ctime);
- inode->i_mtime = *mtime;
- inode->i_atime = *atime;
+ inode_set_mtime_to_ts(inode, *mtime);
+ inode_set_atime_to_ts(inode, *atime);
ci->i_time_warp_seq = time_warp_seq;
} else {
warn = 1;
@@ -2553,20 +2556,22 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr,
}
if (ia_valid & ATTR_ATIME) {
+ struct timespec64 atime = inode_get_atime(inode);
+
dout("setattr %p atime %lld.%ld -> %lld.%ld\n", inode,
- inode->i_atime.tv_sec, inode->i_atime.tv_nsec,
+ atime.tv_sec, atime.tv_nsec,
attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec);
if (issued & CEPH_CAP_FILE_EXCL) {
ci->i_time_warp_seq++;
- inode->i_atime = attr->ia_atime;
+ inode_set_atime_to_ts(inode, attr->ia_atime);
dirtied |= CEPH_CAP_FILE_EXCL;
} else if ((issued & CEPH_CAP_FILE_WR) &&
- timespec64_compare(&inode->i_atime,
- &attr->ia_atime) < 0) {
- inode->i_atime = attr->ia_atime;
+ timespec64_compare(&atime,
+ &attr->ia_atime) < 0) {
+ inode_set_atime_to_ts(inode, attr->ia_atime);
dirtied |= CEPH_CAP_FILE_WR;
} else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
- !timespec64_equal(&inode->i_atime, &attr->ia_atime)) {
+ !timespec64_equal(&atime, &attr->ia_atime)) {
ceph_encode_timespec64(&req->r_args.setattr.atime,
&attr->ia_atime);
mask |= CEPH_SETATTR_ATIME;
@@ -2626,20 +2631,21 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr,
}
}
if (ia_valid & ATTR_MTIME) {
+ struct timespec64 mtime = inode_get_mtime(inode);
+
dout("setattr %p mtime %lld.%ld -> %lld.%ld\n", inode,
- inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+ mtime.tv_sec, mtime.tv_nsec,
attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec);
if (issued & CEPH_CAP_FILE_EXCL) {
ci->i_time_warp_seq++;
- inode->i_mtime = attr->ia_mtime;
+ inode_set_mtime_to_ts(inode, attr->ia_mtime);
dirtied |= CEPH_CAP_FILE_EXCL;
} else if ((issued & CEPH_CAP_FILE_WR) &&
- timespec64_compare(&inode->i_mtime,
- &attr->ia_mtime) < 0) {
- inode->i_mtime = attr->ia_mtime;
+ timespec64_compare(&mtime, &attr->ia_mtime) < 0) {
+ inode_set_mtime_to_ts(inode, attr->ia_mtime);
dirtied |= CEPH_CAP_FILE_WR;
} else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
- !timespec64_equal(&inode->i_mtime, &attr->ia_mtime)) {
+ !timespec64_equal(&mtime, &attr->ia_mtime)) {
ceph_encode_timespec64(&req->r_args.setattr.mtime,
&attr->ia_mtime);
mask |= CEPH_SETATTR_MTIME;
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 615db141b6c4..e4cfa3b02187 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -4353,12 +4353,16 @@ static int reconnect_caps_cb(struct inode *inode, int mds, void *arg)
rec.v2.flock_len = (__force __le32)
((ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) ? 0 : 1);
} else {
+ struct timespec64 ts;
+
rec.v1.cap_id = cpu_to_le64(cap->cap_id);
rec.v1.wanted = cpu_to_le32(__ceph_caps_wanted(ci));
rec.v1.issued = cpu_to_le32(cap->issued);
rec.v1.size = cpu_to_le64(i_size_read(inode));
- ceph_encode_timespec64(&rec.v1.mtime, &inode->i_mtime);
- ceph_encode_timespec64(&rec.v1.atime, &inode->i_atime);
+ ts = inode_get_mtime(inode);
+ ceph_encode_timespec64(&rec.v1.mtime, &ts);
+ ts = inode_get_atime(inode);
+ ceph_encode_timespec64(&rec.v1.atime, &ts);
rec.v1.snaprealm = cpu_to_le64(ci->i_snap_realm->ino);
rec.v1.pathbase = cpu_to_le64(pathbase);
}
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index 813f21add992..6732e1ea97d9 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -658,8 +658,8 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
BUG_ON(capsnap->writing);
capsnap->size = i_size_read(inode);
- capsnap->mtime = inode->i_mtime;
- capsnap->atime = inode->i_atime;
+ capsnap->mtime = inode_get_mtime(inode);
+ capsnap->atime = inode_get_atime(inode);
capsnap->ctime = inode_get_ctime(inode);
capsnap->btime = ci->i_btime;
capsnap->change_attr = inode_peek_iversion_raw(inode);
--
2.41.0
next prev parent reply other threads:[~2023-09-28 11:05 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 11:02 [PATCH 00/87] fs: new accessor methods for atime and mtime Jeff Layton
2023-09-28 11:02 ` [PATCH 02/87] fs: convert core infrastructure to new {a,m}time accessors Jeff Layton
2023-09-28 11:02 ` [PATCH 03/87] arch/powerpc/platforms/cell/spufs: convert to new inode " Jeff Layton
2023-09-28 11:02 ` [PATCH 04/87] arch/s390/hypfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 05/87] drivers/android: " Jeff Layton
2023-09-28 11:02 ` [PATCH 06/87] drivers/char: " Jeff Layton
2023-09-28 11:02 ` [PATCH 07/87] drivers/infiniband/hw/qib: " Jeff Layton
2023-09-28 11:02 ` [PATCH 08/87] drivers/misc/ibmasm: " Jeff Layton
2023-09-28 11:02 ` [PATCH 09/87] drivers/misc: " Jeff Layton
2023-09-28 11:02 ` [PATCH 10/87] drivers/platform/x86: " Jeff Layton
2023-09-28 12:34 ` Hans de Goede
2023-09-28 11:02 ` [PATCH 11/87] drivers/tty: " Jeff Layton
2023-09-28 12:13 ` Greg KH
2023-09-28 12:23 ` Jeff Layton
2023-09-28 11:02 ` [PATCH 12/87] drivers/usb/core: " Jeff Layton
2023-09-28 11:02 ` [PATCH 13/87] drivers/usb/gadget/function: " Jeff Layton
2023-09-28 11:02 ` [PATCH 14/87] drivers/usb/gadget/legacy: " Jeff Layton
2023-09-28 11:02 ` [PATCH 15/87] fs/9p: " Jeff Layton
2023-09-28 11:02 ` [PATCH 16/87] fs/adfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 17/87] fs/affs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 18/87] fs/afs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 19/87] fs/autofs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 20/87] fs/befs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 21/87] fs/bfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 22/87] fs/btrfs: " Jeff Layton
2023-09-28 11:02 ` Jeff Layton [this message]
2023-09-28 11:02 ` [PATCH 24/87] fs/coda: " Jeff Layton
2023-09-28 11:02 ` [PATCH 25/87] fs/configfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 26/87] fs/cramfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 27/87] fs/debugfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 28/87] fs/devpts: " Jeff Layton
2023-09-28 11:02 ` [PATCH 29/87] fs/efivarfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 30/87] fs/efs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 31/87] fs/erofs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 32/87] fs/exfat: " Jeff Layton
2023-09-28 11:02 ` [PATCH 33/87] fs/ext2: " Jeff Layton
2023-09-28 11:02 ` [PATCH 34/87] fs/ext4: " Jeff Layton
2023-09-28 11:02 ` [PATCH 35/87] fs/f2fs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 36/87] fs/fat: " Jeff Layton
2023-09-28 11:02 ` [PATCH 37/87] fs/freevxfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 38/87] fs/fuse: " Jeff Layton
2023-09-28 11:02 ` [PATCH 39/87] fs/gfs2: " Jeff Layton
2023-09-28 11:02 ` [PATCH 40/87] fs/hfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 41/87] fs/hfsplus: " Jeff Layton
2023-09-28 11:02 ` [PATCH 42/87] fs/hostfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 43/87] fs/hpfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 44/87] fs/hugetlbfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 45/87] fs/isofs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 46/87] fs/jffs2: " Jeff Layton
2023-09-28 11:02 ` [PATCH 47/87] fs/jfs: " Jeff Layton
2023-10-03 16:33 ` [Jfs-discussion] [PATCH 47/87] fs/jfs: convert to new inode {a, m}time accessors Dave Kleikamp
2023-09-28 11:02 ` [PATCH 48/87] fs/kernfs: convert to new inode {a,m}time accessors Jeff Layton
2023-09-28 11:02 ` [PATCH 49/87] fs/minix: " Jeff Layton
2023-09-28 11:02 ` [PATCH 50/87] fs/nfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 51/87] fs/nfsd: " Jeff Layton
2023-09-28 13:56 ` Chuck Lever
2023-09-28 14:09 ` Jeff Layton
2023-09-28 14:33 ` Chuck Lever
2023-09-28 11:03 ` [PATCH 52/87] fs/nilfs2: " Jeff Layton
2023-09-28 11:03 ` [PATCH 53/87] fs/ntfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 54/87] fs/ntfs3: " Jeff Layton
2023-09-28 11:03 ` [PATCH 55/87] fs/ocfs2: " Jeff Layton
2023-09-28 11:03 ` [PATCH 56/87] fs/omfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 57/87] fs/openpromfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 58/87] fs/orangefs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 59/87] fs/overlayfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 60/87] fs/proc: " Jeff Layton
2023-09-28 11:03 ` [PATCH 61/87] fs/pstore: " Jeff Layton
2023-09-28 11:03 ` [PATCH 62/87] fs/qnx4: " Jeff Layton
2023-09-28 12:41 ` Anders Larsen
2023-09-28 11:03 ` [PATCH 63/87] fs/qnx6: " Jeff Layton
2023-09-28 11:03 ` [PATCH 64/87] fs/ramfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 65/87] fs/reiserfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 66/87] fs/romfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 67/87] fs/smb/client: " Jeff Layton
2023-09-28 11:03 ` [PATCH 68/87] fs/smb/server: " Jeff Layton
2023-09-28 11:03 ` [PATCH 69/87] fs/squashfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 70/87] fs/sysv: " Jeff Layton
2023-09-28 11:03 ` [PATCH 71/87] fs/tracefs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 72/87] fs/ubifs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 73/87] fs/udf: " Jeff Layton
2023-09-28 11:03 ` [PATCH 74/87] fs/ufs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 75/87] fs/vboxsf: " Jeff Layton
2023-09-28 11:03 ` [PATCH 76/87] fs/xfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 77/87] fs/zonefs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 78/87] ipc: " Jeff Layton
2023-09-28 11:03 ` [PATCH 79/87] kernel/bpf: " Jeff Layton
2023-09-28 11:03 ` [PATCH 80/87] mm: " Jeff Layton
2023-09-28 11:03 ` [PATCH 81/87] net/sunrpc: " Jeff Layton
2023-09-28 11:03 ` [PATCH 82/87] security/apparmor: " Jeff Layton
2023-09-28 11:03 ` [PATCH 83/87] security/selinux: " Jeff Layton
2023-10-03 19:53 ` Paul Moore
2023-09-28 11:03 ` [PATCH 84/87] security: " Jeff Layton
2023-10-03 23:41 ` Paul Moore
2023-09-28 11:03 ` [PATCH 01/87] fs: new accessor methods for atime and mtime Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230928110413.33032-22-jlayton@kernel.org \
--to=jlayton@kernel.org \
--cc=brauner@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).