- added basic procfs support to fld.
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);
}
if (rc) {
CERROR("can't init sequence manager "
"proc, rc %d\n", rc);
+ GOTO(err_type, rc);
}
RETURN(0);
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);
if (rc) {
CERROR("can't init sequence manager "
"proc, rc %d\n", rc);
+ GOTO(err, rc);
}
RETURN(0);
#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);
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);
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
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
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
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;
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);
{
ENTRY;
+#ifdef LPROCFS
+ fld_server_proc_fini(fld);
+#endif
+
if (fld->fld_service != NULL) {
ptlrpc_unregister_service(fld->fld_service);
fld->fld_service = NULL;
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
#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;
}
}
#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;
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);
/* 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;
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;
}
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;
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) {
--- /dev/null
+/* -*- 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 <umka@clusterfs.com>
+ *
+ * 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 <libcfs/libcfs.h>
+# include <linux/module.h>
+#else /* __KERNEL__ */
+# include <liblustre.h>
+#endif
+
+#include <obd.h>
+#include <obd_class.h>
+#include <dt_object.h>
+#include <md_object.h>
+#include <obd_support.h>
+#include <lustre_req_layout.h>
+#include <lustre_fld.h>
+#include "fld_internal.h"
+
+#ifdef LPROCFS
+struct lprocfs_vars fld_server_proc_list[] = {
+ { NULL }};
+
+struct lprocfs_vars fld_client_proc_list[] = {
+ { NULL }};
+#endif
struct dt_device *fld_dt;
struct dt_object *fld_obj;
struct lu_fid fld_fid;
+ char fld_name[80];
};
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,
/* 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);
}
}
#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);
/*
* 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;
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;
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);