Whamcloud - gitweb
LU-10467 osp: use wait_event_idle_timeout() 88/35988/10
authorMr NeilBrown <neilb@suse.de>
Wed, 28 Aug 2019 23:28:20 +0000 (09:28 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 10 Jan 2020 07:40:40 +0000 (07:40 +0000)
osp has 4 LWI_TIMEOUT() calls that pass an on_timeout
function.
In each case, the on_timeout function returns 1, so this
is equivalent to using wait_event_idle_timeout(), and
calling the function if the timeout happened.

One of the two functions passed does nothing except return 1, so it
can be ignored.
The other function, used only once, contains a CDEBUG message,
so we now call that when wait_event_idle_timeout() returns 0.

Change-Id: Ic153266e412d684c4aa6c7204ff5755d991d83c6
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/35988
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osp/osp_dev.c
lustre/osp/osp_precreate.c

index 94ce956..8be3bab 100644 (file)
@@ -779,11 +779,6 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev,
        RETURN(0);
 }
 
        RETURN(0);
 }
 
-static int osp_sync_timeout(void *data)
-{
-       return 1;
-}
-
 /**
  * Implementation of dt_device_operations::dt_sync
  *
 /**
  * Implementation of dt_device_operations::dt_sync
  *
@@ -799,7 +794,6 @@ static int osp_sync_timeout(void *data)
 static int osp_sync(const struct lu_env *env, struct dt_device *dev)
 {
        struct osp_device *d = dt2osp_dev(dev);
 static int osp_sync(const struct lu_env *env, struct dt_device *dev)
 {
        struct osp_device *d = dt2osp_dev(dev);
-       struct l_wait_info lwi = { 0 };
        time64_t start = ktime_get_seconds();
        int recs, rc = 0;
        u64 old;
        time64_t start = ktime_get_seconds();
        int recs, rc = 0;
        u64 old;
@@ -824,10 +818,15 @@ static int osp_sync(const struct lu_env *env, struct dt_device *dev)
               atomic_read(&d->opd_async_updates_count));
 
        /* make sure the connection is fine */
               atomic_read(&d->opd_async_updates_count));
 
        /* make sure the connection is fine */
-       lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout), osp_sync_timeout, d);
-       rc = l_wait_event(d->opd_sync_barrier_waitq,
-                         atomic_read(&d->opd_async_updates_count) == 0,
-                         &lwi);
+       rc = wait_event_idle_timeout(
+               d->opd_sync_barrier_waitq,
+               atomic_read(&d->opd_async_updates_count) == 0,
+               cfs_time_seconds(obd_timeout));
+       if (rc > 0)
+               rc = 0;
+       else if (rc == 0)
+               rc = -ETIMEDOUT;
+
        up_write(&d->opd_async_updates_rwsem);
        if (rc != 0)
                GOTO(out, rc);
        up_write(&d->opd_async_updates_rwsem);
        if (rc != 0)
                GOTO(out, rc);
@@ -838,11 +837,11 @@ static int osp_sync(const struct lu_env *env, struct dt_device *dev)
        while (atomic64_read(&d->opd_sync_processed_recs) < old + recs) {
                __u64 last = atomic64_read(&d->opd_sync_processed_recs);
                /* make sure the connection is fine */
        while (atomic64_read(&d->opd_sync_processed_recs) < old + recs) {
                __u64 last = atomic64_read(&d->opd_sync_processed_recs);
                /* make sure the connection is fine */
-               lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout),
-                                 osp_sync_timeout, d);
-               l_wait_event(d->opd_sync_barrier_waitq,
-                            atomic64_read(&d->opd_sync_processed_recs)
-                            >= old + recs, &lwi);
+               wait_event_idle_timeout(
+                       d->opd_sync_barrier_waitq,
+                       atomic64_read(&d->opd_sync_processed_recs)
+                            >= old + recs,
+                       cfs_time_seconds(obd_timeout));
 
                if (atomic64_read(&d->opd_sync_processed_recs) >= old + recs)
                        break;
 
                if (atomic64_read(&d->opd_sync_processed_recs) >= old + recs)
                        break;
@@ -870,11 +869,10 @@ static int osp_sync(const struct lu_env *env, struct dt_device *dev)
        while (atomic_read(&d->opd_sync_rpcs_in_flight) > 0) {
                old = atomic_read(&d->opd_sync_rpcs_in_flight);
 
        while (atomic_read(&d->opd_sync_rpcs_in_flight) > 0) {
                old = atomic_read(&d->opd_sync_rpcs_in_flight);
 
-               lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout),
-                                 osp_sync_timeout, d);
-               l_wait_event(d->opd_sync_barrier_waitq,
-                            atomic_read(&d->opd_sync_rpcs_in_flight) == 0,
-                            &lwi);
+               wait_event_idle_timeout(
+                       d->opd_sync_barrier_waitq,
+                       atomic_read(&d->opd_sync_rpcs_in_flight) == 0,
+                       cfs_time_seconds(obd_timeout));
 
                if (atomic_read(&d->opd_sync_rpcs_in_flight) == 0)
                        break;
 
                if (atomic_read(&d->opd_sync_rpcs_in_flight) == 0)
                        break;
index bf6c462..6e55a23 100644 (file)
@@ -1394,22 +1394,6 @@ static int osp_precreate_ready_condition(const struct lu_env *env,
        return 0;
 }
 
        return 0;
 }
 
-static int osp_precreate_timeout_condition(void *data)
-{
-       struct osp_device *d = data;
-
-       CDEBUG(D_HA, "%s: slow creates, last="DFID", next="DFID", "
-             "reserved=%llu, sync_changes=%u, "
-             "sync_rpcs_in_progress=%d, status=%d\n",
-             d->opd_obd->obd_name, PFID(&d->opd_pre_last_created_fid),
-             PFID(&d->opd_pre_used_fid), d->opd_pre_reserved,
-             atomic_read(&d->opd_sync_changes),
-             atomic_read(&d->opd_sync_rpcs_in_progress),
-             d->opd_pre_status);
-
-       return 1;
-}
-
 /**
  * Reserve object in precreate pool
  *
 /**
  * Reserve object in precreate pool
  *
@@ -1437,7 +1421,6 @@ static int osp_precreate_timeout_condition(void *data)
 int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d)
 {
        time64_t expire = ktime_get_seconds() + obd_timeout;
 int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d)
 {
        time64_t expire = ktime_get_seconds() + obd_timeout;
-       struct l_wait_info lwi;
        int precreated, rc, synced = 0;
 
        ENTRY;
        int precreated, rc, synced = 0;
 
        ENTRY;
@@ -1517,15 +1500,26 @@ int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d)
                /* XXX: don't wake up if precreation is in progress */
                wake_up(&d->opd_pre_waitq);
 
                /* XXX: don't wake up if precreation is in progress */
                wake_up(&d->opd_pre_waitq);
 
-               lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout),
-                                 osp_precreate_timeout_condition, d);
                if (ktime_get_seconds() >= expire) {
                        rc = -ETIMEDOUT;
                        break;
                }
 
                if (ktime_get_seconds() >= expire) {
                        rc = -ETIMEDOUT;
                        break;
                }
 
-               l_wait_event(d->opd_pre_user_waitq,
-                            osp_precreate_ready_condition(env, d), &lwi);
+               if (wait_event_idle_timeout(
+                           d->opd_pre_user_waitq,
+                           osp_precreate_ready_condition(env, d),
+                           cfs_time_seconds(obd_timeout)) == 0) {
+                       CDEBUG(D_HA,
+                              "%s: slow creates, last="DFID", next="DFID", "
+                              "reserved=%llu, sync_changes=%u, "
+                              "sync_rpcs_in_progress=%d, status=%d\n",
+                              d->opd_obd->obd_name,
+                              PFID(&d->opd_pre_last_created_fid),
+                              PFID(&d->opd_pre_used_fid), d->opd_pre_reserved,
+                              atomic_read(&d->opd_sync_changes),
+                              atomic_read(&d->opd_sync_rpcs_in_progress),
+                              d->opd_pre_status);
+               }
        }
 
        RETURN(rc);
        }
 
        RETURN(rc);