Project

General

Profile

Bug #36171

mds: ctime should not use client provided ctime/mtime

Added by Patrick Donnelly almost 2 years ago. Updated 4 months ago.

Status:
In Progress
Priority:
Urgent
Category:
-
Target version:
-
% Done:

0%

Source:
Development
Tags:
Backport:
mimic,luminous
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(FS):
Client, MDS, kceph
Labels (FS):
task(easy)
Pull request ID:
Crash signature:

Description

Otherwise, you can set a ctime that is far in the future and it cannot be rolled back.

pdonnell@senta02 ~/ceph$ cd /home/pdonnell/mnt/tmp.9cYgpRTGXD
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ mkdir foo
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ touch foo/bar
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ getfattr -n ceph.dir.rctime foo
# file: foo
ceph.dir.rctime="1537838662.09897717617" 
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ stat foo/bar
  File: 'foo/bar'
  Size: 0               Blocks: 0          IO Block: 4194304 regular empty file
Device: 2ch/44d Inode: 1099511627777  Links: 1
Access: (0640/-rw-r-----)  Uid: ( 1163/pdonnell)   Gid: ( 1163/pdonnell)
Access: 2018-09-24 21:24:22.893455885 -0400
Modify: 2018-09-24 21:24:22.893455885 -0400
Change: 2018-09-24 21:24:22.897717617 -0400
 Birth: -
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ touch foo/derp
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ date +%s
1537838726
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ getfattr -n ceph.dir.rctime foo
# file: foo
ceph.dir.rctime="1537838725.0981013223" 

pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ touch -m --date='Jan 01 2022' foo/derp
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ getfattr -n ceph.dir.rctime foo
# file: foo
ceph.dir.rctime="1641013200.090" 

pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ rm foo/derp
pdonnell@senta02 ~/mnt/tmp.9cYgpRTGXD$ getfattr -n ceph.dir.rctime foo
# file: foo
ceph.dir.rctime="1641013200.090" 

Partially caused by 60f73cde4e04be2685eaf7cd04e03c045e1f9977 and #35945.

I think the right approach here is to have the client set its own ctime so that it's locally useful but not to transmit it to the MDS. The MDS always uses its own clock to update the ctime/rctime. This means from the client's perspective that the ctime changes twice for a single metadata operation but I think that's acceptable. The standards provide no guarantees or guidance on this.

History

#1 Updated by Patrick Donnelly almost 2 years ago

  • Subject changed from mds: ctime should not use mtime value to mds: ctime should not client provided ctime/mtime

#2 Updated by Patrick Donnelly almost 2 years ago

  • Subject changed from mds: ctime should not client provided ctime/mtime to mds: ctime should not use client provided ctime/mtime
  • Status changed from New to In Progress
  • Assignee set to Patrick Donnelly

#3 Updated by Patrick Donnelly almost 2 years ago

  • Status changed from In Progress to Fix Under Review

#4 Updated by Patrick Donnelly over 1 year ago

  • Target version changed from v14.0.0 to v15.0.0

#5 Updated by Patrick Donnelly over 1 year ago

  • Status changed from Fix Under Review to In Progress
  • Pull request ID set to 24277

#6 Updated by Patrick Donnelly 7 months ago

  • Target version deleted (v15.0.0)

#7 Updated by Malcolm Haak 4 months ago

I think the right approach here is to have the client set its own ctime so that it's locally useful but not to transmit it to the MDS. The MDS always uses its own clock to update the ctime/rctime. This means from the client's perspective that the ctime changes twice for a single metadata operation but I think that's acceptable. The standards provide no guarantees or guidance on this.

I totally disagree for the mtime case. This breaks rsync and lots of other applications expected behaviour. At least for mtime anyway. Ctime this is the sane behaviour.

mtime should be arbitrary. I've had issues with applications freak out when its in the future but it is technically 'valid'. But I've also encountered workloads where it gets set into the future so it gets left alone until after that date. (I work in HPC and scientists are odd sometimes). But the real issue is if I can't update mtime, rsync can't cheat and use mtimes to detect file changes. That makes many backups sad.

Anyway long story short, mtime should ALWAYS be whatever weird thing the client sets it to. Ctime is less important.

Thanks.

#8 Updated by Greg Farnum 4 months ago

Yeah, we previously assigned mtimes from the MDS and it was a disaster. That's not something we'll be going back to!

I'm less sure about ctimes but I don't think applications outside of samba tend to care about those much...

#9 Updated by Zheng Yan 4 months ago

see https://github.com/ceph/ceph/pull/32126. that commit add 'dirty_from' field to rstat, which is mds time. mds can use 'dirty_from' to decide if rctime should be set to a smaller value.

Also available in: Atom PDF