From 79d51f6c1d9f04aac3e7cbbedadf43a72520d424 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 26 Aug 2019 15:59:07 +1000 Subject: [PATCH] LU-10467 lustre: use l_wait_event_abortable where appropriate. If the lwi passed to l_wait_event() was created with lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); the effect is to wait with no timeout and blocking any non-fatal signals. For this, we now have l_wait_event_abortable(), or for one case l_wait_event_abortable_exclusive(); So use those. l_wait_event_abortable() will return -ERESTARTSYS if a signal was received, while l_wait_event() returens -EINTR. We need to be careful to handle this difference. Signed-off-by: Mr NeilBrown Change-Id: Iadf0fab92fcfd46802766198dcbe6b6b349214fa Reviewed-on: https://review.whamcloud.com/35975 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Sebastien Buisson Reviewed-by: Alex Zhuravlev Reviewed-by: Petros Koutoupis Reviewed-by: Oleg Drokin --- lustre/llite/llite_lib.c | 9 ++++----- lustre/obdclass/genops.c | 10 ++++------ lustre/obdclass/llog_obd.c | 5 ++--- lustre/osc/osc_page.c | 11 ++++++----- lustre/osc/osc_request.c | 9 ++++----- lustre/ptlrpc/import.c | 7 +++---- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index e384d64..240fad2 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1231,14 +1231,13 @@ void ll_put_super(struct super_block *sb) /* Wait for unstable pages to be committed to stable storage */ if (force == 0) { - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); - rc = l_wait_event(sbi->ll_cache->ccc_unstable_waitq, - atomic_long_read(&sbi->ll_cache->ccc_unstable_nr) == 0, - &lwi); + rc = l_wait_event_abortable( + sbi->ll_cache->ccc_unstable_waitq, + atomic_long_read(&sbi->ll_cache->ccc_unstable_nr) == 0); } ccc_count = atomic_long_read(&sbi->ll_cache->ccc_unstable_nr); - if (force == 0 && rc != -EINTR) + if (force == 0 && rc != -ERESTARTSYS) LASSERTF(ccc_count == 0, "count: %li\n", ccc_count); /* We need to set force before the lov_disconnect in diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 092ed77..2c822cb 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1990,7 +1990,6 @@ static bool obd_request_slot_avail(struct client_obd *cli, int obd_get_request_slot(struct client_obd *cli) { struct obd_request_slot_waiter orsw; - struct l_wait_info lwi; int rc; spin_lock(&cli->cl_loi_list_lock); @@ -2005,11 +2004,9 @@ int obd_get_request_slot(struct client_obd *cli) orsw.orsw_signaled = false; spin_unlock(&cli->cl_loi_list_lock); - lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); - rc = l_wait_event(orsw.orsw_waitq, - obd_request_slot_avail(cli, &orsw) || - orsw.orsw_signaled, - &lwi); + rc = l_wait_event_abortable(orsw.orsw_waitq, + obd_request_slot_avail(cli, &orsw) || + orsw.orsw_signaled); /* Here, we must take the lock to avoid the on-stack 'orsw' to be * freed but other (such as obd_put_request_slot) is using it. */ @@ -2021,6 +2018,7 @@ int obd_get_request_slot(struct client_obd *cli) else list_del(&orsw.orsw_entry); } + rc = -EINTR; } if (orsw.orsw_signaled) { diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index 1d1f953..b0eddf9 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -105,7 +105,6 @@ EXPORT_SYMBOL(__llog_ctxt_put); int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) { - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct obd_llog_group *olg; int rc, idx; @@ -135,8 +134,8 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) CERROR("Error %d while cleaning up ctxt %p\n", rc, ctxt); - l_wait_event(olg->olg_waitq, - llog_group_ctxt_null(olg, idx), &lwi); + l_wait_event_abortable(olg->olg_waitq, + llog_group_ctxt_null(olg, idx)); RETURN(rc); } diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index 9dae62a..eabe5fd 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -795,7 +795,6 @@ out: static int osc_lru_alloc(const struct lu_env *env, struct client_obd *cli, struct osc_page *opg) { - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct osc_io *oio = osc_env_io(env); int rc = 0; @@ -819,11 +818,13 @@ static int osc_lru_alloc(const struct lu_env *env, struct client_obd *cli, continue; cond_resched(); - rc = l_wait_event(osc_lru_waitq, - atomic_long_read(cli->cl_lru_left) > 0, - &lwi); - if (rc < 0) + rc = l_wait_event_abortable( + osc_lru_waitq, + atomic_long_read(cli->cl_lru_left) > 0); + if (rc < 0) { + rc = -EINTR; break; + } } out: diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index cf3136e..6152adf 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -613,17 +613,16 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, req->rq_interpret_reply = osc_destroy_interpret; if (!osc_can_send_destroy(cli)) { - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); - /* * Wait until the number of on-going destroy RPCs drops * under max_rpc_in_flight */ - rc = l_wait_event_exclusive(cli->cl_destroy_waitq, - osc_can_send_destroy(cli), &lwi); + rc = l_wait_event_abortable_exclusive( + cli->cl_destroy_waitq, + osc_can_send_destroy(cli)); if (rc) { ptlrpc_req_finished(req); - RETURN(rc); + RETURN(-EINTR); } } diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index a21549e..3a4a48a 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -496,12 +496,11 @@ int ptlrpc_reconnect_import(struct obd_import *imp) ptlrpc_disconnect_import(imp, 1); /* Wait for all invalidate calls to finish */ if (atomic_read(&imp->imp_inval_count) > 0) { - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc; - rc = l_wait_event(imp->imp_recovery_waitq, - (atomic_read(&imp->imp_inval_count) == 0), - &lwi); + rc = l_wait_event_abortable( + imp->imp_recovery_waitq, + (atomic_read(&imp->imp_inval_count) == 0)); if (rc) CERROR("Interrupted, inval=%d\n", atomic_read(&imp->imp_inval_count)); -- 1.8.3.1