#include <linux/version.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
+#include <linux/types.h>
#define DEBUG_SUBSYSTEM S_CLASS
#define MAX_STRING_SIZE 100
* Externs
*/
extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
-extern void l_lock_init(struct lustre_lock* );
-extern void l_lock(struct lustre_lock* );
-extern void l_unlock(struct lustre_lock* );
+
/*
* Globals
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;
+/* struct lustre_lock proc_lustre_lock; */
/* static struct proc_dir_entry *proc_lustre_conn_root = 0; */
char* testStr="General..";
LPROCFS_DIR_INDEX(mdc, create),
LPROCFS_DIR_INDEX(mdc, unlink),
LPROCFS_DIR_INDEX(mdc, link),
- LPROCFS_DIR_INDEX(mdc, rename)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(mdc, rename),
};
struct namespace_index dir_mds_index[] = {
LPROCFS_DIR_INDEX(mds, reint_unlink),
LPROCFS_DIR_INDEX(mds, reint_link),
LPROCFS_DIR_INDEX(mds, reint_rename),
- LPROCFS_DIR_INDEX(mds, reint_recreate)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(mds, reint_recreate),
};
LPROCFS_DIR_INDEX(osc, brw),
LPROCFS_DIR_INDEX(osc, punch),
LPROCFS_DIR_INDEX(osc, summary),
- LPROCFS_DIR_INDEX(osc, cancel)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(osc, cancel),
};
LPROCFS_DIR_INDEX(ost, punch),
LPROCFS_DIR_INDEX(ost, summary),
LPROCFS_DIR_INDEX(ost, cancel),
- LPROCFS_DIR_INDEX(ost, getinfo)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(ost, getinfo),
};
struct namespace_index dir_lov_index[] = {
LPROCFS_DIR_INDEX(lov, punch),
LPROCFS_DIR_INDEX(lov, summary),
LPROCFS_DIR_INDEX(lov, cancel),
- LPROCFS_DIR_INDEX(lov, getinfo)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(lov, getinfo),
};
struct namespace_index dir_obdfilter_index[] = {
LPROCFS_DIR_INDEX(obdfilter, punch),
LPROCFS_DIR_INDEX(obdfilter, summary),
LPROCFS_DIR_INDEX(obdfilter, cancel),
- LPROCFS_DIR_INDEX(obdfilter, getinfo)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(obdfilter, getinfo),
};
struct namespace_index dir_ldlm_index[] = {
LPROCFS_DIR_INDEX(ldlm, locks_enqueus),
LPROCFS_DIR_INDEX(ldlm, locks_cancels),
LPROCFS_DIR_INDEX(ldlm, locks_converts),
- LPROCFS_DIR_INDEX(ldlm, locks_matches)
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(ldlm, locks_matches),
};
struct namespace_index dir_ptlrpc_index[] = {
LPROCFS_DIR_INDEX(ptlrpc, mgmt_cleanup),
LPROCFS_DIR_INDEX(ptlrpc, mgmt_connect),
LPROCFS_DIR_INDEX(ptlrpc, mgmt_disconnect),
- LPROCFS_DIR_INDEX(ptlrpc, counters)
-
- /* Maintain this last comma */
- ,
+ LPROCFS_DIR_INDEX(ptlrpc, counters),
};
LPROCFS_CNTR_INDEX(mdc, min_time),
LPROCFS_CNTR_INDEX(mdc, max_time),
LPROCFS_CNTR_INDEX(mdc, sum_time),
- LPROCFS_CNTR_INDEX(mdc, num_ops)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(mdc, num_ops),
};
LPROCFS_CNTR_INDEX(mds, min_time),
LPROCFS_CNTR_INDEX(mds, max_time),
LPROCFS_CNTR_INDEX(mds, sum_time),
- LPROCFS_CNTR_INDEX(mds, num_ops)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(mds, num_ops),
};
struct namespace_index prof_osc_index[]= {
LPROCFS_CNTR_INDEX(osc, min_time),
LPROCFS_CNTR_INDEX(osc, max_time),
LPROCFS_CNTR_INDEX(osc, sum_time),
- LPROCFS_CNTR_INDEX(osc, num_ops)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(osc, num_ops),
};
struct namespace_index prof_ost_index[]= {
LPROCFS_CNTR_INDEX(ost, min_time),
LPROCFS_CNTR_INDEX(ost, max_time),
LPROCFS_CNTR_INDEX(ost, sum_time),
- LPROCFS_CNTR_INDEX(ost, num_ops)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(ost, num_ops),
};
struct namespace_index prof_lov_index[]= {
LPROCFS_CNTR_INDEX(lov, min_time),
LPROCFS_CNTR_INDEX(lov, max_time),
LPROCFS_CNTR_INDEX(lov, sum_time),
- LPROCFS_CNTR_INDEX(lov, num_ops)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(lov, num_ops),
};
struct namespace_index prof_obdfilter_index[]= {
LPROCFS_CNTR_INDEX(obdfilter, min_time),
LPROCFS_CNTR_INDEX(obdfilter, max_time),
LPROCFS_CNTR_INDEX(obdfilter, sum_time),
- LPROCFS_CNTR_INDEX(obdfilter, num_ops)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(obdfilter, num_ops),
};
struct namespace_index prof_ldlm_index[] = {
LPROCFS_CNTR_INDEX(ldlm, num_zerolatency_done),
LPROCFS_CNTR_INDEX(ldlm, nonzero_mintime),
LPROCFS_CNTR_INDEX(ldlm, nonzero_maxtime),
- LPROCFS_CNTR_INDEX(ldlm, nonzero_sumtime)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(ldlm, nonzero_sumtime),
};
LPROCFS_CNTR_INDEX(ptlrpc, recv_length),
LPROCFS_CNTR_INDEX(ptlrpc, send_count),
LPROCFS_CNTR_INDEX(ptlrpc, send_length),
- LPROCFS_CNTR_INDEX(ptlrpc, portal_kmemory)
- /* Maintain this comma */
- ,
+ LPROCFS_CNTR_INDEX(ptlrpc, portal_kmemory),
};
LPROCFS_GROUP_CREATE(lov),
LPROCFS_GROUP_CREATE(obdfilter),
LPROCFS_GROUP_CREATE(ldlm),
- LPROCFS_GROUP_CREATE(ptlrpc)
- /* Retain this comma */
- ,
+ LPROCFS_GROUP_CREATE(ptlrpc),
};
*/
/*
- * lprocfs_register_dev: Registers an instance of the OBD device in the
+ * lprocfs_reg_dev: Registers an instance of the OBD device in the
* proc hierarchy
*/
-int lprocfs_register_dev(struct obd_device* device, \
- lprocfs_group_t* namespace, \
+int lprocfs_reg_dev(struct obd_device* device,
+ lprocfs_group_t* namespace,
unsigned int cnt_struct_size)
{
if(this_dev_root==0){
CERROR("Could not create initial directory");
return LPROCFS_FAILURE;
-
}
- l_lock_init(&proc_lustre_lock);
+
/*
* Obtain the class-array index
*/
- class_array_index=lprocfs_util_getclass_idx(class_index, device->obd_type->typ_name);
+ 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");
* Create the directory namespace
*/
- retval=lprocfs_create_dir_namespace(this_dev_root, namespace, &num_directories);
+ retval=lprocfs_create_dir_namespace(this_dev_root, \
+ namespace,\
+ &num_directories);
if(retval==LPROCFS_FAILURE){
CERROR("!!Could not create proc directory structure !!\n");
return LPROCFS_FAILURE;
*/
if(cnt_struct_size!=0){
- device->counters=kmalloc(num_directories*cnt_struct_size, \
- GFP_KERNEL);
- if(!device->counters){
- CERROR("!!Could not allocate memory for proc counters!!");
- return LPROCFS_FAILURE;
-
- }
- memset(device->counters, 0, num_directories*cnt_struct_size);
+ OBD_ALLOC(device->counters, num_directories*cnt_struct_size);
+ device->cntr_mem_size=num_directories*cnt_struct_size;
}
/*
- * Iterate the proc-dir-namespace, obtain corresponding directory(attribute)
+ * Iterate the proc-dir-namespace, obtain corresponding
+ * directory(attribute)
* entries. Create the proc-counters from namespace, link them into
* dev counters
*/
return LPROCFS_SUCCESS;
}
-int lprocfs_link_dir_counters(struct obd_device* device, \
- struct proc_dir_entry* this_dev_root, \
- lprocfs_group_t* namespace, \
- unsigned int cnt_struct_size, \
- unsigned int class_array_index)
+int lprocfs_link_dir_counters(struct obd_device* device,
+ struct proc_dir_entry* root,
+ lprocfs_group_t* namespace,
+ unsigned int sz,
+ unsigned int cl_idx)
{
unsigned int j=0;
unsigned int k=0;
unsigned int escape=0;
- int dir_array_index=-1;
- int cnt_array_index=-1;
+ int dir_idx=-1;
+ int cnt_idx=-1;
- struct proc_dir_entry* this_dir_root=0;
+ struct proc_dir_entry* dir_root=0;
lprocfs_group_t* temp;
- lprocfs_vars_t* func_n_counters;
+ lprocfs_vars_t* fn_ctr;
+ struct namespace_index* cntr_names;
while(1) {
temp=&namespace[i];
- dir_array_index=-1;
+ dir_idx=-1;
if(temp->count_func_namespace==0) break;
+
while((temp->dir_namespace)[j]!=0){
- this_dir_root=lprocfs_util_add_dir_node(this_dev_root, (temp->dir_namespace)[j], (const char*)tok, &escape);
+ dir_root=lprocfs_add_dir(root,\
+ (temp->dir_namespace)[j], \
+ (const char*)tok, &escape);
if(escape){
j++;
continue;
}
- dir_array_index=lprocfs_util_get_index(class_index[class_array_index].directory,(temp->dir_namespace)[j]);
- /* printk("Class name=%s, Directory name=%s, index=%d\t", device->obd_type->typ_name, (temp->dir_namespace)[j], dir_array_index); */
+ dir_idx=lprocfs_get_idx(class_index[cl_idx].directory,\
+ (temp->dir_namespace)[j]);
while(1){
- cnt_array_index=-1;
- func_n_counters=&((temp->count_func_namespace)[k]);
- if(func_n_counters->read_fptr==0)break;
- cnt_array_index=lprocfs_util_get_index(class_index[class_array_index].counters, func_n_counters->name);
- /* printk("Counter name=%s, index=%d\n", func_n_counters->name, cnt_array_index); */
- if(lprocfs_util_add_var_node(device, \
- this_dir_root, \
- func_n_counters, \
- dir_array_index, \
- cnt_array_index, \
- cnt_struct_size, \
- temp->prof_type)==LPROCFS_FAILURE){
+ cnt_idx=-1;
+ fn_ctr=&((temp->count_func_namespace)[k]);
+ if(fn_ctr->read_fptr==0)break;
+ cntr_names=class_index[cl_idx].counters;
+ cnt_idx=lprocfs_get_idx(cntr_names, \
+ fn_ctr->name);
+
+ if(lprocfs_add_var(device, \
+ dir_root, \
+ fn_ctr, \
+ dir_idx, \
+ cnt_idx, \
+ sz, \
+ temp->prof_type)==\
+ LPROCFS_FAILURE){
CERROR("Could not create leaf node!");
return LPROCFS_FAILURE;
-int lprocfs_create_dir_namespace(struct proc_dir_entry* this_dev_root, \
+int lprocfs_create_dir_namespace(struct proc_dir_entry* root, \
lprocfs_group_t* namespace, \
unsigned int *num_dirs)
{
unsigned int i=0;
unsigned int j=0;
- struct proc_dir_entry* this_dir_root=0;
+ struct proc_dir_entry* dir_root=0;
lprocfs_group_t* temp;
unsigned int escape=0;
temp=&namespace[i];
if(temp->count_func_namespace==0) break;
while((temp->dir_namespace)[j]!=0){
- this_dir_root=lprocfs_util_add_dir_node(this_dev_root, (temp->dir_namespace)[j], (const char*)tok, &escape);
- if(this_dir_root==0){
- CERROR("!! Could not create directory entry %s !! \n", (temp->dir_namespace)[j]);
+ dir_root=lprocfs_add_dir(root, \
+ (temp->dir_namespace)[j], \
+ (const char*)tok, &escape);
+ if(dir_root==0){
+ CERROR("!! Could not create dir %s !! \n", \
+ (temp->dir_namespace)[j]);
return LPROCFS_FAILURE;
}
if(temp->prof_type!=e_specific && !escape)
-int lprocfs_util_getclass_idx(struct groupspace_index* group, const char* classname)
+int lprocfs_getclass_idx(struct groupspace_index* group,
+ const char* classname)
{
unsigned int idx=0;
while(group[idx].name!=""){
if (!proc_lustre_root) {
proc_lustre_root =
- lprocfs_util_mkdir("lustre", &proc_root);
+ lprocfs_mkdir("lustre", &proc_root);
if (!proc_lustre_root){
CERROR(" !! Cannot create /proc/lustre !! \n");
return 0;
}
proc_lustre_dev_root =
- lprocfs_util_mkdir("devices", proc_lustre_root);
+ lprocfs_mkdir("devices", proc_lustre_root);
if(!proc_lustre_dev_root){
CERROR(" !! Cannot create /proc/lustre/devices !! \n");
* this class in the lprocfs hierarchy.
*/
- temp_proc=lprocfs_search(proc_lustre_dev_root, device->obd_type->typ_name);
+ temp_proc=lprocfs_srch(proc_lustre_dev_root, \
+ device->obd_type->typ_name);
if(!temp_proc){
- temp_proc=lprocfs_util_mkdir(device->obd_type->typ_name, proc_lustre_dev_root);
+ temp_proc=lprocfs_mkdir(device->obd_type->typ_name, \
+ proc_lustre_dev_root);
if(!temp_proc){
- CERROR("!! Could not create proc for device class %s !!\n", device->obd_type->typ_name);
+ 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_util_mkdir(device->obd_name, temp_proc);
+ this_dev_root=lprocfs_mkdir(device->obd_name, temp_proc);
if(!this_dev_root){
- CERROR("!! Cannot create proc entry for device instance %s !! \n", device->obd_name);
+ CERROR("!Cant create proc entry for instance %s !! \n", \
+ device->obd_name);
return 0;
}
-int lprocfs_util_get_index(struct namespace_index* class, const char* dir_name)
+int lprocfs_get_idx(struct namespace_index* class,
+ const char* dir_name)
{
unsigned int index = 0;
-struct proc_dir_entry* lprocfs_util_mkdir(const char* dname, struct proc_dir_entry *parent)
+struct proc_dir_entry* lprocfs_mkdir(const char* dname,
+ struct proc_dir_entry *parent)
{
struct proc_dir_entry *child_dir_entry;
* Returns non-zero on success, zero on failure
*/
-unsigned int lprocfs_util_add_var_node(struct obd_device* device, \
- struct proc_dir_entry* root, \
- lprocfs_vars_t* variable, \
- int dir_arr_index, \
- int cnt_arr_index, \
- unsigned int cnt_struct_size, \
- lprocfs_profilers_e type \
- )
+unsigned int lprocfs_add_var(struct obd_device* device,
+ struct proc_dir_entry* root,
+ lprocfs_vars_t* variable,
+ int dir_idx,
+ int cnt_idx,
+ unsigned int sz,
+ lprofilers_e type
+ )
{
struct proc_dir_entry* new_proc_entry;
- unsigned long long* temp;
+ __u64* temp;
unsigned int actual_idx;
+ unsigned int blk_size;
new_proc_entry=create_proc_entry(variable->name, \
DEFAULT_MODE,
switch(type){
case e_generic:
if(device->counters) {
- if(dir_arr_index!=-1 && cnt_arr_index!=-1){
- temp=(unsigned long long*)device->counters;
- actual_idx=(dir_arr_index*((cnt_struct_size)/(sizeof(unsigned long long))))+cnt_arr_index;
+ if(dir_idx!=-1 && cnt_idx!=-1){
+ temp=(__u64*)device->counters;
+ blk_size=((sz)/(sizeof(__u64)));
+ actual_idx=(dir_idx*blk_size)+cnt_idx;
temp+=actual_idx;
- new_proc_entry->data = (unsigned long long*)temp;
+ new_proc_entry->data =(__u64*)temp;
}
}
break;
* the escaping character (#)
*/
-struct proc_dir_entry* lprocfs_util_add_dir_node(struct proc_dir_entry *root, \
- const char* string, \
- const char* tok, \
- unsigned int* escape)
+struct proc_dir_entry* lprocfs_add_dir(struct proc_dir_entry *root,
+ const char* string,
+ const char* tok,
+ unsigned int* escape)
{
struct proc_dir_entry* new_root=0;
struct proc_dir_entry* temp_entry=0;
new_root=root;
while(my_str!=NULL){
- temp_entry=lprocfs_search(new_root, my_str);
+ temp_entry=lprocfs_srch(new_root, my_str);
if(temp_entry==0){
- new_entry=lprocfs_util_mkdir(my_str, new_root);
+ new_entry=lprocfs_mkdir(my_str, new_root);
if(new_entry==0){
- CERROR("!! LPROCFS: Failed to create new directory %s !!\n", \
+ CERROR("! Did not create new dir %s !!\n", \
my_str);
return 0;
}
}
-struct proc_dir_entry* lprocfs_search(struct proc_dir_entry* head, const char* name)
+struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
+ const char* name)
{
struct proc_dir_entry* temp;
-struct proc_dir_entry* lprocfs_bfs_search(struct proc_dir_entry* root, const char* name)
+struct proc_dir_entry* lprocfs_bfs_srch(struct proc_dir_entry* root, const char* name)
{
struct proc_dir_entry* temp=root;
if(!strcmp(temp->name, name)){
return temp;
}
- if((temp=lprocfs_bfs_search(root->next, name))!=0){
+ if((temp=lprocfs_bfs_srch(root->next, name))!=0){
return temp;
}
- if((temp=lprocfs_bfs_search(root->subdir, name))!=0){
+ if((temp=lprocfs_bfs_srch(root->subdir, name))!=0){
return temp;
}
return temp;
}
-int lprocfs_get_namespace(char* name, \
- lprocfs_obd_namespace_t* collection)
+int lprocfs_get_nm(char* name, \
+ lprocfs_obd_nm_t* collection)
{
int i=0;
- while(collection[i].obd_namespace!=0){
- if(!strcmp(collection[i].obd_classname, name)){
+ while(collection[i].obd_names!=0){
+ if(!strcmp(collection[i].obd_clname, name)){
return i;
}
i++;
}
-int lprocfs_deregister_dev (struct obd_device* device)
+int lprocfs_dereg_dev (struct obd_device* device)
{
struct proc_dir_entry* temp;
}
printk("SEARCH: Device = %s\n", device->obd_name);
- l_lock(&proc_lustre_lock);
-
- temp=lprocfs_bfs_search(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");
return LPROCFS_FAILURE;
}
lprocfs_remove_all(temp);
- l_unlock(&proc_lustre_lock);
-
+
/*
* Free the memory held by counters
*/
if(device->counters)
- kfree(device->counters);
+ OBD_FREE(device->counters,
+ device->cntr_mem_size);
return LPROCFS_SUCCESS;
}
-int lprocfs_longlong_read(char* page, char **start, off_t off,
+int lprocfs_ll_rd(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
- unsigned long long* temp=(unsigned long long*)data;
+ __u64* temp=(__u64*)data;
len=sprintf(page, "%lld\n", *temp);
return len;
}
-int read_other(char* page, char **start, off_t off,
+int rd_other(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
printk("Hello other");
return 0;
}
-int read_string(char* page, char **start, off_t off,
+int rd_string(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
printk("Hello string");
return 0;
}
-int lprocfs_longlong_write(struct file* file, const char *buffer,
+int lprocfs_ll_wr(struct file* file, const char *buffer,
unsigned long count, void *data)
{
printk("Write default");
}
-int write_other(struct file* file, const char *buffer,
+int wr_other(struct file* file, const char *buffer,
unsigned long count, void *data)
{
printk("Write other");
}
-int write_string(struct file* file, const char *buffer,
- unsigned long count, void *data)
+int wr_string(struct file* file, const char *buffer,
+ unsigned long count, void *data)
{
printk("Write string");
return 0;
}
-int lprocfs_register_conn(unsigned int conn_number, \
+int lprocfs_reg_conn(unsigned int conn_number,
struct lprocfs_conn_namespace* namespace)
{
return 0;
}
-int lprocfs_deregister_conn(unsigned int conn_number)
+int lprocfs_dereg_conn(unsigned int conn_number)
{
return 0;
}
/*
* Import/Export APIs
*/
-int lprocfs_add_export(unsigned int conn_number, struct obd_device* device)
+int lprocfs_add_export(unsigned int conn_number,
+ struct obd_device* device)
{
return 0;
}
-int lprocfs_add_import(unsigned int conn_number, struct obd_device* device)
+int lprocfs_add_import(unsigned int conn_number,
+ struct obd_device* device)
{
return 0;
}
-int lprocfs_remove_export(unsigned int conn_number, struct obd_device* device)
+int lprocfs_remove_export(unsigned int conn_number,
+ struct obd_device* device)
{
return 0;
}
-int lprocfs_remove_import(unsigned int conn_number, struct obd_device* device)
+int lprocfs_remove_import(unsigned int conn_number,
+ struct obd_device* device)
{
return 0;
}