]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket recreation should not clobber bucket info
authorYehuda Sadeh <yehuda@inktank.com>
Thu, 7 Feb 2013 00:43:48 +0000 (16:43 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Thu, 7 Feb 2013 21:55:17 +0000 (13:55 -0800)
Fixes: #4039
User's list of buckets is getting modified even if bucket already
exists. This fix removes the newly created directory object, and
makes sure that user info's data points at the correct bucket.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
(cherry picked from commit 9d006ec40ced9d97b590ee07ca9171f0c9bec6e9)

Conflicts:
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc

src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc

index cfb7d177926f513331eab2cdbc4fd4ad5c17caf5..eb22223a442c1479890caee582f2ca64e104ef40 100644 (file)
@@ -834,6 +834,27 @@ void RGWCreateBucket::execute()
 
   existed = (ret == -EEXIST);
 
+  if (existed) {
+    /* bucket already existed, might have raced with another bucket creation, or
+     * might be partial bucket creation that never completed. Read existing bucket
+     * info, verify that the reported bucket owner is the current user.
+     * If all is ok then update the user's list of buckets
+     */
+    RGWBucketInfo info;
+    map<string, bufferlist> attrs;
+    int r = store->get_bucket_info(NULL, s->bucket.name, info, &attrs);
+    if (r < 0) {
+      ldout(s->cct, 0) << "ERROR: get_bucket_info on bucket=" << s->bucket.name << " returned err=" << r << " after create_bucket returned -EEXIST" << dendl;
+      ret = r;
+      return;
+    }
+    if (info.owner.compare(s->user.user_id) != 0) {
+      ret = -ERR_BUCKET_EXISTS;
+      return;
+    }
+    s->bucket = info.bucket;
+  }
+
   ret = rgw_add_bucket(store, s->user.user_id, s->bucket);
   if (ret && !existed && ret != -EEXIST)   /* if it exists (or previously existed), don't remove it! */
     rgw_remove_user_bucket_info(store, s->user.user_id, s->bucket);
index dfec5387fea0b4aa05b4db3a92dca3d8aee55a81..80f0cd8c4e0316027ca4207bb1752564b67a8998 100644 (file)
@@ -805,6 +805,9 @@ int RGWRados::create_bucket(string& owner, rgw_bucket& bucket,
   info.bucket = bucket;
   info.owner = owner;
   ret = store_bucket_info(info, &attrs, exclusive);
+  if (ret == -EEXIST) {
+    io_ctx.remove(dir_oid);
+  }
 
   return ret;
 }