]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: suspend/enable buckets through pool async api
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 17 Jun 2011 22:30:41 +0000 (15:30 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 17 Jun 2011 23:00:59 +0000 (16:00 -0700)
src/rgw/rgw_access.h
src/rgw/rgw_admin.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index d6838c959598643bbc3b6f06c86cc9ddafc7d975..47e3b53c3096be52c195ef47ba8ac6bf404af59a 100644 (file)
@@ -96,8 +96,8 @@ public:
    */
   virtual int delete_bucket(std::string& id, std::string& bucket) = 0;
 
-  virtual int disable_bucket(std::string& bucket) { return -ENOTSUP; }
-  virtual int enable_bucket(std::string& bucket, uint64_t auid) { return -ENOTSUP; }
+  virtual int disable_buckets(std::vector<std::string>& buckets) { return -ENOTSUP; }
+  virtual int enable_buckets(std::vector<std::string>& buckets, uint64_t auid) { return -ENOTSUP; }
   virtual int bucket_suspended(std::string& bucket, bool *suspended) {
     *suspended = false;
     return 0;
index 3fc07a6277a4734e26328627cc495fd54e305e2c..80557d353f1422d2686114dc109a9ab6fef693a8 100644 (file)
@@ -939,21 +939,19 @@ int main(int argc, char **argv)
     else
       RGW_LOG(0) << "enabling user buckets" << dendl;
 
-    bool fail = false;
-
+    vector<string> bucket_names;
     for (iter = m.begin(); iter != m.end(); ++iter) {
       RGWBucketEnt obj = iter->second;
-      if (disable)
-        ret = rgwstore->disable_bucket(obj.name);
-      else
-        ret = rgwstore->enable_bucket(obj.name, info.auid);
-      if (ret < 0) {
-        cerr << "ERROR: could not disable bucket " << obj.name << " ret=" << ret << std::endl;
-        fail = true;
-      }
+      bucket_names.push_back(obj.name);
+    }
+    if (disable)
+      ret = rgwstore->disable_buckets(bucket_names);
+    else
+      ret = rgwstore->enable_buckets(bucket_names, info.auid);
+    if (ret < 0) {
+      cerr << "ERROR: failed to change pool" << std::endl;
+      exit(1);
     }
-    if (fail)
-      return 1;
   } 
 
   return 0;
index 40d648924aa39446f14a2b7489fe34e867ca70a2..9f8bff0bc994f837743474dc2d22cc3a4d935ff4 100644 (file)
@@ -143,6 +143,7 @@ int read_acls(struct req_state *s, RGWAccessControlPolicy *policy, string& bucke
     int ret = rgwstore->bucket_suspended(bucket, &suspended);
     if (ret < 0)
       return ret;
+
     if (suspended)
       return -ERR_USER_SUSPENDED;
   }
index 3fe68e367fc5921bd15e0411eae4c179aa21a498..816187a84c9f7723553ec9b68017ab82fe8ae4f1 100644 (file)
@@ -486,27 +486,41 @@ int RGWRados::delete_bucket(std::string& id, std::string& bucket)
   return 0;
 }
 
-int RGWRados::disable_bucket(std::string& bucket)
+int RGWRados::set_buckets_auid(vector<std::string>& buckets, uint64_t auid)
 {
   librados::IoCtx ctx;
-  int r = open_bucket_ctx(bucket, ctx);
-  if (r < 0)
-    return r;
+  vector<librados::PoolAsyncCompletion *> completions;
+
+  vector<std::string>::iterator iter;
+  for (iter = buckets.begin(); iter != buckets.end(); ++iter) {
+    string& bucket = *iter;
+    int r = open_bucket_ctx(bucket, ctx);
+    if (r < 0)
+      return r;
+
+    librados::PoolAsyncCompletion *c = librados::Rados::pool_async_create_completion();
+    completions.push_back(c);
+    ctx.set_auid_async(auid, c);
+  }
 
-  ctx.set_auid(RGW_SUSPENDED_USER_AUID);
+  vector<librados::PoolAsyncCompletion *>::iterator citer;
+  for (citer = completions.begin(); citer != completions.end(); ++citer) {
+    PoolAsyncCompletion *c = *citer;
+    c->wait();
+    c->release();
+  }
 
   return 0;
 }
 
-int RGWRados::enable_bucket(std::string& bucket, uint64_t auid)
+int RGWRados::disable_buckets(vector<std::string>& buckets)
 {
-  librados::IoCtx ctx;
-  int r = open_bucket_ctx(bucket, ctx);
-  if (r < 0)
-    return r;
+  return set_buckets_auid(buckets, RGW_SUSPENDED_USER_AUID);
+}
 
-  ctx.set_auid(auid);
-  return 0;
+int RGWRados::enable_buckets(vector<std::string>& buckets, uint64_t auid)
+{
+  return set_buckets_auid(buckets, auid);
 }
 
 int RGWRados::bucket_suspended(std::string& bucket, bool *suspended)
index 89f6a4937379cba92964fe851ed980d35fda8879..0e30e2553de945dd4cbeee5b378add9a8040a1a0 100644 (file)
@@ -19,6 +19,8 @@ class RGWRados  : public RGWAccess
     GetObjState() : sent_data(false) {}
   };
 
+  int set_buckets_auid(vector<std::string>& buckets, uint64_t auid);
+
 public:
   /** Initialize the RADOS instance and prepare to do other ops */
   virtual int initialize(CephContext *cct);
@@ -61,8 +63,8 @@ public:
   /** delete a bucket*/
   virtual int delete_bucket(std::string& id, std::string& bucket);
 
-  virtual int disable_bucket(std::string& bucket);
-  virtual int enable_bucket(std::string& bucket, uint64_t auid);
+  virtual int disable_buckets(std::vector<std::string>& buckets);
+  virtual int enable_buckets(std::vector<std::string>& buckets, uint64_t auid);
   virtual int bucket_suspended(std::string& bucket, bool *suspended);
 
   /** Delete an object.*/