]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: move internals of rgw_read into RGWLibFS::read(...)
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 7 Apr 2016 21:35:52 +0000 (17:35 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Apr 2016 20:10:44 +0000 (16:10 -0400)
Initially, all RGWRequest logic was open coded, but it's all
moving into RGWLibFS to get better encapsulation (e.g., for atomicity).

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 4c28867d2532fd3e18bff778c18c4856309f06f0..db59a59419b558717990ded54b76380902a1aa07 100644 (file)
@@ -145,6 +145,24 @@ namespace rgw {
     return fhr;
   } /* RGWLibFS::stat_leaf */
 
+  int RGWLibFS::read(RGWFileHandle* rgw_fh, uint64_t offset, size_t length,
+                    size_t* bytes_read, void* buffer, uint32_t flags)
+  {
+    if (! rgw_fh->is_file())
+      return -EINVAL;
+
+    RGWReadRequest req(get_context(), get_user(), rgw_fh, offset, length,
+                      buffer);
+
+    int rc = rgwlib.get_fe()->execute_req(&req);
+    if ((rc == 0) &&
+       (req.get_ret() == 0)) {
+      *bytes_read = req.nread;
+    }
+
+    return rc;
+  }
+
   int RGWLibFS::unlink(RGWFileHandle* parent, const char *name)
   {
     int rc = 0;
@@ -1083,22 +1101,10 @@ int rgw_read(struct rgw_fs *rgw_fs,
             size_t length, size_t *bytes_read, void *buffer,
             uint32_t flags)
 {
-  CephContext* cct = static_cast<CephContext*>(rgw_fs->rgw);
   RGWLibFS *fs = static_cast<RGWLibFS*>(rgw_fs->fs_private);
   RGWFileHandle* rgw_fh = get_rgwfh(fh);
 
-  if (! rgw_fh->is_file())
-    return -EINVAL;
-
-  RGWReadRequest req(cct, fs->get_user(), rgw_fh, offset, length, buffer);
-
-  int rc = rgwlib.get_fe()->execute_req(&req);
-  if ((rc == 0) &&
-      (req.get_ret() == 0)) {
-    *bytes_read = req.nread;
-  }
-
-  return rc;
+  return fs->read(rgw_fh, offset, length, bytes_read, buffer, flags);
 }
 
 /*
index aa580c63743c8b8087b8cc34032c5de2433da7a8..ec8bc97c6e84f964b2fe9afead1e30fb56194ee9 100644 (file)
@@ -857,6 +857,9 @@ namespace rgw {
     LookupFHResult stat_leaf(RGWFileHandle* parent, const char *path,
                             uint32_t flags);
 
+    int read(RGWFileHandle* rgw_fh, uint64_t offset, size_t length,
+            size_t* bytes_read, void* buffer, uint32_t flags);
+
     int rename(RGWFileHandle* old_fh, RGWFileHandle* new_fh,
               const char *old_name, const char *new_name);