From 401fcd760ce251bc94017dfdb560af7dead95346 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Thu, 26 Aug 2010 00:22:31 +0800 Subject: [PATCH] b=18213 Handle the signal to avoid process hang. i=johann i=hongchao.zhang --- lustre/mdc/mdc_internal.h | 2 +- lustre/mdc/mdc_lib.c | 9 ++++++--- lustre/mdc/mdc_locks.c | 14 +++++++++----- lustre/mdc/mdc_request.c | 13 +++++++++---- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 924ee12..6e3a1d9 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -79,7 +79,7 @@ void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa, __u64 valid, struct obd_client_handle *och); void mdc_exit_request(struct client_obd *cli); -void mdc_enter_request(struct client_obd *cli); +int mdc_enter_request(struct client_obd *cli); int seq_client_init(struct lu_client_seq *seq, struct obd_export *exp, diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index 2085cf5..9fed54c 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -947,21 +947,24 @@ static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) /* We record requests in flight in cli->cl_r_in_flight here. * There is only one write rpc possible in mdc anyway. If this to change * in the future - the code may need to be revisited. */ -void mdc_enter_request(struct client_obd *cli) +int mdc_enter_request(struct client_obd *cli) { + int rc = 0; struct mdc_cache_waiter mcw; - struct l_wait_info lwi = { 0 }; + struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); spin_lock(&cli->cl_loi_list_lock); if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) { list_add_tail(&mcw.mcw_entry, &cli->cl_cache_waiters); init_waitqueue_head(&mcw.mcw_waitq); spin_unlock(&cli->cl_loi_list_lock); - l_wait_event(mcw.mcw_waitq, mdc_req_avail(cli, &mcw), &lwi); + rc = l_wait_event(mcw.mcw_waitq, mdc_req_avail(cli, &mcw), + &lwi); } else { cli->cl_r_in_flight++; spin_unlock(&cli->cl_loi_list_lock); } + return rc; } void mdc_exit_request(struct client_obd *cli) diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index c5f9bc4..a478335 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -637,10 +637,12 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, * threads that are serialised with rpc_lock are not polluting our * rpcs in flight counter */ mdc_get_rpc_lock(obddev->u.cli.cl_rpc_lock, it); - mdc_enter_request(&obddev->u.cli); - rc = ldlm_cli_enqueue(exp, &req, einfo, res_id, &policy, &flags, NULL, - 0, NULL, lockh, 0); - mdc_exit_request(&obddev->u.cli); + rc = mdc_enter_request(&obddev->u.cli); + if (rc == 0) { + rc = ldlm_cli_enqueue(exp, &req, einfo, res_id, &policy, &flags, + NULL, 0, NULL, lockh, 0); + mdc_exit_request(&obddev->u.cli); + } mdc_put_rpc_lock(obddev->u.cli.cl_rpc_lock, it); if (rc < 0) { CERROR("ldlm_cli_enqueue: %d\n", rc); @@ -945,7 +947,9 @@ int mdc_intent_getattr_async(struct obd_export *exp, if (!req) RETURN(-ENOMEM); - mdc_enter_request(&obddev->u.cli); + rc = mdc_enter_request(&obddev->u.cli); + if (rc) + RETURN(rc); rc = ldlm_cli_enqueue(exp, &req, einfo, res_id, &policy, &flags, NULL, 0, NULL, &minfo->mi_lockh, 1); if (rc < 0) { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 568a78d..486d3ca 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -148,7 +148,9 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, ptlrpc_req_set_repsize(req, bufcount, size); - mdc_enter_request(&obddev->u.cli); + rc = mdc_enter_request(&obddev->u.cli); + if (rc != 0) + RETURN(rc); rc = ptlrpc_queue_wait(req); mdc_exit_request(&obddev->u.cli); if (rc != 0) @@ -271,7 +273,7 @@ int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid, [REQ_REC_OFF + 1] = 0, /* capa */ [REQ_REC_OFF + 2] = 0, /* name */ [REQ_REC_OFF + 3] = 0 }; - int rc, xattr_namelen = 0, bufcnt = 2, offset = REQ_REC_OFF + 1; + int rc = 0, xattr_namelen = 0, bufcnt = 2, offset = REQ_REC_OFF + 1; void *tmp; ENTRY; @@ -348,8 +350,11 @@ int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid, /* make rpc */ if (opcode == MDS_SETXATTR || opcode == MDS_REINT) mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL); - else - mdc_enter_request(&obddev->u.cli); + else { + rc = mdc_enter_request(&obddev->u.cli); + if (rc != 0) + GOTO(err_out, rc); + } rc = ptlrpc_queue_wait(req); -- 1.8.3.1