]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client/mds: add flags field to MClientCaps
authorJeff Layton <jlayton@redhat.com>
Wed, 9 Nov 2016 14:36:06 +0000 (09:36 -0500)
committerJeff Layton <jlayton@redhat.com>
Wed, 9 Nov 2016 14:36:06 +0000 (09:36 -0500)
...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 <jlayton@redhat.com>
src/client/Client.cc
src/client/Client.h
src/messages/MClientCaps.h

index aa9a12d4210d802c996f789cf21a7b2d4ed09728..3ab101e9f5d99aab284e99d2bd7c470798354d6e 100644 (file)
@@ -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<ceph_tid_t,int>::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);
   }
index 736c9fc9b7005d0d7fa354ef417588c5e999d62f..38d0cdab4ac02ea4da637205694ad5ddc9be6958 100644 (file)
@@ -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);
index 7153f7fbbc0f0966c76555e4aaf898e22008073d..e53ea7f312e66bc370ee9b340e0d6a63a679430c 100644 (file)
 #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);
   }
 };