From: Matt Benjamin Date: Thu, 7 Apr 2016 21:35:52 +0000 (-0400) Subject: rgw_file: move internals of rgw_read into RGWLibFS::read(...) X-Git-Tag: v10.2.0~8^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2dbefba0d8460175b018bcdd0149b31d09059bc4;p=ceph.git rgw_file: move internals of rgw_read into RGWLibFS::read(...) 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 --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 4c28867d2532..db59a59419b5 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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(rgw_fs->rgw); RGWLibFS *fs = static_cast(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); } /* diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index aa580c63743c..ec8bc97c6e84 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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);