From 6cd51fecedd25837710c4a068440228e770a0bca Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 2 Oct 2012 15:22:34 -0700 Subject: [PATCH] librbd: remove callback from handle_sparse_read We always used simple_read_cb, so put it inline. Signed-off-by: Sage Weil --- src/librbd/AioCompletion.cc | 2 +- src/librbd/internal.cc | 21 ++++++--------------- src/librbd/internal.h | 3 +-- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/librbd/AioCompletion.cc b/src/librbd/AioCompletion.cc index d842adc28caa3..767b232a4d91a 100644 --- a/src/librbd/AioCompletion.cc +++ b/src/librbd/AioCompletion.cc @@ -44,7 +44,7 @@ namespace librbd { << " len=" << m_req->length() << dendl; r = handle_sparse_read(m_cct, m_req->data(), m_req->offset(), m_req->ext_map(), 0, m_req->length(), - simple_read_cb, m_out_buf); + m_out_buf); } m_completion->complete_request(m_cct, r); } diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index b06d0b4d78097..1629472957f1b 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -2239,10 +2239,8 @@ reprotect_and_return_err: const map &data_map, uint64_t buf_ofs, // offset into buffer size_t buf_len, // length in buffer (not size of buffer!) - int (*cb)(uint64_t, size_t, const char *, void *), - void *arg) + char *dest_buf) { - int r; uint64_t bl_ofs = 0; size_t buf_left = buf_len; @@ -2260,10 +2258,8 @@ reprotect_and_return_err: if (extent_ofs > block_ofs) { uint64_t gap = extent_ofs - block_ofs; ldout(cct, 10) << "<1>zeroing " << buf_ofs << "~" << gap << dendl; - r = cb(buf_ofs, gap, NULL, arg); - if (r < 0) { - return r; - } + memset(dest_buf + buf_ofs, 0, gap); + buf_ofs += gap; buf_left -= gap; block_ofs = extent_ofs; @@ -2280,10 +2276,8 @@ reprotect_and_return_err: /* data */ ldout(cct, 10) << "<2>copying " << buf_ofs << "~" << extent_len << " from ofs=" << bl_ofs << dendl; - r = cb(buf_ofs, extent_len, data_bl.c_str() + bl_ofs, arg); - if (r < 0) { - return r; - } + 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); @@ -2294,10 +2288,7 @@ reprotect_and_return_err: /* last hole */ if (buf_left > 0) { ldout(cct, 10) << "<3>zeroing " << buf_ofs << "~" << buf_left << dendl; - r = cb(buf_ofs, buf_left, NULL, arg); - if (r < 0) { - return r; - } + memset(dest_buf + buf_ofs, 0, buf_left); } return buf_len; diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 231e214f8bf3a..c26c5086fdf91 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -185,8 +185,7 @@ namespace librbd { const std::map &data_map, uint64_t buf_ofs, size_t buf_len, - int (*cb)(uint64_t, size_t, const char *, void *), - void *arg); + char *dest_buf); AioCompletion *aio_create_completion(); AioCompletion *aio_create_completion(void *cb_arg, callback_t cb_complete); -- 2.39.5