New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cephfs: fix future rctimes #37938
cephfs: fix future rctimes #37938
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2852,11 +2852,9 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock, | |
pi.inode->rstat.rbytes = new_size; | ||
dout(10) << "check_inode_max_size mtime " << pi.inode->mtime << " -> " << new_mtime << dendl; | ||
pi.inode->mtime = new_mtime; | ||
if (new_mtime > pi.inode->ctime) { | ||
pi.inode->ctime = new_mtime; | ||
if (new_mtime > pi.inode->rstat.rctime) | ||
pi.inode->rstat.rctime = new_mtime; | ||
} | ||
pi.inode->ctime = ceph_clock_now(); | ||
if (pi.inode->ctime > pi.inode->rstat.rctime) | ||
pi.inode->rstat.rctime = pi.inode->ctime; | ||
thmour marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// use EOpen if the file is still open; otherwise, use EUpdate. | ||
|
@@ -3657,22 +3655,16 @@ void Locker::_update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> | |
return; | ||
|
||
/* m must be valid if there are dirty caps */ | ||
bool changed = false; | ||
ceph_assert(m); | ||
uint64_t features = m->get_connection()->get_features(); | ||
|
||
if (m->get_ctime() > pi->ctime) { | ||
dout(7) << " ctime " << pi->ctime << " -> " << m->get_ctime() | ||
<< " for " << *in << dendl; | ||
pi->ctime = m->get_ctime(); | ||
if (m->get_ctime() > pi->rstat.rctime) | ||
pi->rstat.rctime = m->get_ctime(); | ||
} | ||
|
||
if ((features & CEPH_FEATURE_FS_CHANGE_ATTR) && | ||
m->get_change_attr() > pi->change_attr) { | ||
dout(7) << " change_attr " << pi->change_attr << " -> " << m->get_change_attr() | ||
<< " for " << *in << dendl; | ||
pi->change_attr = m->get_change_attr(); | ||
changed = true; | ||
} | ||
|
||
// file | ||
|
@@ -3687,20 +3679,21 @@ void Locker::_update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> | |
dout(7) << " mtime " << pi->mtime << " -> " << mtime | ||
<< " for " << *in << dendl; | ||
pi->mtime = mtime; | ||
if (mtime > pi->rstat.rctime) | ||
pi->rstat.rctime = mtime; | ||
thmour marked this conversation as resolved.
Show resolved
Hide resolved
|
||
changed = true; | ||
} | ||
if (in->is_file() && // ONLY if regular file | ||
size > pi->size) { | ||
dout(7) << " size " << pi->size << " -> " << size | ||
<< " for " << *in << dendl; | ||
pi->size = size; | ||
pi->rstat.rbytes = size; | ||
changed = true; | ||
} | ||
if (in->is_file() && | ||
(dirty & CEPH_CAP_FILE_WR) && | ||
inline_version > pi->inline_data.version) { | ||
pi->inline_data.version = inline_version; | ||
changed = true; | ||
if (inline_version != CEPH_INLINE_NONE && m->inline_data.length() > 0) | ||
pi->inline_data.set_data(m->inline_data); | ||
else | ||
|
@@ -3710,12 +3703,14 @@ void Locker::_update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> | |
dout(7) << " atime " << pi->atime << " -> " << atime | ||
<< " for " << *in << dendl; | ||
pi->atime = atime; | ||
changed = true; | ||
} | ||
if ((dirty & CEPH_CAP_FILE_EXCL) && | ||
ceph_seq_cmp(pi->time_warp_seq, m->get_time_warp_seq()) < 0) { | ||
dout(7) << " time_warp_seq " << pi->time_warp_seq << " -> " << m->get_time_warp_seq() | ||
<< " for " << *in << dendl; | ||
pi->time_warp_seq = m->get_time_warp_seq(); | ||
changed = true; | ||
} | ||
} | ||
// auth | ||
|
@@ -3725,26 +3720,35 @@ void Locker::_update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> | |
<< " -> " << m->head.uid | ||
<< " for " << *in << dendl; | ||
pi->uid = m->head.uid; | ||
changed = true; | ||
} | ||
if (m->head.gid != pi->gid) { | ||
dout(7) << " gid " << pi->gid | ||
<< " -> " << m->head.gid | ||
<< " for " << *in << dendl; | ||
pi->gid = m->head.gid; | ||
changed = true; | ||
} | ||
if (m->head.mode != pi->mode) { | ||
dout(7) << " mode " << oct << pi->mode | ||
<< " -> " << m->head.mode << dec | ||
<< " for " << *in << dendl; | ||
pi->mode = m->head.mode; | ||
changed = true; | ||
} | ||
if ((features & CEPH_FEATURE_FS_BTIME) && m->get_btime() != pi->btime) { | ||
dout(7) << " btime " << oct << pi->btime | ||
<< " -> " << m->get_btime() << dec | ||
<< " for " << *in << dendl; | ||
pi->btime = m->get_btime(); | ||
changed = true; | ||
} | ||
} | ||
|
||
if (changed) { | ||
pi->ctime = std::max(pi->ctime, ceph_clock_now()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the |
||
pi->rstat.rctime = std::max(pi->rstat.rctime, pi->ctime); | ||
} | ||
} | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5324,6 +5324,21 @@ bool Server::xlock_policylock(MDRequestRef& mdr, CInode *in, bool want_layout, b | |
return true; | ||
} | ||
|
||
bool Server::wrlock_nestlock(MDRequestRef& mdr, CInode *in) | ||
{ | ||
if (mdr->locking_state & MutationImpl::ALL_LOCKED) | ||
return true; | ||
|
||
MutationImpl::LockOpVec lov; | ||
lov.add_wrlock(&in->nestlock); | ||
|
||
if (!mds->locker->acquire_locks(mdr, lov)) | ||
return false; | ||
|
||
mdr->locking_state |= MutationImpl::ALL_LOCKED; | ||
return true; | ||
} | ||
|
||
CInode* Server::try_get_auth_inode(MDRequestRef& mdr, inodeno_t ino) | ||
{ | ||
CInode *in = mdcache->get_inode(ino); | ||
|
@@ -5861,6 +5876,34 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur) | |
auto pi = cur->project_inode(mdr); | ||
cur->setxattr_ephemeral_dist(val); | ||
pip = pi.inode.get(); | ||
} else if (name == "ceph.dir.rctime") { | ||
if (!cur->is_dir()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you update an inode's rctime? You could fix all of the rctimes but none of the inodes? |
||
respond_to_request(mdr, -EINVAL); | ||
return; | ||
} | ||
|
||
uint64_t sec, nsec = 0; | ||
try { | ||
if (auto pos = value.find('.', 0); pos != string::npos) { | ||
sec = boost::lexical_cast<uint64_t>(value.substr(0, pos)); | ||
nsec = boost::lexical_cast<uint64_t>(value.substr(pos+1)); | ||
} else { | ||
sec = boost::lexical_cast<uint64_t>(value); | ||
} | ||
} catch (boost::bad_lexical_cast const&) { | ||
dout(10) << "bad vxattr value, unable to parse utime_t for " << name << dendl; | ||
respond_to_request(mdr, -EINVAL); | ||
return; | ||
} | ||
utime_t val(sec, nsec); | ||
|
||
if (!wrlock_nestlock(mdr, cur)) | ||
return; | ||
|
||
auto pi = cur->project_inode(mdr); | ||
pi.inode->rstat.rctime = val; | ||
mdr->no_early_reply = true; | ||
pip = pi.inode.get(); | ||
} else { | ||
dout(10) << " unknown vxattr " << name << dendl; | ||
respond_to_request(mdr, -CEPHFS_EINVAL); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be breaking pjd test - https://pulpito.ceph.com/vshankar-2022-03-14_08:09:40-fs-wip-vshankar-testing1-20220314-103400-testing-default-smithi/6735687/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and only the recovery will set the
new_size
and also themtime
will be readed from the data pool objects, I don't see any case will user modifiedmtime
could affect thectime
here.