Whamcloud - gitweb
LU-9019 osc: migrate to time64_t 63/30063/3
authorJames Simmons <uja.ornl@yahoo.com>
Tue, 21 Nov 2017 03:39:40 +0000 (22:39 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 17 Dec 2017 06:18:50 +0000 (06:18 +0000)
Change od_contention_time from int to time64_t to make it clear
this field is in units of seconds. With this change move the other
*_contention_time fields from jiffies to time64_t to avoid the
overhead of switching between the two different time formats.
Change ops_submit_time also to time64_t since using jiffies
doesn't gain us anything and having it in time64_t makes it clear
this is code related to time.

Change-Id: I97d3685ac61781e6b1dc8634bc105bb0ffe76aa0
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/30063
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_osc.h
lustre/mdc/lproc_mdc.c
lustre/osc/lproc_osc.c
lustre/osc/osc_cache.c
lustre/osc/osc_object.c
lustre/osc/osc_page.c

index 734566d..06d4499 100644 (file)
@@ -120,7 +120,7 @@ struct osc_device {
        } od_stats;
 
        /* configuration item(s) */
-       int                     od_contention_time;
+       time64_t                od_contention_time;
        int                     od_lockless_truncate;
 };
 
@@ -256,7 +256,7 @@ struct osc_object {
         * True if locking against this stripe got -EUSERS.
         */
        int                     oo_contended;
-       cfs_time_t              oo_contention_time;
+       time64_t                oo_contention_time;
 #ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
        /**
         * IO context used for invariant checks in osc_lock_has_pages().
@@ -358,7 +358,7 @@ static inline int osc_object_is_locked(struct osc_object *obj)
 
 static inline void osc_object_set_contended(struct osc_object *obj)
 {
-       obj->oo_contention_time = cfs_time_current();
+       obj->oo_contention_time = ktime_get_seconds();
        /* mb(); */
        obj->oo_contended = 1;
 }
@@ -541,7 +541,7 @@ struct osc_page {
        /**
         * Submit time - the time when the page is starting RPC. For debugging.
         */
-       cfs_time_t              ops_submit_time;
+       time64_t                ops_submit_time;
 };
 
 struct osc_brw_async_args {
index cf37467..3c9d67c 100644 (file)
@@ -190,7 +190,7 @@ static int mdc_contention_seconds_seq_show(struct seq_file *m, void *v)
        struct obd_device *obd = m->private;
        struct osc_device *od  = obd2osc_dev(obd);
 
-       seq_printf(m, "%u\n", od->od_contention_time);
+       seq_printf(m, "%lld\n", od->od_contention_time);
        return 0;
 }
 
index 40b2e5f..b999f53 100644 (file)
@@ -508,7 +508,7 @@ static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
        struct obd_device *obd = m->private;
        struct osc_device *od  = obd2osc_dev(obd);
 
-       seq_printf(m, "%u\n", od->od_contention_time);
+       seq_printf(m, "%lld\n", od->od_contention_time);
        return 0;
 }
 
index f94f053..751938c 100644 (file)
@@ -1286,7 +1286,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
        ENTRY;
        result = cl_page_make_ready(env, page, CRT_WRITE);
        if (result == 0)
-               opg->ops_submit_time = cfs_time_current();
+               opg->ops_submit_time = ktime_get_seconds();
        RETURN(result);
 }
 
index 4f4e8ac..025e68a 100644 (file)
@@ -308,10 +308,9 @@ drop_lock:
 
 int osc_object_is_contended(struct osc_object *obj)
 {
-        struct osc_device *dev  = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
-        int osc_contention_time = dev->od_contention_time;
-        cfs_time_t cur_time     = cfs_time_current();
-        cfs_time_t retry_time;
+       struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
+       time64_t osc_contention_time = dev->od_contention_time;
+       time64_t retry_time;
 
         if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
                 return 1;
@@ -319,17 +318,16 @@ int osc_object_is_contended(struct osc_object *obj)
         if (!obj->oo_contended)
                 return 0;
 
-        /*
-         * I like copy-paste. the code is copied from
-         * ll_file_is_contended.
-         */
-        retry_time = cfs_time_add(obj->oo_contention_time,
-                                  cfs_time_seconds(osc_contention_time));
-        if (cfs_time_after(cur_time, retry_time)) {
-                osc_object_clear_contended(obj);
-                return 0;
-        }
-        return 1;
+       /*
+        * I like copy-paste. the code is copied from
+        * ll_file_is_contended.
+        */
+       retry_time = obj->oo_contention_time + osc_contention_time;
+       if (ktime_get_seconds() > retry_time) {
+               osc_object_clear_contended(obj);
+               return 0;
+       }
+       return 1;
 }
 EXPORT_SYMBOL(osc_object_is_contended);
 
index 81d0c52..2681660 100644 (file)
@@ -119,12 +119,12 @@ static const char *osc_list(struct list_head *head)
        return list_empty(head) ? "-" : "+";
 }
 
-static inline cfs_time_t osc_submit_duration(struct osc_page *opg)
+static inline time64_t osc_submit_duration(struct osc_page *opg)
 {
-        if (opg->ops_submit_time == 0)
-                return 0;
+       if (opg->ops_submit_time == 0)
+               return 0;
 
-        return (cfs_time_current() - opg->ops_submit_time);
+       return ktime_get_seconds() - opg->ops_submit_time;
 }
 
 static int osc_page_print(const struct lu_env *env,
@@ -139,7 +139,7 @@ static int osc_page_print(const struct lu_env *env,
        return (*printer)(env, cookie, LUSTRE_OSC_NAME"-page@%p %lu: "
                          "1< %#x %d %u %s %s > "
                          "2< %lld %u %u %#x %#x | %p %p %p > "
-                         "3< %d %lu %d > "
+                         "3< %d %lld %d > "
                          "4< %d %d %d %lu %s | %s %s %s %s > "
                          "5< %s %s %s %s | %d %s | %d %s %s>\n",
                          opg, osc_index(opg),
@@ -327,7 +327,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
                oap->oap_cmd |= OBD_BRW_NOQUOTA;
        }
 
-       opg->ops_submit_time = cfs_time_current();
+       opg->ops_submit_time = ktime_get_seconds();
        osc_page_transfer_get(opg, "transfer\0imm");
        osc_page_transfer_add(env, opg, crt);
 }