rgw: check_disk_state() removes multipart parts from index

Besides suggesting changes to the object's index, we also need
to remove the parts that build the object. This only applies to
parts of multipart objects.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2012-11-27 16:35:48 -08:00
parent 9e8c86173a
commit e5dc46f6aa
3 changed files with 38 additions and 3 deletions

View File

@ -26,8 +26,8 @@
using namespace std;
using ceph::crypto::MD5;
static string mp_ns = "multipart";
static string shadow_ns = "shadow";
static string mp_ns = RGW_OBJ_NS_MULTIPART;
static string shadow_ns = RGW_OBJ_NS_SHADOW;
class MultipartMetaFilter : public RGWAccessListFilter {
public:

View File

@ -1746,6 +1746,18 @@ int RGWRados::delete_obj(void *ctx, rgw_obj& obj)
return r;
}
int RGWRados::delete_obj_index(rgw_obj& obj)
{
rgw_bucket bucket;
std::string oid, key;
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
string tag;
int r = complete_update_index_del(bucket, obj.object, tag, 0);
return r;
}
static void generate_fake_tag(CephContext *cct, map<string, bufferlist>& attrset, RGWObjManifest& manifest, bufferlist& manifest_bl, bufferlist& tag_bl)
{
string tag;
@ -3254,6 +3266,24 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
}
}
if (astate->has_manifest) {
map<uint64_t, RGWObjManifestPart>::iterator miter;
RGWObjManifest& manifest = astate->manifest;
for (miter = manifest.objs.begin(); miter != manifest.objs.end(); ++miter) {
RGWObjManifestPart& part = miter->second;
rgw_obj& loc = part.loc;
if (loc.ns == RGW_OBJ_NS_MULTIPART) {
dout(10) << "check_disk_state(): removing manifest part from index: " << loc << dendl;
r = delete_obj_index(loc);
if (r < 0) {
dout(0) << "WARNING: delete_obj_index() returned r=" << r << dendl;
}
}
}
}
object.etag = etag;
object.content_type = content_type;
object.owner = owner.get_id();
@ -3271,7 +3301,6 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
list_state.meta.owner = owner.get_id();
list_state.meta.owner_display_name = owner.get_display_name();
list_state.exists = true;
cls_rgw_encode_suggestion(CEPH_RGW_UPDATE, list_state, suggested_updates);
return 0;

View File

@ -17,6 +17,9 @@ class RGWGC;
#define PUT_OBJ_EXCL 0x02
#define PUT_OBJ_CREATE_EXCL (PUT_OBJ_CREATE | PUT_OBJ_EXCL)
#define RGW_OBJ_NS_MULTIPART "multipart"
#define RGW_OBJ_NS_SHADOW "shadow"
static inline void prepend_bucket_marker(rgw_bucket& bucket, string& orig_oid, string& oid)
{
if (bucket.marker.empty() || orig_oid.empty()) {
@ -555,6 +558,9 @@ public:
/** Delete an object.*/
virtual int delete_obj(void *ctx, rgw_obj& src_obj);
/** Remove an object from the bucket index */
int delete_obj_index(rgw_obj& obj);
/**
* Get the attributes for an object.
* bucket: name of the bucket holding the object.