mirror of
https://github.com/ceph/ceph
synced 2025-03-25 11:48:05 +00:00
Merge pull request #8380 from dillaman/wip-cls-fadvise
cls_rbd: pass WILLNEED fadvise flags during object map update Reviewed-by: Josh Durgin <jdurgin@redhat.com> Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
bf38318070
@ -2332,7 +2332,8 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
|
||||
|
||||
BitVector<2> object_map;
|
||||
bufferlist header_bl;
|
||||
r = cls_cxx_read(hctx, 0, object_map.get_header_length(), &header_bl);
|
||||
r = cls_cxx_read2(hctx, 0, object_map.get_header_length(), &header_bl,
|
||||
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
|
||||
if (r < 0) {
|
||||
CLS_ERR("object map header read failed");
|
||||
return r;
|
||||
@ -2347,8 +2348,9 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
|
||||
}
|
||||
|
||||
bufferlist footer_bl;
|
||||
r = cls_cxx_read(hctx, object_map.get_footer_offset(),
|
||||
size - object_map.get_footer_offset(), &footer_bl);
|
||||
r = cls_cxx_read2(hctx, object_map.get_footer_offset(),
|
||||
size - object_map.get_footer_offset(), &footer_bl,
|
||||
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
|
||||
if (r < 0) {
|
||||
CLS_ERR("object map footer read failed");
|
||||
return r;
|
||||
@ -2372,8 +2374,8 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
|
||||
&byte_offset, &byte_length);
|
||||
|
||||
bufferlist data_bl;
|
||||
r = cls_cxx_read(hctx, object_map.get_header_length() + byte_offset,
|
||||
byte_length, &data_bl);
|
||||
r = cls_cxx_read2(hctx, object_map.get_header_length() + byte_offset,
|
||||
byte_length, &data_bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
|
||||
if (r < 0) {
|
||||
CLS_ERR("object map data read failed");
|
||||
return r;
|
||||
@ -2386,7 +2388,7 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
|
||||
CLS_ERR("failed to decode data chunk [%" PRIu64 "]: %s",
|
||||
byte_offset, err.what());
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
bool updated = false;
|
||||
for (uint64_t object_no = start_object_no; object_no < end_object_no;
|
||||
@ -2407,21 +2409,22 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
|
||||
|
||||
bufferlist data_bl;
|
||||
object_map.encode_data(data_bl, byte_offset, byte_length);
|
||||
r = cls_cxx_write(hctx, object_map.get_header_length() + byte_offset,
|
||||
data_bl.length(), &data_bl);
|
||||
r = cls_cxx_write2(hctx, object_map.get_header_length() + byte_offset,
|
||||
data_bl.length(), &data_bl,
|
||||
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
|
||||
if (r < 0) {
|
||||
CLS_ERR("failed to write object map header: %s", cpp_strerror(r).c_str());
|
||||
return r;
|
||||
CLS_ERR("failed to write object map header: %s", cpp_strerror(r).c_str());
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
footer_bl.clear();
|
||||
object_map.encode_footer(footer_bl);
|
||||
r = cls_cxx_write(hctx, object_map.get_footer_offset(), footer_bl.length(),
|
||||
&footer_bl);
|
||||
r = cls_cxx_write2(hctx, object_map.get_footer_offset(), footer_bl.length(),
|
||||
&footer_bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
|
||||
if (r < 0) {
|
||||
CLS_ERR("failed to write object map footer: %s", cpp_strerror(r).c_str());
|
||||
CLS_ERR("failed to write object map footer: %s", cpp_strerror(r).c_str());
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CLS_LOG(20, "object_map_update: no update necessary");
|
||||
}
|
||||
|
@ -268,6 +268,12 @@ int cls_cxx_stat2(cls_method_context_t hctx, uint64_t *size, ceph::real_time *mt
|
||||
}
|
||||
|
||||
int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, bufferlist *outbl)
|
||||
{
|
||||
return cls_cxx_read2(hctx, ofs, len, outbl, 0);
|
||||
}
|
||||
|
||||
int cls_cxx_read2(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *outbl, uint32_t op_flags)
|
||||
{
|
||||
ReplicatedPG::OpContext **pctx = (ReplicatedPG::OpContext **)hctx;
|
||||
vector<OSDOp> ops(1);
|
||||
@ -275,6 +281,7 @@ int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, bufferlist *outbl)
|
||||
ops[0].op.op = CEPH_OSD_OP_SYNC_READ;
|
||||
ops[0].op.extent.offset = ofs;
|
||||
ops[0].op.extent.length = len;
|
||||
ops[0].op.flags = op_flags;
|
||||
ret = (*pctx)->pg->do_osd_ops(*pctx, ops);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -283,12 +290,19 @@ int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, bufferlist *outbl)
|
||||
}
|
||||
|
||||
int cls_cxx_write(cls_method_context_t hctx, int ofs, int len, bufferlist *inbl)
|
||||
{
|
||||
return cls_cxx_write2(hctx, ofs, len, inbl, 0);
|
||||
}
|
||||
|
||||
int cls_cxx_write2(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *inbl, uint32_t op_flags)
|
||||
{
|
||||
ReplicatedPG::OpContext **pctx = (ReplicatedPG::OpContext **)hctx;
|
||||
vector<OSDOp> ops(1);
|
||||
ops[0].op.op = CEPH_OSD_OP_WRITE;
|
||||
ops[0].op.extent.offset = ofs;
|
||||
ops[0].op.extent.length = len;
|
||||
ops[0].op.flags = op_flags;
|
||||
ops[0].indata = *inbl;
|
||||
return (*pctx)->pg->do_osd_ops(*pctx, ops);
|
||||
}
|
||||
|
@ -145,7 +145,11 @@ extern int cls_cxx_remove(cls_method_context_t hctx);
|
||||
extern int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime);
|
||||
extern int cls_cxx_stat2(cls_method_context_t hctx, uint64_t *size, ceph::real_time *mtime);
|
||||
extern int cls_cxx_read(cls_method_context_t hctx, int ofs, int len, bufferlist *bl);
|
||||
extern int cls_cxx_read2(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *bl, uint32_t op_flags);
|
||||
extern int cls_cxx_write(cls_method_context_t hctx, int ofs, int len, bufferlist *bl);
|
||||
extern int cls_cxx_write2(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *bl, uint32_t op_flags);
|
||||
extern int cls_cxx_write_full(cls_method_context_t hctx, bufferlist *bl);
|
||||
extern int cls_cxx_getxattr(cls_method_context_t hctx, const char *name,
|
||||
bufferlist *outbl);
|
||||
|
@ -1118,6 +1118,11 @@ int cls_cxx_map_set_vals(cls_method_context_t hctx,
|
||||
|
||||
int cls_cxx_read(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *outbl) {
|
||||
return cls_cxx_read2(hctx, ofs, len, outbl, 0);
|
||||
}
|
||||
|
||||
int cls_cxx_read2(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *outbl, uint32_t op_flags) {
|
||||
librados::TestClassHandler::MethodContext *ctx =
|
||||
reinterpret_cast<librados::TestClassHandler::MethodContext*>(hctx);
|
||||
return ctx->io_ctx_impl->read(ctx->oid, len, ofs, outbl);
|
||||
@ -1138,6 +1143,11 @@ int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime) {
|
||||
|
||||
int cls_cxx_write(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *inbl) {
|
||||
return cls_cxx_write2(hctx, ofs, len, inbl, 0);
|
||||
}
|
||||
|
||||
int cls_cxx_write2(cls_method_context_t hctx, int ofs, int len,
|
||||
bufferlist *inbl, uint32_t op_flags) {
|
||||
librados::TestClassHandler::MethodContext *ctx =
|
||||
reinterpret_cast<librados::TestClassHandler::MethodContext*>(hctx);
|
||||
return ctx->io_ctx_impl->write(ctx->oid, *inbl, len, ofs, ctx->snapc);
|
||||
|
Loading…
Reference in New Issue
Block a user