From: nikita Date: Wed, 19 Jul 2006 11:30:59 +0000 (+0000) Subject: lu_context_key: add tags to contexts and keys to control which keys should be allocat... X-Git-Tag: v1_8_0_110~486^2~1388 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=7bd43cf4ae8505bb114e93c06e8a771de93f1b60;p=fs%2Flustre-release.git lu_context_key: add tags to contexts and keys to control which keys should be allocated in which threads --- diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index efc93aa..92b41c4 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -48,9 +48,6 @@ static struct lu_device_operations cmm_lu_ops; static inline int lu_device_is_cmm(struct lu_device *d) { - /* - * XXX for now. Tags in lu_device_type->ldt_something are needed. - */ return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &cmm_lu_ops); } @@ -62,7 +59,7 @@ static int cmm_root_get(const struct lu_context *ctx, struct md_device *md, if (cmm_dev->cmm_local_num == 0) return cmm_child_ops(cmm_dev)->mdo_root_get(ctx, cmm_dev->cmm_child, fid); - else + else return -EINVAL; } @@ -77,14 +74,14 @@ static int cmm_statfs(const struct lu_context *ctxt, struct md_device *md, RETURN (rc); } -int cmm_notify(const struct lu_context *ctxt, struct md_device *md, - struct obd_device *watched, +int cmm_notify(const struct lu_context *ctxt, struct md_device *md, + struct obd_device *watched, enum obd_notify_event ev, void *data) { struct cmm_device *cmm_dev = md2cmm_dev(md); int rc; - rc = cmm_child_ops(cmm_dev)->mdo_notify(ctxt, cmm_dev->cmm_child, + rc = cmm_child_ops(cmm_dev)->mdo_notify(ctxt, cmm_dev->cmm_child, watched, ev, data); return rc; @@ -184,7 +181,7 @@ static int cmm_process_config(const struct lu_context *ctx, const char *index = lustre_cfg_string(cfg, 2); char *p; LASSERT(index); - + /* lower layers should be set up at first */ err = next->ld_ops->ldo_process_config(ctx, next, cfg); if (err == 0) { @@ -269,7 +266,7 @@ static int cmm_device_init(const struct lu_context *ctx, OBD_ALLOC_PTR(ls->ls_client_fld); if (!ls->ls_client_fld) RETURN(-ENOMEM); - + err = fld_client_init(ls->ls_client_fld, "CMM_UUID", LUSTRE_CLI_FLD_HASH_RRB); if (err) { @@ -290,7 +287,7 @@ static struct lu_device *cmm_device_fini(const struct lu_context *ctx, fld_client_fini(ls->ls_client_fld); OBD_FREE_PTR(ls->ls_client_fld); ls->ls_client_fld = NULL; - + /* finish all mdc devices */ spin_lock(&cm->cmm_tgt_guard); list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) { @@ -319,9 +316,10 @@ static struct lu_device_type_operations cmm_device_type_ops = { }; static struct lu_device_type cmm_device_type = { - .ldt_tags = LU_DEVICE_MD, - .ldt_name = LUSTRE_CMM0_NAME, - .ldt_ops = &cmm_device_type_ops + .ldt_tags = LU_DEVICE_MD, + .ldt_name = LUSTRE_CMM0_NAME, + .ldt_ops = &cmm_device_type_ops, + .ldt_ctx_tags = LCT_MD_THREAD }; struct lprocfs_vars lprocfs_cmm_obd_vars[] = { diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index 5ea72ab..74f944f 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -41,9 +41,6 @@ static struct lu_device_operations mdc_lu_ops; static inline int lu_device_is_mdc(struct lu_device *ld) { - /* - * XXX for now. Tags in lu_device_type->ldt_something are needed. - */ return ergo(ld != NULL && ld->ld_ops != NULL, ld->ld_ops == &mdc_lu_ops); } @@ -67,10 +64,10 @@ static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg) ENTRY; LASSERT(uuid_str); LASSERT(index); - + mc->mc_num = simple_strtol(index, &p, 10); if (*p) { - CERROR("Invalid index in lustre_cgf, offset 2\n"); + CERROR("Invalid index in lustre_cgf, offset 2\n"); RETURN(-EINVAL); } @@ -222,6 +219,7 @@ static void mdc_thread_fini(const struct lu_context *ctx, } struct lu_context_key mdc_thread_key = { + .lct_tags = LCT_MD_THREAD|LCT_CL_THREAD, .lct_init = mdc_thread_init, .lct_fini = mdc_thread_fini }; @@ -248,8 +246,9 @@ static struct lu_device_type_operations mdc_device_type_ops = { }; struct lu_device_type mdc_device_type = { - .ldt_tags = LU_DEVICE_MD, - .ldt_name = LUSTRE_MDC0_NAME, - .ldt_ops = &mdc_device_type_ops + .ldt_tags = LU_DEVICE_MD, + .ldt_name = LUSTRE_MDC0_NAME, + .ldt_ops = &mdc_device_type_ops, + .ldt_ctx_tags = LCT_MD_THREAD|LCT_CL_THREAD }; diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index e3850bd..8482cb3 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -71,7 +71,7 @@ seq_server_init_ctlr(struct lu_server_seq *seq, { int rc = 0; ENTRY; - + LASSERT(cli != NULL); if (seq->seq_cli) { @@ -85,7 +85,7 @@ seq_server_init_ctlr(struct lu_server_seq *seq, cli->seq_exp->exp_client_uuid.uuid); down(&seq->seq_sem); - + /* assign controller */ seq->seq_cli = cli; @@ -124,7 +124,7 @@ seq_server_fini_ctlr(struct lu_server_seq *seq) down(&seq->seq_sem); seq->seq_cli = NULL; up(&seq->seq_sem); - + EXIT; } EXPORT_SYMBOL(seq_server_fini_ctlr); @@ -141,7 +141,7 @@ __seq_server_alloc_super(struct lu_server_seq *seq, ENTRY; LASSERT(range_is_sane(space)); - + if (range_space(space) < seq->seq_super_width) { CWARN("sequences space is going to exhaust soon. " "Only can allocate "LPU64" sequences\n", @@ -167,7 +167,7 @@ __seq_server_alloc_super(struct lu_server_seq *seq, CDEBUG(D_INFO, "SEQ-MGR(srv): allocated super-sequence " "["LPX64"-"LPX64"]\n", range->lr_start, range->lr_end); } - + RETURN(rc); } @@ -182,7 +182,7 @@ seq_server_alloc_super(struct lu_server_seq *seq, down(&seq->seq_sem); rc = __seq_server_alloc_super(seq, range, ctx); up(&seq->seq_sem); - + RETURN(rc); } @@ -243,13 +243,13 @@ seq_server_alloc_meta(struct lu_server_seq *seq, down(&seq->seq_sem); rc = __seq_server_alloc_meta(seq, range, ctx); up(&seq->seq_sem); - + RETURN(rc); } static int seq_server_handle(struct lu_server_seq *seq, - const struct lu_context *ctx, + const struct lu_context *ctx, struct lu_range *range, __u32 opc) { @@ -273,7 +273,7 @@ seq_server_handle(struct lu_server_seq *seq, static int seq_req_handle0(const struct lu_context *ctx, - struct ptlrpc_request *req) + struct ptlrpc_request *req) { int rep_buf_size[2] = { 0, }; struct obd_device *obd; @@ -301,7 +301,7 @@ seq_req_handle0(const struct lu_context *ctx, CERROR("can't get range buffer\n"); GOTO(out_pill, rc= -EPROTO); } - + if (*opc == SEQ_ALLOC_META) { if (!site->ls_server_seq) { CERROR("sequence-server is not initialized\n"); @@ -327,8 +327,8 @@ out_pill: return rc; } -static int -seq_req_handle(struct ptlrpc_request *req) +static int +seq_req_handle(struct ptlrpc_request *req) { int fail = OBD_FAIL_SEQ_ALL_REPLY_NET; const struct lu_context *ctx; @@ -336,7 +336,7 @@ seq_req_handle(struct ptlrpc_request *req) ENTRY; OBD_FAIL_RETURN(OBD_FAIL_SEQ_ALL_REPLY_NET | OBD_FAIL_ONCE, 0); - + ctx = req->rq_svc_thread->t_ctx; LASSERT(ctx != NULL); LASSERT(ctx->lc_thread == req->rq_svc_thread); @@ -360,7 +360,7 @@ seq_req_handle(struct ptlrpc_request *req) out: target_send_reply(req, rc, fail); return 0; -} +} #ifdef LPROCFS static int @@ -427,20 +427,21 @@ seq_server_init(struct lu_server_seq *seq, struct dt_device *dev, const char *uuid, lu_server_type_t type, - const struct lu_context *ctx) + const struct lu_context *ctx) { int rc, portal = (type == LUSTRE_SEQ_SRV) ? SEQ_SRV_PORTAL : SEQ_CTLR_PORTAL; - - struct ptlrpc_service_conf seq_conf = { - .psc_nbufs = MDS_NBUFS, - .psc_bufsize = MDS_BUFSIZE, + + struct ptlrpc_service_conf seq_conf = { + .psc_nbufs = MDS_NBUFS, + .psc_bufsize = MDS_BUFSIZE, .psc_max_req_size = MDS_MAXREQSIZE, .psc_max_reply_size = MDS_MAXREPSIZE, .psc_req_portal = portal, .psc_rep_portal = MDC_REPLY_PORTAL, - .psc_watchdog_timeout = SEQ_SERVICE_WATCHDOG_TIMEOUT, - .psc_num_threads = SEQ_NUM_THREADS + .psc_watchdog_timeout = SEQ_SERVICE_WATCHDOG_TIMEOUT, + .psc_num_threads = SEQ_NUM_THREADS, + .psc_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD }; ENTRY; @@ -458,16 +459,16 @@ seq_server_init(struct lu_server_seq *seq, snprintf(seq->seq_name, sizeof(seq->seq_name), "%s-%s-%s", LUSTRE_SEQ_NAME, (type == LUSTRE_SEQ_SRV ? "srv" : "ctlr"), uuid); - + seq->seq_space = LUSTRE_SEQ_SPACE_RANGE; seq->seq_super = LUSTRE_SEQ_ZERO_RANGE; - + lu_device_get(&seq->seq_dev->dd_lu_dev); rc = seq_store_init(seq, ctx); if (rc) GOTO(out, rc); - + /* request backing store for saved sequence info */ rc = seq_store_read(seq, ctx); if (rc == -ENODATA) { @@ -483,7 +484,7 @@ seq_server_init(struct lu_server_seq *seq, rc); GOTO(out, rc); } - + #ifdef LPROCFS rc = seq_server_proc_init(seq); if (rc) @@ -493,13 +494,13 @@ seq_server_init(struct lu_server_seq *seq, seq->seq_service = ptlrpc_init_svc_conf(&seq_conf, seq_req_handle, LUSTRE_SEQ_NAME, - seq->seq_proc_entry, - NULL); + seq->seq_proc_entry, + NULL); if (seq->seq_service != NULL) rc = ptlrpc_start_threads(NULL, seq->seq_service, LUSTRE_SEQ_NAME); - else - rc = -ENOMEM; + else + rc = -ENOMEM; EXIT; @@ -511,12 +512,12 @@ out: (type == LUSTRE_SEQ_SRV ? "Server" : "Controller")); } return rc; -} +} EXPORT_SYMBOL(seq_server_init); void seq_server_fini(struct lu_server_seq *seq, - const struct lu_context *ctx) + const struct lu_context *ctx) { ENTRY; @@ -535,7 +536,7 @@ seq_server_fini(struct lu_server_seq *seq, lu_device_put(&seq->seq_dev->dd_lu_dev); seq->seq_dev = NULL; } - + CDEBUG(D_INFO|D_WARNING, "Server Sequence " "Manager\n"); EXIT; @@ -554,8 +555,8 @@ static int fid_fini(void) RETURN(0); } -static int -__init fid_mod_init(void) +static int +__init fid_mod_init(void) { /* init caches if any */ @@ -563,8 +564,8 @@ __init fid_mod_init(void) return 0; } -static void -__exit fid_mod_exit(void) +static void +__exit fid_mod_exit(void) { /* free caches if any */ fid_fini(); diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 32d3631..106a867 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -306,7 +306,8 @@ fld_server_init(struct lu_server_fld *fld, .psc_req_portal = FLD_REQUEST_PORTAL, .psc_rep_portal = MDC_REPLY_PORTAL, .psc_watchdog_timeout = FLD_SERVICE_WATCHDOG_TIMEOUT, - .psc_num_threads = FLD_NUM_THREADS + .psc_num_threads = FLD_NUM_THREADS, + .psc_ctx_tags = LCT_DT_THREAD|LCT_MD_THREAD }; ENTRY; diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index 3b91d3d..cbed158 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -98,6 +98,7 @@ static void fld_key_fini(const struct lu_context *ctx, static int fld_key_registered = 0; static struct lu_context_key fld_thread_key = { + .lct_tags = LCT_MD_THREAD|LCT_DT_THREAD, .lct_init = fld_key_init, .lct_fini = fld_key_fini }; diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 3f6eef0..101dc7b 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -263,6 +263,10 @@ struct lu_device_type { * XXX: temporary pointer to associated obd_type. */ struct obd_type *ldt_obd_type; + /* + * XXX: temporary: context tags used by obd_*() calls. + */ + __u32 ldt_ctx_tags; }; /* @@ -736,8 +740,8 @@ struct lu_context { * * To achieve this, set of tags in introduced. Contexts and keys are * marked with tags. Key value are created only for context whose set - * of tags has non-empty intersection with one for key. NOT YET - * IMPLEMENTED. + * of tags has non-empty intersection with one for key. Tags are taken + * from enum lu_context_tag. */ __u32 lc_tags; /* @@ -756,12 +760,22 @@ struct lu_context { * lu_context_key interface. Similar to pthread_key. */ +enum lu_context_tag { + LCT_MD_THREAD = 1 << 0, + LCT_DT_THREAD = 1 << 1, + LCT_TX_HANDLE = 1 << 2, + LCT_CL_THREAD = 1 << 3 +}; /* * Key. Represents per-context value slot. */ struct lu_context_key { /* + * Set of tags for which values of this key are to be instantiated. + */ + __u32 lct_tags; + /* * Value constructor. This is called when new value is created for a * context. Returns pointer to new value of error pointer. */ @@ -803,7 +817,7 @@ void *lu_context_key_get(const struct lu_context *ctx, /* * Initialize context data-structure. Create values for all keys. */ -int lu_context_init(struct lu_context *ctx); +int lu_context_init(struct lu_context *ctx, __u32 tags); /* * Finalize context data-structure. Destroy key values. */ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 22adf17..48231f0 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -575,6 +575,11 @@ struct ptlrpc_service { cfs_waitq_t srv_free_rs_waitq; /* + * Tags for lu_context associated with this thread, see struct + * lu_context. + */ + __u32 srv_ctx_tags; + /* * if non-NULL called during thread creation (ptlrpc_start_thread()) * to initialize service specific per-thread state. */ @@ -728,6 +733,7 @@ struct ptlrpc_service_conf { int psc_rep_portal; int psc_watchdog_timeout; /* in ms */ int psc_num_threads; + __u32 psc_ctx_tags; }; /* ptlrpc/service.c */ @@ -746,7 +752,8 @@ struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int watchdog_timeout, /* in ms */ svc_handler_t, char *name, cfs_proc_dir_entry_t *proc_entry, - svcreq_printfn_t, int num_threads); + svcreq_printfn_t, int num_threads, + __u32 ctx_tags); void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); int ptlrpc_start_threads(struct obd_device *dev, struct ptlrpc_service *svc, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index cc7ce1f..851cf8a 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -357,7 +357,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (ldt != NULL) { struct lu_context ctx; - rc = lu_context_init(&ctx); + rc = lu_context_init(&ctx, ldt->ldt_ctx_tags); if (rc == 0) { lu_context_enter(&ctx); d = ldt->ldt_ops->ldto_device_alloc(&ctx, ldt, cfg); @@ -407,7 +407,7 @@ static inline int obd_cleanup(struct obd_device *obd) if (ldt != NULL && d != NULL) { struct lu_context ctx; - rc = lu_context_init(&ctx); + rc = lu_context_init(&ctx, ldt->ldt_ctx_tags); if (rc == 0) { lu_context_enter(&ctx); ldt->ldt_ops->ldto_device_free(&ctx, d); @@ -441,7 +441,7 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) if (ldt != NULL && d != NULL) { struct lu_context ctx; - rc = lu_context_init(&ctx); + rc = lu_context_init(&ctx, ldt->ldt_ctx_tags); if (rc == 0) { lu_context_enter(&ctx); rc = d->ld_ops->ldo_process_config(&ctx, d, data); diff --git a/lustre/kernel_patches/patches/ext3-iam-separate.patch b/lustre/kernel_patches/patches/ext3-iam-separate.patch index 13e8532..61178cd 100644 --- a/lustre/kernel_patches/patches/ext3-iam-separate.patch +++ b/lustre/kernel_patches/patches/ext3-iam-separate.patch @@ -1,7 +1,7 @@ Index: iam/fs/ext3/Makefile =================================================================== --- iam.orig/fs/ext3/Makefile 2006-05-31 20:24:32.000000000 +0400 -+++ iam/fs/ext3/Makefile 2006-07-07 23:18:44.000000000 +0400 ++++ iam/fs/ext3/Makefile 2006-07-19 15:20:42.000000000 +0400 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ @@ -5441,7 +5441,7 @@ Index: iam/fs/ext3/namei.c Index: iam/include/linux/lustre_iam.h =================================================================== --- iam.orig/include/linux/lustre_iam.h 2006-05-31 20:24:32.000000000 +0400 -+++ iam/include/linux/lustre_iam.h 2006-07-07 23:18:44.000000000 +0400 ++++ iam/include/linux/lustre_iam.h 2006-07-19 15:20:42.000000000 +0400 @@ -1,9 +1,68 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: diff --git a/lustre/kernel_patches/patches/ext3-iam-uapi.patch b/lustre/kernel_patches/patches/ext3-iam-uapi.patch index 6404c02..77bd122 100644 --- a/lustre/kernel_patches/patches/ext3-iam-uapi.patch +++ b/lustre/kernel_patches/patches/ext3-iam-uapi.patch @@ -1,7 +1,7 @@ Index: iam/fs/ext3/Makefile =================================================================== ---- iam.orig/fs/ext3/Makefile 2006-07-07 23:18:44.000000000 +0400 -+++ iam/fs/ext3/Makefile 2006-07-07 23:18:45.000000000 +0400 +--- iam.orig/fs/ext3/Makefile 2006-07-19 15:20:42.000000000 +0400 ++++ iam/fs/ext3/Makefile 2006-07-19 15:20:43.000000000 +0400 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ @@ -13,8 +13,8 @@ Index: iam/fs/ext3/Makefile ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o Index: iam/fs/ext3/dir.c =================================================================== ---- iam.orig/fs/ext3/dir.c 2006-07-07 23:18:44.000000000 +0400 -+++ iam/fs/ext3/dir.c 2006-07-07 23:18:45.000000000 +0400 +--- iam.orig/fs/ext3/dir.c 2006-07-19 15:20:42.000000000 +0400 ++++ iam/fs/ext3/dir.c 2006-07-19 15:20:43.000000000 +0400 @@ -28,6 +28,7 @@ #include #include @@ -112,8 +112,8 @@ Index: iam/fs/ext3/dir.c (filp->f_version != inode->i_version)) { Index: iam/fs/ext3/file.c =================================================================== ---- iam.orig/fs/ext3/file.c 2006-07-07 23:18:44.000000000 +0400 -+++ iam/fs/ext3/file.c 2006-07-07 23:18:45.000000000 +0400 +--- iam.orig/fs/ext3/file.c 2006-07-19 15:20:42.000000000 +0400 ++++ iam/fs/ext3/file.c 2006-07-19 15:20:43.000000000 +0400 @@ -23,6 +23,7 @@ #include #include @@ -149,7 +149,7 @@ Index: iam/fs/ext3/file.c Index: iam/fs/ext3/iam-uapi.c =================================================================== --- iam.orig/fs/ext3/iam-uapi.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam-uapi.c 2006-07-07 23:18:45.000000000 +0400 ++++ iam/fs/ext3/iam-uapi.c 2006-07-19 15:20:43.000000000 +0400 @@ -0,0 +1,361 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: @@ -514,8 +514,8 @@ Index: iam/fs/ext3/iam-uapi.c +} Index: iam/fs/ext3/ioctl.c =================================================================== ---- iam.orig/fs/ext3/ioctl.c 2006-07-07 23:18:44.000000000 +0400 -+++ iam/fs/ext3/ioctl.c 2006-07-07 23:18:45.000000000 +0400 +--- iam.orig/fs/ext3/ioctl.c 2006-07-19 15:20:42.000000000 +0400 ++++ iam/fs/ext3/ioctl.c 2006-07-19 15:20:43.000000000 +0400 @@ -250,6 +250,6 @@ flags_err: @@ -526,8 +526,8 @@ Index: iam/fs/ext3/ioctl.c } Index: iam/include/linux/lustre_iam.h =================================================================== ---- iam.orig/include/linux/lustre_iam.h 2006-07-07 23:18:44.000000000 +0400 -+++ iam/include/linux/lustre_iam.h 2006-07-07 23:18:45.000000000 +0400 +--- iam.orig/include/linux/lustre_iam.h 2006-07-19 15:20:42.000000000 +0400 ++++ iam/include/linux/lustre_iam.h 2006-07-19 15:20:43.000000000 +0400 @@ -30,9 +30,6 @@ #ifndef __LINUX_LUSTRE_IAM_H__ #define __LINUX_LUSTRE_IAM_H__ diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 74f635b..1d555e7 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1548,7 +1548,8 @@ static int ldlm_setup(void) LDLM_MAXREPSIZE, LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, ldlm_timeout * 900, ldlm_callback_handler, "ldlm_cbd", - ldlm_svc_proc_dir, NULL, LDLM_NUM_THREADS); + ldlm_svc_proc_dir, NULL, LDLM_NUM_THREADS, + LCT_MD_THREAD|LCT_DT_THREAD); if (!ldlm_state->ldlm_cb_service) { CERROR("failed to start service\n"); @@ -1560,7 +1561,8 @@ static int ldlm_setup(void) LDLM_MAXREPSIZE, LDLM_CANCEL_REQUEST_PORTAL, LDLM_CANCEL_REPLY_PORTAL, 30000, ldlm_cancel_handler, "ldlm_canceld", - ldlm_svc_proc_dir, NULL, LDLM_NUM_THREADS); + ldlm_svc_proc_dir, NULL, LDLM_NUM_THREADS, + LCT_MD_THREAD|LCT_DT_THREAD); if (!ldlm_state->ldlm_cancel_service) { CERROR("failed to start service\n"); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 0d1749f..5b441d2 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -826,7 +826,7 @@ static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj, GOTO(cleanup, rc); inserted = 1; - + if (dt_try_as_dir(ctxt, dt_son)) { rc = __mdd_ref_add(ctxt, mdo, handle); if (rc) @@ -1124,9 +1124,10 @@ static struct lu_device_type_operations mdd_device_type_ops = { }; static struct lu_device_type mdd_device_type = { - .ldt_tags = LU_DEVICE_MD, - .ldt_name = LUSTRE_MDD0_NAME, - .ldt_ops = &mdd_device_type_ops + .ldt_tags = LU_DEVICE_MD, + .ldt_name = LUSTRE_MDD0_NAME, + .ldt_ops = &mdd_device_type_ops, + .ldt_ctx_tags = LCT_MD_THREAD }; static void *mdd_key_init(const struct lu_context *ctx, @@ -1148,6 +1149,7 @@ static void mdd_key_fini(const struct lu_context *ctx, } static struct lu_context_key mdd_thread_key = { + .lct_tags = LCT_MD_THREAD, .lct_init = mdd_key_init, .lct_fini = mdd_key_fini }; diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 1498ad3..fb7d30e 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -55,25 +55,22 @@ struct mdd_thread_info { int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd, struct lustre_cfg *cfg); int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd); -int mdd_notify(const struct lu_context *ctxt, struct md_device *md, - struct obd_device *watched, enum obd_notify_event ev, +int mdd_notify(const struct lu_context *ctxt, struct md_device *md, + struct obd_device *watched, enum obd_notify_event ev, void *data); int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj, const void *buf, int buf_len, const char *name); int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, - struct md_object *child, struct lov_mds_md *lmm, + struct md_object *child, struct lov_mds_md *lmm, int lmm_size); int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, - struct mdd_object *child, struct lov_mds_md **lmm, + struct mdd_object *child, struct lov_mds_md **lmm, int *lmm_size); struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx); extern struct lu_device_operations mdd_lu_ops; static inline int lu_device_is_mdd(struct lu_device *d) { - /* - * XXX for now. Tags in lu_device_type->ldt_something are needed. - */ return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &mdd_lu_ops); } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 68d3456..023b81d 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2462,7 +2462,7 @@ static int mdt_setup(struct obd_device *obd, struct lustre_cfg *lcfg) MDS_MAXREPSIZE, MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, MDS_SERVICE_WATCHDOG_TIMEOUT, mds_handle, LUSTRE_MDS_NAME, - obd->obd_proc_entry, NULL, mds_num_threads); + obd->obd_proc_entry, NULL, mds_num_threads, 0); if (!mds->mds_service) { CERROR("failed to start service\n"); @@ -2478,7 +2478,7 @@ static int mdt_setup(struct obd_device *obd, struct lustre_cfg *lcfg) MDS_MAXREPSIZE, MDS_SETATTR_PORTAL, MDC_REPLY_PORTAL, MDS_SERVICE_WATCHDOG_TIMEOUT, mds_handle, "mds_setattr", - obd->obd_proc_entry, NULL, mds_num_threads); + obd->obd_proc_entry, NULL, mds_num_threads, 0); if (!mds->mds_setattr_service) { CERROR("failed to start getattr service\n"); GOTO(err_thread, rc = -ENOMEM); @@ -2494,7 +2494,7 @@ static int mdt_setup(struct obd_device *obd, struct lustre_cfg *lcfg) MDS_MAXREPSIZE, MDS_READPAGE_PORTAL, MDC_REPLY_PORTAL, MDS_SERVICE_WATCHDOG_TIMEOUT, mds_handle, "mds_readpage", - obd->obd_proc_entry, NULL, mds_num_threads); + obd->obd_proc_entry, NULL, mds_num_threads, 0); if (!mds->mds_readpage_service) { CERROR("failed to start readpage service\n"); GOTO(err_thread2, rc = -ENOMEM); diff --git a/lustre/mdt/mdt_fs.c b/lustre/mdt/mdt_fs.c index 0524fba..0ed3a82 100644 --- a/lustre/mdt/mdt_fs.c +++ b/lustre/mdt/mdt_fs.c @@ -40,9 +40,9 @@ * It should not be possible to fail adding an existing client - otherwise * mdt_init_server_data() callsite needs to be fixed. */ -int mdt_client_add(const struct lu_context *ctxt, +int mdt_client_add(const struct lu_context *ctxt, struct mdt_device *mdt, - struct mdt_export_data *med, + struct mdt_export_data *med, int cl_idx) { unsigned long *bitmap = mdt->mdt_client_bitmap; @@ -82,18 +82,18 @@ int mdt_client_add(const struct lu_context *ctxt, cl_idx, med->med_mcd->mcd_uuid); med->med_lr_idx = cl_idx; - med->med_lr_off = le32_to_cpu(msd->msd_client_start) + + med->med_lr_off = le32_to_cpu(msd->msd_client_start) + (cl_idx * le16_to_cpu(msd->msd_client_size)); LASSERTF(med->med_lr_off > 0, "med_lr_off = %llu\n", med->med_lr_off); if (new_client) { loff_t off = med->med_lr_off; int rc = 0; - + /* - rc = mdt->mdt_last->do_body_ops->dbo_write(ctxt, + rc = mdt->mdt_last->do_body_ops->dbo_write(ctxt, mdt->mdt_last, - mcd, sizeof(*mcd), + mcd, sizeof(*mcd), &off); */ if (rc) @@ -104,8 +104,8 @@ int mdt_client_add(const struct lu_context *ctxt, return 0; } -int mdt_update_server_data(const struct lu_context *ctxt, - struct mdt_device *mdt, +int mdt_update_server_data(const struct lu_context *ctxt, + struct mdt_device *mdt, int sync) { struct mdt_server_data *msd = &mdt->mdt_msd; @@ -115,10 +115,10 @@ int mdt_update_server_data(const struct lu_context *ctxt, CDEBUG(D_SUPER, "MDS mount_count is "LPU64", last_transno is "LPU64"\n", mdt->mdt_mount_count, mdt->mdt_last_transno); - + msd->msd_last_transno = cpu_to_le64(mdt->mdt_last_transno); /* - rc = mdt->mdt_last->do_body_ops->dbo_write(ctxt, + rc = mdt->mdt_last->do_body_ops->dbo_write(ctxt, mdt->mdt_last, msd, sizeof(*msd), &off); @@ -127,8 +127,8 @@ int mdt_update_server_data(const struct lu_context *ctxt, } -int mdt_client_free(const struct lu_context *ctxt, - struct mdt_device *mdt, +int mdt_client_free(const struct lu_context *ctxt, + struct mdt_device *mdt, struct mdt_export_data *med) { struct mdt_client_data *mcd = med->med_mcd; @@ -162,7 +162,7 @@ int mdt_client_free(const struct lu_context *ctxt, memset(mcd, 0, sizeof *mcd); /* - rc = mdt->mdt_last->do_body_ops->dbo_write(ctxt, + rc = mdt->mdt_last->do_body_ops->dbo_write(ctxt, mdt->mdt_last, mcd, sizeof(*mcd), &off); @@ -189,7 +189,7 @@ free: return 0; } -static int mdt_init_server_data(const struct lu_context *ctxt, +static int mdt_init_server_data(const struct lu_context *ctxt, struct mdt_device *mdt) { struct mdt_server_data *msd = &mdt->mdt_msd; @@ -222,7 +222,7 @@ static int mdt_init_server_data(const struct lu_context *ctxt, OBD_INCOMPAT_COMMON_LR); } else { /* - rc = mdt->mdt_last->do_body_ops->dbo_read(ctxt, + rc = mdt->mdt_last->do_body_ops->dbo_read(ctxt, mdt->mdt_last, msd, sizeof(*msd), &off); @@ -308,7 +308,7 @@ static int mdt_init_server_data(const struct lu_context *ctxt, off = le32_to_cpu(msd->msd_client_start) + cl_idx * le16_to_cpu(msd->msd_client_size); /* - rc = mdt->mdt_last->do_body_ops->dbo_read(ctxt, + rc = mdt->mdt_last->do_body_ops->dbo_read(ctxt, mdt->mdt_last, mcd, sizeof(*mcd), &off); @@ -392,7 +392,7 @@ out: } /* - * last_rcvd update callbacks + * last_rcvd update callbacks */ extern struct lu_context_key mdt_txn_key; @@ -454,8 +454,8 @@ static int mdt_txn_commit_cb(const struct lu_context *ctx, return 0; } - -int mdt_fs_setup(const struct lu_context *ctxt, + +int mdt_fs_setup(const struct lu_context *ctxt, struct mdt_device *mdt) { //struct lu_fid last_fid; @@ -468,9 +468,9 @@ int mdt_fs_setup(const struct lu_context *ctxt, mdt->mdt_txn_cb.dtc_txn_stop = mdt_txn_stop_cb; mdt->mdt_txn_cb.dtc_txn_commit = mdt_txn_commit_cb; mdt->mdt_txn_cb.dtc_cookie = mdt; - + dt_txn_callback_add(mdt->mdt_bottom, &mdt->mdt_txn_cb); -/* +/* last = dt_store_open(ctxt, mdt->mdt_bottom, LAST_RCVD, &last_fid); if(!IS_ERR(last)) { mdt->mdt_last_rcvd = last; @@ -488,11 +488,11 @@ int mdt_fs_setup(const struct lu_context *ctxt, } -void mdt_fs_cleanup(const struct lu_context *ctxt, +void mdt_fs_cleanup(const struct lu_context *ctxt, struct mdt_device *mdt) { struct obd_device *obd = mdt->mdt_md_dev.md_lu_dev.ld_obd; - + /* remove transaction callback */ dt_txn_callback_del(mdt->mdt_bottom, &mdt->mdt_txn_cb); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 5f20021..e4c5fb4 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -60,7 +60,7 @@ */ unsigned long mdt_num_threads; -/* ptlrpc request handler for MDT. All handlers are +/* ptlrpc request handler for MDT. All handlers are * grouped into several slices - struct mdt_opc_slice, * and stored in an array - mdt_handlers[]. */ @@ -71,7 +71,7 @@ struct mdt_handler { int mh_fail_id; /* Operation code for this handler */ __u32 mh_opc; - /* flags are listed in enum mdt_handler_flags below. */ + /* flags are listed in enum mdt_handler_flags below. */ __u32 mh_flags; /* The actual handler function to execute. */ int (*mh_act)(struct mdt_thread_info *info); @@ -159,8 +159,8 @@ static int mdt_statfs(struct mdt_thread_info *info) RETURN(result); } -void mdt_pack_attr2body(struct mdt_body *b, - struct lu_attr *attr, +void mdt_pack_attr2body(struct mdt_body *b, + struct lu_attr *attr, const struct lu_fid *fid) { b->valid |= OBD_MD_FLCTIME | OBD_MD_FLUID | @@ -218,8 +218,8 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, rc = mo_attr_get(ctxt, next, la); if (rc == -EREMOTE) { /* FIXME: This object is located on remote node. - * What value should we return to client? - * also in mdt_md_create() and mdt_object_open() + * What value should we return to client? + * also in mdt_md_create() and mdt_object_open() */ if (need_pack_reply) { rc = req_capsule_pack(&info->mti_pill); @@ -232,7 +232,7 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, repbody->fid1 = *mdt_object_fid(o); repbody->valid |= OBD_MD_FLID; RETURN(0); - } + } if (rc){ CERROR("getattr error for "DFID3": %d\n", PFID3(mdt_object_fid(o)), rc); @@ -241,7 +241,7 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, if ( !need_pack_reply) goto skip_packing; - + /* pre-getattr: to guess how many bytes we need. */ if (mdt_body_has_lov(la, reqbody)) { /* this should return the total length, or error */ @@ -275,7 +275,7 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, RETURN(rc); } rc = 0; - } + } req_capsule_set_size(pill, &RMF_EADATA, RCL_SERVER, rc); } #endif @@ -330,7 +330,7 @@ skip_packing: repbody->valid |= OBD_MD_FLMODEASIZE; } - if (rc != 0) + if (rc != 0) RETURN(rc); #ifdef CONFIG_FS_POSIX_ACL if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) && @@ -341,7 +341,7 @@ skip_packing: &RMF_EADATA, RCL_SERVER); if (length > 0) { - rc = mo_xattr_get(info->mti_ctxt, next, buffer, + rc = mo_xattr_get(info->mti_ctxt, next, buffer, length, XATTR_NAME_ACL_ACCESS); if (rc < 0) { CERROR("got acl size: %d\n", rc); @@ -397,7 +397,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, name = req_capsule_client_get(&info->mti_pill, &RMF_NAME); if (name == NULL) RETURN(-EFAULT); - + intent_set_disposition(ldlm_rep, DISP_LOOKUP_EXECD); if (strlen(name) == 0) { /* only open the child. parent is on another node. */ @@ -412,7 +412,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, result = mdt_object_lock(info, child, lhc, child_bits); if (result != 0) { /* finally, we can get attr for child. */ - result = mdt_getattr_internal(info, child, + result = mdt_getattr_internal(info, child, ldlm_rep ? 0 : 1); if (result != 0) mdt_object_unlock(info, child, lhc); @@ -440,7 +440,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, /* *step 3: find the child object by fid & lock it. * regardless if it is local or remote. - */ + */ mdt_lock_handle_init(lhc); lhc->mlh_mode = LCK_CR; child = mdt_object_find_lock(info, child_fid, lhc, child_bits); @@ -621,10 +621,10 @@ static int mdt_sync(struct mdt_thread_info *info) rc = mo_attr_get(info->mti_ctxt, next, &info->mti_attr.ma_attr); if (rc == 0) { - body = req_capsule_server_get(pill, + body = req_capsule_server_get(pill, &RMF_MDT_BODY); - mdt_pack_attr2body(body, - &info->mti_attr.ma_attr, + mdt_pack_attr2body(body, + &info->mti_attr.ma_attr, fid); } } @@ -793,7 +793,7 @@ struct mdt_object *mdt_object_find(const struct lu_context *ctxt, RETURN(m); } -int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o, +int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o, struct mdt_lock_handle *lh, __u64 ibits) { ldlm_policy_data_t *policy = &info->mti_policy; @@ -989,13 +989,13 @@ int mdt_update_last_transno(struct mdt_thread_info *info, int rc) } spin_unlock(&mdt->mdt_transno_lock); } - + /*last_committed = (mdt->mdt_last_committed);*/ last_committed = last_transno; #endif txi = lu_context_key_get(info->mti_ctxt, &mdt_txn_key); last_transno = txi->txi_transno; - CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n", + CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n", last_transno, last_committed); req->rq_repmsg->transno = req->rq_transno = last_transno; req->rq_repmsg->last_xid = req->rq_xid; @@ -1035,10 +1035,10 @@ static int mdt_req_handle(struct mdt_thread_info *info, result = mdt_unpack_req_pack_rep(info, flags); } - + if (result == 0 && flags & HABEO_MUTABOR) { if (req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY) - result = -EROFS; + result = -EROFS; } if (result == 0 && flags & HABEO_CLAVIS) { struct ldlm_request *dlm_req; @@ -1084,7 +1084,7 @@ static int mdt_req_handle(struct mdt_thread_info *info, } /* If we're DISCONNECTing, the mdt_export_data is already freed */ - + if (h->mh_opc != MDS_DISCONNECT && h->mh_opc != MDS_READPAGE && h->mh_opc != LDLM_ENQUEUE) { @@ -1112,7 +1112,7 @@ static void mdt_thread_info_init(struct ptlrpc_request *req, int i; memset(info, 0, sizeof(*info)); - + info->mti_rep_buf_nr = ARRAY_SIZE(info->mti_rep_buf_size); for (i = 0; i < ARRAY_SIZE(info->mti_lh); i++) mdt_lock_handle_init(&info->mti_lh[i]); @@ -1297,7 +1297,7 @@ static int mdt_recovery(struct ptlrpc_request *req) RETURN(+1); } -static int mdt_reply(struct ptlrpc_request *req, int result, +static int mdt_reply(struct ptlrpc_request *req, int result, struct mdt_thread_info *info) { struct obd_device *obd; @@ -1522,7 +1522,7 @@ static int mdt_intent_getattr(enum mdt_it_code opcode, ldlm_rep = req_capsule_server_get(&info->mti_pill, &RMF_DLM_REP); intent_set_disposition(ldlm_rep, DISP_IT_EXECD); - ldlm_rep->lock_policy_res2 = + ldlm_rep->lock_policy_res2 = mdt_getattr_name_lock(info, lhc, child_bits, ldlm_rep); if (intent_disposition(ldlm_rep, DISP_LOOKUP_NEG)) @@ -1971,8 +1971,9 @@ static int mdt_start_ptlrpc_service(struct mdt_device *m) * We'd like to have a mechanism to set this on a per-device * basis, but alas... */ - .psc_num_threads = min(max(mdt_num_threads, MDT_MIN_THREADS), - MDT_MAX_THREADS) + .psc_num_threads = min(max(mdt_num_threads, MDT_MIN_THREADS), + MDT_MAX_THREADS), + .psc_ctx_tags = LCT_MD_THREAD }; ENTRY; @@ -1998,7 +1999,8 @@ static int mdt_start_ptlrpc_service(struct mdt_device *m) MDC_REPLY_PORTAL, MDT_SERVICE_WATCHDOG_TIMEOUT, mdt_handle, "mds_readpage", m->mdt_md_dev.md_lu_dev.ld_proc_entry, NULL, - min(max(mdt_num_threads, MDT_MIN_THREADS), MDT_MAX_THREADS)); + min(max(mdt_num_threads, MDT_MIN_THREADS), + MDT_MAX_THREADS), LCT_MD_THREAD); if (m->mdt_readpage_service == NULL) { CERROR("failed to start readpage service\n"); @@ -2137,7 +2139,7 @@ static void mdt_fini(const struct lu_context *ctx, struct mdt_device *m) struct lu_site *ls = d->ld_site; ENTRY; - + mdt_fs_cleanup(ctx, m); ping_evictor_stop(); @@ -2181,7 +2183,7 @@ static int mdt_init0(const struct lu_context *ctx, struct mdt_device *m, LASSERT(info != NULL); obd = class_name2obd(dev); - + spin_lock_init(&m->mdt_transno_lock); /* FIXME: We need to load them from disk. But now fake it */ m->mdt_last_transno = 100; @@ -2229,7 +2231,7 @@ static int mdt_init0(const struct lu_context *ctx, struct mdt_device *m, snprintf(info->mti_u.ns_name, sizeof info->mti_u.ns_name, LUSTRE_MDT0_NAME"-%p", m); - m->mdt_namespace = ldlm_namespace_new(info->mti_u.ns_name, + m->mdt_namespace = ldlm_namespace_new(info->mti_u.ns_name, LDLM_NAMESPACE_SERVER); if (m->mdt_namespace == NULL) GOTO(err_fini_seq, rc = -ENOMEM); @@ -2322,7 +2324,7 @@ static int mdt_object_init(const struct lu_context *ctxt, struct lu_object *o) int rc = 0; ENTRY; - CDEBUG(D_INFO, "object init, fid = "DFID3"\n", + CDEBUG(D_INFO, "object init, fid = "DFID3"\n", PFID3(&o->lo_header->loh_fid)); under = &d->mdt_child->md_lu_dev; @@ -2440,7 +2442,7 @@ static int mdt_obd_connect(struct lustre_handle *conn, struct obd_device *obd, if (mcd != NULL) { memcpy(mcd->mcd_uuid, cluuid, sizeof mcd->mcd_uuid); med->med_mcd = mcd; - rc = lu_context_init(&ctxt); + rc = lu_context_init(&ctxt, LCT_MD_THREAD); if (rc == 0) { lu_context_enter(&ctxt); /* @@ -2521,7 +2523,7 @@ static int mdt_destroy_export(struct obd_export *export) if (obd_uuid_equals(&export->exp_client_uuid, &obd->obd_uuid)) RETURN(0); - rc = lu_context_init(&ctxt); + rc = lu_context_init(&ctxt, LCT_MD_THREAD); if (rc) RETURN(rc); @@ -2563,15 +2565,15 @@ static int mdt_notify(struct obd_device *obd, struct obd_device *watched, int rc; ENTRY; - lu_context_init(&ctxt); + lu_context_init(&ctxt, LCT_MD_THREAD); mdt = mdt_dev(obd->obd_lu_dev); next = mdt->mdt_child; - + lu_context_enter(&ctxt); rc = next->md_ops->mdo_notify(&ctxt, next, watched, ev, data); lu_context_exit(&ctxt); - + lu_context_fini(&ctxt); RETURN(rc); } @@ -2642,6 +2644,7 @@ static void mdt_thread_fini(const struct lu_context *ctx, } static struct lu_context_key mdt_thread_key = { + .lct_tags = LCT_MD_THREAD, .lct_init = mdt_thread_init, .lct_fini = mdt_thread_fini }; @@ -2669,6 +2672,7 @@ static void mdt_txn_fini(const struct lu_context *ctx, } struct lu_context_key mdt_txn_key = { + .lct_tags = LCT_TX_HANDLE|LCT_MD_THREAD, .lct_init = mdt_txn_init, .lct_fini = mdt_txn_fini }; @@ -2699,9 +2703,10 @@ static struct lu_device_type_operations mdt_device_type_ops = { }; static struct lu_device_type mdt_device_type = { - .ldt_tags = LU_DEVICE_MD, - .ldt_name = LUSTRE_MDT0_NAME, - .ldt_ops = &mdt_device_type_ops + .ldt_tags = LU_DEVICE_MD, + .ldt_name = LUSTRE_MDT0_NAME, + .ldt_ops = &mdt_device_type_ops, + .ldt_ctx_tags = LCT_MD_THREAD }; static struct lprocfs_vars lprocfs_mdt_obd_vars[] = { @@ -2760,7 +2765,7 @@ DEF_MDT_HNDL_F(0, DISCONNECT, mdt_disconnect), DEF_MDT_HNDL_F(0 |HABEO_REFERO, GETSTATUS, mdt_getstatus), DEF_MDT_HNDL_F(HABEO_CORPUS, GETATTR, mdt_getattr), DEF_MDT_HNDL_F(HABEO_CORPUS, GETATTR_NAME, mdt_getattr_name), -DEF_MDT_HNDL_F(HABEO_CORPUS|HABEO_REFERO|HABEO_MUTABOR, +DEF_MDT_HNDL_F(HABEO_CORPUS|HABEO_REFERO|HABEO_MUTABOR, SETXATTR, mdt_setxattr), DEF_MDT_HNDL_F(HABEO_CORPUS, GETXATTR, mdt_getxattr), DEF_MDT_HNDL_F(0 |HABEO_REFERO, STATFS, mdt_statfs), diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 17411a6..f67a4ad 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -181,7 +181,8 @@ static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg) MGS_MAXREPSIZE, MGS_REQUEST_PORTAL, MGC_REPLY_PORTAL, MGS_SERVICE_WATCHDOG_TIMEOUT, mgs_handle, LUSTRE_MGS_NAME, - obd->obd_proc_entry, NULL, MGS_NUM_THREADS); + obd->obd_proc_entry, NULL, MGS_NUM_THREADS, + LCT_MD_THREAD); if (!mgs->mgs_service) { CERROR("failed to start service\n"); @@ -275,7 +276,7 @@ static int mgs_cleanup(struct obd_device *obd) /* Free the namespace in it's own thread, so that if the ldlm_cancel_handler put the last mgs obd ref, we won't deadlock here. */ - cfs_kernel_thread(mgs_ldlm_nsfree, obd->obd_namespace, + cfs_kernel_thread(mgs_ldlm_nsfree, obd->obd_namespace, CLONE_VM | CLONE_FILES); lvfs_clear_rdonly(save_dev); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 5599f14..f31b886 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -653,7 +653,7 @@ static int keys_init(struct lu_context *ctx) struct lu_context_key *key; key = lu_keys[i]; - if (key != NULL) { + if (key != NULL && key->lct_tags & ctx->lc_tags) { void *value; LASSERT(key->lct_init != NULL); @@ -677,9 +677,10 @@ static int keys_init(struct lu_context *ctx) /* * Initialize context data-structure. Create values for all keys. */ -int lu_context_init(struct lu_context *ctx) +int lu_context_init(struct lu_context *ctx, __u32 tags) { memset(ctx, 0, sizeof *ctx); + ctx->lc_tags = tags; keys_init(ctx); return 0; } diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 4a071db..dc8626c 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -416,7 +416,7 @@ static struct thandle *osd_trans_start(const struct lu_context *ctx, th->th_dev = d; lu_device_get(&d->dd_lu_dev); /* add commit callback */ - lu_context_init(&th->th_ctx); + lu_context_init(&th->th_ctx, LCT_TX_HANDLE); journal_callback_set(jh, osd_trans_commit_cb, (struct journal_callback *)&oh->ot_jcb); } else { @@ -1130,6 +1130,7 @@ static void osd_type_fini(struct lu_device_type *t) } static struct lu_context_key osd_key = { + .lct_tags = LCT_MD_THREAD|LCT_DT_THREAD, .lct_init = osd_key_init, .lct_fini = osd_key_fini }; @@ -1525,9 +1526,10 @@ static struct lu_device_type_operations osd_device_type_ops = { }; static struct lu_device_type osd_device_type = { - .ldt_tags = LU_DEVICE_DT, - .ldt_name = LUSTRE_OSD0_NAME, - .ldt_ops = &osd_device_type_ops + .ldt_tags = LU_DEVICE_DT, + .ldt_name = LUSTRE_OSD0_NAME, + .ldt_ops = &osd_device_type_ops, + .ldt_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD }; /* diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 0bb8c64..9d6662c 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1634,7 +1634,7 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg) OSC_REPLY_PORTAL, obd_timeout * 1000, ost_handle, LUSTRE_OSS_NAME, obd->obd_proc_entry, ost_print_req, - ost_num_threads); + ost_num_threads, LCT_DT_THREAD); if (ost->ost_service == NULL) { CERROR("failed to start service\n"); GOTO(out_lprocfs, rc = -ENOMEM); @@ -1649,7 +1649,8 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg) OST_MAXREPSIZE, OST_CREATE_PORTAL, OSC_REPLY_PORTAL, obd_timeout * 1000, ost_handle, "ost_create", - obd->obd_proc_entry, ost_print_req, 1); + obd->obd_proc_entry, ost_print_req, 1, + LCT_DT_THREAD); if (ost->ost_create_service == NULL) { CERROR("failed to start OST create service\n"); GOTO(out_service, rc = -ENOMEM); @@ -1666,7 +1667,7 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg) OSC_REPLY_PORTAL, obd_timeout * 1000, ost_handle, "ost_io", obd->obd_proc_entry, ost_print_req, - ost_num_threads); + ost_num_threads, LCT_DT_THREAD); if (ost->ost_io_service == NULL) { CERROR("failed to start OST I/O service\n"); GOTO(out_create, rc = -ENOMEM); diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index cca18c7..83ce195 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -267,7 +267,7 @@ struct ptlrpc_service *ptlrpc_init_svc_conf(struct ptlrpc_service_conf *c, c->psc_req_portal, c->psc_rep_portal, c->psc_watchdog_timeout, h, name, proc_entry, - prntfn, c->psc_num_threads); + prntfn, c->psc_num_threads, c->psc_ctx_tags); } EXPORT_SYMBOL(ptlrpc_init_svc_conf); @@ -276,7 +276,8 @@ ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int max_reply_size, int req_portal, int rep_portal, int watchdog_timeout, svc_handler_t handler, char *name, cfs_proc_dir_entry_t *proc_entry, - svcreq_printfn_t svcreq_printfn, int num_threads) + svcreq_printfn_t svcreq_printfn, int num_threads, + __u32 ctx_tags) { int rc; struct ptlrpc_service *service; @@ -284,6 +285,7 @@ ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int max_reply_size, LASSERT (nbufs > 0); LASSERT (bufsize >= max_req_size); + LASSERT (ctx_tags != 0); OBD_ALLOC(service, sizeof(*service)); if (service == NULL) @@ -307,6 +309,7 @@ ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int max_reply_size, service->srv_request_seq = 1; /* valid seq #s start at 1 */ service->srv_request_max_cull_seq = 0; service->srv_num_threads = num_threads; + service->srv_ctx_tags = ctx_tags; CFS_INIT_LIST_HEAD(&service->srv_request_queue); CFS_INIT_LIST_HEAD(&service->srv_idle_rqbds); @@ -921,7 +924,7 @@ static int ptlrpc_main(void *arg) goto out; } - rc = lu_context_init(&ctx); + rc = lu_context_init(&ctx, svc->srv_ctx_tags); if (rc) goto out_srv_init;