Whamcloud - gitweb
- added proc interface to seq-mgr, it will be used for testing.
authoryury <yury>
Thu, 22 Jun 2006 11:05:11 +0000 (11:05 +0000)
committeryury <yury>
Thu, 22 Jun 2006 11:05:11 +0000 (11:05 +0000)
lustre/fid/Makefile.in
lustre/fid/autoMakefile.am
lustre/fid/fid_handler.c
lustre/fid/fid_internal.h
lustre/fid/lproc_fid.c [new file with mode: 0644]
lustre/include/lustre_fid.h
lustre/lmv/lmv_fld.c
lustre/ptlrpc/lproc_ptlrpc.c

index cb15fe8..d81e598 100644 (file)
@@ -1,4 +1,4 @@
 MODULES := fid
-fid-objs := fid_handler.o fid_request.o fid_lib.o
+fid-objs := fid_handler.o fid_request.o lproc_fid.o fid_lib.o
 
 @INCLUDE_RULES@
index 0c8c5a1..b2819c8 100644 (file)
@@ -5,7 +5,7 @@
 
 if LIBLUSTRE
 noinst_LIBRARIES = libfid.a
-libfid_a_SOURCES = fid_handler.c fid_request.c fid_lib.c fid_internal.h
+libfid_a_SOURCES = fid_handler.c fid_request.c lproc_fid.c fid_lib.c fid_internal.h
 libfid_a_CPPFLAGS = $(LLCPPFLAGS)
 libfid_a_CFLAGS = $(LLCFLAGS)
 endif
index 96cfb21..87d9152 100644 (file)
@@ -103,7 +103,7 @@ __seq_server_alloc_super(struct lu_server_seq *seq,
         LASSERT(range_is_sane(space));
         
         if (range_space(space) < LUSTRE_SEQ_SUPER_WIDTH) {
-                CWARN("sequences space is going to exhauste soon. "
+                CWARN("sequences space is going to exhaust soon. "
                       "Only can allocate "LPU64" sequences\n",
                       space->lr_end - space->lr_start);
                 *range = *space;
@@ -380,6 +380,66 @@ seq_server_controller(struct lu_server_seq *seq,
 }
 EXPORT_SYMBOL(seq_server_controller);
 
+#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,
+                                             proc_lustre_root,
+                                             NULL, NULL);
+        if (IS_ERR(seq_type_proc_dir)) {
+                CERROR("LProcFS failed in seq-init\n");
+                rc = PTR_ERR(seq_type_proc_dir);
+                GOTO(err, rc);
+        }
+
+        seq->seq_proc_entry = lprocfs_register("services",
+                                               seq_type_proc_dir,
+                                               NULL, NULL);
+        if (IS_ERR(seq->seq_proc_entry)) {
+                CERROR("LProcFS failed in seq-init\n");
+                rc = PTR_ERR(seq->seq_proc_entry);
+                GOTO(err_type, rc);
+        }
+
+        rc = lprocfs_add_vars(seq_type_proc_dir,
+                              seq_proc_list, seq);
+        if (rc) {
+                CERROR("can't init sequence manager "
+                       "proc, rc %d\n", rc);
+        }
+
+        RETURN(0);
+
+err_type:
+        lprocfs_remove(seq_type_proc_dir);
+err:
+        seq_type_proc_dir = NULL;
+        seq->seq_proc_entry = NULL;
+        return rc;
+}
+
+void seq_server_proc_fini(struct lu_server_seq *seq)
+{
+        ENTRY;
+        if (seq->seq_proc_entry) {
+                lprocfs_remove(seq->seq_proc_entry);
+                seq->seq_proc_entry = NULL;
+        }
+
+        if (seq_type_proc_dir) {
+                lprocfs_remove(seq_type_proc_dir);
+                seq_type_proc_dir = NULL;
+        }
+        EXIT;
+}
+#endif
+
 int
 seq_server_init(struct lu_server_seq *seq,
                 struct dt_device *dev, int flags,
@@ -421,7 +481,13 @@ seq_server_init(struct lu_server_seq *seq,
                GOTO(out, rc);
        }
         
-       seq->seq_service =  ptlrpc_init_svc_conf(&seq_conf,
+#ifdef LPROCFS
+        rc  = seq_server_proc_init(seq);
+        if (rc)
+               GOTO(out, rc);
+#endif
+
+        seq->seq_service =  ptlrpc_init_svc_conf(&seq_conf,
                                                 seq_req_handle,
                                                 LUSTRE_SEQ0_NAME,
                                                 seq->seq_proc_entry, 
@@ -435,11 +501,15 @@ seq_server_init(struct lu_server_seq *seq,
        EXIT;
 
 out:
-       if (rc)
+       if (rc) {
+#ifdef LPROCFS
+                seq_server_proc_fini(seq);
+#endif
                seq_server_fini(seq, ctx);
-        else
+        } else {
                 CDEBUG(D_INFO|D_WARNING, "Server Sequence "
                        "Manager\n");
+        }
        return rc;
 } 
 EXPORT_SYMBOL(seq_server_init);
@@ -455,6 +525,10 @@ seq_server_fini(struct lu_server_seq *seq,
                 seq->seq_service = NULL;
         }
 
+#ifdef LPROCFS
+        seq_server_proc_fini(seq);
+#endif
+
         if (seq->seq_dev != NULL) {
                 lu_device_put(&seq->seq_dev->dd_lu_dev);
                 seq->seq_dev = NULL;
index 1d99fe4..e65ab9c 100644 (file)
@@ -28,4 +28,8 @@
 
 #define SEQ_SERVICE_WATCHDOG_TIMEOUT (obd_timeout * 1000)
 
+#ifdef LPROCFS
+extern struct lprocfs_vars seq_proc_list[];
+#endif
+
 #endif
diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c
new file mode 100644 (file)
index 0000000..141be0a
--- /dev/null
@@ -0,0 +1,167 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  lustre/fid/lproc_fid.c
+ *  Lustre Sequence Manager
+ *
+ *  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_FID
+
+#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_fid.h>
+#include "fid_internal.h"
+
+#ifdef LPROCFS
+static int
+seq_proc_write_range(struct file *file, const char *buffer,
+                    unsigned long count, void *data,
+                    struct lu_range *range)
+{
+       struct lu_range tmp;
+       int rc;
+       ENTRY;
+
+       LASSERT(range != NULL);
+
+        rc = sscanf(buffer, "["LPU64"-"LPU64"]\n",
+                   &tmp.lr_start, &tmp.lr_end);
+
+       *range = tmp;
+        RETURN(count);
+}
+
+static int
+seq_proc_read_range(char *page, char **start, off_t off,
+                   int count, int *eof, void *data,
+                   struct lu_range *range)
+{
+       int rc;
+       ENTRY;
+
+        *eof = 1;
+        rc = snprintf(page, count, "["LPU64"-"LPU64"]\n",
+                     range->lr_start, range->lr_end);
+       RETURN(rc);
+}
+
+static int
+seq_proc_write_space(struct file *file, const char *buffer,
+                    unsigned long count, void *data)
+{
+        struct lu_server_seq *seq = (struct lu_server_seq *)data;
+       ENTRY;
+
+        LASSERT(seq != NULL);
+
+       down(&seq->seq_sem);
+       seq_proc_write_range(file, buffer, count,
+                            data, &seq->seq_space);
+
+       CDEBUG(D_WARNING, "sequences space range is changed "
+              "to ["LPU64"-"LPU64"]\n", seq->seq_space.lr_start,
+              seq->seq_space.lr_end);
+       
+       up(&seq->seq_sem);
+       
+        RETURN(count);
+}
+
+static int
+seq_proc_read_space(char *page, char **start, off_t off,
+                   int count, int *eof, void *data)
+{
+        struct lu_server_seq *seq = (struct lu_server_seq *)data;
+       int rc;
+       ENTRY;
+
+        LASSERT(seq != NULL);
+
+       down(&seq->seq_sem);
+       rc = seq_proc_read_range(page, start, off, count, eof,
+                                data, &seq->seq_space);
+       up(&seq->seq_sem);
+       
+       RETURN(rc);
+}
+
+static int
+seq_proc_write_super(struct file *file, const char *buffer,
+                    unsigned long count, void *data)
+{
+        struct lu_server_seq *seq = (struct lu_server_seq *)data;
+       ENTRY;
+
+        LASSERT(seq != NULL);
+
+       down(&seq->seq_sem);
+       seq_proc_write_range(file, buffer, count,
+                            data, &seq->seq_super);
+
+       CDEBUG(D_WARNING, "super-sequence range is changed to "
+              "["LPU64"-"LPU64"]\n", seq->seq_super.lr_start,
+              seq->seq_super.lr_end);
+       
+       up(&seq->seq_sem);
+       
+        RETURN(count);
+}
+
+static int
+seq_proc_read_super(char *page, char **start, off_t off,
+                   int count, int *eof, void *data)
+{
+        struct lu_server_seq *seq = (struct lu_server_seq *)data;
+       int rc;
+       ENTRY;
+
+        LASSERT(seq != NULL);
+
+       down(&seq->seq_sem);
+       rc = seq_proc_read_range(page, start, off, count, eof,
+                                data, &seq->seq_super);
+       up(&seq->seq_sem);
+       
+       RETURN(rc);
+}
+
+struct lprocfs_vars seq_proc_list[] = {
+       { "space", seq_proc_read_space, seq_proc_write_space, NULL },
+       { "super", seq_proc_read_super, seq_proc_write_super, NULL },
+       { NULL }};
+#endif
index bbdff35..f7474c2 100644 (file)
@@ -64,7 +64,7 @@ struct lu_client_seq {
         struct lu_range         seq_range;
 
         /* seq related proc */
-        struct proc_dir_entry  *seq_proc_entry;
+        cfs_proc_dir_entry_t   *seq_proc_entry;
 
         /* this holds last allocated fid in last obtained seq */
         struct lu_fid           seq_fid;
@@ -88,7 +88,7 @@ struct lu_server_seq {
         int                     seq_flags;
 
         /* seq related proc */
-        struct proc_dir_entry  *seq_proc_entry;
+        cfs_proc_dir_entry_t   *seq_proc_entry;
 
         /* server side seq service */
         struct ptlrpc_service  *seq_service;
index 4ba2e7d..4d5ab1e 100644 (file)
@@ -59,8 +59,8 @@ int lmv_fld_lookup(struct obd_device *obd, const struct lu_fid *fid)
                        fid_seq(fid), rc);
                 RETURN(rc);
         }
-        CWARN("LMV: got MDS "LPU64" for sequence: "LPU64"\n",
-              mds, fid_seq(fid));
+        CDEBUG(D_WARNING, "LMV: got MDS "LPU64" for sequence: "LPU64"\n",
+               mds, fid_seq(fid));
         if (mds >= lmv->desc.ld_tgt_count || mds < 0) {
                 CERROR("Got invalid mdsno: %llu (max: %d)\n",
                        mds, lmv->desc.ld_tgt_count);
index 70266b5..aa92378 100644 (file)
@@ -84,7 +84,8 @@ struct ll_rpc_opcode {
         { OBD_PING,         "obd_ping" },
         { OBD_LOG_CANCEL,   "llog_origin_handle_cancel" },
         { OBD_QC_CALLBACK,  "obd_qc_callback" },
-        { FLD_QUERY,        "fld_query" }
+        { FLD_QUERY,        "fld_query" },
+        { SEQ_QUERY,        "seq_query" }
 };
 
 const char* ll_opcode2str(__u32 opcode)