From: Matt Benjamin Date: Tue, 22 Dec 2015 21:01:19 +0000 (-0500) Subject: librgw: move readdir operations into RGWFileHandle::readdir X-Git-Tag: v10.1.0~382^2~75 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7acb20d87743418951bf0221f5a77bd2f2641556;p=ceph.git librgw: move readdir operations into RGWFileHandle::readdir The motivation here is to localize state updates to the class, e.g., to hide consistency logic. Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 4dbb36559360..c4aa8b646afa 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -155,6 +155,35 @@ namespace rgw { return true; } /* RGWFileHandle::reclaim */ + int RGWFileHandle::readdir(rgw_readdir_cb rcb, void *cb_arg, uint64_t *offset, + bool *eof) + { + int rc = 0; + CephContext* cct = fs->get_context(); + if (is_root()) { + RGWListBucketsRequest req(cct, fs->get_user(), this, rcb, cb_arg, + offset); + rc = librgw.get_fe()->execute_req(&req); + if (! rc) { + lock_guard guard(mtx); + (void) clock_gettime(CLOCK_MONOTONIC_COARSE, &state.atime); + *eof = req.eof(); + } + } else { + // XXX finish marker handling + rgw_obj_key marker{"", ""}; + RGWReaddirRequest req(cct, fs->get_user(), this, rcb, cb_arg, offset); + rc = librgw.get_fe()->execute_req(&req); + if (! rc) { + lock_guard guard(mtx); + /* XXX update link count (incorrectly) */ + parent->set_nlink(3 + *offset); + *eof = req.eof(); + } + } + return rc; + } /* RGWFileHandle::readdir */ + int RGWFileHandle::write(uint64_t off, size_t len, size_t *bytes_written, void *buffer) { @@ -867,39 +896,13 @@ int rgw_readdir(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh, uint64_t *offset, rgw_readdir_cb rcb, void *cb_arg, bool *eof) { - int rc; - - RGWLibFS *fs = static_cast(rgw_fs->fs_private); - CephContext* cct = static_cast(rgw_fs->rgw); - - /* TODO: - * deal with markers (continuation) - * deal with authorization - * consider non-default tenancy/user and bucket layouts - */ RGWFileHandle* parent = get_rgwfh(parent_fh); if (! parent) { /* bad parent */ return -EINVAL; } - - if (parent->is_root()) { - RGWListBucketsRequest req(cct, fs->get_user(), parent, rcb, cb_arg, offset); - rc = librgw.get_fe()->execute_req(&req); - } else { - // XXX finish marker handling - rgw_obj_key marker{"", ""}; - RGWReaddirRequest req(cct, fs->get_user(), parent, rcb, cb_arg, offset); - rc = librgw.get_fe()->execute_req(&req); - - /* XXX update link count (incorrectly) */ - parent->set_nlink(3 + *offset); - } - - /* XXXX request MUST set this */ - *eof = true; // XXX move into RGGWListBucket(s)Request - - return rc; + int rc = parent->readdir(rcb, cb_arg, offset, eof); + return -rc; } /* diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index d4eb03673dda..87cbfbf43099 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -404,6 +404,7 @@ namespace rgw { return EPERM; } + int readdir(rgw_readdir_cb rcb, void *cb_arg, uint64_t *offset, bool *eof); int write(uint64_t off, size_t len, size_t *nbytes, void *buffer); int write_finish(); int close();