From 013233c0bc70c9dfde8e7c21f2f1a940e6693a3c Mon Sep 17 00:00:00 2001 From: yury Date: Sun, 25 Jun 2006 15:26:33 +0000 Subject: [PATCH] - fixes in seq-mgr procfs stuff; - added basic procfs support to fld. --- lustre/cmm/cmm_device.c | 3 +- lustre/fid/fid_handler.c | 9 ++-- lustre/fid/fid_request.c | 19 ++++++--- lustre/fid/lproc_fid.c | 22 +++++++++- lustre/fld/Makefile.in | 2 +- lustre/fld/autoMakefile.am | 2 +- lustre/fld/fld_handler.c | 102 ++++++++++++++++++++++++++++++++++++++------ lustre/fld/fld_internal.h | 5 +++ lustre/fld/fld_request.c | 90 +++++++++++++++++++++++++++++++++----- lustre/fld/lproc_fld.c | 56 ++++++++++++++++++++++++ lustre/include/lustre_fld.h | 4 ++ lustre/lmv/lmv_obd.c | 3 +- lustre/mdt/mdt_handler.c | 12 ++++-- 13 files changed, 284 insertions(+), 45 deletions(-) create mode 100644 lustre/fld/lproc_fld.c diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 123770a..bad1f3c 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -249,7 +249,8 @@ static int cmm_device_init(const struct lu_context *ctx, m->cmm_tgt_count = 0; m->cmm_child = lu2md_dev(next); - err = fld_client_init(&m->cmm_fld, LUSTRE_CLI_FLD_HASH_RRB); + err = fld_client_init(&m->cmm_fld, "CMM_UUID", + LUSTRE_CLI_FLD_HASH_RRB); if (err) { CERROR("can't init FLD, err %d\n", err); } diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index abb2ca9..7646da6 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -410,6 +410,7 @@ seq_server_proc_init(struct lu_server_seq *seq) if (rc) { CERROR("can't init sequence manager " "proc, rc %d\n", rc); + GOTO(err_type, rc); } RETURN(0); @@ -507,15 +508,11 @@ seq_server_init(struct lu_server_seq *seq, EXIT; out: - if (rc) { -#ifdef LPROCFS - seq_server_proc_fini(seq); -#endif + if (rc) seq_server_fini(seq, ctx); - } else { + else CDEBUG(D_INFO|D_WARNING, "Server Sequence " "Manager\n"); - } return rc; } EXPORT_SYMBOL(seq_server_init); diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index e40b8e8..2970c78 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -270,6 +270,7 @@ seq_client_proc_init(struct lu_client_seq *seq) if (rc) { CERROR("can't init sequence manager " "proc, rc %d\n", rc); + GOTO(err, rc); } RETURN(0); @@ -312,14 +313,18 @@ seq_client_init(struct lu_client_seq *seq, #ifdef LPROCFS rc = seq_client_proc_init(seq); - if (rc) { - class_export_put(seq->seq_exp); - RETURN(rc); - } + if (rc) + GOTO(out, rc); #endif - - CDEBUG(D_INFO|D_WARNING, "Client Sequence Manager\n"); - RETURN(0); + + EXIT; +out: + if (rc) + seq_client_fini(seq); + else + CDEBUG(D_INFO|D_WARNING, + "Client Sequence Manager\n"); + return rc; } EXPORT_SYMBOL(seq_client_init); diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index 9b30ac8..8c1b05c8 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -372,7 +372,26 @@ seq_proc_read_seq_width(char *page, char **start, off_t off, LASSERT(seq != NULL); down(&seq->seq_sem); - rc = snprintf(page, count, LPU64"\n", seq->seq_width); + rc = snprintf(page, count, LPU64"\n", + seq->seq_width); + up(&seq->seq_sem); + + RETURN(rc); +} + +static int +seq_proc_read_next_fid(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct lu_client_seq *seq = (struct lu_client_seq *)data; + int rc; + ENTRY; + + LASSERT(seq != NULL); + + down(&seq->seq_sem); + rc = snprintf(page, count, DFID3"\n", + PFID3(&seq->seq_fid)); up(&seq->seq_sem); RETURN(rc); @@ -404,6 +423,7 @@ struct lprocfs_vars seq_server_proc_list[] = { struct lprocfs_vars seq_client_proc_list[] = { { "range", seq_proc_read_range, seq_proc_write_range, NULL }, { "server", seq_proc_read_server, NULL, NULL }, + { "next_fid" , seq_proc_read_next_fid, NULL, NULL }, { "seq_width", seq_proc_read_seq_width, seq_proc_write_seq_width, NULL }, { NULL }}; #endif diff --git a/lustre/fld/Makefile.in b/lustre/fld/Makefile.in index 31e9ddf..0eb8776 100644 --- a/lustre/fld/Makefile.in +++ b/lustre/fld/Makefile.in @@ -1,5 +1,5 @@ MODULES := fld -fld-objs := fld_handler.o fld_request.o fld_index.o +fld-objs := fld_handler.o fld_request.o fld_index.o lproc_fld.o EXTRA_PRE_CFLAGS := -I@LUSTRE@ -I@LUSTRE@/ldiskfs diff --git a/lustre/fld/autoMakefile.am b/lustre/fld/autoMakefile.am index d6c4037..4a48179 100644 --- a/lustre/fld/autoMakefile.am +++ b/lustre/fld/autoMakefile.am @@ -5,7 +5,7 @@ if LIBLUSTRE noinst_LIBRARIES = libfld.a -libfld_a_SOURCES = fld_handler.c fld_request.c fld_index.c fld_internal.h +libfld_a_SOURCES = fld_handler.c fld_request.c fld_index.c lproc_fld.c fld_internal.h libfld_a_CPPFLAGS = $(LLCPPFLAGS) libfld_a_CFLAGS = $(LLCFLAGS) endif diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 73d8f9b..b790263 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -215,9 +215,69 @@ out: return 0; } +#ifdef LPROCFS +static int +fld_server_proc_init(struct lu_server_fld *fld) +{ + int rc; + ENTRY; + + fld->fld_proc_dir = lprocfs_register(fld->fld_name, + proc_lustre_root, + NULL, NULL); + if (IS_ERR(fld->fld_proc_dir)) { + CERROR("LProcFS failed in fld-init\n"); + rc = PTR_ERR(fld->fld_proc_dir); + GOTO(err, rc); + } + + fld->fld_proc_entry = lprocfs_register("services", + fld->fld_proc_dir, + NULL, NULL); + if (IS_ERR(fld->fld_proc_entry)) { + CERROR("LProcFS failed in fld-init\n"); + rc = PTR_ERR(fld->fld_proc_entry); + GOTO(err_type, rc); + } + + rc = lprocfs_add_vars(fld->fld_proc_dir, + fld_server_proc_list, fld); + if (rc) { + CERROR("can't init FLD proc, rc %d\n", rc); + GOTO(err_type, rc); + } + + RETURN(0); + +err_type: + lprocfs_remove(fld->fld_proc_dir); +err: + fld->fld_proc_dir = NULL; + fld->fld_proc_entry = NULL; + return rc; +} + +static void +fld_server_proc_fini(struct lu_server_fld *fld) +{ + ENTRY; + if (fld->fld_proc_entry) { + lprocfs_remove(fld->fld_proc_entry); + fld->fld_proc_entry = NULL; + } + + if (fld->fld_proc_dir) { + lprocfs_remove(fld->fld_proc_dir); + fld->fld_proc_dir = NULL; + } + EXIT; +} +#endif + int fld_server_init(struct lu_server_fld *fld, const struct lu_context *ctx, + const char *uuid, struct dt_device *dt) { int rc; @@ -235,25 +295,37 @@ fld_server_init(struct lu_server_fld *fld, fld->fld_dt = dt; lu_device_get(&dt->dd_lu_dev); + + snprintf(fld->fld_name, sizeof(fld->fld_name), + "%s-%s", LUSTRE_FLD_NAME, uuid); + rc = fld_index_init(fld, ctx); + if (rc) + GOTO(out, rc); - if (rc == 0) { - fld->fld_service = - ptlrpc_init_svc_conf(&fld_conf, fld_req_handle, - LUSTRE_FLD_NAME, - fld->fld_proc_entry, NULL); - if (fld->fld_service != NULL) - rc = ptlrpc_start_threads(NULL, fld->fld_service, - LUSTRE_FLD_NAME); - else - rc = -ENOMEM; - } +#ifdef LPROCFS + rc = fld_server_proc_init(fld); + if (rc) + GOTO(out, rc); +#endif + + fld->fld_service = + ptlrpc_init_svc_conf(&fld_conf, fld_req_handle, + LUSTRE_FLD_NAME, + fld->fld_proc_entry, NULL); + if (fld->fld_service != NULL) + rc = ptlrpc_start_threads(NULL, fld->fld_service, + LUSTRE_FLD_NAME); + else + rc = -ENOMEM; - if (rc != 0) + EXIT; +out: + if (rc) fld_server_fini(fld, ctx); else CDEBUG(D_INFO|D_WARNING, "Server FLD\n"); - RETURN(rc); + return rc; } EXPORT_SYMBOL(fld_server_init); @@ -263,6 +335,10 @@ fld_server_fini(struct lu_server_fld *fld, { ENTRY; +#ifdef LPROCFS + fld_server_proc_fini(fld); +#endif + if (fld->fld_service != NULL) { ptlrpc_unregister_service(fld->fld_service); fld->fld_service = NULL; diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index b169730..7570fe8 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -74,4 +74,9 @@ int fld_index_init(struct lu_server_fld *fld, void fld_index_fini(struct lu_server_fld *fld, const struct lu_context *ctx); +#ifdef LPROCFS +extern struct lprocfs_vars fld_server_proc_list[]; +extern struct lprocfs_vars fld_client_proc_list[]; +#endif + #endif diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index 86f04fa..9b3218d 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -55,7 +55,8 @@ #ifdef __KERNEL__ extern struct fld_cache_info *fld_cache; -static __u32 fld_cache_hash(__u64 seq) +static __u32 +fld_cache_hash(__u64 seq) { return seq; } @@ -144,7 +145,8 @@ fld_cache_lookup(struct fld_cache_info *fld_cache, __u64 seq) } #endif -static int fld_rrb_hash(struct lu_client_fld *fld, __u64 seq) +static int +fld_rrb_hash(struct lu_client_fld *fld, __u64 seq) { if (fld->fld_count == 0) return 0; @@ -152,7 +154,8 @@ static int fld_rrb_hash(struct lu_client_fld *fld, __u64 seq) return do_div(seq, fld->fld_count); } -static int fld_dht_hash(struct lu_client_fld *fld, __u64 seq) +static int +fld_dht_hash(struct lu_client_fld *fld, __u64 seq) { /* XXX: here should DHT hash */ return fld_rrb_hash(fld, seq); @@ -197,7 +200,8 @@ fld_client_get_export(struct lu_client_fld *fld, __u64 seq) /* add export to FLD. This is usually done by CMM and LMV as they are main users * of FLD module. */ -int fld_client_add_export(struct lu_client_fld *fld, +int +fld_client_add_export(struct lu_client_fld *fld, struct obd_export *exp) { struct obd_export *fld_exp; @@ -230,7 +234,8 @@ int fld_client_add_export(struct lu_client_fld *fld, EXPORT_SYMBOL(fld_client_add_export); /* remove export from FLD */ -int fld_client_del_export(struct lu_client_fld *fld, +int +fld_client_del_export(struct lu_client_fld *fld, struct obd_export *exp) { struct obd_export *fld_exp; @@ -255,7 +260,53 @@ int fld_client_del_export(struct lu_client_fld *fld, } EXPORT_SYMBOL(fld_client_del_export); -int fld_client_init(struct lu_client_fld *fld, int hash) +#ifdef LPROCFS +static int +fld_client_proc_init(struct lu_client_fld *fld) +{ + int rc; + ENTRY; + + fld->fld_proc_dir = lprocfs_register(fld->fld_name, + proc_lustre_root, + NULL, NULL); + + if (IS_ERR(fld->fld_proc_dir)) { + CERROR("LProcFS failed in fld-init\n"); + rc = PTR_ERR(fld->fld_proc_dir); + GOTO(err, rc); + } + + rc = lprocfs_add_vars(fld->fld_proc_dir, + fld_client_proc_list, fld); + if (rc) { + CERROR("can't init FLD " + "proc, rc %d\n", rc); + GOTO(err, rc); + } + + RETURN(0); + +err: + fld->fld_proc_dir = NULL; + return rc; +} + +static void +fld_client_proc_fini(struct lu_client_fld *fld) +{ + ENTRY; + if (fld->fld_proc_dir) { + lprocfs_remove(fld->fld_proc_dir); + fld->fld_proc_dir = NULL; + } + EXIT; +} +#endif + +int +fld_client_init(struct lu_client_fld *fld, + const char *uuid, int hash) { int rc = 0; ENTRY; @@ -272,18 +323,37 @@ int fld_client_init(struct lu_client_fld *fld, int hash) fld->fld_hash = &fld_hash[hash]; fld->fld_count = 0; - CDEBUG(D_INFO|D_WARNING, "Client FLD, using \"%s\" hash\n", - fld->fld_hash->fh_name); - RETURN(rc); + snprintf(fld->fld_name, sizeof(fld->fld_name), + "%s-%s", LUSTRE_FLD_NAME, uuid); + +#ifdef LPROCFS + rc = fld_client_proc_init(fld); + if (rc) + GOTO(out, rc); +#endif + EXIT; +out: + if (rc) + fld_client_fini(fld); + else + CDEBUG(D_INFO|D_WARNING, + "Client FLD, using \"%s\" hash\n", + fld->fld_hash->fh_name); + return rc; } EXPORT_SYMBOL(fld_client_init); -void fld_client_fini(struct lu_client_fld *fld) +void +fld_client_fini(struct lu_client_fld *fld) { struct obd_export *fld_exp; struct obd_export *tmp; ENTRY; +#ifdef LPROCFS + fld_client_proc_fini(fld); +#endif + spin_lock(&fld->fld_lock); list_for_each_entry_safe(fld_exp, tmp, &fld->fld_exports, exp_fld_chain) { diff --git a/lustre/fld/lproc_fld.c b/lustre/fld/lproc_fld.c new file mode 100644 index 0000000..e9820c2 --- /dev/null +++ b/lustre/fld/lproc_fld.c @@ -0,0 +1,56 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * lustre/fld/lproc_fld.c + * FLD (FIDs Location Database) + * + * Copyright (c) 2006 Cluster File Systems, Inc. + * Author: Yury Umanets + * + * This file is part of the Lustre file system, http://www.lustre.org + * Lustre is a trademark of Cluster File Systems, Inc. + * + * You may have signed or agreed to another license before downloading + * this software. If so, you are bound by the terms and conditions + * of that agreement, and the following does not apply to you. See the + * LICENSE file included with this distribution for more information. + * + * If you did not agree to a different license, then this copy of Lustre + * is open source software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * In either case, Lustre is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * license text for more details. + */ + +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif +#define DEBUG_SUBSYSTEM S_FLD + +#ifdef __KERNEL__ +# include +# include +#else /* __KERNEL__ */ +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include "fld_internal.h" + +#ifdef LPROCFS +struct lprocfs_vars fld_server_proc_list[] = { + { NULL }}; + +struct lprocfs_vars fld_client_proc_list[] = { + { NULL }}; +#endif diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index e046119..09a8297 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -49,6 +49,7 @@ struct lu_server_fld { struct dt_device *fld_dt; struct dt_object *fld_obj; struct lu_fid fld_fid; + char fld_name[80]; }; struct lu_client_fld { @@ -57,11 +58,13 @@ struct lu_client_fld { struct lu_fld_hash *fld_hash; int fld_count; spinlock_t fld_lock; + char fld_name[80]; }; /* server methods */ int fld_server_init(struct lu_server_fld *fld, const struct lu_context *ctx, + const char *uuid, struct dt_device *dt); void fld_server_fini(struct lu_server_fld *fld, @@ -69,6 +72,7 @@ void fld_server_fini(struct lu_server_fld *fld, /* client methods */ int fld_client_init(struct lu_client_fld *fld, + const char *uuid, int hash); void fld_client_fini(struct lu_client_fld *fld); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index f1ebc5e..41d9185 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -820,7 +820,8 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } } #endif - rc = fld_client_init(&lmv->lmv_fld, LUSTRE_CLI_FLD_HASH_RRB); + rc = fld_client_init(&lmv->lmv_fld, + "LMV_UUID", LUSTRE_CLI_FLD_HASH_RRB); if (rc) { CERROR("can't init FLD, err %d\n", rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e6b8653..b475a24 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1782,7 +1782,9 @@ static void mdt_seq_ctlr_fini(struct mdt_device *m) /* * FLD wrappers */ -static int mdt_fld_init(const struct lu_context *ctx, struct mdt_device *m) +static int mdt_fld_init(const struct lu_context *ctx, + const char *uuid, + struct mdt_device *m) { struct lu_site *ls; int rc; @@ -1793,14 +1795,16 @@ static int mdt_fld_init(const struct lu_context *ctx, struct mdt_device *m) OBD_ALLOC_PTR(ls->ls_fld); if (ls->ls_fld != NULL) - rc = fld_server_init(ls->ls_fld, ctx, m->mdt_bottom); + rc = fld_server_init(ls->ls_fld, ctx, + uuid, m->mdt_bottom); else rc = -ENOMEM; RETURN(rc); } -static int mdt_fld_fini(const struct lu_context *ctx, struct mdt_device *m) +static int mdt_fld_fini(const struct lu_context *ctx, + struct mdt_device *m) { struct lu_site *ls = m->mdt_md_dev.md_lu_dev.ld_site; ENTRY; @@ -2073,7 +2077,7 @@ static int mdt_init0(struct mdt_device *m, s->ls_node_id = simple_strtol(num, NULL, 10); lu_context_enter(&ctx); - rc = mdt_fld_init(&ctx, m); + rc = mdt_fld_init(&ctx, obd->obd_name, m); lu_context_exit(&ctx); if (rc) GOTO(err_fini_stack, rc); -- 1.8.3.1