// new object.
object_info_t oi(soid);
SnapSetContext *ssc = get_snapset_context(
- soid, true, 0);
+ soid, true, 0, false);
obc = create_object_context(oi, ssc);
dout(10) << __func__ << ": " << obc << " " << soid
<< " " << obc->rwstate
SnapSetContext *ReplicatedPG::get_snapset_context(
const hobject_t& oid,
bool can_create,
- map<string, bufferlist> *attrs)
+ map<string, bufferlist> *attrs,
+ bool oid_existed)
{
Mutex::Locker l(snapset_contexts_lock);
SnapSetContext *ssc;
} else {
bufferlist bv;
if (!attrs) {
- int r = pgbackend->objects_get_attr(oid.get_head(), SS_ATTR, &bv);
+ int r = -ENOENT;
+ if (!(oid.is_head() && !oid_existed))
+ r = pgbackend->objects_get_attr(oid.get_head(), SS_ATTR, &bv);
if (r < 0) {
// try _snapset
+ if (!(oid.is_snapdir() && !oid_existed))
r = pgbackend->objects_get_attr(oid.get_snapdir(), SS_ATTR, &bv);
if (r < 0 && !can_create)
return NULL;
SnapSetContext *get_snapset_context(
const hobject_t& oid,
bool can_create,
- map<string, bufferlist> *attrs = 0
+ map<string, bufferlist> *attrs = 0,
+ bool oid_existed = true //indicate this oid whether exsited in backend
);
void register_snapset_context(SnapSetContext *ssc) {
Mutex::Locker l(snapset_contexts_lock);