Skip to contentSkip to conversation

ceph: fix snapshot directory timestamps

PATCH In review Luis Henriques 2 participants 2 messages Mar 11, 2020 – Mar 16, 2020 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ceph: fix snapshot directory timestamps

The .snap directory timestamps are kept at 0 (1970-01-01 00:00), which isn't consistent with what the fuse client does. This patch makes the behaviour consistent, by setting these timestamps (atime, btime, ctime, mtime) to those of the parent directory.

---
 fs/ceph/inode.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ceph/inode.c +4 -0
index d01710a16a4a..968d55ca898d 100644
@@ -82,10 +82,14 @@ 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->i_ctime = parent->i_ctime;
+	inode->i_atime = parent->i_atime;
 	inode->i_op = &ceph_snapdir_iops;
 	inode->i_fop = &ceph_snapdir_fops;
 	ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */
 	ci->i_rbytes = 0;
+	ci->i_btime = ceph_inode(parent)->i_btime;
 
 	if (inode->i_state & I_NEW)
 		unlock_new_inode(inode);
#1 lore raw
Quoted 20 lines · Luis Henriques

The .snap directory timestamps are kept at 0 (1970-01-01 00:00), which isn't consistent with what the fuse client does. This patch makes the behaviour consistent, by setting these timestamps (atime, btime, ctime, mtime) to those of the parent directory.

---
 fs/ceph/inode.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ceph/inode.c +1 -0
index d01710a16a4a..968d55ca898d 100644
@@ -82,10 +82,14 @@ 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;

fs/ceph/inode.c struct inode *ceph_get_snapdir(struct inode *parent) · line 95

Quoted 10 lines
fs/ceph/inode.c +3 -0
+	inode->i_ctime = parent->i_ctime;
+	inode->i_atime = parent->i_atime;
 	inode->i_op = &ceph_snapdir_iops;
 	inode->i_fop = &ceph_snapdir_fops;
 	ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */
 	ci->i_rbytes = 0;
+	ci->i_btime = ceph_inode(parent)->i_btime;
 
 	if (inode->i_state & I_NEW)
 		unlock_new_inode(inode);

Merged into testing branch -- thanks for the patch!

Signature · 1 line
Jeff Layton <[email protected]>