From: yury Date: Sun, 25 Jun 2006 13:20:53 +0000 (+0000) Subject: - fixes in seq-mgr proc stuff. By now all seq-mgr proc root entriy names based on... X-Git-Tag: v1_8_0_110~486^2~1552 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=23ca84df748e11c0926dc51913d31e929ea236ed;p=fs%2Flustre-release.git - fixes in seq-mgr proc stuff. By now all seq-mgr proc root entriy names based on name of obd they are stick with; - added seq-mgr client proc basics. --- diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index ffc74d2..5b0201e 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -381,25 +381,23 @@ out: } #ifdef LPROCFS -static cfs_proc_dir_entry_t *seq_type_proc_dir = NULL; - static int seq_server_proc_init(struct lu_server_seq *seq) { int rc; ENTRY; - seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ0_NAME, + seq->seq_proc_dir = lprocfs_register(seq->seq_name, proc_lustre_root, NULL, NULL); - if (IS_ERR(seq_type_proc_dir)) { + if (IS_ERR(seq->seq_proc_dir)) { CERROR("LProcFS failed in seq-init\n"); - rc = PTR_ERR(seq_type_proc_dir); + rc = PTR_ERR(seq->seq_proc_dir); GOTO(err, rc); } seq->seq_proc_entry = lprocfs_register("services", - seq_type_proc_dir, + seq->seq_proc_dir, NULL, NULL); if (IS_ERR(seq->seq_proc_entry)) { CERROR("LProcFS failed in seq-init\n"); @@ -407,7 +405,7 @@ seq_server_proc_init(struct lu_server_seq *seq) GOTO(err_type, rc); } - rc = lprocfs_add_vars(seq_type_proc_dir, + rc = lprocfs_add_vars(seq->seq_proc_dir, seq_server_proc_list, seq); if (rc) { CERROR("can't init sequence manager " @@ -417,14 +415,15 @@ seq_server_proc_init(struct lu_server_seq *seq) RETURN(0); err_type: - lprocfs_remove(seq_type_proc_dir); + lprocfs_remove(seq->seq_proc_dir); err: - seq_type_proc_dir = NULL; + seq->seq_proc_dir = NULL; seq->seq_proc_entry = NULL; return rc; } -void seq_server_proc_fini(struct lu_server_seq *seq) +static void +seq_server_proc_fini(struct lu_server_seq *seq) { ENTRY; if (seq->seq_proc_entry) { @@ -432,9 +431,9 @@ void seq_server_proc_fini(struct lu_server_seq *seq) seq->seq_proc_entry = NULL; } - if (seq_type_proc_dir) { - lprocfs_remove(seq_type_proc_dir); - seq_type_proc_dir = NULL; + if (seq->seq_proc_dir) { + lprocfs_remove(seq->seq_proc_dir); + seq->seq_proc_dir = NULL; } EXIT; } @@ -443,6 +442,7 @@ void seq_server_proc_fini(struct lu_server_seq *seq) int seq_server_init(struct lu_server_seq *seq, struct dt_device *dev, + const char *uuid, const struct lu_context *ctx) { int rc; @@ -459,11 +459,15 @@ seq_server_init(struct lu_server_seq *seq, ENTRY; LASSERT(dev != NULL); + LASSERT(uuid != NULL); seq->seq_dev = dev; seq->seq_cli = NULL; sema_init(&seq->seq_sem, 1); + snprintf(seq->seq_name, sizeof(seq->seq_name), + "%s-%s", LUSTRE_SEQ_NAME, uuid); + seq->seq_space = LUSTRE_SEQ_SPACE_RANGE; seq->seq_super = LUSTRE_SEQ_ZERO_RANGE; @@ -488,12 +492,12 @@ seq_server_init(struct lu_server_seq *seq, seq->seq_service = ptlrpc_init_svc_conf(&seq_conf, seq_req_handle, - LUSTRE_SEQ0_NAME, + LUSTRE_SEQ_NAME, seq->seq_proc_entry, NULL); if (seq->seq_service != NULL) rc = ptlrpc_start_threads(NULL, seq->seq_service, - LUSTRE_SEQ0_NAME); + LUSTRE_SEQ_NAME); else rc = -ENOMEM; diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index 86afbda..f5c842d 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -248,10 +248,55 @@ out: } EXPORT_SYMBOL(seq_client_alloc_fid); +#ifdef LPROCFS +static int +seq_client_proc_init(struct lu_client_seq *seq) +{ + int rc; + ENTRY; + + seq->seq_proc_dir = lprocfs_register(seq->seq_name, + proc_lustre_root, + NULL, NULL); + + if (IS_ERR(seq->seq_proc_dir)) { + CERROR("LProcFS failed in seq-init\n"); + rc = PTR_ERR(seq->seq_proc_dir); + GOTO(err, rc); + } + + rc = lprocfs_add_vars(seq->seq_proc_dir, + seq_client_proc_list, seq); + if (rc) { + CERROR("can't init sequence manager " + "proc, rc %d\n", rc); + } + + RETURN(0); + +err: + seq->seq_proc_dir = NULL; + return rc; +} + +static void +seq_client_proc_fini(struct lu_client_seq *seq) +{ + ENTRY; + if (seq->seq_proc_dir) { + lprocfs_remove(seq->seq_proc_dir); + seq->seq_proc_dir = NULL; + } + EXIT; +} +#endif + int -seq_client_init(struct lu_client_seq *seq, +seq_client_init(struct lu_client_seq *seq, + const char *uuid, struct obd_export *exp) { + int rc; ENTRY; LASSERT(exp != NULL); @@ -261,8 +306,18 @@ seq_client_init(struct lu_client_seq *seq, sema_init(&seq->seq_sem, 1); seq->seq_exp = class_export_get(exp); - CDEBUG(D_INFO|D_WARNING, "Client Sequence " - "Manager initialized\n"); + snprintf(seq->seq_name, sizeof(seq->seq_name), + "%s-%s", LUSTRE_SEQ_NAME, uuid); + +#ifdef LPROCFS + rc = seq_client_proc_init(seq); + if (rc) { + class_export_put(seq->seq_exp); + RETURN(rc); + } +#endif + + CDEBUG(D_INFO|D_WARNING, "Client Sequence Manager\n"); RETURN(0); } EXPORT_SYMBOL(seq_client_init); @@ -270,11 +325,18 @@ EXPORT_SYMBOL(seq_client_init); void seq_client_fini(struct lu_client_seq *seq) { ENTRY; + +#ifdef LPROCFS + seq_client_proc_fini(seq); +#endif + if (seq->seq_exp != NULL) { class_export_put(seq->seq_exp); seq->seq_exp = NULL; } - CDEBUG(D_INFO|D_WARNING, "Client Sequence Manager finalized\n"); + + CDEBUG(D_INFO|D_WARNING, "Client Sequence Manager\n"); + EXIT; } EXPORT_SYMBOL(seq_client_fini); diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index 871fe04..33f787a 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -48,10 +48,11 @@ #include "fid_internal.h" #ifdef LPROCFS +/* server side procfs stuff */ static int -seq_proc_write_range(struct file *file, const char *buffer, - unsigned long count, void *data, - struct lu_range *range) +seq_proc_write_common(struct file *file, const char *buffer, + unsigned long count, void *data, + struct lu_range *range) { struct lu_range tmp; int rc; @@ -74,9 +75,9 @@ seq_proc_write_range(struct file *file, const char *buffer, } static int -seq_proc_read_range(char *page, char **start, off_t off, - int count, int *eof, void *data, - struct lu_range *range) +seq_proc_read_common(char *page, char **start, off_t off, + int count, int *eof, void *data, + struct lu_range *range) { int rc; ENTRY; @@ -98,8 +99,8 @@ seq_proc_write_space(struct file *file, const char *buffer, LASSERT(seq != NULL); down(&seq->seq_sem); - rc = seq_proc_write_range(file, buffer, count, - data, &seq->seq_space); + rc = seq_proc_write_common(file, buffer, count, + data, &seq->seq_space); if (rc == 0) { CDEBUG(D_WARNING, "SEQ-MGR(srv): sequences space has changed " "to ["LPU64"-"LPU64"]\n", seq->seq_space.lr_start, @@ -122,8 +123,8 @@ seq_proc_read_space(char *page, char **start, off_t off, LASSERT(seq != NULL); down(&seq->seq_sem); - rc = seq_proc_read_range(page, start, off, count, eof, - data, &seq->seq_space); + rc = seq_proc_read_common(page, start, off, count, eof, + data, &seq->seq_space); up(&seq->seq_sem); RETURN(rc); @@ -140,8 +141,8 @@ seq_proc_write_super(struct file *file, const char *buffer, LASSERT(seq != NULL); down(&seq->seq_sem); - rc = seq_proc_write_range(file, buffer, count, - data, &seq->seq_super); + rc = seq_proc_write_common(file, buffer, count, + data, &seq->seq_super); if (rc == 0) { CDEBUG(D_WARNING, "SEQ-MGR(srv): super-sequence has changed to " @@ -165,41 +166,40 @@ seq_proc_read_super(char *page, char **start, off_t off, LASSERT(seq != NULL); down(&seq->seq_sem); - rc = seq_proc_read_range(page, start, off, count, eof, - data, &seq->seq_super); + rc = seq_proc_read_common(page, start, off, count, eof, + data, &seq->seq_super); up(&seq->seq_sem); RETURN(rc); } static int -seq_proc_write_meta(struct file *file, const char *buffer, - unsigned long count, void *data) +seq_proc_read_controller(char *page, char **start, off_t off, + int count, int *eof, void *data) { - struct lu_client_seq *seq = (struct lu_client_seq *)data; + struct lu_server_seq *seq = (struct lu_server_seq *)data; int rc; ENTRY; LASSERT(seq != NULL); - down(&seq->seq_sem); - rc = seq_proc_write_range(file, buffer, count, - data, &seq->seq_range); + *eof = 1; + if (seq->seq_cli) { + struct obd_export *exp = seq->seq_cli->seq_exp; - if (rc == 0) { - CDEBUG(D_WARNING, "SEQ-MGR(cli): meta-sequence has changed to " - "["LPU64"-"LPU64"]\n", seq->seq_range.lr_start, - seq->seq_range.lr_end); + rc = snprintf(page, count, "%s\n", + exp->exp_client_uuid.uuid); + } else { + rc = snprintf(page, count, "\n"); } - up(&seq->seq_sem); - - RETURN(count); + RETURN(rc); } +/* client side procfs stuff */ static int -seq_proc_read_meta(char *page, char **start, off_t off, - int count, int *eof, void *data) +seq_proc_write_range(struct file *file, const char *buffer, + unsigned long count, void *data) { struct lu_client_seq *seq = (struct lu_client_seq *)data; int rc; @@ -208,32 +208,34 @@ seq_proc_read_meta(char *page, char **start, off_t off, LASSERT(seq != NULL); down(&seq->seq_sem); - rc = seq_proc_read_range(page, start, off, count, eof, - data, &seq->seq_range); + rc = seq_proc_write_common(file, buffer, count, + data, &seq->seq_range); + + if (rc == 0) { + CDEBUG(D_WARNING, "SEQ-MGR(cli): meta-sequence has changed to " + "["LPU64"-"LPU64"]\n", seq->seq_range.lr_start, + seq->seq_range.lr_end); + } + up(&seq->seq_sem); - RETURN(rc); + RETURN(count); } static int -seq_proc_read_controller(char *page, char **start, off_t off, - int count, int *eof, void *data) +seq_proc_read_range(char *page, char **start, off_t off, + int count, int *eof, void *data) { - struct lu_server_seq *seq = (struct lu_server_seq *)data; + struct lu_client_seq *seq = (struct lu_client_seq *)data; int rc; ENTRY; LASSERT(seq != NULL); - *eof = 1; - if (seq->seq_cli) { - struct obd_export *exp = seq->seq_cli->seq_exp; - - rc = snprintf(page, count, "%s\n", - exp->exp_client_uuid.uuid); - } else { - rc = snprintf(page, count, "\n"); - } + down(&seq->seq_sem); + rc = seq_proc_read_common(page, start, off, count, eof, + data, &seq->seq_range); + up(&seq->seq_sem); RETURN(rc); } @@ -245,6 +247,6 @@ struct lprocfs_vars seq_server_proc_list[] = { { NULL }}; struct lprocfs_vars seq_client_proc_list[] = { - { "meta", seq_proc_read_meta, seq_proc_write_meta, NULL }, + { "range", seq_proc_read_range, seq_proc_write_range, NULL }, { NULL }}; #endif diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 00e7e2c..73d8f9b 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -240,11 +240,11 @@ fld_server_init(struct lu_server_fld *fld, if (rc == 0) { fld->fld_service = ptlrpc_init_svc_conf(&fld_conf, fld_req_handle, - LUSTRE_FLD0_NAME, + LUSTRE_FLD_NAME, fld->fld_proc_entry, NULL); if (fld->fld_service != NULL) rc = ptlrpc_start_threads(NULL, fld->fld_service, - LUSTRE_FLD0_NAME); + LUSTRE_FLD_NAME); else rc = -ENOMEM; } diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index 6bc8563..992d0be 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -61,10 +61,14 @@ struct lu_client_seq { struct lu_range seq_range; /* seq related proc */ - cfs_proc_dir_entry_t *seq_proc_entry; + cfs_proc_dir_entry_t *seq_proc_dir; /* this holds last allocated fid in last obtained seq */ struct lu_fid seq_fid; + + /* service uuid, passed from MDT + seq name to form unique seq name to + * use it with procfs. */ + char seq_name[80]; }; #ifdef __KERNEL__ @@ -83,6 +87,8 @@ struct lu_server_seq { /* seq related proc */ cfs_proc_dir_entry_t *seq_proc_entry; + cfs_proc_dir_entry_t *seq_proc_dir; + /* server side seq service */ struct ptlrpc_service *seq_service; @@ -92,12 +98,17 @@ struct lu_server_seq { /* semaphore for protecting allocation */ struct semaphore seq_sem; + + /* service uuid, passed from MDT + seq name to form unique seq name to + * use it with procfs. */ + char seq_name[80]; }; #endif #ifdef __KERNEL__ int seq_server_init(struct lu_server_seq *seq, struct dt_device *dev, + const char *uuid, const struct lu_context *ctx); void seq_server_fini(struct lu_server_seq *seq, @@ -109,6 +120,7 @@ int seq_server_set_ctlr(struct lu_server_seq *seq, #endif int seq_client_init(struct lu_client_seq *seq, + const char *uuid, struct obd_export *exp); void seq_client_fini(struct lu_client_seq *seq); diff --git a/lustre/include/obd.h b/lustre/include/obd.h index ddfa9d8..772940d 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -550,18 +550,19 @@ struct lu_placement_hint { int ph_opc; }; +#define LUSTRE_FLD_NAME "fld" +#define LUSTRE_SEQ_NAME "seq" + /* device types (not names--FIXME) */ /* FIXME all the references to these defines need to be updated */ -#define LUSTRE_MDS_NAME "mds" -#define LUSTRE_MDT_NAME "mdt" +#define LUSTRE_MDS_NAME "mds" +#define LUSTRE_MDT_NAME "mdt" /* new MDS layers. Prototype */ #define LUSTRE_MDT0_NAME "mdt0" #define LUSTRE_CMM0_NAME "cmm0" #define LUSTRE_MDD0_NAME "mdd0" #define LUSTRE_OSD0_NAME "osd0" -#define LUSTRE_FLD0_NAME "fld0" -#define LUSTRE_SEQ0_NAME "seq0" #define LUSTRE_MDC0_NAME "mdc0" #define LUSTRE_MDC_NAME "mdc" diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index c7cdece..13badfb 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1067,7 +1067,8 @@ static int mdc_fid_init(struct obd_export *exp) RETURN(-ENOMEM); /* init client side sequence-manager */ - rc = seq_client_init(cli->cl_seq, exp); + rc = seq_client_init(cli->cl_seq, + exp->exp_obd->obd_name, exp); if (rc) GOTO(out_free_seq, rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e560595..e6b8653 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1672,6 +1672,7 @@ static int mdt_seq_fini(const struct lu_context *ctx, } static int mdt_seq_init(const struct lu_context *ctx, + const char *uuid, struct mdt_device *m) { struct lu_site *ls; @@ -1683,8 +1684,9 @@ static int mdt_seq_init(const struct lu_context *ctx, OBD_ALLOC_PTR(ls->ls_server_seq); if (ls->ls_server_seq != NULL) { - rc = seq_server_init(ls->ls_server_seq, - m->mdt_bottom, ctx); + rc = seq_server_init(ls->ls_server_seq, + m->mdt_bottom, uuid, + ctx); } else rc = -ENOMEM; @@ -1740,6 +1742,7 @@ static int mdt_seq_ctlr_init(const struct lu_context *ctx, if (ls->ls_client_seq != NULL) { rc = seq_client_init(ls->ls_client_seq, + mdc->obd_name, ls->ls_controller); } else rc = -ENOMEM; @@ -2076,7 +2079,7 @@ static int mdt_init0(struct mdt_device *m, GOTO(err_fini_stack, rc); lu_context_enter(&ctx); - rc = mdt_seq_init(&ctx, m); + rc = mdt_seq_init(&ctx, obd->obd_name, m); lu_context_exit(&ctx); if (rc) GOTO(err_fini_fld, rc);