/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2002 Intel Corporation
+ * Copyright (C) 2002 Cluster File Systems, Inc.
*
* This file is part of Lustre, http://www.lustre.org.
*
* You should have received a copy of the GNU General Public License
* along with Lustre; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
- * Author: Hariharan Thantry
- * File Name: lprocfs.c
- *
- * During initialization (of lustre), the following directory materializes
- * /proc/lustre
- * When the first OBD device of a class is created (due to insmod)
- * the directory
- * /proc/lustre/devices/<device-class> is created.
- * When an instance of a device is created (during attach) the
- * directory entry for that instance along with the variables for
- * that entry gets created. These variables could be counters, string
- * variables etc.
- * Each API further describes the functionality offered.
*
*/
* Externs
*/
extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
-
+extern struct obd_type *class_nm_to_type(char *nm);
/*
* Globals
*/
+struct proc_dir_entry *proc_lustre_root = 0;
+struct proc_dir_entry *proc_lustre_dev_root = 0;
+
-static struct proc_dir_entry *proc_lustre_root = 0;
-static struct proc_dir_entry *proc_lustre_dev_root = 0;
-/* struct lustre_lock proc_lustre_lock; */
-/* static struct proc_dir_entry *proc_lustre_conn_root = 0; */
-char *testStr = "General..";
/*
* Link the namespace with the internal array indices for
LPROCFS_DIR_INDEX(mds, reint_recreate),
};
+struct namespace_index dir_mdt_index[] = {
+ LPROCFS_DIR_INDEX(mdt, mgmt_setup),
+ LPROCFS_DIR_INDEX(mdt, mgmt_cleanup),
+ LPROCFS_DIR_INDEX(mdt, mgmt_connect),
+ LPROCFS_DIR_INDEX(mdt, mgmt_disconnect),
+};
+
struct namespace_index dir_osc_index[] = {
LPROCFS_DIR_INDEX(osc, mgmt_setup),
LPROCFS_DIR_INDEX(osc, mgmt_cleanup),
LPROCFS_CNTR_INDEX(mds, num_ops),
};
+struct namespace_index prof_mdt_index[]= {
+ LPROCFS_CNTR_INDEX(mds, min_time),
+ LPROCFS_CNTR_INDEX(mds, max_time),
+ LPROCFS_CNTR_INDEX(mds, sum_time),
+ LPROCFS_CNTR_INDEX(mds, num_ops),
+};
+
struct namespace_index prof_osc_index[]= {
LPROCFS_CNTR_INDEX(osc, min_time),
LPROCFS_CNTR_INDEX(osc, max_time),
struct groupspace_index class_index[] = {
LPROCFS_GROUP_CREATE(mdc),
LPROCFS_GROUP_CREATE(mds),
+ LPROCFS_GROUP_CREATE(mdt),
LPROCFS_GROUP_CREATE(osc),
LPROCFS_GROUP_CREATE(ost),
LPROCFS_GROUP_CREATE(lov),
};
-/*
- * API implementations
- */
-
-/*
- * lprocfs_reg_dev: Registers an instance of the OBD device in the
- * proc hierarchy
- */
int lprocfs_reg_dev(struct obd_device* device, lprocfs_group_t* namespace,
unsigned int cnt_struct_size)
return LPROCFS_FAILURE;
}
-
/* Obtain the class-array index */
class_array_index = lprocfs_getclass_idx(class_index,
device->obd_type->typ_name);
if (class_array_index == LPROCFS_FAILURE) {
- CERROR("!! Could not find class !! \n");
+ CERROR("Could not find class for %s\n",
+ device->obd_type->typ_name);
return LPROCFS_FAILURE;
}
+ CDEBUG(D_OTHER, "Obtained the class array index\n");
/* Create the directory namespace */
retval = lprocfs_create_dir_namespace(this_dev_root, namespace,
while (1) {
temp = &namespace[i];
- if (temp->count_func_namespace == 0)
+ if (temp->count_func_namespace)
break;
while ((temp->dir_namespace)[j] != 0){
dir_root = lprocfs_add_dir(root,
return LPROCFS_FAILURE;
}
-struct proc_dir_entry* lprocfs_mkinitdir(struct obd_device* device)
-{
- struct proc_dir_entry* this_dev_root = 0;
- struct proc_dir_entry* temp_proc = 0;
-
- /*
- * First check if /proc/lustre exits. If it does not,
- * instantiate the same and the devices directory
- */
- if (!proc_lustre_root) {
- proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
- if (!proc_lustre_root) {
- CERROR(" !! Cannot create /proc/lustre !! \n");
- return 0;
- }
- proc_lustre_dev_root =
- lprocfs_mkdir("devices", proc_lustre_root);
-
- if (!proc_lustre_dev_root) {
- CERROR(" !! Cannot create /proc/lustre/devices !! \n");
- return 0;
- }
- }
-
- /*
- * Check if this is the first instance for a device of
- * this class in the lprocfs hierarchy.
- */
- temp_proc = lprocfs_srch(proc_lustre_dev_root,
- device->obd_type->typ_name);
-
- if (!temp_proc) {
- temp_proc = lprocfs_mkdir(device->obd_type->typ_name,
- proc_lustre_dev_root);
- if (!temp_proc) {
- CERROR("! Proc dir for device class %s !!\n",
- device->obd_type->typ_name);
- return 0;
- }
- }
-
- /* Next create the proc_dir_entry for this instance */
- this_dev_root = lprocfs_mkdir(device->obd_name, temp_proc);
- if (!this_dev_root) {
- CERROR("!Can't create proc entry for instance %s !! \n",
- device->obd_name);
- return 0;
- }
-
- return this_dev_root;
-}
int lprocfs_get_idx(struct namespace_index* class, const char* dir_name)
return new_root;
}
-struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
- const char* name)
-{
- struct proc_dir_entry* temp;
-
- if (!head)
- return 0;
- temp = head->subdir;
- while (temp != NULL) {
- if (!strcmp(temp->name, name))
- return temp;
- temp = temp->next;
- }
-
- return 0;
-}
-
-#warning FIXME: recursive code is VERY bad in the kernel because of stack limit
-struct proc_dir_entry* lprocfs_bfs_srch(struct proc_dir_entry* root,
- const char* name)
-{
- struct proc_dir_entry* temp = root;
-
- if (!temp)
- return 0;
-
- if (!strcmp(temp->name, name))
- return temp;
-
- if ((temp = lprocfs_bfs_srch(root->next, name)) != 0)
- return temp;
-
- if ((temp = lprocfs_bfs_srch(root->subdir, name)) != 0)
- return temp;
-
- return temp;
-}
int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection)
{
{
struct proc_dir_entry* temp;
- CDEBUG(D_OTHER, "LPROCFS removing device = %s\n", \
- device->obd_name);
+ CDEBUG(D_OTHER, "LPROCFS removing device = %s\n", device->obd_name);
if (!device) {
CDEBUG(D_OTHER, "! LProcfs: Null pointer !\n");
return LPROCFS_FAILURE;
}
- temp = lprocfs_bfs_srch(proc_lustre_dev_root->subdir, \
- device->obd_name);
+ temp = lprocfs_bfs_srch(proc_lustre_dev_root->subdir, device->obd_name);
if (temp == 0) {
- CERROR("!! No root obtained, device does not exist !!\n");
+ CERROR("Device %s not in lprocfs\n", device->obd_name);
return LPROCFS_FAILURE;
}