]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lc: [non-functional change] use const expr to represent seconds in a day
authorOguzhan Ozmen <oozmen@bloomberg.net>
Wed, 22 Nov 2023 20:32:20 +0000 (15:32 -0500)
committerMykola Golub <mgolub@suse.com>
Tue, 12 Dec 2023 11:55:52 +0000 (13:55 +0200)
Signed-off-by: Oguzhan Ozmen <oozmen@bloomberg.net>
(cherry picked from commit b3afae981a389118abf1557ab6eb237be21bc157)

Conflicts:
src/rgw/rgw_lc.cc (allow_shard_rollover is not here,
        It was added in 0ecc2b8fc07011c77ef99d09b9c3f12bf4c5d9b4,
        so when it is eventually backported we will miss this change,
        but it does not introduce an issue, as it is just a
        replacement of 24*60*60 with secs_in_a_day constant)

src/rgw/rgw_lc.cc

index 798032c8fe4038b9440da7d2a3022d178f88f386..3bcae4fbd0a925bc8f0bd0848bb6bbfc0ee9642e 100644 (file)
@@ -45,6 +45,9 @@
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
+constexpr int32_t hours_in_a_day = 24;
+constexpr int32_t secs_in_a_day = hours_in_a_day * 60 * 60;
+
 using namespace std;
 
 const char* LC_STATUS[] = {
@@ -351,7 +354,7 @@ static bool obj_has_expired(const DoutPrefixProvider *dpp, CephContext *cct, cep
   utime_t base_time;
   if (cct->_conf->rgw_lc_debug_interval <= 0) {
     /* Normal case, run properly */
-    cmp = double(days)*24*60*60;
+    cmp = double(days) * secs_in_a_day;
     base_time = ceph_clock_now().round_to_day();
   } else {
     /* We're in debug mode; Treat each rgw_lc_debug_interval seconds as a day */
@@ -2035,8 +2038,7 @@ int RGWLC::process(LCWorker* worker,
 bool RGWLC::expired_session(time_t started)
 {
   time_t interval = (cct->_conf->rgw_lc_debug_interval > 0)
-    ? cct->_conf->rgw_lc_debug_interval
-    : 24*60*60;
+    ? cct->_conf->rgw_lc_debug_interval : secs_in_a_day;
 
   auto now = time(nullptr);
 
@@ -2052,8 +2054,7 @@ bool RGWLC::expired_session(time_t started)
 time_t RGWLC::thread_stop_at()
 {
   uint64_t interval = (cct->_conf->rgw_lc_debug_interval > 0)
-    ? cct->_conf->rgw_lc_debug_interval
-    : 24*60*60;
+    ? cct->_conf->rgw_lc_debug_interval : secs_in_a_day;
 
   return time(nullptr) + interval;
 }
@@ -2353,7 +2354,7 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
   nt = mktime(&bdt);
   secs = nt - tt;
 
-  return secs>0 ? secs : secs+24*60*60;
+  return secs > 0 ? secs : secs + secs_in_a_day;
 }
 
 RGWLC::LCWorker::~LCWorker()
@@ -2639,7 +2640,7 @@ std::string s3_expiration_header(
       if (rule_expiration.has_days()) {
        rule_expiration_date =
          boost::optional<ceph::real_time>(
-           mtime + make_timespan(double(rule_expiration.get_days())*24*60*60 - ceph::real_clock::to_time_t(mtime)%(24*60*60) + 24*60*60));
+           mtime + make_timespan(double(rule_expiration.get_days()) * secs_in_a_day - ceph::real_clock::to_time_t(mtime)%(secs_in_a_day) + secs_in_a_day));
       }
     }
 
@@ -2718,7 +2719,7 @@ bool s3_multipart_abort_header(
     std::optional<ceph::real_time> rule_abort_date;
     if (mp_expiration.has_days()) {
       rule_abort_date = std::optional<ceph::real_time>(
-              mtime + make_timespan(mp_expiration.get_days()*24*60*60 - ceph::real_clock::to_time_t(mtime)%(24*60*60) + 24*60*60));
+              mtime + make_timespan(mp_expiration.get_days() * secs_in_a_day - ceph::real_clock::to_time_t(mtime)%(secs_in_a_day) + secs_in_a_day));
     }
 
     // update earliest abort date