From 93c568a4594be3e68bfd858dd1d7efcf1268fe6d Mon Sep 17 00:00:00 2001 From: shaver Date: Fri, 5 Jul 2002 18:03:59 +0000 Subject: [PATCH] Prevent C-c and C-z from locking us up, and make most of our waits uninterruptible. We'll move to a more robust system shortly, but this will make for a usable testing environment in the interim. --- lustre/include/linux/lustre_lib.h | 40 +++++++++++++++++++++++++++++++++++++++ lustre/ldlm/ldlm_lock.c | 4 ++-- lustre/ldlm/ldlm_request.c | 8 ++++---- lustre/ldlm/ldlm_test.c | 3 +-- lustre/llite/commit_callback.c | 10 ++++------ lustre/lov/lov_obd.c | 3 +-- lustre/mds/handler.c | 2 +- lustre/obdfs/flushd.c | 6 +++--- lustre/osc/osc_request.c | 2 +- lustre/ost/ost_handler.c | 7 ++++--- lustre/ptlrpc/client.c | 14 ++++++-------- lustre/ptlrpc/events.c | 6 +++--- lustre/ptlrpc/recovd.c | 7 +++---- lustre/ptlrpc/service.c | 16 +--------------- 14 files changed, 74 insertions(+), 54 deletions(-) diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index e9c6070..46f7bcf 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -112,4 +112,44 @@ void obd_statfs_unpack(struct obd_statfs *osfs, struct statfs *sfs); #include +/* XXX this should be one mask-check */ +#define l_killable_pending(task) \ +(sigismember(&(task->pending.signal), SIGKILL) || \ + sigismember(&(task->pending.signal), SIGINT) || \ + sigismember(&(task->pending.signal), SIGTERM)) + +/* + * Like wait_event_interruptible, but we're only interruptible by KILL, INT, or + * TERM. + */ +#define __l_wait_event_killable(wq, condition, ret) \ +do { \ + wait_queue_t __wait; \ + init_waitqueue_entry(&__wait, current); \ + \ + add_wait_queue(&wq, &__wait); \ + for (;;) { \ + set_current_state(TASK_INTERRUPTIBLE); \ + if (condition) \ + break; \ + if (!signal_pending(current) || \ + !l_killable_pending(current)) { \ + schedule(); \ + continue; \ + } \ + ret = -ERESTARTSYS; \ + break; \ + } \ + current->state = TASK_RUNNING; \ + remove_wait_queue(&wq, &__wait); \ +} while(0) + +#define l_wait_event_killable(wq, condition) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __l_wait_event_killable(wq, condition, __ret); \ + __ret; \ +}) + #endif /* _LUSTRE_LIB_H */ diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index c94e9e2..c43240e 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -651,8 +651,8 @@ int ldlm_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type, if (lock) { ldlm_lock2handle(lock, lockh); - wait_event_interruptible(lock->l_waitq, lock->l_req_mode == - lock->l_granted_mode); + wait_event(lock->l_waitq, + lock->l_req_mode == lock->l_granted_mode); } if (rc) LDLM_DEBUG(lock, "matched"); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 1b055ca..e42d804 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -134,8 +134,8 @@ int ldlm_cli_enqueue(struct ptlrpc_client *cl, struct ptlrpc_connection *conn, LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock," " sleeping"); ldlm_lock_dump(lock); - wait_event_interruptible(lock->l_waitq, lock->l_req_mode == - lock->l_granted_mode); + wait_event(lock->l_waitq, + lock->l_req_mode == lock->l_granted_mode); LDLM_DEBUG(lock, "client-side enqueue waking up: granted"); } LDLM_DEBUG(lock, "client-side enqueue END"); @@ -239,8 +239,8 @@ int ldlm_cli_convert(struct ptlrpc_client *cl, struct lustre_handle *lockh, /* FIXME: or cancelled. */ CDEBUG(D_NET, "convert returned a blocked lock, " "going to sleep.\n"); - wait_event_interruptible(lock->l_waitq, lock->l_req_mode == - lock->l_granted_mode); + wait_event(lock->l_waitq, + lock->l_req_mode == lock->l_granted_mode); CDEBUG(D_NET, "waking up, the lock must be granted.\n"); } ldlm_lock_put(lock); diff --git a/lustre/ldlm/ldlm_test.c b/lustre/ldlm/ldlm_test.c index e5df2dd..61c3224 100644 --- a/lustre/ldlm/ldlm_test.c +++ b/lustre/ldlm/ldlm_test.c @@ -311,8 +311,7 @@ int ldlm_regression_stop(void) spin_unlock(&ctl_lock); wake_up(&thread->t_ctl_waitq); - wait_event_interruptible(thread->t_ctl_waitq, - thread->t_flags & SVC_STOPPED); + wait_event(thread->t_ctl_waitq, thread->t_flags & SVC_STOPPED); spin_lock(&ctl_lock); list_del(&thread->t_link); diff --git a/lustre/llite/commit_callback.c b/lustre/llite/commit_callback.c index 3bb7820..1f2c288 100644 --- a/lustre/llite/commit_callback.c +++ b/lustre/llite/commit_callback.c @@ -73,9 +73,8 @@ static int ll_commitcbd_main(void *arg) /* And now, loop forever on requests */ while (1) { - wait_event_interruptible - (sbi->ll_commitcbd_waitq, - ll_commitcbd_check_event(sbi)); + wait_event(sbi->ll_commitcbd_waitq, + ll_commitcbd_check_event(sbi)); spin_lock(&sbi->ll_commitcbd_lock); if (sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPING) { @@ -121,8 +120,7 @@ int ll_commitcbd_cleanup(struct ll_sb_info *sbi) sbi->ll_commitcbd_flags = LL_COMMITCBD_STOPPING; wake_up(&sbi->ll_commitcbd_waitq); - wait_event_interruptible - (sbi->ll_commitcbd_ctl_waitq, - sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPED); + wait_event(sbi->ll_commitcbd_ctl_waitq, + sbi->ll_commitcbd_flags & LL_COMMITCBD_STOPPED); RETURN(0); } diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 3a0b3b8..57836a0 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -467,8 +467,7 @@ static int lov_brw(int cmd, struct lustre_handle *conn, obd_count num_oa, buf += size; } - wait_event_interruptible(&cb_data->waitq, - lov_read_check_status(cb_data)); + wait_event(&cb_data->waitq, lov_read_check_status(cb_data)); if (cb_data->flags & PTL_RPC_FL_INTR) rc = -EINTR; diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index d625aca..18f342b 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -78,7 +78,7 @@ static int mds_sendpage(struct ptlrpc_request *req, struct file *file, GOTO(cleanup_buf, rc); } - wait_event_interruptible(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); + wait_event(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); if (desc->b_flags & PTL_RPC_FL_INTR) GOTO(cleanup_buf, rc = -EINTR); diff --git a/lustre/obdfs/flushd.c b/lustre/obdfs/flushd.c index 9ba45ee..66c9f3d 100644 --- a/lustre/obdfs/flushd.c +++ b/lustre/obdfs/flushd.c @@ -349,7 +349,7 @@ int obdfs_flush_dirty_pages(unsigned long check_time) static void pupdate_wakeup(unsigned long l) { - wake_up_interruptible(&pupdated.waitq); + wake_up(&pupdated.waitq); } @@ -442,7 +442,7 @@ static int pupdate(void *unused) CDEBUG(D_CACHE, "pupdated stopped...\n"); pupdated.active = -1; - wake_up_interruptible (&pupdated.waitq); + wake_up(&pupdated.waitq); return 0; } @@ -465,7 +465,7 @@ int obdfs_flushd_cleanup(void) if (pupdated.active > 0) { CDEBUG(D_CACHE, "inform pupdated\n"); pupdated.active = 0; - wake_up_interruptible(&pupdated.waitq); + wake_up(&pupdated.waitq); CDEBUG(D_CACHE, "wait for pupdated\n"); while (pupdated.active == 0) { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 5f39ad9..3846d60 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -627,7 +627,7 @@ static int osc_brw_write(struct lustre_handle *conn, obd_count num_oa, GOTO(out, rc); /* If there's no callback function, sleep here until complete. */ - wait_event_interruptible(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); + l_wait_event_killable(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); if (desc->b_flags & PTL_RPC_FL_INTR) rc = -EINTR; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 207691f..11ce4a8 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -261,7 +261,8 @@ static int ost_brw_read(struct ptlrpc_request *req) if (rc) GOTO(out_bulk, rc); - wait_event_interruptible(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); +#warning OST must time out here. + wait_event(desc->b_waitq, ptlrpc_check_bulk_sent(desc)); if (desc->b_flags & PTL_RPC_FL_INTR) rc = -EINTR; @@ -372,8 +373,8 @@ static int ost_brw_write(struct ptlrpc_request *req) reply_sent = 1; ptlrpc_reply(req->rq_svc, req); - wait_event_interruptible(desc->b_waitq, - desc->b_flags & PTL_BULK_FL_RCVD); +#warning OST must time out here. + wait_event(desc->b_waitq, desc->b_flags & PTL_BULK_FL_RCVD); rc = obd_commitrw(cmd, conn, objcount, tmp1, niocount, local_nb, desc->b_desc_private); diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 7f0c58d..350b894 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -426,7 +426,7 @@ void ptlrpc_continue_req(struct ptlrpc_request *req) ENTRY; CDEBUG(D_INODE, "continue delayed request %Ld opc %d\n", req->rq_xid, req->rq_reqmsg->opc); - wake_up_interruptible(&req->rq_wait_for_rep); + wake_up(&req->rq_wait_for_rep); EXIT; } @@ -439,7 +439,7 @@ void ptlrpc_resend_req(struct ptlrpc_request *req) req->rq_level = LUSTRE_CONN_RECOVD; req->rq_flags |= PTL_RPC_FL_RESEND; req->rq_flags &= ~PTL_RPC_FL_TIMEOUT; - wake_up_interruptible(&req->rq_wait_for_rep); + wake_up(&req->rq_wait_for_rep); EXIT; } @@ -451,7 +451,7 @@ void ptlrpc_restart_req(struct ptlrpc_request *req) req->rq_status = -ERESTARTSYS; req->rq_flags |= PTL_RPC_FL_RECOVERY; req->rq_flags &= ~PTL_RPC_FL_TIMEOUT; - wake_up_interruptible(&req->rq_wait_for_rep); + wake_up(&req->rq_wait_for_rep); EXIT; } @@ -473,7 +473,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) list_del_init(&req->rq_list); list_add(&req->rq_list, cli->cli_delayed_head.prev); spin_unlock(&cli->cli_lock); - wait_event_interruptible + l_wait_event_killable (req->rq_wait_for_rep, req->rq_level <= req->rq_connection->c_level); spin_lock(&cli->cli_lock); @@ -500,8 +500,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) spin_unlock(&cli->cli_lock); CDEBUG(D_OTHER, "-- sleeping\n"); - wait_event_interruptible(req->rq_wait_for_rep, - ptlrpc_check_reply(req)); + l_wait_event_killable(req->rq_wait_for_rep, ptlrpc_check_reply(req)); CDEBUG(D_OTHER, "-- done\n"); if (req->rq_flags & PTL_RPC_FL_RESEND) { @@ -565,8 +564,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req) } CDEBUG(D_OTHER, "-- sleeping\n"); - wait_event_interruptible(req->rq_wait_for_rep, - ptlrpc_check_reply(req)); + l_wait_event_killable(req->rq_wait_for_rep, ptlrpc_check_reply(req)); CDEBUG(D_OTHER, "-- done\n"); up(&cli->cli_rpc_sem); diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index b2ae37e..56d3829 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -86,7 +86,7 @@ static int reply_in_callback(ptl_event_t *ev) if (ev->type == PTL_EVENT_PUT) { req->rq_repmsg = ev->mem_desc.start + ev->offset; barrier(); - wake_up_interruptible(&req->rq_wait_for_rep); + wake_up(&req->rq_wait_for_rep); } else { // XXX make sure we understand all events, including ACK's CERROR("Unknown event %d\n", ev->type); @@ -126,7 +126,7 @@ static int bulk_source_callback(ptl_event_t *ev) bulk->b_cb(bulk); if (atomic_dec_and_test(&desc->b_pages_remaining)) { desc->b_flags |= PTL_BULK_FL_SENT; - wake_up_interruptible(&desc->b_waitq); + wake_up(&desc->b_waitq); if (desc->b_cb != NULL) desc->b_cb(desc, desc->b_cb_data); } @@ -151,7 +151,7 @@ static int bulk_sink_callback(ptl_event_t *ev) bulk->b_cb(bulk); if (atomic_dec_and_test(&desc->b_pages_remaining)) { desc->b_flags |= PTL_BULK_FL_RCVD; - wake_up_interruptible(&desc->b_waitq); + wake_up(&desc->b_waitq); if (desc->b_cb != NULL) desc->b_cb(desc, desc->b_cb_data); } diff --git a/lustre/ptlrpc/recovd.c b/lustre/ptlrpc/recovd.c index ad1c96c..6875531 100644 --- a/lustre/ptlrpc/recovd.c +++ b/lustre/ptlrpc/recovd.c @@ -170,8 +170,7 @@ static int recovd_main(void *arg) /* And now, loop forever on requests */ while (1) { - wait_event_interruptible(recovd->recovd_waitq, - recovd_check_event(recovd)); + wait_event(recovd->recovd_waitq, recovd_check_event(recovd)); spin_lock(&recovd->recovd_lock); if (recovd->recovd_flags & RECOVD_STOPPING) { @@ -223,7 +222,7 @@ int recovd_cleanup(struct recovd_obd *recovd) wake_up(&recovd->recovd_waitq); spin_unlock(&recovd->recovd_lock); - wait_event_interruptible(recovd->recovd_ctl_waitq, - (recovd->recovd_flags & RECOVD_STOPPED)); + wait_event(recovd->recovd_ctl_waitq, + (recovd->recovd_flags & RECOVD_STOPPED)); RETURN(0); } diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 1b8da1e..262c830 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -34,13 +34,6 @@ static int ptlrpc_check_event(struct ptlrpc_service *svc, ENTRY; spin_lock(&svc->srv_lock); - if (sigismember(&(current->pending.signal), SIGKILL) || - sigismember(&(current->pending.signal), SIGTERM) || - sigismember(&(current->pending.signal), SIGINT)) { - thread->t_flags |= SVC_KILLED; - GOTO(out, rc = 1); - } - if (thread->t_flags & SVC_STOPPING) GOTO(out, rc = 1); @@ -264,12 +257,6 @@ static int ptlrpc_main(void *arg) ptlrpc_check_event(svc, thread, &event)); spin_lock(&svc->srv_lock); - if (thread->t_flags & SVC_SIGNAL) { - thread->t_flags &= ~SVC_SIGNAL; - spin_unlock(&svc->srv_lock); - EXIT; - break; - } if (thread->t_flags & SVC_STOPPING) { thread->t_flags &= ~SVC_STOPPING; @@ -307,8 +294,7 @@ static void ptlrpc_stop_thread(struct ptlrpc_service *svc, spin_unlock(&svc->srv_lock); wake_up(&svc->srv_waitq); - wait_event_interruptible(thread->t_ctl_waitq, - (thread->t_flags & SVC_STOPPED)); + wait_event(thread->t_ctl_waitq, (thread->t_flags & SVC_STOPPED)); } void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) -- 1.8.3.1