mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
rgw: fix check_disk_state; add a strip_namespace function.
Use copies of the IoCtx rather than references so that we can set locators without breaking stuff, and make use of the on-disk locators which we just added. Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
This commit is contained in:
parent
927c357725
commit
f57c33df48
@ -724,6 +724,35 @@ public:
|
||||
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);
|
||||
|
@ -2165,7 +2165,9 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, string start, uint32_t num, ma
|
||||
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;
|
||||
@ -2190,16 +2192,22 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, string start, uint32_t num, ma
|
||||
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
|
||||
|
@ -338,7 +338,7 @@ public:
|
||||
* 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,
|
||||
|
Loading…
Reference in New Issue
Block a user