Whamcloud - gitweb
- fixes in seq-mgr procfs stuff;
authoryury <yury>
Sun, 25 Jun 2006 15:26:33 +0000 (15:26 +0000)
committeryury <yury>
Sun, 25 Jun 2006 15:26:33 +0000 (15:26 +0000)
- added basic procfs support to fld.

13 files changed:
lustre/cmm/cmm_device.c
lustre/fid/fid_handler.c
lustre/fid/fid_request.c
lustre/fid/lproc_fid.c
lustre/fld/Makefile.in
lustre/fld/autoMakefile.am
lustre/fld/fld_handler.c
lustre/fld/fld_internal.h
lustre/fld/fld_request.c
lustre/fld/lproc_fld.c [new file with mode: 0644]
lustre/include/lustre_fld.h
lustre/lmv/lmv_obd.c
lustre/mdt/mdt_handler.c

index 123770a..bad1f3c 100644 (file)
@@ -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);
         }
index abb2ca9..7646da6 100644 (file)
@@ -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);
index e40b8e8..2970c78 100644 (file)
@@ -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);
 
index 9b30ac8..8c1b05c 100644 (file)
@@ -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
index 31e9ddf..0eb8776 100644 (file)
@@ -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
 
index d6c4037..4a48179 100644 (file)
@@ -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
index 73d8f9b..b790263 100644 (file)
@@ -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;
index b169730..7570fe8 100644 (file)
@@ -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
index 86f04fa..9b3218d 100644 (file)
@@ -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 (file)
index 0000000..e9820c2
--- /dev/null
@@ -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 <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
index e046119..09a8297 100644 (file)
@@ -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);
index f1ebc5e..41d9185 100644 (file)
@@ -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);
index e6b8653..b475a24 100644 (file)
@@ -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);