*/
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;
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;
int ret = rgwstore->bucket_suspended(bucket, &suspended);
if (ret < 0)
return ret;
+
if (suspended)
return -ERR_USER_SUSPENDED;
}
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)
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);
/** 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.*/