#include "librbd/image/DetachParentRequest.h"
#include "librbd/Types.h"
#include "librbd/io/ObjectRequest.h"
+#include "librbd/io/Utils.h"
#include "common/dout.h"
#include "common/errno.h"
#include <boost/lambda/bind.hpp>
class C_FlattenObject : public C_AsyncObjectThrottle<I> {
public:
C_FlattenObject(AsyncObjectThrottle<I> &throttle, I *image_ctx,
- ::SnapContext snapc, uint64_t object_no)
- : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_snapc(snapc),
+ IOContext io_context, uint64_t object_no)
+ : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_io_context(io_context),
m_object_no(object_no) {
}
}
}
- bufferlist bl;
- auto req = new io::ObjectWriteRequest<I>(&image_ctx, m_object_no, 0,
- std::move(bl), m_snapc, 0, {},
- this);
- if (!req->has_parent()) {
+ if (!io::util::trigger_copyup(
+ &image_ctx, m_object_no, m_io_context, this)) {
// stop early if the parent went away - it just means
// another flatten finished first or the image was resized
- delete req;
return 1;
}
- req->send();
return 0;
}
private:
- ::SnapContext m_snapc;
+ IOContext m_io_context;
uint64_t m_object_no;
};
&FlattenRequest<I>::handle_flatten_objects>(this);
typename AsyncObjectThrottle<I>::ContextFactory context_factory(
boost::lambda::bind(boost::lambda::new_ptr<C_FlattenObject<I> >(),
- boost::lambda::_1, &image_ctx, m_snapc, boost::lambda::_2));
+ boost::lambda::_1, &image_ctx, image_ctx.get_data_io_context(),
+ boost::lambda::_2));
AsyncObjectThrottle<I> *throttle = new AsyncObjectThrottle<I>(
this, image_ctx, context_factory, ctx, &m_prog_ctx, 0, m_overlap_objects);
throttle->start_ops(