mirror of
https://github.com/ceph/ceph
synced 2025-03-29 23:09:47 +00:00
osd/MemStore: handle collection_move_rename within the same collection
Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
ad4a4e1346
commit
a2594a5472
@ -1375,19 +1375,37 @@ int MemStore::_collection_move_rename(coll_t oldcid, const ghobject_t& oldoid,
|
||||
CollectionRef oc = get_collection(oldcid);
|
||||
if (!oc)
|
||||
return -ENOENT;
|
||||
RWLock::WLocker l1(MIN(c, oc)->lock);
|
||||
RWLock::WLocker l2(MAX(c, oc)->lock);
|
||||
|
||||
// note: c and oc may be the same
|
||||
if (&(*c) == &(*oc)) {
|
||||
c->lock.get_write();
|
||||
} else if (&(*c) < &(*oc)) {
|
||||
c->lock.get_write();
|
||||
oc->lock.get_write();
|
||||
} else if (&(*c) > &(*oc)) {
|
||||
oc->lock.get_write();
|
||||
c->lock.get_write();
|
||||
}
|
||||
|
||||
int r = -EEXIST;
|
||||
if (c->object_hash.count(oid))
|
||||
return -EEXIST;
|
||||
goto out;
|
||||
r = -ENOENT;
|
||||
if (oc->object_hash.count(oldoid) == 0)
|
||||
return -ENOENT;
|
||||
ObjectRef o = oc->object_hash[oldoid];
|
||||
c->object_map[oid] = o;
|
||||
c->object_hash[oid] = o;
|
||||
oc->object_map.erase(oldoid);
|
||||
oc->object_hash.erase(oldoid);
|
||||
return 0;
|
||||
goto out;
|
||||
{
|
||||
ObjectRef o = oc->object_hash[oldoid];
|
||||
c->object_map[oid] = o;
|
||||
c->object_hash[oid] = o;
|
||||
oc->object_map.erase(oldoid);
|
||||
oc->object_hash.erase(oldoid);
|
||||
}
|
||||
r = 0;
|
||||
out:
|
||||
c->lock.put_write();
|
||||
if (c != oc)
|
||||
oc->lock.put_write();
|
||||
return r;
|
||||
}
|
||||
|
||||
int MemStore::_collection_setattr(coll_t cid, const char *name,
|
||||
|
Loading…
Reference in New Issue
Block a user