From 216e1efa8f12e113dbbb8f0ae2b00efe58cccac4 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 29 Aug 2019 09:28:20 +1000 Subject: [PATCH] LU-10467 osp: use wait_event_idle_timeout() 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 Reviewed-on: https://review.whamcloud.com/35988 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Petros Koutoupis Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lustre/osp/osp_dev.c | 38 ++++++++++++++++++-------------------- lustre/osp/osp_precreate.c | 36 +++++++++++++++--------------------- 2 files changed, 33 insertions(+), 41 deletions(-) diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 94ce956..8be3bab 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -779,11 +779,6 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev, RETURN(0); } -static int osp_sync_timeout(void *data) -{ - return 1; -} - /** * 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); - struct l_wait_info lwi = { 0 }; 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 */ - 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); @@ -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 */ - 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; @@ -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); - 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; diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index bf6c462..6e55a23 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -1394,22 +1394,6 @@ static int osp_precreate_ready_condition(const struct lu_env *env, 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 * @@ -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; - struct l_wait_info lwi; 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); - lwi = LWI_TIMEOUT(cfs_time_seconds(obd_timeout), - osp_precreate_timeout_condition, d); 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); -- 1.8.3.1