From 8588768075d63aa3ba5c3a49b945581db66003cd Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 9 Nov 2016 09:36:06 -0500 Subject: [PATCH] client/mds: add flags field to MClientCaps ...and encode/decode it appropriately. The idea of this field is to be advisory, to allow the MDS to handle things differently if it so chooses. We deliberately do _not_ offer any firm policy here. We start with a flag that tells the MDS when an application may end up blocking on the result of this cap request. A new "sync" arg is added to send_cap, and we set the new flag in the cap request based on its value. For now, the callers all set the sync boolean to false everywhere to preserve the existing behavior. Signed-off-by: Jeff Layton --- src/client/Client.cc | 12 ++++++++---- src/client/Client.h | 2 +- src/messages/MClientCaps.h | 19 +++++++++++++++---- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index aa9a12d4210..3ab101e9f5d 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3175,8 +3175,8 @@ void Client::cap_delay_requeue(Inode *in) } void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, - int used, int want, int retain, int flush, - ceph_tid_t flush_tid) + bool sync, int used, int want, int retain, + int flush, ceph_tid_t flush_tid) { int held = cap->issued | cap->implemented; int revoking = cap->implemented & ~cap->issued; @@ -3186,6 +3186,7 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, ldout(cct, 10) << "send_cap " << *in << " mds." << session->mds_num << " seq " << cap->seq + << (sync ? " sync " : " async ") << " used " << ccap_string(used) << " want " << ccap_string(want) << " flush " << ccap_string(flush) @@ -3261,6 +3262,8 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, m->btime = in->btime; m->time_warp_seq = in->time_warp_seq; m->change_attr = in->change_attr; + if (sync) + m->flags |= CLIENT_CAPS_SYNC; if (flush & CEPH_CAP_FILE_WR) { m->inline_version = in->inline_version; @@ -3426,7 +3429,8 @@ void Client::check_caps(Inode *in, bool no_delay) flush_tid = 0; } - send_cap(in, session, cap, cap_used, wanted, retain, flushing, flush_tid); + send_cap(in, session, cap, false, cap_used, wanted, retain, flushing, + flush_tid); } } @@ -4138,7 +4142,7 @@ void Client::flush_caps(Inode *in, MetaSession *session) for (map::iterator p = in->flushing_cap_tids.begin(); p != in->flushing_cap_tids.end(); ++p) { - send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()), + send_cap(in, session, cap, false, (get_caps_used(in) | in->caps_dirty()), in->caps_wanted(), (cap->issued | cap->implemented), p->second, p->first); } diff --git a/src/client/Client.h b/src/client/Client.h index 736c9fc9b70..38d0cdab4ac 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -648,7 +648,7 @@ protected: void handle_cap_flushsnap_ack(MetaSession *session, Inode *in, class MClientCaps *m); void handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, class MClientCaps *m); void cap_delay_requeue(Inode *in); - void send_cap(Inode *in, MetaSession *session, Cap *cap, + void send_cap(Inode *in, MetaSession *session, Cap *cap, bool sync, int used, int want, int retain, int flush, ceph_tid_t flush_tid); void check_caps(Inode *in, bool immediate); diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index 7153f7fbbc0..e53ea7f312e 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -18,9 +18,10 @@ #include "msg/Message.h" #include "include/ceph_features.h" +#define CLIENT_CAPS_SYNC (0x1) class MClientCaps : public Message { - static const int HEAD_VERSION = 9; + static const int HEAD_VERSION = 10; static const int COMPAT_VERSION = 1; public: @@ -46,6 +47,9 @@ class MClientCaps : public Message { uint32_t caller_uid; uint32_t caller_gid; + /* advisory CLIENT_CAPS_* flags to send to mds */ + unsigned flags; + int get_caps() { return head.caps; } int get_wanted() { return head.wanted; } int get_dirty() { return head.dirty; } @@ -117,7 +121,8 @@ class MClientCaps : public Message { time_warp_seq(0), osd_epoch_barrier(0), oldest_flush_tid(0), - caller_uid(0), caller_gid(0) { + caller_uid(0), caller_gid(0), + flags(0) { inline_version = 0; } MClientCaps(int op, @@ -139,7 +144,8 @@ class MClientCaps : public Message { time_warp_seq(0), osd_epoch_barrier(oeb), oldest_flush_tid(0), - caller_uid(0), caller_gid(0) { + caller_uid(0), caller_gid(0), + flags(0) { memset(&head, 0, sizeof(head)); head.op = op; head.ino = ino; @@ -165,7 +171,8 @@ class MClientCaps : public Message { time_warp_seq(0), osd_epoch_barrier(oeb), oldest_flush_tid(0), - caller_uid(0), caller_gid(0) { + caller_uid(0), caller_gid(0), + flags(0) { memset(&head, 0, sizeof(head)); head.op = op; head.ino = ino; @@ -264,6 +271,9 @@ public: ::decode(btime, p); ::decode(change_attr, p); } + if (header.version >= 10) { + ::decode(flags, p); + } } void encode_payload(uint64_t features) { header.version = HEAD_VERSION; @@ -322,6 +332,7 @@ public: ::encode(layout.pool_ns, payload); ::encode(btime, payload); ::encode(change_attr, payload); + ::encode(flags, payload); } }; -- 2.39.5