]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/internal: Modify read/write api to handle op flags.
authorJianpeng Ma <jianpeng.ma@intel.com>
Wed, 19 Nov 2014 01:52:32 +0000 (09:52 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Fri, 12 Dec 2014 06:23:34 +0000 (14:23 +0800)
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/librbd/AioRequest.cc
src/librbd/internal.cc
src/librbd/internal.h
src/librbd/librbd.cc

index 5cf9a11d3b53f69f25c0d5bf55246a44d259e92a..e03f67d52eeffaa3f6acafb6ef45273241a40c08 100644 (file)
@@ -49,7 +49,7 @@ namespace librbd {
                           << " extents " << image_extents
                           << dendl;
     aio_read(m_ictx->parent, image_extents, NULL, &m_read_data,
-            m_parent_completion);
+            m_parent_completion, 0);
   }
 
   /** read **/
index d84361721c08233ac4f7cde9f7f0b3b85737af62..093ef0c86a4ddcee53b580a6955959a9cbc5dfbe 100644 (file)
@@ -1939,7 +1939,7 @@ reprotect_and_return_err:
     cp->prog_ctx.update_progress(offset, cp->src_size);
     int ret = 0;
     if (buf) {
-      ret = write(cp->destictx, offset, len, buf);
+      ret = write(cp->destictx, offset, len, buf, 0);
     }
     return ret;
   }
@@ -2017,7 +2017,7 @@ reprotect_and_return_err:
 
       Context *ctx = new C_CopyWrite(m_throttle, m_bl);
       AioCompletion *comp = aio_create_completion_internal(ctx, rbd_ctx_cb);
-      r = aio_write(m_dest, m_offset, m_bl->length(), m_bl->c_str(), comp);
+      r = aio_write(m_dest, m_offset, m_bl->length(), m_bl->c_str(), comp, 0);
       if (r < 0) {
        ctx->complete(r);
        comp->release();
@@ -2060,7 +2060,7 @@ reprotect_and_return_err:
       bufferlist *bl = new bufferlist();
       Context *ctx = new C_CopyRead(&throttle, dest, offset, bl);
       AioCompletion *comp = aio_create_completion_internal(ctx, rbd_ctx_cb);
-      r = aio_read(src, offset, len, NULL, bl, comp);
+      r = aio_read(src, offset, len, NULL, bl, comp, 0);
       if (r < 0) {
        ctx->complete(r);
        comp->release();
@@ -2439,7 +2439,7 @@ reprotect_and_return_err:
 
       Context *ctx = new C_SafeCond(&mylock, &cond, &done, &ret);
       AioCompletion *c = aio_create_completion_internal(ctx, rbd_ctx_cb);
-      r = aio_read(ictx, off, read_len, NULL, &bl, c);
+      r = aio_read(ictx, off, read_len, NULL, &bl, c, 0);
       if (r < 0) {
        c->release();
        delete ctx;
@@ -2658,14 +2658,15 @@ reprotect_and_return_err:
     return 0;
   }
 
-  ssize_t read(ImageCtx *ictx, uint64_t ofs, size_t len, char *buf)
+  ssize_t read(ImageCtx *ictx, uint64_t ofs, size_t len, char *buf, int op_flags)
   {
     vector<pair<uint64_t,uint64_t> > extents;
     extents.push_back(make_pair(ofs, len));
-    return read(ictx, extents, buf, NULL);
+    return read(ictx, extents, buf, NULL, op_flags);
   }
 
-  ssize_t read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents, char *buf, bufferlist *pbl)
+  ssize_t read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents,
+               char *buf, bufferlist *pbl, int op_flags)
   {
     Mutex mylock("IoCtxImpl::write::mylock");
     Cond cond;
@@ -2674,7 +2675,7 @@ reprotect_and_return_err:
 
     Context *ctx = new C_SafeCond(&mylock, &cond, &done, &ret);
     AioCompletion *c = aio_create_completion_internal(ctx, rbd_ctx_cb);
-    int r = aio_read(ictx, image_extents, buf, pbl, c);
+    int r = aio_read(ictx, image_extents, buf, pbl, c, op_flags);
     if (r < 0) {
       c->release();
       delete ctx;
@@ -2689,7 +2690,7 @@ reprotect_and_return_err:
     return ret;
   }
 
-  ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf)
+  ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf, int op_flags)
   {
     utime_t start_time, elapsed;
     ldout(ictx->cct, 20) << "write " << ictx << " off = " << off << " len = "
@@ -2709,7 +2710,7 @@ reprotect_and_return_err:
 
     Context *ctx = new C_SafeCond(&mylock, &cond, &done, &ret);
     AioCompletion *c = aio_create_completion_internal(ctx, rbd_ctx_cb);
-    r = aio_write(ictx, off, mylen, buf, c);
+    r = aio_write(ictx, off, mylen, buf, c, op_flags);
     if (r < 0) {
       c->release();
       delete ctx;
@@ -2950,7 +2951,7 @@ reprotect_and_return_err:
   }
 
   int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
-               AioCompletion *c)
+               AioCompletion *c, int op_flags)
   {
     CephContext *cct = ictx->cct;
     ldout(cct, 20) << "aio_write " << ictx << " off = " << off << " len = "
@@ -3132,11 +3133,11 @@ reprotect_and_return_err:
 
   int aio_read(ImageCtx *ictx, uint64_t off, size_t len,
               char *buf, bufferlist *bl,
-              AioCompletion *c)
+              AioCompletion *c, int op_flags)
   {
     vector<pair<uint64_t,uint64_t> > image_extents(1);
     image_extents[0] = make_pair(off, len);
-    return aio_read(ictx, image_extents, buf, bl, c);
+    return aio_read(ictx, image_extents, buf, bl, c, op_flags);
   }
 
   struct C_RBD_Readahead : public Context {
@@ -3199,7 +3200,7 @@ reprotect_and_return_err:
   }
 
   int aio_read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents,
-              char *buf, bufferlist *pbl, AioCompletion *c)
+              char *buf, bufferlist *pbl, AioCompletion *c, int op_flags)
   {
     ldout(ictx->cct, 20) << "aio_read " << ictx << " completion " << c << " " << image_extents << dendl;
 
index 8990dea783712925a7393e3efc6088d8449aaba3..d9aa1b5ce9af8307bd2c912f1f1e8d7a7d93c831 100644 (file)
@@ -177,18 +177,18 @@ namespace librbd {
                   uint64_t off, uint64_t len,
                   int (*cb)(uint64_t, size_t, int, void *),
                   void *arg);
-  ssize_t read(ImageCtx *ictx, uint64_t off, size_t len, char *buf);
+  ssize_t read(ImageCtx *ictx, uint64_t off, size_t len, char *buf, int op_flags);
   ssize_t read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents,
-              char *buf, bufferlist *pbl);
-  ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf);
+              char *buf, bufferlist *pbl, int op_flags);
+  ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf, int op_flags);
   int discard(ImageCtx *ictx, uint64_t off, uint64_t len);
   int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
-               AioCompletion *c);
+               AioCompletion *c, int op_flags);
   int aio_discard(ImageCtx *ictx, uint64_t off, uint64_t len, AioCompletion *c);
   int aio_read(ImageCtx *ictx, uint64_t off, size_t len,
-              char *buf, bufferlist *pbl, AioCompletion *c);
+              char *buf, bufferlist *pbl, AioCompletion *c, int op_flags);
   int aio_read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents,
-              char *buf, bufferlist *pbl, AioCompletion *c);
+              char *buf, bufferlist *pbl, AioCompletion *c, int op_flags);
   int aio_flush(ImageCtx *ictx, AioCompletion *c);
   int flush(ImageCtx *ictx);
   int _flush(ImageCtx *ictx);
index 0dc4b650c403a6748b208c9b483dafb82bcce3c0..58870f1f1141af7d2772f307d67310cbee6bbd23 100644 (file)
@@ -591,7 +591,7 @@ namespace librbd {
     tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len);
     bufferptr ptr(len);
     bl.push_back(ptr);
-    int r = librbd::read(ictx, ofs, len, bl.c_str());
+    int r = librbd::read(ictx, ofs, len, bl.c_str(), 0);
     tracepoint(librbd, read_exit, r);
     return r;
   }
@@ -640,7 +640,7 @@ namespace librbd {
       tracepoint(librbd, write_exit, -EINVAL);
       return -EINVAL;
     }
-    int r = librbd::write(ictx, ofs, len, bl.c_str());
+    int r = librbd::write(ictx, ofs, len, bl.c_str(), 0);
     tracepoint(librbd, write_exit, r);
     return r;
   }
@@ -664,7 +664,7 @@ namespace librbd {
       return -EINVAL;
     }
     int r = librbd::aio_write(ictx, off, len, bl.c_str(),
-                            (librbd::AioCompletion *)c->pc);
+                            (librbd::AioCompletion *)c->pc, 0);
     tracepoint(librbd, aio_write_exit, r);
     return r;
   }
@@ -685,7 +685,7 @@ namespace librbd {
     tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, bl.c_str(), c->pc);
     ldout(ictx->cct, 10) << "Image::aio_read() buf=" << (void *)bl.c_str() << "~"
                         << (void *)(bl.c_str() + len - 1) << dendl;
-    int r = librbd::aio_read(ictx, off, len, NULL, &bl, (librbd::AioCompletion *)c->pc);
+    int r = librbd::aio_read(ictx, off, len, NULL, &bl, (librbd::AioCompletion *)c->pc, 0);
     tracepoint(librbd, aio_read_exit, r);
     return r;
   }
@@ -1416,7 +1416,7 @@ extern "C" ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len,
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len);
-  int r = librbd::read(ictx, ofs, len, buf);
+  int r = librbd::read(ictx, ofs, len, buf, 0);
   tracepoint(librbd, read_exit, r);
   return r;
 }
@@ -1463,7 +1463,7 @@ extern "C" ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len,
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len, buf);
-  int r = librbd::write(ictx, ofs, len, buf);
+  int r = librbd::write(ictx, ofs, len, buf, 0);
   tracepoint(librbd, write_exit, r);
   return r;
 }
@@ -1494,7 +1494,7 @@ extern "C" int rbd_aio_write(rbd_image_t image, uint64_t off, size_t len,
   librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
   tracepoint(librbd, aio_write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc);
   int r = librbd::aio_write(ictx, off, len, buf,
-                          (librbd::AioCompletion *)comp->pc);
+                          (librbd::AioCompletion *)comp->pc, 0);
   tracepoint(librbd, aio_write_exit, r);
   return r;
 }
@@ -1517,7 +1517,7 @@ extern "C" int rbd_aio_read(rbd_image_t image, uint64_t off, size_t len,
   librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
   tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc);
   int r = librbd::aio_read(ictx, off, len, buf, NULL,
-                         (librbd::AioCompletion *)comp->pc);
+                         (librbd::AioCompletion *)comp->pc, 0);
   tracepoint(librbd, aio_read_exit, r);
   return r;
 }