summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2012-12-17 13:00:30 -0800
committerDan Mick <dan.mick@inktank.com>2012-12-17 13:00:30 -0800
commitada79ed0644f76fbc40d5bd8df2ddeb7ac77580d (patch)
tree236b7241296d5194c165f8d736a96f8161d0e14d
parent7050351cfd7b8a81b705fc7821f971c438da6997 (diff)
downloadceph-ada79ed0644f76fbc40d5bd8df2ddeb7ac77580d.tar.gz
AioCompletion.cc: finalize(): allow and zero-pad short read.
Also assert that either read_buf is true or read_bl, but not both
-rw-r--r--src/librbd/AioCompletion.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librbd/AioCompletion.cc b/src/librbd/AioCompletion.cc
index 86b5b504ebd..03b9d9cd67a 100644
--- a/src/librbd/AioCompletion.cc
+++ b/src/librbd/AioCompletion.cc
@@ -40,11 +40,13 @@ namespace librbd {
bufferlist bl;
destriper.assemble_result(cct, bl, true);
+ // legal to have read_buf or read_bl, but not neither nor both
+ assert((read_buf != NULL) ^ (read_bl != NULL));
if (read_buf) {
- assert(bl.length() == read_buf_len);
- bl.copy(0, read_buf_len, read_buf);
- ldout(cct, 20) << "AioCompletion::finalize() copied resulting " << bl.length()
- << " bytes to " << (void*)read_buf << dendl;
+ // pad end with zeros if necessary
+ ldout(cct, 20) << "AioCompletion::finalize() zero-padding " << bl.length() << " with extra " << read_buf_len - bl.length() << " to " << (void*)read_buf << dendl;
+ bl.append_zero(read_buf_len - bl.length());
+ bl.copy(0, bl.length(), read_buf);
}
if (read_bl) {
ldout(cct, 20) << "AioCompletion::finalize() moving resulting " << bl.length()