summaryrefslogtreecommitdiffstats
path: root/src/libradosstriper/RadosStriperImpl.cc
diff options
context:
space:
mode:
authorSebastien Ponce <sebastien.ponce@cern.ch>2016-05-10 11:27:59 +0200
committerroot <root@lxbre43a05.cern.ch>2016-11-01 16:36:05 +0100
commit7cce1e8c51640f466d8bb37a21c0d5f1b00db8ab (patch)
treec4e259514ee3d936fe0f5628442c1cf7a75bb540 /src/libradosstriper/RadosStriperImpl.cc
parentradosstriper : optimized truncation and removal of striped objects (diff)
downloadceph-7cce1e8c51640f466d8bb37a21c0d5f1b00db8ab.tar.xz
ceph-7cce1e8c51640f466d8bb37a21c0d5f1b00db8ab.zip
radosstriper : protect aio_write API from calls with 0 bytes
an assertion was failing so far, while we only have to return without doing anything Signed-off-by: Sebastien Ponce <sebastien.ponce@cern.ch>
Diffstat (limited to '')
-rw-r--r--src/libradosstriper/RadosStriperImpl.cc56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/libradosstriper/RadosStriperImpl.cc b/src/libradosstriper/RadosStriperImpl.cc
index d33aa522c30..8c0d8ec36f8 100644
--- a/src/libradosstriper/RadosStriperImpl.cc
+++ b/src/libradosstriper/RadosStriperImpl.cc
@@ -880,33 +880,37 @@ libradosstriper::RadosStriperImpl::internal_aio_write(const std::string& soid,
uint64_t off,
const ceph_file_layout& layout)
{
- // get list of extents to be written to
- vector<ObjectExtent> extents;
- std::string format = soid + RADOS_OBJECT_EXTENSION_FORMAT;
- file_layout_t l;
- l.from_legacy(layout);
- Striper::file_to_extents(cct(), format.c_str(), &l, off, len, 0, extents);
- // go through the extents
int r = 0;
- for (vector<ObjectExtent>::iterator p = extents.begin(); p != extents.end(); ++p) {
- // assemble pieces of a given object into a single buffer list
- bufferlist oid_bl;
- for (vector<pair<uint64_t,uint64_t> >::iterator q = p->buffer_extents.begin();
- q != p->buffer_extents.end();
- ++q) {
- bufferlist buffer_bl;
- buffer_bl.substr_of(bl, q->first, q->second);
- oid_bl.append(buffer_bl);
- }
- // and write the object
- c->add_request();
- librados::AioCompletion *rados_completion =
- m_radosCluster.aio_create_completion(c, rados_req_write_complete, rados_req_write_safe);
- r = m_ioCtx.aio_write(p->oid.name, rados_completion, oid_bl, p->length, p->offset);
- rados_completion->release();
- if (r < 0)
- break;
- }
+ // Do not try anything if we are called with empty buffer,
+ // file_to_extents would raise an exception
+ if (len > 0) {
+ // get list of extents to be written to
+ vector<ObjectExtent> extents;
+ std::string format = soid + RADOS_OBJECT_EXTENSION_FORMAT;
+ file_layout_t l;
+ l.from_legacy(layout);
+ Striper::file_to_extents(cct(), format.c_str(), &l, off, len, 0, extents);
+ // go through the extents
+ for (vector<ObjectExtent>::iterator p = extents.begin(); p != extents.end(); ++p) {
+ // assemble pieces of a given object into a single buffer list
+ bufferlist oid_bl;
+ for (vector<pair<uint64_t,uint64_t> >::iterator q = p->buffer_extents.begin();
+ q != p->buffer_extents.end();
+ ++q) {
+ bufferlist buffer_bl;
+ buffer_bl.substr_of(bl, q->first, q->second);
+ oid_bl.append(buffer_bl);
+ }
+ // and write the object
+ c->add_request();
+ librados::AioCompletion *rados_completion =
+ m_radosCluster.aio_create_completion(c, rados_req_write_complete, rados_req_write_safe);
+ r = m_ioCtx.aio_write(p->oid.name, rados_completion, oid_bl, p->length, p->offset);
+ rados_completion->release();
+ if (r < 0)
+ break;
+ }
+ }
c->finish_adding_requests();
return r;
}