From 1a7faefd035aa8f31ab11ddfe1046989d0e69aac Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 21 Sep 2016 17:18:20 -0400 Subject: [PATCH] rgw_file: pre-assign times Set unix timestamps based on RGW values for creation, modification time for buckets, objects in stat requests. Regard any saved value of these in unix attributes as an overlay. Fixes: http://tracker.ceph.com/issues/17367 Signed-off-by: Matt Benjamin (cherry picked from commit 969750e96380859a350e25015bc8cbf9bdf88512) Fixes: http://tracker.ceph.com/issues/17394 --- src/rgw/rgw_file.cc | 5 +++-- src/rgw/rgw_file.h | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 4f513c9152a14..69f6b708edd9e 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -59,6 +59,7 @@ namespace rgw { RGWFileHandle::FLAG_BUCKET); if (get<0>(fhr)) { RGWFileHandle* rgw_fh = get<0>(fhr); + rgw_fh->set_times(req.get_ctime()); /* restore attributes */ auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1); auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1); @@ -122,7 +123,7 @@ namespace rgw { if (get<0>(fhr)) { RGWFileHandle* rgw_fh = get<0>(fhr); rgw_fh->set_size(req.get_size()); - rgw_fh->set_mtime(real_clock::to_timespec(req.get_mtime())); + rgw_fh->set_times(req.get_mtime()); /* restore attributes */ auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1); auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1); @@ -148,7 +149,7 @@ namespace rgw { if (get<0>(fhr)) { RGWFileHandle* rgw_fh = get<0>(fhr); rgw_fh->set_size(req.get_size()); - rgw_fh->set_mtime(real_clock::to_timespec(req.get_mtime())); + rgw_fh->set_times(req.get_mtime()); /* restore attributes */ auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1); auto ux_attrs = req.get_attr(RGW_ATTR_UNIX1); diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 47435a43469f5..71439ce6fa5ba 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -1803,6 +1803,10 @@ public: return (iter != attrs.end()) ? &(iter->second) : nullptr; } + real_time get_ctime() const { + return bucket.creation_time; + } + virtual bool only_bucket() { return false; } virtual int op_init() { @@ -1835,10 +1839,6 @@ public: return 0; } - real_time get_ctime() const { - return bucket.creation_time; - } - virtual int get_params() { return 0; } -- 2.39.5