I was seeing failures of LibRBD.TestIOToSnapshot where we would fail to
refresh after rollback, even though the snap existed. I assume it is
because the std::string whose c_str() we were pointing to was reallocated.
Use a std::string here instead.
This code is weird.
Signed-off-by: Sage Weil <sage@newdream.net>
if (needs_refresh) {
Mutex::Locker l(ictx->lock);
- const char *snap = NULL;
+
+ string snap;
if (ictx->snapid != CEPH_NOSNAP)
- snap = ictx->snapname.c_str();
+ snap = ictx->snapname;
- int r = ictx_refresh(ictx, snap);
+ int r = ictx_refresh(ictx, snap.length() ? snap.c_str() : NULL);
if (r < 0) {
lderr(cct) << "Error re-reading rbd header: " << cpp_strerror(-r) << dendl;
return r;
}
// check if the snapshot at which we were reading was removed
- if (snap && ictx->snapname != snap) {
+ if (ictx->snapname != snap) {
lderr(cct) << "tried to read from a snapshot that no longer exists: " << snap << dendl;
return -ENOENT;
}