]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove unused code
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 10 Oct 2014 00:07:41 +0000 (17:07 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 19 Jan 2015 23:57:41 +0000 (15:57 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/test/encoding/types.h

index 8b82f4aeab62d4106d983f6f9d5c037a1b25a860..aeff06f8263781a2459f53ccecb6ddbbd87ef6f6 100644 (file)
@@ -217,7 +217,6 @@ enum {
   OPT_LOG_RM,
   OPT_USAGE_SHOW,
   OPT_USAGE_TRIM,
-  OPT_TEMP_REMOVE,
   OPT_OBJECT_RM,
   OPT_OBJECT_UNLINK,
   OPT_OBJECT_STAT,
@@ -358,9 +357,6 @@ static int get_cmd(const char *cmd, const char *prev_cmd, bool *need_more)
       return OPT_USAGE_SHOW;
     if (strcmp(cmd, "trim") == 0)
       return OPT_USAGE_TRIM;
-  } else if (strcmp(prev_cmd, "temp") == 0) {
-    if (strcmp(cmd, "remove") == 0)
-      return OPT_TEMP_REMOVE;
   } else if (strcmp(prev_cmd, "caps") == 0) {
     if (strcmp(cmd, "add") == 0)
       return OPT_CAPS_ADD;
@@ -1594,13 +1590,18 @@ int main(int argc, char **argv)
       map<string, bool> common_prefixes;
       string ns;
 
-      rgw_obj_key marker_key(marker);
+      RGWRados::Bucket target(store, bucket);
+      RGWRados::Bucket::List list_op(&target);
+
+      list_op.params.prefix = prefix;
+      list_op.params.delim = delim;
+      list_op.params.marker = rgw_obj_key(marker);
+      list_op.params.ns = ns;
+      list_op.params.enforce_ns = false;
+      list_op.params.list_versions = true;
       
       do {
-        list<rgw_bi_log_entry> entries;
-        ret = store->list_objects(bucket, max_entries - count, prefix, delim,
-                                  marker_key, NULL, result, common_prefixes, true,
-                                  ns, false, true, &truncated, NULL);
+        ret = list_op.list_objects(max_entries - count, &result, &common_prefixes, &truncated);
         if (ret < 0) {
           cerr << "ERROR: store->list_objects(): " << cpp_strerror(-ret) << std::endl;
           return -ret;
@@ -1611,8 +1612,6 @@ int main(int argc, char **argv)
         for (vector<RGWObjEnt>::iterator iter = result.begin(); iter != result.end(); ++iter) {
           RGWObjEnt& entry = *iter;
           encode_json("entry", entry, formatter);
-
-          marker_key = entry.key;
         }
         formatter->flush(cout);
       } while (truncated && count < max_entries);
@@ -1646,24 +1645,6 @@ int main(int argc, char **argv)
     }
   }
 
-  if (opt_cmd == OPT_TEMP_REMOVE) {
-    if (date.empty()) {
-      cerr << "date wasn't specified" << std::endl;
-      return usage();
-    }
-    string parsed_date, parsed_time;
-    int r = utime_t::parse_date(date, NULL, NULL, &parsed_date, &parsed_time);
-    if (r < 0) {
-      cerr << "failure parsing date: " << cpp_strerror(r) << std::endl;
-      return 1;
-    }
-    r = store->remove_temp_objects(parsed_date, parsed_time);
-    if (r < 0) {
-      cerr << "failure removing temp objects: " << cpp_strerror(r) << std::endl;
-      return 1;
-    }
-  }
-
   if (opt_cmd == OPT_LOG_LIST) {
     // filter by date?
     if (date.size() && date.size() != 10) {
index 40a28f2e4fb5ed7c5c13999eb1cbf39c543569f6..2340e63a2a4c2981b7b7c4e2ec87e81e5fd7e20b 100644 (file)
@@ -358,8 +358,6 @@ int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& b
   int ret;
   map<RGWObjCategory, RGWStorageStats> stats;
   std::vector<RGWObjEnt> objs;
-  std::string prefix, delim, ns;
-  rgw_obj_key marker;
   map<string, bool> common_prefixes;
   rgw_obj obj;
   RGWBucketInfo info;
@@ -378,12 +376,15 @@ int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& b
   if (ret < 0)
     return ret;
 
+
+  RGWRados::Bucket target(store, bucket);
+  RGWRados::Bucket::List list_op(&target);
+
+  list_op.params.list_versions = true;
+
   if (delete_children) {
     int max = 1000;
-    ret = store->list_objects(bucket, max, prefix, delim, marker, NULL,
-            objs, common_prefixes,
-            false, ns, true, true, NULL, NULL);
-
+    ret = list_op.list_objects(max, &objs, &common_prefixes, NULL);
     if (ret < 0)
       return ret;
 
@@ -396,8 +397,7 @@ int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& b
       }
       objs.clear();
 
-      ret = store->list_objects(bucket, max, prefix, delim, marker, NULL, objs, common_prefixes,
-                                false, ns, true, true, NULL, NULL);
+      ret = list_op.list_objects(max, &objs, &common_prefixes, NULL);
       if (ret < 0)
         return ret;
     }
@@ -640,9 +640,6 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
   rgw_bucket bucket = op_state.get_bucket();
 
   int max = 1000;
-  string prefix;
-  string delim;
-  rgw_obj_key marker;
 
   map<string, bool> common_prefixes;
   string ns = "multipart";
@@ -651,13 +648,14 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
   map<string, bool> meta_objs;
   map<rgw_obj_key, string> all_objs;
 
+  RGWRados::Bucket target(store, bucket);
+  RGWRados::Bucket::List list_op(&target);
+
+  list_op.params.list_versions = true;
+
   do {
     vector<RGWObjEnt> result;
-    int r = store->list_objects(bucket, max, prefix, delim, marker, NULL,
-                                result, common_prefixes, false,
-                                ns, true, true,
-                                &is_truncated, NULL);
-
+    int r = list_op.list_objects(max, &result, &common_prefixes, &is_truncated);
     if (r < 0) {
       set_err_msg(err_msg, "failed to list objects in bucket=" + bucket.name +
               " err=" +  cpp_strerror(-r));
@@ -675,8 +673,6 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
       rgw_obj_key key;
       obj.get_index_key(&key);
 
-      marker = key;
-
       string oid = key.name;
 
       int pos = oid.find_last_of('.');
index 823c6e09eda0308c6ecc04a00f6fe9fa4ce9b5a5..37c20cbaf1425a9a23420994baef948d7d618d78 100644 (file)
@@ -708,21 +708,20 @@ static int iterate_user_manifest_parts(CephContext *cct, RGWRados *store, off_t
   uint64_t obj_ofs = 0, len_count = 0;
   bool found_start = false, found_end = false;
   string delim;
-  rgw_obj_key marker;
   bool is_truncated;
-  string no_ns;
-  map<string, bool> common_prefixes;
   vector<RGWObjEnt> objs;
 
   utime_t start_time = ceph_clock_now(cct);
 
+  RGWRados::Bucket target(store, bucket);
+  RGWRados::Bucket::List list_op(&target);
+
+  list_op.params.prefix = obj_prefix;
+  list_op.params.delim = delim;
+
   do {
 #define MAX_LIST_OBJS 100
-    int r = store->list_objects(bucket, MAX_LIST_OBJS, obj_prefix, delim, marker, NULL,
-                                objs, common_prefixes,
-                                true, no_ns, true,
-                                false,
-                                &is_truncated, NULL);
+    int r = list_op.list_objects(MAX_LIST_OBJS, &objs, NULL, &is_truncated);
     if (r < 0)
       return r;
 
@@ -757,7 +756,6 @@ static int iterate_user_manifest_parts(CephContext *cct, RGWRados *store, off_t
             return r;
         }
       }
-      marker = ent.key;
 
       start_time = ceph_clock_now(cct);
     }
@@ -1189,10 +1187,18 @@ void RGWListBucket::execute()
   if (ret < 0)
     return;
 
-  rgw_obj_key *pnext_marker = (delimiter.empty() ? NULL : &next_marker);
+  RGWRados::Bucket target(store, s->bucket);
+  RGWRados::Bucket::List list_op(&target);
+
+  list_op.params.prefix = prefix;
+  list_op.params.delim = delimiter;
+  list_op.params.marker = marker;
+  list_op.params.list_versions = list_versions;
 
-  ret = store->list_objects(s->bucket, max, prefix, delimiter, marker, pnext_marker, objs, common_prefixes,
-                               !!(s->prot_flags & RGW_REST_SWIFT), no_ns, true, list_versions, &is_truncated, NULL);
+  ret = list_op.list_objects(max, &objs, &common_prefixes, &is_truncated);
+  if (ret >= 0 && !delimiter.empty()) {
+    next_marker = list_op.get_next_marker();
+  }
 }
 
 int RGWGetBucketLogging::verify_permission()
@@ -3116,8 +3122,17 @@ void RGWListBucketMultiparts::execute()
     }
   }
   marker_meta = marker.get_meta();
-  ret = store->list_objects(s->bucket, max_uploads, prefix, delimiter, marker_meta, NULL, objs, common_prefixes,
-                               !!(s->prot_flags & RGW_REST_SWIFT), mp_ns, true, false, &is_truncated, &mp_filter);
+
+  RGWRados::Bucket target(store, s->bucket);
+  RGWRados::Bucket::List list_op(&target);
+
+  list_op.params.prefix = prefix;
+  list_op.params.delim = delimiter;
+  list_op.params.marker = marker_meta;
+  list_op.params.ns = mp_ns;
+  list_op.params.filter = &mp_filter;
+
+  ret = list_op.list_objects(max_uploads, &objs, &common_prefixes, &is_truncated);
   if (!objs.empty()) {
     vector<RGWObjEnt>::iterator iter;
     RGWMultipartUploadEntry entry;
index 663c0abe4280046b9d775942183e0d3effabc228..e23a110ed8b22a713956e0958b13356809cdc9d7 100644 (file)
@@ -2187,37 +2187,38 @@ int rgw_policy_from_attrset(CephContext *cct, map<string, bufferlist>& attrset,
  * common_prefixes: if delim is filled in, any matching prefixes are placed
  *     here.
  */
-int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string& delim,
-                          const rgw_obj_key& marker, rgw_obj_key *next_marker, vector<RGWObjEnt>& result,
-                           map<string, bool>& common_prefixes,
-                          bool get_content_type, string& ns, bool enforce_ns,
-                           bool list_versions,
-                           bool *is_truncated, RGWAccessListFilter *filter)
+int RGWRados::Bucket::List::list_objects(int max, vector<RGWObjEnt> *result,
+                                         map<string, bool> *common_prefixes,
+                                         bool *is_truncated)
 {
+  RGWRados *store = target->get_store();
+  CephContext *cct = store->ctx();
+  rgw_bucket& bucket = target->get_bucket();
+
   int count = 0;
   bool truncated = true;
 
-  if (bucket_is_system(bucket)) {
+  if (store->bucket_is_system(bucket)) {
     return -EINVAL;
   }
-  result.clear();
+  result->clear();
 
   rgw_obj marker_obj, prefix_obj;
-  marker_obj.set_instance(marker.instance);
-  marker_obj.set_ns(ns);
-  marker_obj.set_obj(marker.name);
+  marker_obj.set_instance(params.marker.instance);
+  marker_obj.set_ns(params.ns);
+  marker_obj.set_obj(params.marker.name);
   rgw_obj_key cur_marker;
   marker_obj.get_index_key(&cur_marker);
 
-  prefix_obj.set_ns(ns);
-  prefix_obj.set_obj(prefix);
+  prefix_obj.set_ns(params.ns);
+  prefix_obj.set_obj(params.prefix);
   string cur_prefix = prefix_obj.get_index_key_name();
 
   string bigger_than_delim;
 
-  if (!delim.empty()) {
-    unsigned long val = decode_utf8((unsigned char *)delim.c_str(), delim.size());
-    char buf[delim.size() + 16];
+  if (!params.delim.empty()) {
+    unsigned long val = decode_utf8((unsigned char *)params.delim.c_str(), params.delim.size());
+    char buf[params.delim.size() + 16];
     int r = encode_utf8(val + 1, (unsigned char *)buf);
     if (r < 0) {
       ldout(cct,0) << "ERROR: encode_utf8() failed" << dendl;
@@ -2231,8 +2232,8 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
   string skip_after_delim;
 
   /* if marker points at a common prefix, fast forward it into its upperbound string */
-  if (!delim.empty()) {
-    int delim_pos = cur_marker.name.find(delim, prefix.size());
+  if (!params.delim.empty()) {
+    int delim_pos = cur_marker.name.find(params.delim, params.prefix.size());
     if (delim_pos >= 0) {
       string s = cur_marker.name.substr(0, delim_pos);
       s.append(bigger_than_delim);
@@ -2246,7 +2247,7 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
       ldout(cct, 20) << "setting cur_marker=" << cur_marker.name << "[" << cur_marker.instance << "]" << dendl;
     }
     std::map<string, RGWObjEnt> ent_map;
-    int r = cls_bucket_list(bucket, cur_marker, cur_prefix, max + 1 - count, list_versions, ent_map,
+    int r = store->cls_bucket_list(bucket, cur_marker, cur_prefix, max + 1 - count, params.list_versions, ent_map,
                             &truncated, &cur_marker);
     if (r < 0)
       return r;
@@ -2258,13 +2259,13 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
       rgw_obj_key key = obj;
       string instance;
 
-      bool check_ns = rgw_obj::translate_raw_obj_to_obj_in_ns(obj.name, instance, ns);
-      if (!list_versions && !entry.is_visible()) {
+      bool check_ns = rgw_obj::translate_raw_obj_to_obj_in_ns(obj.name, instance, params.ns);
+      if (!params.list_versions && !entry.is_visible()) {
         continue;
       }
 
-      if (enforce_ns && !check_ns) {
-        if (!ns.empty()) {
+      if (params.enforce_ns && !check_ns) {
+        if (!params.ns.empty()) {
           /* we've iterated past the namespace we're searching -- done now */
           truncated = false;
           goto done;
@@ -2274,31 +2275,31 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
         continue;
       }
 
-      if (next_marker && count < max) {
-        *next_marker = obj;
+      if (count < max) {
+        params.marker = obj;
+        next_marker = obj;
       }
 
-      if (filter && !filter->filter(obj.name, key.name))
+      if (params.filter && !params.filter->filter(obj.name, key.name))
         continue;
 
-      if (prefix.size() &&  (obj.name.compare(0, prefix.size(), prefix) != 0))
+      if (params.prefix.size() &&  (obj.name.compare(0, params.prefix.size(), params.prefix) != 0))
         continue;
 
-      if (!delim.empty()) {
-        int delim_pos = obj.name.find(delim, prefix.size());
+      if (!params.delim.empty()) {
+        int delim_pos = obj.name.find(params.delim, params.prefix.size());
 
         if (delim_pos >= 0) {
           string prefix_key = obj.name.substr(0, delim_pos + 1);
 
-          if (common_prefixes.find(prefix_key) == common_prefixes.end()) {
+          if (common_prefixes &&
+              common_prefixes->find(prefix_key) == common_prefixes->end()) {
             if (count >= max) {
               truncated = true;
               goto done;
             }
-            if (next_marker) {
-              *next_marker = prefix_key;
-            }
-            common_prefixes[prefix_key] = true;
+            next_marker = prefix_key;
+            (*common_prefixes)[prefix_key] = true;
 
             skip_after_delim = obj.name.substr(0, delim_pos);
             skip_after_delim.append(bigger_than_delim);
@@ -2319,8 +2320,8 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
 
       RGWObjEnt ent = eiter->second;
       ent.key = obj;
-      ent.ns = ns;
-      result.push_back(ent);
+      ent.ns = params.ns;
+      result->push_back(ent);
       count++;
     }
   }
@@ -5348,29 +5349,6 @@ done_err:
   return r;
 }
 
-/* a simple object read */
-int RGWRados::read(void *ctx, rgw_obj& obj, off_t ofs, size_t size, bufferlist& bl)
-{
-  rgw_rados_ref ref;
-  rgw_bucket bucket;
-  int r = get_obj_ref(obj, &ref, &bucket);
-  if (r < 0) {
-    return r;
-  }
-  RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
-  RGWObjState *astate = NULL;
-
-  ObjectReadOperation op;
-
-  r = append_atomic_test(rctx, obj, op, &astate);
-  if (r < 0)
-    return r;
-
-  op.read(ofs, size, &bl, NULL);
-
-  return ref.ioctx.operate(ref.oid, &op, NULL);
-}
-
 int RGWRados::obj_operate(rgw_obj& obj, ObjectWriteOperation *op)
 {
   rgw_rados_ref ref;
index 09addd268525fc54069bdad246e6ef1db167c76f..9e1c7fd3b617fed9ee5b78608a7457bf2deb24a2 100644 (file)
@@ -1284,25 +1284,6 @@ public:
                  bool *is_truncated, RGWUsageIter& read_iter, map<rgw_user_bucket, rgw_usage_log_entry>& usage);
   int trim_usage(string& user, uint64_t start_epoch, uint64_t end_epoch);
 
-  /**
-   * get listing of the objects in a bucket.
-   * bucket: bucket to list contents of
-   * max: maximum number of results to return
-   * prefix: only return results that match this prefix
-   * delim: do not include results that match this string.
-   *     Any skipped results will have the matching portion of their name
-   *     inserted in common_prefixes with a "true" mark.
-   * marker: if filled in, begin the listing with this object.
-   * result: the objects are put in here.
-   * common_prefixes: if delim is filled in, any matching prefixes are placed
-   *     here.
-   */
-  virtual int list_objects(rgw_bucket& bucket, int max, std::string& prefix, std::string& delim,
-                   const rgw_obj_key& marker, rgw_obj_key *next_marker, std::vector<RGWObjEnt>& result,
-                   map<string, bool>& common_prefixes, bool get_content_type, string& ns, bool enforce_ns,
-                   bool list_versions,
-                   bool *is_truncated, RGWAccessListFilter *filter);
-
   virtual int create_pool(rgw_bucket& bucket);
 
   /**
@@ -1407,9 +1388,6 @@ public:
 
       struct GetObjState {
         librados::IoCtx io_ctx;
-        bool sent_data;
-
-        GetObjState() : sent_data(false) {}
       } state;
       
       struct ConditionParams {
@@ -1509,6 +1487,31 @@ public:
       int complete_del(int64_t poolid, uint64_t epoch);
       int cancel();
     };
+
+    struct List {
+      RGWRados::Bucket *target;
+      rgw_obj_key next_marker;
+
+      struct Params {
+        string prefix;
+        string delim;
+        rgw_obj_key marker;
+        string ns;
+        bool enforce_ns;
+        RGWAccessListFilter *filter;
+        bool list_versions;
+
+        Params() : enforce_ns(true), filter(NULL), list_versions(false) {}
+      } params;
+
+    public:
+      List(RGWRados::Bucket *_target) : target(_target) {}
+
+      int list_objects(int max, vector<RGWObjEnt> *result, map<string, bool> *common_prefixes, bool *is_truncated);
+      rgw_obj_key& get_next_marker() {
+        return next_marker;
+      }
+    };
   };
 
   /** Write/overwrite an object to the bucket storage. */
@@ -1672,7 +1675,6 @@ public:
   /**
    * a simple object read without keeping state
    */
-  virtual int read(void *ctx, rgw_obj& obj, off_t ofs, size_t size, bufferlist& bl);
 
   virtual int raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch,
                        map<string, bufferlist> *attrs, bufferlist *first_chunk,
@@ -1698,7 +1700,6 @@ public:
 
   void gen_rand_obj_instance_name(rgw_obj *target);
 
-  virtual bool supports_omap() { return true; }
   int omap_get_vals(rgw_obj& obj, bufferlist& header, const std::string& marker, uint64_t count, std::map<string, bufferlist>& m);
   virtual int omap_get_all(rgw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m);
   virtual int omap_set(rgw_obj& obj, std::string& key, bufferlist& bl);
@@ -1714,14 +1715,6 @@ public:
   virtual int watch_cb(int opcode, uint64_t ver, bufferlist& bl) { return 0; }
   void pick_control_oid(const string& key, string& notify_oid);
 
-  void *create_context(void *user_ctx) {
-    RGWObjectCtx *rctx = new RGWObjectCtx(this);
-    rctx->user_ctx = user_ctx;
-    return rctx;
-  }
-  void destroy_context(void *ctx) {
-    delete static_cast<RGWObjectCtx *>(ctx);
-  }
   void set_atomic(void *ctx, rgw_obj& obj) {
     RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
     rctx->set_atomic(obj);
@@ -1793,9 +1786,6 @@ public:
   int lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, string& zone_id, string& owner_id);
   int unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id);
 
-  /// clean up/process any temporary objects older than given date[/time]
-  int remove_temp_objects(string date, string time);
-
   int gc_operate(string& oid, librados::ObjectWriteOperation *op);
   int gc_aio_operate(string& oid, librados::ObjectWriteOperation *op);
   int gc_operate(string& oid, librados::ObjectReadOperation *op, bufferlist *pbl);
index 4e96f378fd3290d452d9870fbfe98b21a569ea92..d67aef7b3dd98a68a32ff4408d4e88249f163fa4 100644 (file)
@@ -295,7 +295,6 @@ TYPE(rgw_obj)
 
 #include "rgw/rgw_log.h"
 TYPE(rgw_log_entry)
-TYPE(rgw_intent_log_entry)
 
 #include "cls/rbd/cls_rbd.h"
 TYPE(cls_rbd_parent)