diff options
author | Jeff Layton <jlayton@redhat.com> | 2018-01-26 16:23:58 +0100 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2018-01-26 16:23:58 +0100 |
commit | 7a275516a059bb18d62b7aff4b51b81a4df0f4fb (patch) | |
tree | e0f4352eb22889ceff31d8f4eb716616f084ee06 /src | |
parent | Merge pull request #19922 from Rubab-Syed/performance_counter_browser (diff) | |
download | ceph-7a275516a059bb18d62b7aff4b51b81a4df0f4fb.tar.xz ceph-7a275516a059bb18d62b7aff4b51b81a4df0f4fb.zip |
client: add cap_dirtier_uid/gid to CapSnap
Set new fields to whatever the inode has at the time that we create the
CapSnap. In the event that it was unset at the time of the creation and
becomes dirty afterward, we set it again at finish.
This ensures that we send a valid uid/gid in the event that it had dirty
caps at any point during that period.
Tracker: http://tracker.ceph.com/issues/22801
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/Client.cc | 15 | ||||
-rw-r--r-- | src/client/Inode.h | 6 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc index 9a05d4f5b19..a7f84be9ff9 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3504,6 +3504,8 @@ void Client::queue_cap_snap(Inode *in, SnapContext& old_snapc) capsnap.btime = in->btime; capsnap.xattrs = in->xattrs; capsnap.xattr_version = in->xattr_version; + capsnap.cap_dirtier_uid = in->cap_dirtier_uid; + capsnap.cap_dirtier_gid = in->cap_dirtier_gid; if (used & CEPH_CAP_FILE_WR) { ldout(cct, 10) << "queue_cap_snap WR used on " << *in << dendl; @@ -3525,9 +3527,14 @@ void Client::finish_cap_snap(Inode *in, CapSnap &capsnap, int used) capsnap.ctime = in->ctime; capsnap.time_warp_seq = in->time_warp_seq; capsnap.change_attr = in->change_attr; - capsnap.dirty |= in->caps_dirty(); + /* Only reset it if it wasn't set before */ + if (capsnap.cap_dirtier_uid == -1) { + capsnap.cap_dirtier_uid = in->cap_dirtier_uid; + capsnap.cap_dirtier_gid = in->cap_dirtier_gid; + } + if (capsnap.dirty & CEPH_CAP_FILE_WR) { capsnap.inline_data = in->inline_data; capsnap.inline_version = in->inline_version; @@ -3586,10 +3593,8 @@ void Client::flush_snaps(Inode *in, bool all_again) MClientCaps *m = new MClientCaps(CEPH_CAP_OP_FLUSHSNAP, in->ino, in->snaprealm->ino, 0, mseq, cap_epoch_barrier); - if (user_id >= 0) - m->caller_uid = user_id; - if (group_id >= 0) - m->caller_gid = group_id; + m->caller_uid = capsnap.cap_dirtier_uid; + m->caller_gid = capsnap.cap_dirtier_gid; m->set_client_tid(capsnap.flush_tid); m->head.snap_follows = p.first; diff --git a/src/client/Inode.h b/src/client/Inode.h index cbffaec6531..04d3ff312a6 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -93,10 +93,14 @@ struct CapSnap { bool writing, dirty_data; uint64_t flush_tid; + int64_t cap_dirtier_uid; + int64_t cap_dirtier_gid; + explicit CapSnap(Inode *i) : in(i), issued(0), dirty(0), size(0), time_warp_seq(0), change_attr(0), mode(0), uid(0), gid(0), xattr_version(0), inline_version(0), - writing(false), dirty_data(false), flush_tid(0) + writing(false), dirty_data(false), flush_tid(0), cap_dirtier_uid(-1), + cap_dirtier_gid(-1) {} void dump(Formatter *f) const; |