From d0889aa5faf910955fcb769b2b17132dcc389bf3 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 29 Aug 2016 07:16:39 -0400 Subject: [PATCH] mds/client: add btime to CapSnap and MClientCaps Currently we don't have a mechanism to set the btime, but we will need that eventually. If we want to allow the client to cache that change, we need to be able to pass it back and forth between client and server. Signed-off-by: Jeff Layton --- src/client/Client.cc | 5 +++++ src/client/Inode.h | 2 +- src/mds/Locker.cc | 6 ++++++ src/messages/MClientCaps.h | 9 +++++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 6234ea4b26b..e0726aa7339 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3235,6 +3235,7 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, m->mtime = in->mtime; m->atime = in->atime; m->ctime = in->ctime; + m->btime = in->btime; m->time_warp_seq = in->time_warp_seq; if (flush & CEPH_CAP_FILE_WR) { @@ -3421,6 +3422,7 @@ void Client::queue_cap_snap(Inode *in, SnapContext& old_snapc) capsnap->uid = in->uid; capsnap->gid = in->gid; capsnap->mode = in->mode; + capsnap->btime = in->btime; capsnap->xattrs = in->xattrs; capsnap->xattr_version = in->xattr_version; @@ -3519,6 +3521,7 @@ void Client::flush_snaps(Inode *in, bool all_again) m->head.uid = capsnap->uid; m->head.gid = capsnap->gid; m->head.mode = capsnap->mode; + m->btime = capsnap->btime; m->size = capsnap->size; @@ -3526,6 +3529,7 @@ void Client::flush_snaps(Inode *in, bool all_again) ::encode(capsnap->xattrs, m->xattrbl); m->ctime = capsnap->ctime; + m->btime = capsnap->btime; m->mtime = capsnap->mtime; m->atime = capsnap->atime; m->time_warp_seq = capsnap->time_warp_seq; @@ -4869,6 +4873,7 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient in->mode = m->head.mode; in->uid = m->head.uid; in->gid = m->head.gid; + in->btime = m->btime; } bool deleted_inode = false; if ((issued & CEPH_CAP_LINK_EXCL) == 0) { diff --git a/src/client/Inode.h b/src/client/Inode.h index d17475504ae..28fc439a429 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -51,7 +51,7 @@ struct CapSnap { int issued, dirty; uint64_t size; - utime_t ctime, mtime, atime; + utime_t ctime, btime, mtime, atime; version_t time_warp_seq; uint32_t mode; uid_t uid; diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 966a5f2c12f..3ca5efae1f0 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -3039,6 +3039,12 @@ void Locker::_update_cap_fields(CInode *in, int dirty, MClientCaps *m, inode_t * << " for " << *in << dendl; pi->mode = m->head.mode; } + if (m->get_btime() != pi->btime) { + dout(7) << " btime " << oct << pi->btime + << " -> " << m->get_btime() << dec + << " for " << *in << dendl; + pi->btime = m->get_btime(); + } } } diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index 2fabbc7dea4..a210e44284f 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -20,7 +20,7 @@ class MClientCaps : public Message { - static const int HEAD_VERSION = 8; + static const int HEAD_VERSION = 9; static const int COMPAT_VERSION = 1; public: @@ -28,7 +28,7 @@ class MClientCaps : public Message { uint64_t size, max_size, truncate_size; uint32_t truncate_seq; - utime_t mtime, atime, ctime; + utime_t mtime, atime, ctime, btime; file_layout_t layout; uint32_t time_warp_seq; @@ -62,6 +62,7 @@ class MClientCaps : public Message { __u32 get_truncate_seq() { return truncate_seq; } uint64_t get_truncate_size() { return truncate_size; } utime_t get_ctime() { return ctime; } + utime_t get_btime() { return btime; } utime_t get_mtime() { return mtime; } utime_t get_atime() { return atime; } __u32 get_time_warp_seq() { return time_warp_seq; } @@ -255,6 +256,9 @@ public: if (header.version >= 8) { ::decode(layout.pool_ns, p); } + if (header.version >= 9) { + ::decode(btime, p); + } } void encode_payload(uint64_t features) { header.version = HEAD_VERSION; @@ -311,6 +315,7 @@ public: ::encode(caller_gid, payload); ::encode(layout.pool_ns, payload); + ::encode(btime, payload); } }; -- 2.39.5