From 94c4bb37afb3592c5bab09e01d15682158768d80 Mon Sep 17 00:00:00 2001 From: yury Date: Tue, 19 Sep 2006 15:07:40 +0000 Subject: [PATCH] - do not store server ctx to any structs, ctx is only valid in its thread; --- lustre/fid/fid_handler.c | 6 ++++-- lustre/fid/fid_request.c | 29 ++++++++++++++++------------- lustre/include/lustre_fid.h | 12 +++++++----- lustre/mdc/mdc_request.c | 4 ++-- lustre/mdt/mdt_handler.c | 4 ++-- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index ddceecd..8bbe086 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -84,7 +84,7 @@ int seq_server_set_cli(struct lu_server_seq *seq, /* get new range from controller only if super-sequence is not yet * initialized from backing store or something else. */ if (range_is_zero(&seq->lss_super)) { - rc = seq_client_alloc_super(cli); + rc = seq_client_alloc_super(cli, ctx); if (rc) { up(&seq->lss_sem); CERROR("can't allocate super-sequence, " @@ -225,7 +225,7 @@ static int __seq_server_alloc_meta(struct lu_server_seq *seq, RETURN(-EOPNOTSUPP); } - rc = seq_client_alloc_super(seq->lss_cli); + rc = seq_client_alloc_super(seq->lss_cli, ctx); if (rc) { CERROR("can't allocate new super-sequence, " "rc %d\n", rc); @@ -337,6 +337,8 @@ static int seq_req_handle(struct ptlrpc_request *req, } ctx = req->rq_svc_thread->t_ctx; + LASSERT(ctx != NULL); + LASSERT(ctx->lc_thread == req->rq_svc_thread); rc = seq_server_handle(site, ctx, *opc, in, out); } else rc = -EPROTO; diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index 1b509d6..47b1201 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -124,15 +124,17 @@ out_req: } /* request sequence-controller node to allocate new super-sequence. */ -static int __seq_client_alloc_super(struct lu_client_seq *seq) +static int __seq_client_alloc_super(struct lu_client_seq *seq, + const struct lu_context *ctx) { int rc; #ifdef __KERNEL__ if (seq->lcs_srv) { + LASSERT(ctx != NULL); rc = seq_server_alloc_super(seq->lcs_srv, NULL, &seq->lcs_range, - seq->lcs_ctx); + ctx); } else { #endif rc = seq_client_rpc(seq, &seq->lcs_range, @@ -143,13 +145,14 @@ static int __seq_client_alloc_super(struct lu_client_seq *seq) return rc; } -int seq_client_alloc_super(struct lu_client_seq *seq) +int seq_client_alloc_super(struct lu_client_seq *seq, + const struct lu_context *ctx) { int rc; ENTRY; down(&seq->lcs_sem); - rc = __seq_client_alloc_super(seq); + rc = __seq_client_alloc_super(seq, ctx); up(&seq->lcs_sem); RETURN(rc); @@ -157,15 +160,17 @@ int seq_client_alloc_super(struct lu_client_seq *seq) EXPORT_SYMBOL(seq_client_alloc_super); /* request sequence-controller node to allocate new meta-sequence. */ -static int __seq_client_alloc_meta(struct lu_client_seq *seq) +static int __seq_client_alloc_meta(struct lu_client_seq *seq, + const struct lu_context *ctx) { int rc; #ifdef __KERNEL__ if (seq->lcs_srv) { + LASSERT(ctx != NULL); rc = seq_server_alloc_meta(seq->lcs_srv, NULL, &seq->lcs_range, - seq->lcs_ctx); + ctx); } else { #endif rc = seq_client_rpc(seq, &seq->lcs_range, @@ -176,13 +181,14 @@ static int __seq_client_alloc_meta(struct lu_client_seq *seq) return rc; } -int seq_client_alloc_meta(struct lu_client_seq *seq) +int seq_client_alloc_meta(struct lu_client_seq *seq, + const struct lu_context *ctx) { int rc; ENTRY; down(&seq->lcs_sem); - rc = __seq_client_alloc_meta(seq); + rc = __seq_client_alloc_meta(seq, ctx); up(&seq->lcs_sem); RETURN(rc); @@ -200,7 +206,7 @@ static int __seq_client_alloc_seq(struct lu_client_seq *seq, seqno_t *seqnr) /* if we still have free sequences in meta-sequence we allocate new seq * from given range, if not - allocate new meta-sequence. */ if (range_space(&seq->lcs_range) == 0) { - rc = __seq_client_alloc_meta(seq); + rc = __seq_client_alloc_meta(seq, NULL); if (rc) { CERROR("can't allocate new meta-sequence, " "rc %d\n", rc); @@ -338,8 +344,7 @@ int seq_client_init(struct lu_client_seq *seq, struct obd_export *exp, enum lu_cli_type type, const char *prefix, - struct lu_server_seq *srv, - const struct lu_context *ctx) + struct lu_server_seq *srv) { int rc; ENTRY; @@ -347,7 +352,6 @@ int seq_client_init(struct lu_client_seq *seq, LASSERT(seq != NULL); LASSERT(prefix != NULL); - seq->lcs_ctx = ctx; seq->lcs_exp = exp; seq->lcs_srv = srv; seq->lcs_type = type; @@ -357,7 +361,6 @@ int seq_client_init(struct lu_client_seq *seq, seq->lcs_width = LUSTRE_SEQ_MAX_WIDTH; if (exp == NULL) { - LASSERT(seq->lcs_ctx != NULL); LASSERT(seq->lcs_srv != NULL); } else { LASSERT(seq->lcs_exp != NULL); diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index d058380..e792374 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -97,7 +97,6 @@ struct lu_client_seq { /* seq-server for direct talking */ struct lu_server_seq *lcs_srv; - const struct lu_context *lcs_ctx; }; /* server sequence manager interface */ @@ -169,16 +168,19 @@ int seq_client_init(struct lu_client_seq *seq, struct obd_export *exp, enum lu_cli_type type, const char *prefix, - struct lu_server_seq *srv, - const struct lu_context *ctx); + struct lu_server_seq *srv); void seq_client_fini(struct lu_client_seq *seq); -int seq_client_alloc_super(struct lu_client_seq *seq); -int seq_client_alloc_meta(struct lu_client_seq *seq); +int seq_client_alloc_super(struct lu_client_seq *seq, + const struct lu_context *ctx); + +int seq_client_alloc_meta(struct lu_client_seq *seq, + const struct lu_context *ctx); int seq_client_alloc_seq(struct lu_client_seq *seq, seqno_t *seqnr); + int seq_client_alloc_fid(struct lu_client_seq *seq, struct lu_fid *fid); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 9dd364b..797d8c0 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1242,13 +1242,13 @@ static int mdc_fid_init(struct obd_export *exp) /* init client side sequence-manager */ rc = seq_client_init(cli->cl_seq, exp, LUSTRE_SEQ_METADATA, - prefix, NULL, NULL); + prefix, NULL); OBD_FREE(prefix, MAX_OBD_NAME + 5); if (rc) GOTO(out_free_seq, rc); /* pre-allocate meta-sequence */ - rc = seq_client_alloc_meta(cli->cl_seq); + rc = seq_client_alloc_meta(cli->cl_seq, NULL); if (rc) { CERROR("can't allocate new mata-sequence, " "rc %d\n", rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 6f18cce..155f385 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2099,7 +2099,7 @@ static int mdt_seq_init(const struct lu_context *ctx, */ rc = seq_client_init(ls->ls_client_seq, NULL, LUSTRE_SEQ_METADATA, prefix, - ls->ls_control_seq, ctx); + ls->ls_control_seq); OBD_FREE(prefix, MAX_OBD_NAME + 5); if (rc) @@ -2214,7 +2214,7 @@ static int mdt_seq_init_cli(const struct lu_context *ctx, rc = seq_client_init(ls->ls_client_seq, ls->ls_control_exp, LUSTRE_SEQ_METADATA, - prefix, NULL, NULL); + prefix, NULL); OBD_FREE(prefix, MAX_OBD_NAME + 5); } else rc = -ENOMEM; -- 1.8.3.1