]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add locators to the directory objects, and functions handling them
authorGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 21 Oct 2011 00:00:12 +0000 (17:00 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Mon, 24 Oct 2011 17:04:52 +0000 (10:04 -0700)
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/cls_rgw.cc
src/rgw/rgw_cls_api.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 88fc358165adee2cc1c44e76e57d7a1605e299b9..7e5f4de619d297a15d78df1557b8feabedc5305c 100644 (file)
@@ -162,6 +162,7 @@ int rgw_bucket_prepare_op(cls_method_context_t hctx, bufferlist *in, bufferlist
     entry.name = op.name;
     entry.epoch = 0;
     entry.exists = false;
+    entry.locator = op.locator;
   }
 
   // fill in proper state
@@ -209,6 +210,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist
       entry.name = op.name;
       entry.epoch = op.epoch;
       entry.meta = op.meta;
+      entry.locator = op.locator;
       ondisk = false;
     }
   } else {
index d6e7bd73b4029ac612a6986f48154c2ed9d5514d..4eb81ebfa49f858f1fd5a06f9eca93f79f4c6b9a 100644 (file)
@@ -84,6 +84,7 @@ WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta)
 struct rgw_bucket_dir_entry {
   std::string name;
   uint64_t epoch;
+  std::string locator;
   bool exists;
   struct rgw_bucket_dir_entry_meta meta;
   map<string, struct rgw_bucket_pending_info> pending_map;
@@ -92,13 +93,19 @@ struct rgw_bucket_dir_entry {
     epoch(0), exists(false) {}
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
+    __u8 struct_v = 2;
+    if (!locator.size()) {
+      struct_v = 1; // don't waste space encoding it
+    }
     ::encode(struct_v, bl);
     ::encode(name, bl);
     ::encode(epoch, bl);
     ::encode(exists, bl);
     ::encode(meta, bl);
     ::encode(pending_map, bl);
+    if (locator.size()) {
+      ::encode(locator, bl);
+    }
   }
   void decode(bufferlist::iterator &bl) {
     __u8 struct_v;
@@ -108,6 +115,9 @@ struct rgw_bucket_dir_entry {
     ::decode(exists, bl);
     ::decode(meta, bl);
     ::decode(pending_map, bl);
+    if (struct_v >= 2) {
+      ::decode(locator, bl);
+    }
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry)
@@ -174,13 +184,20 @@ struct rgw_cls_obj_prepare_op
   uint8_t op;
   string name;
   string tag;
+  string locator;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
+    __u8 struct_v = 2;
+    if (!locator.size()) {
+      struct_v = 1; // don't waste the encoding space
+    }
     ::encode(struct_v, bl);
     ::encode(op, bl);
     ::encode(name, bl);
     ::encode(tag, bl);
+    if (locator.size()) {
+      ::encode(locator, bl);
+    }
   }
   void decode(bufferlist::iterator &bl) {
     __u8 struct_v;
@@ -188,6 +205,9 @@ struct rgw_cls_obj_prepare_op
     ::decode(op, bl);
     ::decode(name, bl);
     ::decode(tag, bl);
+    if (struct_v >= 2) {
+      ::decode(locator, bl);
+    }
   }
 };
 WRITE_CLASS_ENCODER(rgw_cls_obj_prepare_op)
@@ -196,19 +216,26 @@ struct rgw_cls_obj_complete_op
 {
   uint8_t op;
   string name;
+  string locator;
   uint64_t epoch;
   struct rgw_bucket_dir_entry_meta meta;
   string tag;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
+    __u8 struct_v = 2;
+    if (!locator.size()) {
+      struct_v = 1; // don't waste the encoding space
+    }
     ::encode(struct_v, bl);
     ::encode(op, bl);
     ::encode(name, bl);
     ::encode(epoch, bl);
     ::encode(meta, bl);
     ::encode(tag, bl);
-  }
+    if (locator.size()) {
+      ::encode(locator, bl);
+    }
+ }
   void decode(bufferlist::iterator &bl) {
     __u8 struct_v;
     ::decode(struct_v, bl);
@@ -217,6 +244,9 @@ struct rgw_cls_obj_complete_op
     ::decode(epoch, bl);
     ::decode(meta, bl);
     ::decode(tag, bl);
+    if (struct_v >= 2) {
+      ::decode(locator, bl);
+    }
   }
 };
 WRITE_CLASS_ENCODER(rgw_cls_obj_complete_op)
index 8c27fc4e953a8dcea7e109d52721dbc8a96a797e..eec3825c2cc22c8b07d3490a5b1715349cc0dbb8 100644 (file)
@@ -646,7 +646,7 @@ int RGWRados::put_obj_meta(void *ctx, std::string& id, rgw_obj& obj,  uint64_t s
     return 0;
 
   string tag;
-  r = prepare_update_index(NULL, bucket, obj.object, tag);
+  r = prepare_update_index(NULL, bucket, obj, tag);
   if (r < 0)
     return r;
 
@@ -1011,7 +1011,7 @@ int RGWRados::delete_obj_impl(void *ctx, std::string& id, rgw_obj& obj, bool syn
   string tag;
   op.remove();
   if (sync) {
-    r = prepare_update_index(state, bucket, obj.object, tag);
+    r = prepare_update_index(state, bucket, obj, tag);
     if (r < 0)
       return r;
     r = io_ctx.operate(oid, &op);
@@ -1474,7 +1474,8 @@ done_err:
   return r;
 }
 
-int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket, string& oid, string& tag)
+int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
+                                   rgw_obj& obj, string& tag)
 {
   if (state && state->obj_tag.length()) {
     int len = state->obj_tag.length();
@@ -1485,7 +1486,8 @@ int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket, strin
   } else {
     append_rand_alpha(tag, tag, 32);
   }
-  int ret = cls_obj_prepare_op(bucket, CLS_RGW_OP_ADD, tag, oid);
+  int ret = cls_obj_prepare_op(bucket, CLS_RGW_OP_ADD, tag,
+                               obj.object, obj.key);
 
   return ret;
 }
@@ -1607,7 +1609,7 @@ int RGWRados::clone_objs_impl(void *ctx, rgw_obj& dst_obj,
 
   string tag;
   uint64_t epoch = 0;
-  int ret = prepare_update_index(state, bucket, dst_obj.object, tag);
+  int ret = prepare_update_index(state, bucket, dst_obj, tag);
   if (ret < 0)
     goto done;
 
@@ -2027,7 +2029,8 @@ int RGWRados::cls_rgw_init_index(rgw_bucket& bucket, string& oid)
   return r;
 }
 
-int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag, string& name)
+int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag,
+                                 string& name, string& locator)
 {
   if (bucket.marker.empty()) {
     if (bucket.name[0] == '.')
@@ -2050,6 +2053,7 @@ int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag, st
   call.op = op;
   call.tag = tag;
   call.name = name;
+  call.locator = locator;
   ::encode(call, in);
   r = io_ctx.exec(oid, "rgw", "bucket_prepare_op", in, out);
   return r;
index 9c9e7055febb2be51af011c85f13c892e68ba242..75987059ff40d9419bd2857ad537cabe29376986 100644 (file)
@@ -300,7 +300,8 @@ public:
   virtual int get_bucket_info(string& bucket_name, RGWBucketInfo& info);
 
   int cls_rgw_init_index(rgw_bucket& bucket, string& oid);
-  int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag, string& name);
+  int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag,
+                         string& name, string& locator);
   int cls_obj_complete_op(rgw_bucket& bucket, uint8_t op, string& tag, uint64_t epoch,
                           RGWObjEnt& ent, RGWObjCategory category);
   int cls_obj_complete_add(rgw_bucket& bucket, string& tag, uint64_t epoch, RGWObjEnt& ent, RGWObjCategory category);
@@ -309,7 +310,8 @@ public:
                       map<string, RGWObjEnt>& m, bool *is_truncated,
                       string *last_entry = NULL);
   int cls_bucket_head(rgw_bucket& bucket, struct rgw_bucket_dir_header& header);
-  int prepare_update_index(RGWObjState *state, rgw_bucket& bucket, string& oid, string& tag);
+  int prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
+                           rgw_obj& oid, string& tag);
   int complete_update_index(rgw_bucket& bucket, string& oid, string& tag, uint64_t epoch, uint64_t size,
                             utime_t& ut, string& etag, bufferlist *acl_bl, RGWObjCategory category);
   int complete_update_index_del(rgw_bucket& bucket, string& oid, string& tag, uint64_t epoch) {