]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
encode locator information in osd op
authorYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Wed, 2 Mar 2011 22:24:56 +0000 (14:24 -0800)
committerYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Wed, 2 Mar 2011 22:24:56 +0000 (14:24 -0800)
src/include/rados.h
src/include/rados/librados.hpp
src/librados.cc
src/messages/MOSDOp.h
src/osdc/Objecter.cc

index 97542de37850dd23cabdfbd665beabd1a7569b3f..35ed142805686e72cab1fe091a94b37cfa7b68d5 100644 (file)
@@ -311,20 +311,21 @@ extern const char *ceph_osd_op_name(int op);
  * An op may be READ, WRITE, or READ|WRITE.
  */
 enum {
-       CEPH_OSD_FLAG_ACK = 1,          /* want (or is) "ack" ack */
-       CEPH_OSD_FLAG_ONNVRAM = 2,      /* want (or is) "onnvram" ack */
-       CEPH_OSD_FLAG_ONDISK = 4,       /* want (or is) "ondisk" ack */
-       CEPH_OSD_FLAG_RETRY = 8,        /* resend attempt */
-       CEPH_OSD_FLAG_READ = 16,        /* op may read */
-       CEPH_OSD_FLAG_WRITE = 32,       /* op may write */
-       CEPH_OSD_FLAG_ORDERSNAP = 64,   /* EOLDSNAP if snapc is out of order */
-       CEPH_OSD_FLAG_PEERSTAT = 128,   /* msg includes osd_peer_stat */
-       CEPH_OSD_FLAG_BALANCE_READS = 256,
-       CEPH_OSD_FLAG_PARALLELEXEC = 512, /* execute op in parallel */
-       CEPH_OSD_FLAG_PGOP = 1024,      /* pg op, no object */
-       CEPH_OSD_FLAG_EXEC = 2048,      /* op may exec */
-       CEPH_OSD_FLAG_EXEC_PUBLIC = 4096, /* op may exec (public) */
-       CEPH_OSD_FLAG_LOCALIZE_READS = 8192,  /* read from nearby replica, if any */
+       CEPH_OSD_FLAG_ACK =            0x0001,  /* want (or is) "ack" ack */
+       CEPH_OSD_FLAG_ONNVRAM =        0x0002,  /* want (or is) "onnvram" ack */
+       CEPH_OSD_FLAG_ONDISK =         0x0004,  /* want (or is) "ondisk" ack */
+       CEPH_OSD_FLAG_RETRY =          0x0008,  /* resend attempt */
+       CEPH_OSD_FLAG_READ =           0x0010,  /* op may read */
+       CEPH_OSD_FLAG_WRITE =          0x0020,  /* op may write */
+       CEPH_OSD_FLAG_ORDERSNAP =      0x0040,  /* EOLDSNAP if snapc is out of order */
+       CEPH_OSD_FLAG_PEERSTAT =       0x0080,  /* msg includes osd_peer_stat */
+       CEPH_OSD_FLAG_BALANCE_READS =  0x0100,
+       CEPH_OSD_FLAG_PARALLELEXEC =   0x0200,  /* execute op in parallel */
+       CEPH_OSD_FLAG_PGOP =           0x0400,  /* pg op, no object */
+       CEPH_OSD_FLAG_EXEC =           0x0800,  /* op may exec */
+       CEPH_OSD_FLAG_EXEC_PUBLIC =    0x1000,  /* op may exec (public) */
+       CEPH_OSD_FLAG_LOCALIZE_READS = 0x2000,  /* read from nearby replica, if any */
+       CEPH_OSD_FLAG_OBJ_LOCATOR    = 0x4000,  /* read from nearby replica, if any */
 };
 
 enum {
index 858bb708025f81a7eba8639f4c1dadce5276893d..573214b4d43b43b8581c589a030e5b1605a7954b 100644 (file)
@@ -183,7 +183,7 @@ namespace librados
 
     const std::string& get_pool_name() const;
 
-    void locator_set_key(const std::string& key);
+    void set_locator_key(const std::string& key);
   private:
     /* You can only get IoCtx instances from Rados */
     IoCtx(IoCtxImpl *io_ctx_impl_);
index ec75e3f1697ce605a72516508f26a27665aee436..ab71ed4e029e1b94d70f7e66f5141bc3d49f7292 100644 (file)
@@ -2295,7 +2295,7 @@ get_pool_name() const
 }
 
 void librados::IoCtx::
-locator_set_key(const string& key)
+set_locator_key(const string& key)
 {
   io_ctx_impl->oloc.key = key;
 }
index 7af6d0a8c9160aa5d3f6c062c718bef9fb7c2004..b110cf9633a77ff008761228c119e8e55271dfd0 100644 (file)
@@ -38,6 +38,7 @@ public:
   vector<snapid_t> snaps;
   osd_peer_stat_t peer_stat;
   int rmw_flags;
+  object_locator_t oloc;
 
   friend class MOSDOpReply;
 
@@ -59,8 +60,12 @@ public:
   pg_t     get_pg() const { return pg_t(head.layout.ol_pgid); }
   //ceph_object_layout get_layout() { return head.layout; }
   object_locator_t get_object_locator() const {
-    pg_t pgid = get_pg();
-    return object_locator_t(pgid.pool(), pgid.preferred());
+    if ((int32_t)oloc.pool != -1)
+      return oloc;
+    else {
+     pg_t pgid = get_pg();
+     return object_locator_t(pgid.pool(), pgid.preferred());
+    }
   }
 
   epoch_t  get_map_epoch() { return head.osdmap_epoch; }
@@ -97,7 +102,7 @@ public:
     memset(&head, 0, sizeof(head));
     set_tid(tid);
     head.client_inc = inc;
-    head.layout = ol;
+    set_layout(ol);
     head.osdmap_epoch = mapepoch;
     head.flags = flags;
   }
@@ -106,7 +111,14 @@ private:
   ~MOSDOp() {}
 
 public:
-  void set_layout(const ceph_object_layout& l) { head.layout = l; }
+  void set_layout(const ceph_object_layout& l) {
+    head.layout = l;
+    pg_t pgid = get_pg();
+  }
+  void set_locator(const object_locator_t& ol) {
+    oloc = ol;
+    head.flags = head.flags | CEPH_OSD_FLAG_OBJ_LOCATOR;
+  }
   void set_version(eversion_t v) { head.reassert_version = v; }
   void set_mtime(utime_t mt) { head.mtime = mt; }
 
@@ -181,6 +193,8 @@ public:
     ::encode_nohead(snaps, payload);
     if (head.flags & CEPH_OSD_FLAG_PEERSTAT)
       ::encode(peer_stat, payload);
+    if (head.flags & CEPH_OSD_FLAG_OBJ_LOCATOR)
+      ::encode(oloc, payload);
   }
 
   virtual void decode_payload() {
@@ -197,6 +211,8 @@ public:
     decode_nohead(head.num_snaps, snaps, p);
     if (head.flags & CEPH_OSD_FLAG_PEERSTAT)
       ::decode(peer_stat, p);
+    if (head.flags & CEPH_OSD_FLAG_OBJ_LOCATOR)
+      ::decode(oloc, p);
   }
 
 
@@ -215,6 +231,9 @@ public:
     if (head.snapid != CEPH_NOSNAP)
       out << "@" << snapid_t((uint64_t)head.snapid);
 
+    if (oloc.key.size())
+      out << " " << oloc;
+
     out << " " << ops;
     out << " " << pg_t(head.layout.ol_pgid);
     if (is_retry_attempt()) out << " RETRY";
index d0c00458bb2634889dce052c05f29db80ec3fef2..09005328e1b5cb2e96147ce68a28b133d4993d52 100644 (file)
@@ -662,6 +662,7 @@ void Objecter::send_op(Op *op)
   MOSDOp *m = new MOSDOp(client_inc, op->tid,
                         op->oid, ol, osdmap->get_epoch(),
                         flags);
+  m->set_locator(op->oloc);
 
   m->set_snapid(op->snapid);
   m->set_snap_seq(op->snapc.seq);