56 op_data.ceph_read_op.read(offset, size, &buf.bl, &buf.rc);
74 for (
auto &op_data: operations) {
75 size_t obj_idx = op_data.first;
77 char object_suffix[18];
79 sp_bytes_written = snprintf(object_suffix,
sizeof(object_suffix),
".%016zx", obj_idx);
80 if (sp_bytes_written >= (
int)
sizeof(object_suffix)) {
81 log_func((
char*)
"Can not fit object suffix into buffer for file %s -- too big\n", file_ref->
name.c_str());
87 obj_name = file_ref->
name + std::string(object_suffix);
88 }
catch (std::bad_alloc&) {
89 log_func((
char*)
"Can not create object string for file %s)", file_ref->
name.c_str());
92 context->aio_operate(obj_name, op_data.second.cmpl.use(), &op_data.second.ceph_read_op, 0);
95 for (
auto &op_data: operations) {
96 op_data.second.cmpl.wait_for_complete();
97 int rval = op_data.second.cmpl.get_return_value();
107 log_func((
char*)
"Read of the object %ld for file %s failed", op_data.first, file_ref->
name.c_str());
159 log_func((
char*)
"Zero-length read request for file %s, probably client error", file_ref->
name.c_str());
163 char*
const buf_start_ptr = (
char*) out_buf;
167 size_t to_read = req_size;
169 size_t start_block = offset / object_size;
171 size_t chunk_start = offset % object_size;
173 while (to_read > 0) {
174 size_t chunk_len = std::min(to_read, object_size - chunk_start);
176 if (buf_pos >= req_size) {
177 log_func((
char*)
"Internal bug! Attempt to read %lu data for block (%lu, %lu) of file %s\n", buf_pos, offset, req_size, file_ref->
name.c_str());
181 int rc = addRequest(start_block, buf_start_ptr + buf_pos, chunk_len, chunk_start);
183 log_func((
char*)
"Unable to submit async read request, rc=%d\n", rc);
187 buf_pos += chunk_len;
191 if (chunk_len > to_read) {
192 log_func((
char*)
"Internal bug! Read %lu bytes, more than expected %lu bytes for block (%lu, %lu) of file %s\n", chunk_len, to_read, offset, req_size, file_ref->
name.c_str());
195 to_read = to_read - chunk_len;