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;
}
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,
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,
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);
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;
--- /dev/null
+/* -*- 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