return true;
}
+ /**
+ * Given a mangled object name and an empty namespace string, this
+ * function extracts the namespace into the string and sets the object
+ * name to be the unmangled version.
+ *
+ * It returns true after successfully doing so, or
+ * false if it fails.
+ */
+ static bool strip_namespace_from_object(string& obj, string& ns) {
+ ns.clear();
+ if (obj[0] != '_') {
+ return true;
+ }
+
+ size_t pos = obj.find('_', 1);
+ if (pos == string::npos) {
+ return false;
+ }
+
+ size_t period_pos = obj.find('.');
+ if (period_pos < pos) {
+ return false;
+ }
+
+ ns = obj.substr(1, pos-1);
+ obj = obj.substr(pos+1, string::npos);
+ return true;
+ }
+
void encode(bufferlist& bl) const {
__u8 struct_v = 2;
::encode(struct_v, bl);
if (!dirent.exists || !dirent.pending_map.empty()) {
/* there are uncommitted ops. We need to check the current state,
* and if the tags are old we need to do cleanup as well. */
- r = check_disk_state(io_ctx, bucket, dirent, e, updates);
+ librados::IoCtx sub_ctx;
+ sub_ctx.dup(io_ctx);
+ r = check_disk_state(sub_ctx, bucket, dirent, e, updates);
if (r < 0) {
if (r == -ENOENT)
continue;
return m.size();
}
-int RGWRados::check_disk_state(librados::IoCtx& io_ctx,
+int RGWRados::check_disk_state(librados::IoCtx io_ctx,
rgw_bucket& bucket,
rgw_bucket_dir_entry& list_state,
RGWObjEnt& object,
bufferlist& suggested_updates)
{
rgw_obj obj;
- std::string oid, key;
- obj.init(bucket, list_state.name);
+ std::string oid, key, ns;
+ oid = list_state.name;
+ if (!rgw_obj::strip_namespace_from_object(oid, ns)) {
+ // well crap
+ assert(0 == "got bad object name off disk");
+ }
+ obj.init(bucket, oid, list_state.locator, ns);
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
+ io_ctx.locator_set_key(key);
int r = io_ctx.stat(oid, &object.size, &object.mtime);
list_state.pending_map.clear(); // we don't need this and it inflates size
* and -errno on other failures. (-ENOENT is not a failure, and it
* will encode that info as a suggested update.)
*/
- int check_disk_state(librados::IoCtx& io_ctx,
+ int check_disk_state(librados::IoCtx io_ctx,
rgw_bucket& bucket,
rgw_bucket_dir_entry& list_state,
RGWObjEnt& object,