return num;
}
- int init_rbd_info(struct rbd_info *info)
- {
- memset(info, 0, sizeof(*info));
- return 0;
- }
-
void trim_image(ImageCtx *ictx, uint64_t newsize, ProgressContext& prog_ctx)
{
assert(ictx->owner_lock.is_locked());
}
}
- int read_rbd_info(IoCtx& io_ctx, const string& info_oid,
- struct rbd_info *info)
- {
- int r;
- bufferlist bl;
- r = io_ctx.read(info_oid, bl, sizeof(*info), 0);
- if (r < 0)
- return r;
- if (r == 0) {
- return init_rbd_info(info);
- }
-
- if (r < (int)sizeof(*info))
- return -EIO;
-
- memcpy(info, bl.c_str(), r);
- return 0;
- }
-
int read_header_bl(IoCtx& io_ctx, const string& header_oid,
bufferlist& header, uint64_t *ver)
{
return 0;
}
- int write_header(IoCtx& io_ctx, const string& header_oid, bufferlist& header)
- {
- bufferlist bl;
- int r = io_ctx.write(header_oid, header, header.length(), 0);
-
- notify_change(io_ctx, header_oid, NULL);
-
- return r;
- }
-
int tmap_set(IoCtx& io_ctx, const string& imgname)
{
bufferlist cmdbl, emptybl;
return r;
}
- int simple_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
- {
- char *dest_buf = (char *)arg;
- if (buf)
- memcpy(dest_buf + ofs, buf, len);
- else
- memset(dest_buf + ofs, 0, len);
-
- return 0;
- }
-
ssize_t read(ImageCtx *ictx, uint64_t ofs, size_t len, char *buf, int op_flags)
{
ssize_t ret;
return mylen;
}
- ssize_t handle_sparse_read(CephContext *cct,
- bufferlist data_bl,
- uint64_t block_ofs,
- const map<uint64_t, uint64_t> &data_map,
- uint64_t buf_ofs, // offset into buffer
- size_t buf_len, // length in buffer (not size of buffer!)
- char *dest_buf)
- {
- uint64_t bl_ofs = 0;
- size_t buf_left = buf_len;
-
- for (map<uint64_t, uint64_t>::const_iterator iter = data_map.begin();
- iter != data_map.end();
- ++iter) {
- uint64_t extent_ofs = iter->first;
- size_t extent_len = iter->second;
-
- ldout(cct, 10) << "extent_ofs=" << extent_ofs
- << " extent_len=" << extent_len << dendl;
- ldout(cct, 10) << "block_ofs=" << block_ofs << dendl;
-
- /* a hole? */
- if (extent_ofs > block_ofs) {
- uint64_t gap = extent_ofs - block_ofs;
- ldout(cct, 10) << "<1>zeroing " << buf_ofs << "~" << gap << dendl;
- memset(dest_buf + buf_ofs, 0, gap);
-
- buf_ofs += gap;
- buf_left -= gap;
- block_ofs = extent_ofs;
- } else if (extent_ofs < block_ofs) {
- assert(0 == "osd returned data prior to what we asked for");
- return -EIO;
- }
-
- if (bl_ofs + extent_len > (buf_ofs + buf_left)) {
- assert(0 == "osd returned more data than we asked for");
- return -EIO;
- }
-
- /* data */
- ldout(cct, 10) << "<2>copying " << buf_ofs << "~" << extent_len
- << " from ofs=" << bl_ofs << dendl;
- memcpy(dest_buf + buf_ofs, data_bl.c_str() + bl_ofs, extent_len);
-
- bl_ofs += extent_len;
- buf_ofs += extent_len;
- assert(buf_left >= extent_len);
- buf_left -= extent_len;
- block_ofs += extent_len;
- }
-
- /* last hole */
- if (buf_left > 0) {
- ldout(cct, 10) << "<3>zeroing " << buf_ofs << "~" << buf_left << dendl;
- memset(dest_buf + buf_ofs, 0, buf_left);
- }
-
- return buf_len;
- }
-
void rados_req_cb(rados_completion_t c, void *arg)
{
AioRequest *req = reinterpret_cast<AioRequest *>(arg);
int open_image(ImageCtx *ictx);
int close_image(ImageCtx *ictx);
- int copyup_block(ImageCtx *ictx, uint64_t offset, size_t len,
- const char *buf);
int flatten(ImageCtx *ictx, ProgressContext &prog_ctx);
int rebuild_object_map(ImageCtx *ictx, ProgressContext &prog_ctx);
const std::string& cookie);
void trim_image(ImageCtx *ictx, uint64_t newsize, ProgressContext& prog_ctx);
- int read_rbd_info(librados::IoCtx& io_ctx, const std::string& info_oid,
- struct rbd_info *info);
int read_header_bl(librados::IoCtx& io_ctx, const std::string& md_oid,
ceph::bufferlist& header, uint64_t *ver);
ImageCtx *ictx);
int read_header(librados::IoCtx& io_ctx, const std::string& md_oid,
struct rbd_obj_header_ondisk *header, uint64_t *ver);
- int write_header(librados::IoCtx& io_ctx, const std::string& md_oid,
- ceph::bufferlist& header);
int tmap_set(librados::IoCtx& io_ctx, const std::string& imgname);
int tmap_rm(librados::IoCtx& io_ctx, const std::string& imgname);
void rollback_object(ImageCtx *ictx, uint64_t snap_id, const string& oid,
int rollback_image(ImageCtx *ictx, uint64_t snap_id,
ProgressContext& prog_ctx);
void image_info(const ImageCtx *ictx, image_info_t& info, size_t info_size);
- std::string get_block_oid(const std::string &object_prefix, uint64_t num,
- bool old_format);
uint64_t oid_to_object_no(const std::string& oid,
const std::string& object_prefix);
int clip_io(ImageCtx *ictx, uint64_t off, uint64_t *len);
- int init_rbd_info(struct rbd_info *info);
void init_rbd_header(struct rbd_obj_header_ondisk& ondisk,
uint64_t size, int order, uint64_t bid);
int metadata_set(ImageCtx *ictx, const std::string &key, const std::string &value);
int metadata_remove(ImageCtx *ictx, const std::string &key);
- ssize_t handle_sparse_read(CephContext *cct,
- ceph::bufferlist data_bl,
- uint64_t block_ofs,
- const std::map<uint64_t, uint64_t> &data_map,
- uint64_t buf_ofs,
- size_t buf_len,
- char *dest_buf);
-
AioCompletion *aio_create_completion();
AioCompletion *aio_create_completion(void *cb_arg, callback_t cb_complete);
AioCompletion *aio_create_completion_internal(void *cb_arg,
callback_t cb_complete);
// raw callbacks
- int simple_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg);
void rados_req_cb(rados_completion_t cb, void *arg);
void rados_ctx_cb(rados_completion_t cb, void *arg);
void rbd_req_cb(completion_t cb, void *arg);