#include <linux/fs.h>
#include <linux/ext2_fs.h>
+#include <linux/proc_fs.h>
#include <linux/obd_class.h>
#include <linux/lustre_net.h>
obd_uuid_t ll_sb_uuid;
struct lustre_handle ll_mdc_conn;
struct lustre_handle ll_osc_conn;
+ struct proc_dir_entry* ll_mnt_root;
obd_id ll_rootino; /* number of root inode */
int ll_flags;
struct obd_type {
struct list_head typ_chain;
struct obd_ops *typ_ops;
+ struct proc_dir_entry *typ_procroot;
char *typ_name;
int typ_refcnt;
};
__u32 mode, struct lustre_handle *);
int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
int local_only);
+
};
static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
#include <linux/lustre_idl.h>
#include <linux/lustre_mds.h>
#include <linux/lustre_dlm.h>
+#include <linux/lprocfs_status.h>
#endif
* <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
-int class_register_type(struct obd_ops *ops, char *nm);
+int class_register_type(struct obd_ops *ops, lprocfs_vars_t* vars, char *nm);
int class_unregister_type(char *nm);
int class_name2dev(char *name);
int class_uuid2dev(char *uuid);
struct obd_device *class_uuid2obd(char *uuid);
struct obd_export *class_new_export(struct obd_device *obddev);
+struct obd_type *class_nm_to_type(char* name);
void class_destroy_export(struct obd_export *exp);
int class_connect(struct lustre_handle *conn, struct obd_device *obd,
obd_uuid_t cluuid);
static int __init ldlm_init(void)
{
- int rc = class_register_type(&ldlm_obd_ops, OBD_LDLM_DEVICENAME);
+ int rc = class_register_type(&ldlm_obd_ops, 0, OBD_LDLM_DEVICENAME);
if (rc != 0)
return rc;
llite_SOURCES = dcache.c commit_callback.c super.c rw.c super25.c
llite_SOURCES += file.c dir.c sysctl.c symlink.c $(LINX)
-llite_SOURCES += lov_pack.c recover.c namei.c
+llite_SOURCES += lov_pack.c recover.c namei.c lproc_llite.c
lov_pack.c:
test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
*
*/
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
+
#include <linux/lustre_lite.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/lustre_lib.h>
+#include <linux/lprocfs_status.h>
+
int rd_path(char* page, char **start, off_t off,
(sb->s_op->statfs)(sb, &mystats);
blk_size=mystats.f_bsize;
- len+=snprintf(page, count, LPU64"\n", \
+ len+=snprintf(page, count, LPU64"\n",
(__u64)((mystats.f_bfree)/(blk_size*1024)));
return len;
}
-int rd_numobjects(char* page, char **start, off_t off,
+int rd_filestotal(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return len;
}
-int rd_objfree(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return len;
}
-int rd_objgroups(char* page, char **start, off_t off,
+int rd_filegroups(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return 0;
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/mntpt_path", rd_path, 0},
- {"snmp/fs_type", rd_fstype, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_objects", rd_numobjects, 0},
- {"snmp/f_objectsfree", rd_objfree, 0},
- {"snmp/f_objectgroups", rd_objgroups, 0},
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/mntpt_path", rd_path, 0},
+ {"status/fs_type", rd_fstype, 0},
+ {"status/blocksize",rd_blksize, 0},
+ {"status/blockstotal",rd_blktotal, 0},
+ {"status/blocksfree",rd_blkfree, 0},
+ {"status/kbytesfree", rd_kbfree, 0},
+ {"status/filestotal", rd_filestotal, 0},
+ {"status/filesfree", rd_filesfree, 0},
+ {"status/filegroups", rd_filegroups, 0},
{0}
};
#include <linux/lustre_dlm.h>
#include <linux/init.h>
#include <linux/fs.h>
+#include <linux/lprocfs_status.h>
+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
kmem_cache_t *ll_file_data_slab;
extern int ll_commitcbd_setup(struct ll_sb_info *);
extern int ll_commitcbd_cleanup(struct ll_sb_info *);
+extern int rd_dev_uuid(char* page, char **start, off_t off,
+ int count, int *eof, void *data);
+
+extern int rd_dev_name(char* page, char **start, off_t off,
+ int count, int *eof, void *data);
+
+
+extern lprocfs_vars_t status_var_nm_1[];
+
static char *ll_read_opt(const char *opt, char *data)
{
char *value;
struct ll_read_inode2_cookie lic;
class_uuid_t uuid;
+
+ /* Lprocfs variables */
+ char mnt_name[100];
+ char uuid_name[100];
+ lprocfs_vars_t d_vars[3];
+
+
+
ENTRY;
MOD_INC_USE_COUNT;
ptlrpc_req_finished(request);
request = NULL;
+
+ /* Register this mount instance with LProcFS */
+
+ snprintf(mnt_name, 100, "mount_%s", sbi->ll_sb_uuid);
+ sbi->ll_mnt_root=lprocfs_reg_mnt(mnt_name);
+ if(!sbi->ll_mnt_root)
+ goto out_dev;
+
+ /* Add the static configuration info */
+ lprocfs_add_vars(sbi->ll_mnt_root, (lprocfs_vars_t*)status_var_nm_1,
+ (void*)sb);
+
+ /* Add the dynamic configuration stuff */
+ /* MDC */
+ obd = class_uuid2obd(mdc);
+
+ /* Reuse mnt_name */
+
+ sprintf(mnt_name, "status/%s/common_name", obd->obd_type->typ_name);
+
+ memset(d_vars, 0, sizeof(d_vars));
+ d_vars[0].read_fptr=rd_dev_name;
+ d_vars[0].write_fptr=0;
+ d_vars[0].name=(char*)mnt_name;
+
+ memset(uuid_name, '\0', strlen(uuid_name));
+ sprintf(uuid_name, "status/%s/uuid", obd->obd_type->typ_name);
+ d_vars[1].read_fptr=rd_dev_uuid;
+ d_vars[1].write_fptr=0;
+ d_vars[1].name=(char*)uuid_name;
+
+ err=lprocfs_add_vars(sbi->ll_mnt_root, (lprocfs_vars_t*)d_vars,
+ (void*)obd);
+ if (err) {
+ CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables");
+ }
+
+ /* OSC or LOV*/
+ obd = class_uuid2obd(osc);
+ /* Reuse mnt_name */
+ memset(mnt_name, '\0', strlen(mnt_name));
+ sprintf(mnt_name, "status/%s/common_name", obd->obd_type->typ_name);
+
+ memset(d_vars, 0, sizeof(d_vars));
+ d_vars[0].read_fptr=rd_dev_name;
+ d_vars[0].write_fptr=0;
+ d_vars[0].name=(char*)mnt_name;
+
+ memset(uuid_name, '\0', strlen(uuid_name));
+ sprintf(uuid_name, "status/%s/uuid", obd->obd_type->typ_name);
+ d_vars[1].read_fptr=rd_dev_uuid;
+ d_vars[1].write_fptr=0;
+ d_vars[1].name=(char*)uuid_name;
+
+ err=lprocfs_add_vars(sbi->ll_mnt_root, (lprocfs_vars_t*)d_vars,
+ (void*)obd);
+ if (err) {
+ CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables");
+ }
out_dev:
if (mdc)
OBD_FREE(mdc, strlen(mdc) + 1);
*/
mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
+ lprocfs_dereg_mnt(sbi->ll_mnt_root);
obd_disconnect(&sbi->ll_mdc_conn);
OBD_FREE(sbi, sizeof(*sbi));
EXTRA_PROGRAMS = lov
LINX= lov_pack.c
-lov_SOURCES = lov_obd.c $(LINX)
+lov_SOURCES = lov_obd.c lproc_lov.c $(LINX)
lov_pack.c:
test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
* lov/lov.c
#include <linux/random.h>
#include <linux/slab.h>
#include <asm/div64.h>
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
static kmem_cache_t *lov_file_cache;
RETURN(rc);
}
+int lov_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int lov_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+
+ }
+
struct obd_ops lov_obd_ops = {
+ o_attach: lov_attach,
+ o_detach: lov_detach,
o_setup: lov_setup,
o_connect: lov_connect,
o_disconnect: lov_disconnect,
static int __init lov_init(void)
{
+ int rc;
+
printk(KERN_INFO "Lustre Logical Object Volume driver " LOV_VERSION
", info@clusterfs.com\n");
lov_file_cache = kmem_cache_create("ll_lov_file_data",
if (!lov_file_cache)
RETURN(-ENOMEM);
- return class_register_type(&lov_obd_ops, OBD_LOV_DEVICENAME);
+ rc = class_register_type(&lov_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ OBD_LOV_DEVICENAME);
+ if (rc) RETURN(rc);
+
+ return 0;
+
+
}
static void __exit lov_exit(void)
{
- class_unregister_type(OBD_LOV_DEVICENAME);
+
if (kmem_cache_destroy(lov_file_cache))
CERROR("couldn't free LOV open cache\n");
+ class_unregister_type(OBD_LOV_DEVICENAME);
+
}
MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
/*
- * Common SNMP namespace
+ * Common STATUS namespace
*/
int rd_uuid(char* page, char **start, off_t off,
struct obd_device* dev=(struct obd_device*)data;
int len=0;
struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n", \
- (__u64)(lov->desc.ld_default_stripe_count));
+ len+=snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_default_stripe_size));
return len;
}
-int rd_stripedepth(char* page, char **start, off_t off,
+int rd_stripeoffset(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct obd_device* dev=(struct obd_device*)data;
int len=0;
struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n", \
- lov->desc.ld_default_stripe_size);
+ len+=snprintf(page, count, LPU64"\n",
+ lov->desc.ld_default_stripe_offset);
return len;
}
-int rd_stripefactor(char* page, char **start, off_t off,
+
+int rd_stripetype(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct obd_device* dev=(struct obd_device*)data;
int len=0;
struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n", \
- lov->desc.ld_default_stripe_offset);
+ len+=snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_pattern));
return len;
}
+int rd_stripecount(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device* dev=(struct obd_device*)data;
+ int len=0;
+ struct lov_obd* lov=&dev->u.lov;
+ len+=snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_default_stripe_count));
+ return len;
-int rd_stripetype(char* page, char **start, off_t off,
+}
+int rd_numobd(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct obd_device* dev=(struct obd_device*)data;
int len=0;
struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n", \
- (__u64)(lov->desc.ld_pattern));
+ len+=snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_tgt_count));
+ return len;
+
+}
+
+int rd_activeobd(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device* dev=(struct obd_device*)data;
+ int len=0;
+ struct lov_obd* lov=&dev->u.lov;
+ len+=snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_active_tgt_count));
return len;
}
struct lov_obd* lov=&dev->u.lov;
struct lov_tgt_desc* tgts=lov->tgts;
while(i<lov->desc.ld_tgt_count){
- len+=snprintf(page, count, \
- "OBD Device [%d] UUID: %s\n", \
- i, tgts->uuid);
-
+ len+=snprintf(page, count, "%d: %s\n", i, tgts->uuid);
i++;
tgts++;
}
struct obd_device* dev=(struct obd_device*)data;
int len=0;
struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, \
- "%s\n", \
- lov->mdcobd->obd_uuid);
+ len+=snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
+ return len;
+}
+
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/stripesize",rd_stripesize, 0},
+ {"status/stripeoffset",rd_stripeoffset, 0},
+ {"status/stripecount",rd_stripecount, 0},
+ {"status/stripetype", rd_stripetype, 0},
+ {"status/numobd",rd_numobd, 0},
+ {"status/activeobd", rd_activeobd, 0},
+ {"status/objects", rd_numobjects, 0},
+ {"status/objectsfree", rd_objfree, 0},
+ {"status/objectgroups", rd_objgroups, 0},
+ {"status/blocksize", rd_blksize, 0},
+ {"status/blockstotal", rd_blktotal, 0},
+ {"status/kbytesfree", rd_kbfree, 0},
+ {"status/blocksfree", rd_blkfree, 0},
+ {"status/target_obd", rd_target, 0},
+ {"status/target_mdc", rd_mdc, 0},
+
+ {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
return len;
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/lov_stripesize",rd_stripesize, 0},
- {"snmp/lov_stripedepth",rd_stripedepth, 0},
- {"snmp/lov_stripefactor",rd_stripefactor, 0},
- {"snmp/lov_stripetype", rd_stripetype, 0},
- {"snmp/f_objects", rd_numobjects, 0},
- {"snmp/f_objectsfree", rd_objfree, 0},
- {"snmp/f_objectgroups", rd_objgroups, 0},
- {"snmp/f_blocksize", rd_blksize, 0},
- {"snmp/f_blockstotal", rd_blktotal, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_blocksfree", rd_blkfree, 0},
- {"snmp/target_obd", rd_target, 0},
- {"snmp/target_mdc", rd_mdc, 0},
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
EXTRA_PROGRAMS = mdc
LINX= mds_updates.c ll_pack.c lov_pack.c client.c
-mdc_SOURCES = mdc_request.c mdc_reint.c $(LINX)
+mdc_SOURCES = mdc_request.c mdc_reint.c lproc_mdc.c $(LINX)
lov_pack.c:
test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
+
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
int rd_blksize(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
- return 0;
-}
-int rd_blktotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
return 0;
-}
-int rd_blkfree(char* page, char **start, off_t off,
+}
+int rd_kbtotal(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return 0;
return 0;
}
-int rd_numobjects(char* page, char **start, off_t off,
+
+int rd_files(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return 0;
}
-int rd_objfree(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return 0;
}
-int rd_objgroups(char* page, char **start, off_t off,
+int rd_filegroups(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
return 0;
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_objects", rd_numobjects, 0},
- {"snmp/f_objectsfree", rd_objfree, 0},
- {"snmp/f_objectgroups", rd_objgroups, 0},
- {"snmp/server_uuid", rd_server_uuid, 0},
- {"snmp/conn_uuid", rd_conn_uuid, 0},
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/blocksize",rd_blksize, 0},
+ {"status/kbytestotal",rd_kbtotal, 0},
+ {"status/kbytesfree", rd_kbfree, 0},
+ {"status/files", rd_files, 0},
+ {"status/filesfree", rd_filesfree, 0},
+ {"status/filegroups", rd_filegroups, 0},
+ {"status/server_uuid", rd_server_uuid, 0},
+ {"status/conn_uuid", rd_conn_uuid, 0},
+ {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
#include <linux/lustre_dlm.h>
#include <linux/init.h>
#include <linux/obd_lov.h>
+#include <linux/lprocfs_status.h>
#define REQUEST_MINOR 244
extern int mds_queue_req(struct ptlrpc_request *);
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
/* should become mdc_getinfo() */
int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid)
return rc;
}
+int mdc_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int mdc_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+}
struct obd_ops mdc_obd_ops = {
+ o_attach: mdc_attach,
+ o_detach: mdc_detach,
o_setup: client_obd_setup,
o_cleanup: client_obd_cleanup,
o_connect: client_obd_connect,
static int __init ptlrpc_request_init(void)
{
- return class_register_type(&mdc_obd_ops, LUSTRE_MDC_NAME);
+ int rc;
+ rc = class_register_type(&mdc_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ LUSTRE_MDC_NAME);
+ if(rc)
+ RETURN(rc);
+ return 0;
+
}
static void __exit ptlrpc_request_exit(void)
{
+
class_unregister_type(LUSTRE_MDC_NAME);
+
}
MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
target.c:
test -e target.c || ln -sf $(top_srcdir)/lib/target.c
-mds_SOURCES = mds_lov.c handler.c mds_reint.c mds_fs.c $(LINX)
+mds_SOURCES = mds_lov.c handler.c mds_reint.c mds_fs.c lproc_mds.c $(LINX)
include $(top_srcdir)/Rules
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
#include <linux/buffer_head.h>
#endif
+#include <linux/lprocfs_status.h>
static kmem_cache_t *mds_file_cache;
struct ptlrpc_request *req);
static int mds_cleanup(struct obd_device * obddev);
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
{
return &req->rq_export->exp_obd->u.mds;
RETURN(rc);
}
+int mds_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int mds_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+
+}
#define MDT_NUM_THREADS 8
static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
/* use obd ops to offer management infrastructure */
static struct obd_ops mds_obd_ops = {
+ o_attach: mds_attach,
+ o_detach: mds_detach,
o_connect: mds_connect,
o_disconnect: mds_disconnect,
o_setup: mds_setup,
static int __init mds_init(void)
{
+
mds_file_cache = kmem_cache_create("ll_mds_file_data",
sizeof(struct mds_file_data),
0, 0, NULL, NULL);
if (mds_file_cache == NULL)
return -ENOMEM;
- class_register_type(&mds_obd_ops, LUSTRE_MDS_NAME);
- class_register_type(&mdt_obd_ops, LUSTRE_MDT_NAME);
+ class_register_type(&mds_obd_ops, (lprocfs_vars_t*)status_class_var,
+ LUSTRE_MDS_NAME);
+ class_register_type(&mdt_obd_ops, 0, LUSTRE_MDT_NAME);
+
ldlm_register_intent(ldlm_intent_policy);
+
return 0;
+
}
static void __exit mds_exit(void)
{
+
+
ldlm_unregister_intent();
class_unregister_type(LUSTRE_MDS_NAME);
class_unregister_type(LUSTRE_MDT_NAME);
if (kmem_cache_destroy(mds_file_cache))
CERROR("couldn't free MDS file cache\n");
+
}
MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
+
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
return 0;
}
blk_size=mystats.f_bsize;
- len+=snprintf(page, count, LPU64"\n", \
+ len+=snprintf(page, count, LPU64"\n",
(__u64)((mystats.f_bfree)/(blk_size*1024)));
return len;
return 0;
}
- len+=snprintf(page, count, LPU64"\n", \
- (__u64)(mystats.f_files));
+ len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
return len;
return 0;
}
- len+=snprintf(page, count, LPU64"\n", \
- (__u64)(mystats.f_ffree));
+ len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
return len;
}
{
return 0;
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_fstype", rd_fstype, 0},
- {"snmp/f_files", rd_ffiles, 0},
- {"snmp/f_inodesfree", rd_inodesfree, 0},
- {"snmp/f_filesets", rd_filesets, 0},
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/f_blocksize",rd_blksize, 0},
+ {"status/f_blockstotal",rd_blktotal, 0},
+ {"status/f_blocksfree",rd_blkfree, 0},
+ {"status/f_kbytesfree", rd_kbfree, 0},
+ {"status/f_fstype", rd_fstype, 0},
+ {"status/f_files", rd_ffiles, 0},
+ {"status/f_inodesfree", rd_inodesfree, 0},
+ {"status/f_filesets", rd_filesets, 0},
+ {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
modulefs_DATA = obdclass.o
EXTRA_PROGRAMS = obdclass
obdclass_SOURCES = debug.c genops.c proc_lustre.c class_obd.c sysctl.c uuid.c \
- lprocfs.c
+ lprocfs_status.c
include $(top_srcdir)/Rules
#include <linux/obd_class.h>
#include <linux/lustre_debug.h>
#include <linux/smp_lock.h>
-#include <linux/lprocfs.h>
+#include <linux/lprocfs_status.h>
struct semaphore obd_conf_sem; /* serialize configuration commands */
struct obd_device obd_dev[MAX_OBD_DEVICES];
char obd_recovery_upcall[128] = "/usr/lib/lustre/ha_assist";
extern struct obd_type *class_nm_to_type(char *nm);
-/*
- * LProcFS specific data structures. These define the namespace for
- * the various device classes. We will need to distribute these
- * later, to individual modules (e.g. MDS, MDC etc)
- */
-
-#ifdef LPROCFS_EXISTS
-
-/*
- * Common SNMP namespace
- */
-
-char *snmp_dir_nm[] = {
- "snmp",
- 0
-
-};
-
-lprocfs_vars_t snmp_var_nm[]={
- {"uuid", rd_uuid, wr_uuid},
- {"f_blocksize",rd_blksize, wr_other},
- {"f_blockstotal",rd_blktotal, wr_other},
- {"f_blocksfree",rd_blkfree, wr_other},
- {"f_kbytesfree", rd_kbfree, wr_other},
- {"f_objects", rd_numobjects, wr_other},
- {"f_objectsfree", rd_objfree, wr_other},
- {"f_objectgroups", rd_objgroups, wr_other},
- {"0", 0, 0}
-};
-
-
-
-
-/*
- * Common OBD namespace for lprocFS (these are used very often)
- */
-
-char* obd_dir_nm_1[]= {
- "mgmt%",
- "mgmt/setup",
- "mgmt/cleanup",
- "mgmt/connect",
- "mgmt/disconnect",
- 0
-};
-
-lprocfs_vars_t obd_var_nm_1[]= {
- {"num_ops", lprocfs_ll_rd, lprocfs_ll_wr},
- {"min_time", lprocfs_ll_rd, lprocfs_ll_wr},
- {"max_time", lprocfs_ll_rd, lprocfs_ll_wr},
- {"sum_time", lprocfs_ll_rd, lprocfs_ll_wr},
- {"0", 0, 0}
-};
-
-
-/*
- * MDC Spcific namespace for lprocFS
- */
-
-char *mdc_dir_nm_1[]= {
- "reint",
- "getstatus",
- "getattr",
- "setattr",
- "open",
- "readpage",
- "create",
- "unlink",
- "link",
- "rename",
- 0
-};
-
-
-
-
-
-/*
- * Create the MDC groupings
- */
-lprocfs_group_t lprocfs_mdc_nm[]= {
-
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {mdc_dir_nm_1, obd_var_nm_1, e_generic},
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {0, 0, 0}
-};
-
-/*
- * MDS Device Groupings
- */
-char *mds_dir_nm_1[]={
- "getstatus",
- "connect",
- "disconnect_callback",
- "getattr",
- "readpage",
- "open",
- "close",
- "create",
- "unlink",
- "link",
- "rename",
- "reint%",
- "reint/summary",
- "reint/setattr",
- "reint/create",
- "reint/unlink",
- "reint/link",
- "reint/rename",
- "reint/recreate",
- 0
-};
-/*
-char *mds_dir_nm_2[]={
- "mstatfs",
- 0
-};
-
-
-lprocfs_vars_t mds_var_nm_2[]={
- {"f_type", rd_fs_type, wr_other},
- {"f_bsize",rd_other, wr_other},
- {"f_blocks",rd_other, wr_other},
- {"f_bfree",rd_other, wr_other},
- {"f_bavail",rd_other, wr_other},
- {"uuid",rd_string, wr_string},
- {"0", 0, 0}
-};
-
-*/
-
-char *mds_snmp_dir_nm_1[] = {
- "snmp",
- 0
-};
-
-
-lprocfs_vars_t mds_snmp_var_nm_1[] = {
- {"f_fstype", rd_fs_type, wr_other},
- {"f_files",rd_other, wr_other},
- {"f_inodesfree",rd_other, wr_other},
- {"f_filesets",rd_other, wr_other},
- {"0", 0, 0}
-};
-
-lprocfs_group_t lprocfs_mds_nm[]={
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {mds_dir_nm_1, obd_var_nm_1, e_generic},
- /* {mds_dir_nm_2, mds_var_nm_2, e_specific}, */
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {mds_snmp_dir_nm_1, mds_snmp_var_nm_1, e_specific},
- {0, 0, 0}
-};
-
-lprocfs_group_t lprocfs_mdt_nm[]={
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- /* {mds_dir_nm_1, obd_var_nm_1, e_generic}, */
- /* {mds_dir_nm_2, mds_var_nm_2, e_specific}, */
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {mds_snmp_dir_nm_1, mds_snmp_var_nm_1, e_specific},
- {0, 0, 0}
-};
-
-/*
- * OSC Namespace
- */
-
-char* osc_dir_nm_1[]={
- "create",
- "destroy",
- "getattr",
- "setattr",
- "open",
- "close",
- "brw",
- "punch",
- "summary",
- "cancel",
- 0
-};
-
-lprocfs_group_t lprocfs_osc_nm[]={
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {osc_dir_nm_1, obd_var_nm_1, e_generic},
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {0, 0, 0}
-};
-
-
-/*
- * OST, LOV, OBD_FILTER namespace
- * Note: These namespaces are exactly similar to the osc_dir_namespace
- * Hence, I use the osc namespace as the base class and add only
- * those attributes that are missing in osc_dir_namespace.
- */
-
-char *ost_lov_obdfilter_dir_nm_1[]={
- "getinfo",
- 0
-
-};
-
-
-
-/*
-char *ost_lov_obdfilter_dir_nm_2[]={
- "ostatfs",
- 0
-};
-
-lprocfs_vars_t ost_lov_obdfilter_var_nm_2[]={
- {"f_type", rd_fs_type, wr_other},
- {"f_bsize",rd_other, wr_other},
- {"f_blocks",rd_other, wr_other},
- {"f_bfree",rd_other, wr_other},
- {"f_bavail",rd_other, wr_other},
- {"f_objects", rd_other, wr_other},
- {"f_ofree", rd_other, wr_other},
- {"f_objectgroups", rd_other, wr_other},
- {"f_uuid", rd_string, wr_string},
- {"0", 0, 0}
-};
-*/
-
-
-char* obdfilter_snmp_dir_nm_1[] = {
- "snmp",
- 0
-};
-lprocfs_vars_t obdfilter_snmp_var_nm_1[] = {
- {"f_fstype", rd_other, wr_other},
- {"f_inodestotal", rd_other, wr_other},
- {"f_inodesfree", rd_other, wr_other},
- {"0", 0, 0}
-};
-
-
-lprocfs_group_t lprocfs_ost_nm[] = {
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {osc_dir_nm_1, obd_var_nm_1, e_generic},
- {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
- /* {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific}, */
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {0, 0, 0}
-};
-
-char* lov_snmp_dir_nm_1[] = {
- "snmp",
- 0
-};
-lprocfs_vars_t lov_snmp_var_nm_1[] = {
- {"lov_stripesize", rd_other, wr_other},
- {"lov_stripedepth", rd_other, wr_other},
- {"lov_stripefactor", rd_other, wr_other},
- {"lov_stripetype", rd_other, wr_other},
- {"0", 0, 0}
-};
-
-lprocfs_group_t lprocfs_lov_nm[] = {
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {osc_dir_nm_1, obd_var_nm_1, e_generic},
- {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
- /* {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific}, */
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {lov_snmp_dir_nm_1, lov_snmp_var_nm_1, e_specific},
- {0, 0, 0}
-};
-
-lprocfs_group_t lprocfs_obdf_nm[] = {
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {osc_dir_nm_1, obd_var_nm_1, e_generic},
- {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
- /* {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific}, */
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {obdfilter_snmp_dir_nm_1, obdfilter_snmp_var_nm_1, e_specific},
- {0, 0, 0}
-};
-
-
-/*
- * LDLM Device namespace
- */
-
-
-char* ldlm_dir_nm_1[]={
- "locks%",
- "locks/enqueus",
- "locks/cancels",
- "locks/converts",
- "locks/matches",
- 0
-};
-
-lprocfs_vars_t ldlm_var_nm_1[]= {
- {"num_total", lprocfs_ll_rd, lprocfs_ll_wr},
- {"num_zerolatency", lprocfs_ll_rd, lprocfs_ll_wr},
- {"num_zerolatency_inflight", lprocfs_ll_rd, lprocfs_ll_wr},
- {"num_zerolatency_done", lprocfs_ll_rd, lprocfs_ll_wr},
- {"nonzero_mintime", lprocfs_ll_rd, lprocfs_ll_wr},
- {"nonzero_maxtime", lprocfs_ll_rd, lprocfs_ll_wr},
- {"nonzero_sumtime", lprocfs_ll_rd, lprocfs_ll_wr},
- {"0", 0, 0}
-
-};
-
-lprocfs_group_t lprocfs_ldlm_nm[]={
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {ldlm_dir_nm_1, ldlm_var_nm_1, e_generic},
- {0, 0, 0}
-};
-
-/*
- * Note: Need to add namespace for breaking out locks by device class
- */
-
-/*
- * PTLRPC Namespace
- */
-char* ptlrpc_dir_nm_1[]={
- "counters",
- 0
-};
-
-lprocfs_vars_t ptlrpc_var_nm_1[]={
- {"msgs_alloc", lprocfs_ll_rd, lprocfs_ll_wr},
- {"msgs_max", lprocfs_ll_rd, lprocfs_ll_wr},
- {"recv_count", lprocfs_ll_rd, lprocfs_ll_wr},
- {"recv_length", lprocfs_ll_rd, lprocfs_ll_wr},
- {"send_count", lprocfs_ll_rd, lprocfs_ll_wr},
- {"send_length", lprocfs_ll_rd, lprocfs_ll_wr},
- {"portal_kmemory", lprocfs_ll_rd, lprocfs_ll_wr},
- {"0", 0, 0}
-};
-
-char* ptlrpc_dir_nm_2[] = {
- "network",
- 0
-};
-
-lprocfs_vars_t ptlrpc_var_nm_2[] = {
- {"type", rd_string, wr_string},
- {"mtu", lprocfs_ll_rd, lprocfs_ll_wr},
- {"rxpackets", lprocfs_ll_rd, lprocfs_ll_wr},
- {"txpackets", lprocfs_ll_rd, lprocfs_ll_wr},
- {"txbytes", lprocfs_ll_rd, lprocfs_ll_wr},
- {"0", 0, 0}
-};
-
-lprocfs_group_t lprocfs_ptlrpc_nm[]={
- {obd_dir_nm_1, obd_var_nm_1, e_generic},
- {ptlrpc_dir_nm_1, ptlrpc_var_nm_1, e_generic},
- {ptlrpc_dir_nm_2, ptlrpc_var_nm_2, e_specific},
- {snmp_dir_nm, snmp_var_nm, e_specific},
- {0, 0, 0}
-};
-
-
-/*
- * Building the entire device namespace. This will be used during attach and
- * detach to associate the namespace with the class of the device
- */
-
-lprocfs_obd_nm_t obd_nm[]={
- {"mdc", lprocfs_mdc_nm, sizeof(struct lprofiler_gen)},
- {"mds", lprocfs_mds_nm, sizeof(struct lprofiler_gen)},
- {"mdt", lprocfs_mdt_nm, sizeof(struct lprofiler_gen)},
- {"osc", lprocfs_osc_nm, sizeof(struct lprofiler_gen)},
- {"ost", lprocfs_ost_nm, sizeof(struct lprofiler_gen)},
- {"lov", lprocfs_lov_nm, sizeof(struct lprofiler_gen)},
- {"obdfilter", lprocfs_obdf_nm, sizeof(struct lprofiler_gen)},
- {"obdecho", lprocfs_ost_nm, sizeof(struct lprofiler_gen)},
- {"ldlm", lprocfs_ldlm_nm, sizeof(struct lprofiler_ldlm)},
- {"ptlrpc", lprocfs_ptlrpc_nm, sizeof(struct lprofiler_ptlrpc)},
- {"0", 0, 0}
-};
-
-#else
-
-lprocfs_obd_nm_t* obd_nm=0;
-
-#endif
/* opening /dev/obd */
static int obd_class_open(struct inode * inode, struct file * file)
int rw = OBD_BRW_READ;
int err = 0;
int serialised = 0;
- int l_idx = 0;
+
ENTRY;
switch (cmd)
INIT_LIST_HEAD(&obd->obd_imports);
spin_lock_init(&obd->obd_dev_lock);
- /* do the attach */
- if (OBP(obd, attach))
- err = OBP(obd,attach)(obd, sizeof(*data), data);
- if (err) {
- obd->obd_type = NULL;
- } else {
- obd->obd_flags |= OBD_ATTACHED;
-
- type->typ_refcnt++;
- CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
- obd->obd_minor, data->ioc_inlbuf1);
if (data->ioc_inlbuf2) {
int len = strlen(data->ioc_inlbuf2) + 1;
OBD_ALLOC(obd->obd_name, len);
LBUG();
}
memcpy(obd->obd_name, data->ioc_inlbuf2, len);
- /* obd->obd_proc_entry =
- proc_lustre_register_obd_device(obd);
- */
} else {
CERROR("WARNING: unnamed obd device\n");
- obd->obd_proc_entry = NULL;
}
-
if (data->ioc_inlbuf3) {
int len = strlen(data->ioc_inlbuf3);
if (len >= sizeof(obd->obd_uuid)) {
}
memcpy(obd->obd_uuid, data->ioc_inlbuf3, len);
}
+ /* do the attach */
+ if (OBP(obd, attach))
+ err = OBP(obd,attach)(obd, sizeof(*data), data);
+ if (err) {
+ if(data->ioc_inlbuf2)
+ OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
+ obd->obd_type = NULL;
- /* Get the LprocFS namespace for this device class */
- l_idx = lprocfs_get_nm(data->ioc_inlbuf1, obd_nm);
- if (l_idx < 0) {
- CERROR("Non-existent device class"
- "or proc/lustre not compiled \n");
} else {
- lprocfs_reg_dev(obd, obd_nm[l_idx].obd_names,
- obd_nm[l_idx].cntr_blk_sz);
- }
+ obd->obd_flags |= OBD_ATTACHED;
+
+ type->typ_refcnt++;
+ CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
+ obd->obd_minor, data->ioc_inlbuf1);
CDEBUG(D_IOCTL, "MOD_INC_USE for attach: count = %d\n",
atomic_read(&(THIS_MODULE)->uc.usecount));
}
forcibly_detach_exports(obd);
}
-
- if (lprocfs_dereg_dev(obd) != LPROCFS_SUCCESS) {
- CERROR("Could not remove /proc entry\n");
- }
+ if (OBP(obd, detach))
+ err=OBP(obd,detach)(obd);
if (obd->obd_name) {
OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
obd->obd_name = NULL;
}
- /*
- if (obd->obd_proc_entry)
- proc_lustre_release_obd_device(obd);
- */
obd->obd_flags &= ~OBD_ATTACHED;
obd->obd_type->typ_refcnt--;
EXPORT_SYMBOL(class_signal_connection_failure);
EXPORT_SYMBOL(ll_sync_io_cb);
EXPORT_SYMBOL(ll_init_cb);
+EXPORT_SYMBOL(class_nm_to_type);
static int __init init_obdclass(void)
{
obd->obd_minor = i;
err = obd_init_caches();
+
if (err)
return err;
obd_sysctl_init();
+
+ err=lprocfs_reg_main();
+
return 0;
}
static void __exit cleanup_obdclass(void)
{
- int i;
+ int i, err;
ENTRY;
misc_deregister(&obd_psdev);
obd_cleanup_caches();
obd_sysctl_clean();
+
+ err = lprocfs_dereg_main();
+
CERROR("obd memory leaked: %ld bytes\n", obd_memory);
EXIT;
}
#include <linux/obd_class.h>
#include <linux/random.h>
#include <linux/slab.h>
+#include <linux/lprocfs_status.h>
extern struct list_head obd_types;
kmem_cache_t *obdo_cachep = NULL;
return type;
}
-int class_register_type(struct obd_ops *ops, char *nm)
+int class_register_type(struct obd_ops *ops, struct lprocfs_vars* vars, char *nm)
{
struct obd_type *type;
+ int rc;
ENTRY;
list_add(&type->typ_chain, &obd_types);
memcpy(type->typ_ops, ops, sizeof(*type->typ_ops));
strcpy(type->typ_name, nm);
+ rc = lprocfs_reg_class(type, (lprocfs_vars_t *)vars, (void*)type);
+ if(rc)
+ RETURN(rc);
+
RETURN(0);
}
OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
RETURN(-EBUSY);
}
+ if(type->typ_procroot)
+ lprocfs_dereg_class(type);
list_del(&type->typ_chain);
OBD_FREE(type->typ_name, strlen(nm) + 1);
/* -*- 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
};
-/*
- * 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)
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)
{
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2002 Cluster File Systems, Inc.
- *
- * This file is part of Lustre, http://www.lustre.org.
- *
- * Lustre is free 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.
- *
- * 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
- * GNU General Public License for more details.
- *
- * 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.
- *
- */
-
-#define EXPORT_SYMTAB
-#include <linux/config.h>
-#include <linux/module.h>
-#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
-
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
-
-#ifdef LPROCFS_EXISTS
-
-#define DEFAULT_MODE 0644
-/*
- * Tokenizer array. Change this array to include special
- * characters for string tokenizing
- */
-char tok[] = {'/', (char)0};
-
-
-
-/*
- * 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;
-
-/*
- * API implementations
- */
-/*
- * lprocfs_reg_obd: Registers an instance of the OBD device in the
- * proc hierarchy
- */
-
-int lprocfs_reg_obd(struct obd_device* device,
- lprocfs_vars_t* list,
- void* data)
-{
-
- int retval = 0;
- struct proc_dir_entry* this_dev_root=0;
-
-
- /* Obtain this device root */
- this_dev_root = lprocfs_mkinitdir(device);
- if (this_dev_root == 0) {
- CERROR("Could not create initial directory");
- return LPROCFS_FAILURE;
- }
-
- device->obd_proc_entry=this_dev_root;
- retval=lprocfs_new_vars(device, \
- this_dev_root, list, \
- (const char*)tok,
- data);
-
- return retval;
-}
-
-int lprocfs_add_new_vars(struct obd_device* device,
- lprocfs_vars_t* var,
- void* data)
-{
- int retval=0;
- if(!device) {
- CERROR("Null pointer passed!");
- return LPROCFS_FAILURE;
- }
- if(!(device->obd_proc_entry)){
- CDEBUG(D_OTHER, \
- "Device instance not registered yet!!");
- return LPROCFS_FAILURE;
-
- }
- retval=lprocfs_new_vars(device,
- device->obd_proc_entry, \
- var, (const char*) tok, data);
- return retval;
-}
-
-int lprocfs_dereg_obd(struct obd_device* device)
-{
- struct proc_dir_entry* parent;
-
- CDEBUG(D_OTHER, "LPROCFS removing device = %s\n", \
- device->obd_name);
-
- if (!device) {
- CDEBUG(D_OTHER, "! LProcfs: Null pointer !\n");
- return LPROCFS_SUCCESS;
- }
-
- if (!(device->obd_name)) {
- CERROR(" !! Device does not have a name !! \n");
- return LPROCFS_FAILURE;
- }
- if(!(device->obd_proc_entry)){
- CERROR("This device has not been registered\n");
- return LPROCFS_FAILURE;
- }
- parent=device->obd_proc_entry->parent;
- lprocfs_remove_all(device->obd_proc_entry);
-
- /*
- * Free the memory held by counters
- */
- if (device->counters)
- OBD_FREE(device->counters, device->cntr_mem_size);
-
-
- while((!(parent->subdir) && \
- memcmp(parent, &proc_root, sizeof(*parent)))) {
- remove_proc_entry(parent->name, parent->parent);
- parent=parent->parent;
- }
-
- CDEBUG(D_OTHER, "LPROCFS removed device = %s\n", \
- device->obd_name);
-
- return LPROCFS_SUCCESS;
-}
-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==0) {
- proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
- if (!proc_lustre_root) {
- CERROR(" !! Cannot create /proc/lustre !! \n");
- return 0;
- }
- }
- if (proc_lustre_dev_root==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;
-}
-
-struct proc_dir_entry* lprocfs_mkdir(const char* dname,
- struct proc_dir_entry *parent)
-{
- struct proc_dir_entry *child_dir_entry;
-
- child_dir_entry = proc_mkdir(dname, parent);
-
- if (!child_dir_entry)
- CERROR("lustre: failed to create /proc entry %s\n", dname);
-
- return child_dir_entry;
-}
-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;
-}
-void lprocfs_remove_all(struct proc_dir_entry* root)
-{
- if (root->subdir != 0)
- lprocfs_remove_all(root->subdir);
-
- if (root->next != 0)
- lprocfs_remove_all(root->next);
-
- if (root->parent != 0)
- remove_proc_entry(root->name, root->parent);
- else
- remove_proc_entry(root->name, NULL);
-}
-/*
- * This function will be invoked during a module loading. The path parameter
- * is relative to /proc/lustre, and hence needs to begin as
- * dir_1/dir_2 etc
- * The list is a simple variable list of names, which will be created under
- * the "path". If none is specified, no variable entries will be created.
- * Returns: The root for this module.
- */
-
-struct proc_dir_entry* lprocfs_reg_module(char* name, char* path,
- lprocfs_vars_t* list,
- void* data)
-{
- struct proc_dir_entry* root=0;
- int retVal=0;
- if(!name){
- CERROR("LProcFS: Null pointer for name\n");
- return 0;
- }
- if(!path){
- CERROR("LProcFS: Insertion path not provided\n");
- return 0;
- }
- if (proc_lustre_root==0) {
- proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
- if (!proc_lustre_root) {
- CERROR(" !! Cannot create /proc/lustre !! \n");
- return 0;
- }
- }
- if((root=lprocfs_new_dir(proc_lustre_root, \
- path, (const char*)tok))==0){
-
- CERROR("!! LProcFS: Failed to create dirs");
- return 0;
- }
-
- root=lprocfs_mkdir(name, root);
- retVal=lprocfs_new_vars(NULL, root, list, \
- (const char*)tok, data);
- if(retVal==LPROCFS_FAILURE)
- return 0;
- return root;
-
-}
-
-int lprocfs_dereg_module(char* name)
-{
- struct proc_dir_entry* temp=0;
- struct proc_dir_entry* parent=0;
- if (proc_lustre_root==0) {
- CERROR(" !! LProc Does not exist !! \n");
- return 0;
- }
- temp = lprocfs_bfs_srch(proc_lustre_root->subdir, \
- name);
- if (temp == 0) {
- CDEBUG(D_OTHER, "!! Module not inserted!!");
- return LPROCFS_FAILURE;
- }
- parent=temp->parent;
- lprocfs_remove_all(temp);
- while((!(parent->subdir) && \
- memcmp(parent, &proc_root, sizeof(*parent)))) {
- remove_proc_entry(parent->name, parent->parent);
- parent=parent->parent;
- }
-
- CDEBUG(D_OTHER, "LPROCFS removed = %s\n", \
- name);
-
-
- return LPROCFS_SUCCESS;
-
-}
-
-struct proc_dir_entry* lprocfs_new_dir(struct proc_dir_entry* root,
- const char* string,
- const char* tok)
-{
- struct proc_dir_entry* new_root = 0;
- struct proc_dir_entry* temp_entry = 0;
-
- char temp_string[MAX_STRING_SIZE];
- char* my_str;
- char* mover_str;
-
- /*
- * Remove trailing escaping character
- */
- memset(temp_string, 0, MAX_STRING_SIZE);
- if (strlen(string) >= MAX_STRING_SIZE) {
- CDEBUG(D_OTHER, "Directory namespace too long");
- return 0;
- }
-
- strcpy(temp_string, string);
- temp_string[strlen(string) + 1] = '\0';
-
- new_root=root;
- mover_str=temp_string;
- while ((my_str = strsep(&mover_str, tok))) {
- if(!*my_str)
- continue;
- CDEBUG(D_OTHER, "SEARCH= %s\t, ROOT=%s\n", \
- my_str, new_root->name);
- temp_entry = lprocfs_srch(new_root, my_str);
- if (temp_entry == 0) {
- CDEBUG(D_OTHER, "Adding: %s\n", my_str);
- temp_entry = lprocfs_mkdir(my_str, new_root);
- if (temp_entry == 0) {
- CDEBUG(D_OTHER,
- "! Did not create new dir %s !!\n",
- my_str);
- return 0;
- }
- }
- new_root = temp_entry;
- }
-
- return new_root;
-}
-
-
-int lprocfs_add_mod_vars(struct proc_dir_entry* root,
- lprocfs_vars_t* list,
- void* data)
-{
- int retval=0;
- retval=lprocfs_new_vars(NULL, root, list, \
- (const char*) tok, data);
- return retval;
-}
-
-int lprocfs_new_vars(struct obd_device* dev,
- struct proc_dir_entry* root,
- lprocfs_vars_t* list,
- const char* tok,
- void* data)
-{
- struct proc_dir_entry* temp_root=0;
- struct proc_dir_entry* new_leaf=0;
- struct proc_dir_entry* new_parent=0;
- char temp_string[MAX_STRING_SIZE];
-
- if(!list)
- return LPROCFS_SUCCESS;
-
- while(list->name){
- temp_root=lprocfs_new_dir(root, \
- list->name, \
- tok);
-
- if(!temp_root){
- CDEBUG(D_OTHER, "!LProcFS: Mods: No root!");
- return LPROCFS_FAILURE;
- }
- /* Convert the last element into a leaf-node */
- memset(temp_string, 0, MAX_STRING_SIZE);
- strcpy(temp_string, temp_root->name);
- temp_string[strlen(temp_root->name) + 1] = '\0';
- new_parent=temp_root->parent;
- if (new_parent != 0){
- remove_proc_entry(temp_root->name, new_parent);
- } else {
- remove_proc_entry(temp_root->name, NULL);
- }
- new_leaf = create_proc_entry(temp_string, \
- DEFAULT_MODE, \
- new_parent);
- new_leaf->read_proc = list->read_fptr;
- new_leaf->write_proc = list->write_fptr;
- new_leaf->data=data;
- if(dev)
- new_leaf->data=dev;
- list++;
- }
- return LPROCFS_SUCCESS;
-
-}
-int lprocfs_ll_rd(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- __u64 *temp = (__u64 *)data;
- int len;
-
- len = snprintf(page, count, LPU64"\n", *temp);
-
- return len;
-}
-
-#endif /* LPROCFS_EXISTS */
-
-
-EXPORT_SYMBOL(lprocfs_reg_obd);
-EXPORT_SYMBOL(lprocfs_dereg_obd);
-EXPORT_SYMBOL(lprocfs_add_new_vars);
-EXPORT_SYMBOL(lprocfs_reg_module);
-EXPORT_SYMBOL(lprocfs_dereg_module);
-EXPORT_SYMBOL(lprocfs_ll_rd);
-EXPORT_SYMBOL(lprocfs_add_mod_vars);
-
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free 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.
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *
+ */
+
+#define EXPORT_SYMTAB
+#include <linux/config.h>
+#include <linux/module.h>
+#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
+
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
+
+#ifdef LPROC_SNMP
+
+#define DEFAULT_MODE 0444
+/*
+ * Tokenizer array. Change this array to include special
+ * characters for string tokenizing
+ */
+char tok[] = {'/', (char)0};
+
+
+
+/*
+ * Externs
+ */
+extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
+
+/*
+ * Globals
+ */
+struct proc_dir_entry *proc_lustre_root = 0;
+struct proc_dir_entry *proc_lustre_dev_root = 0;
+struct proc_dir_entry *proc_lustre_fs_root=0;
+
+struct proc_dir_entry* lprocfs_mkdir(const char* dname,
+ struct proc_dir_entry *parent)
+{
+ struct proc_dir_entry *child_dir_entry;
+
+ child_dir_entry = proc_mkdir(dname, parent);
+
+ if (!child_dir_entry)
+ CERROR("lustre: failed to create /proc entry %s\n", dname);
+
+ return child_dir_entry;
+}
+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;
+}
+
+
+void lprocfs_remove_all(struct proc_dir_entry* root)
+{
+
+ struct proc_dir_entry *temp=root;
+ struct proc_dir_entry* rm_entry;
+
+ while(1){
+
+ while(temp->subdir){
+ temp=temp->subdir;
+ }
+ rm_entry=temp;
+ temp=temp->parent;
+ remove_proc_entry(rm_entry->name, rm_entry->parent);
+ if(temp==root->parent) break;
+
+ }
+
+
+}
+
+struct proc_dir_entry* lprocfs_new_dir(struct proc_dir_entry* root,
+ const char* string,
+ const char* tok)
+{
+ struct proc_dir_entry* new_root = 0;
+ struct proc_dir_entry* temp_entry = 0;
+
+ char temp_string[MAX_STRING_SIZE];
+ char* my_str;
+ char* mover_str;
+
+ /*
+ * Remove trailing escaping character
+ */
+ memset(temp_string, 0, MAX_STRING_SIZE);
+ if (strlen(string) >= MAX_STRING_SIZE) {
+ CDEBUG(D_OTHER, "Directory namespace too long");
+ return 0;
+ }
+
+ strcpy(temp_string, string);
+ temp_string[strlen(string) + 1] = '\0';
+
+ new_root=root;
+ mover_str=temp_string;
+ while ((my_str = strsep(&mover_str, tok))) {
+ if(!*my_str)
+ continue;
+ CDEBUG(D_OTHER, "SEARCH= %s\t, ROOT=%s\n", my_str,
+ new_root->name);
+ temp_entry = lprocfs_srch(new_root, my_str);
+ if (temp_entry == 0) {
+ CDEBUG(D_OTHER, "Adding: %s\n", my_str);
+ temp_entry = lprocfs_mkdir(my_str, new_root);
+ if (temp_entry == 0) {
+ CDEBUG(D_OTHER,
+ "! Did not create new dir %s !!\n",
+ my_str);
+ return 0;
+ }
+ }
+ new_root = temp_entry;
+ }
+
+ return new_root;
+}
+
+int lprocfs_new_vars(struct proc_dir_entry* root,
+ lprocfs_vars_t* list,
+ const char* tok,
+ void* data)
+{
+ struct proc_dir_entry* temp_root=0;
+ struct proc_dir_entry* new_leaf=0;
+ struct proc_dir_entry* new_parent=0;
+ char temp_string[MAX_STRING_SIZE];
+
+ if(!list)
+ return 0;
+
+ while(list->name){
+ temp_root=lprocfs_new_dir(root, list->name, tok);
+
+ if(!temp_root){
+ CDEBUG(D_OTHER, "!LProcFS: Mods: No root!");
+ return -EINVAL;
+ }
+ /* Convert the last element into a leaf-node */
+ memset(temp_string, 0, MAX_STRING_SIZE);
+ strcpy(temp_string, temp_root->name);
+ temp_string[strlen(temp_root->name) + 1] = '\0';
+ new_parent=temp_root->parent;
+ if (new_parent != 0){
+ remove_proc_entry(temp_root->name, new_parent);
+ } else {
+ remove_proc_entry(temp_root->name, NULL);
+ }
+ new_leaf = create_proc_entry(temp_string, DEFAULT_MODE,
+ new_parent);
+ new_leaf->read_proc = list->read_fptr;
+ new_leaf->write_proc = list->write_fptr;
+ new_leaf->data=data;
+ list++;
+ }
+ return 0;
+
+}
+
+/*
+ * API implementations
+ */
+
+int lprocfs_add_vars(struct proc_dir_entry* root,
+ lprocfs_vars_t* var,
+ void* data)
+{
+
+ return lprocfs_new_vars(root, var,
+ (const char*) tok, data);
+
+
+}
+
+int lprocfs_reg_obd(struct obd_device* device,
+ lprocfs_vars_t* list,
+ void* data)
+{
+
+ int retval = 0;
+ struct proc_dir_entry* this_dev_root=0;
+
+ /* Obtain this device root */
+ this_dev_root = lprocfs_mkdir(device->obd_name,
+ device->obd_type->typ_procroot);
+
+ device->obd_proc_entry=this_dev_root;
+ retval=lprocfs_add_vars(this_dev_root, list,
+ data);
+
+ return retval;
+}
+
+int lprocfs_dereg_obd(struct obd_device* device)
+{
+
+ CDEBUG(D_OTHER, "LPROCFS removing device = %s\n", device->obd_name);
+
+ if (!device) {
+ CDEBUG(D_OTHER, "! LProcfs: Null pointer !\n");
+ return 0;
+ }
+
+ lprocfs_remove_all(device->obd_proc_entry);
+
+ if (device->counters)
+ OBD_FREE(device->counters, device->cntr_mem_size);
+
+ return 0;
+}
+
+struct proc_dir_entry* lprocfs_reg_mnt(char* mnt_name)
+{
+ return lprocfs_mkdir(mnt_name, proc_lustre_fs_root);
+
+}
+
+int lprocfs_dereg_mnt(struct proc_dir_entry* root)
+{
+ lprocfs_remove_all(root);
+ return 0;
+
+}
+
+int lprocfs_reg_class(struct obd_type* type,
+ lprocfs_vars_t* list,
+ void* data)
+{
+ struct proc_dir_entry* root;
+ int retval;
+
+ root=lprocfs_mkdir(type->typ_name, proc_lustre_dev_root);
+
+ type->typ_procroot=root;
+
+ retval=lprocfs_add_vars(root, list, data);
+
+ return retval;
+}
+
+int lprocfs_dereg_class(struct obd_type* class)
+{
+ if(!class){
+ CDEBUG(D_OTHER, "Non-existent class",
+ class->typ_name);
+ return 0;
+ }
+
+ lprocfs_remove_all(class->typ_procroot);
+
+ CDEBUG(D_OTHER, "LPROCFS removed = %s\n", class->typ_name);
+
+ return 0;
+
+}
+int lprocfs_reg_main()
+{
+ proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
+ if (!proc_lustre_root) {
+ CERROR(" !! Cannot create /proc/lustre !! \n");
+ return -EINVAL;
+ }
+
+ proc_lustre_dev_root =lprocfs_mkdir("devices", proc_lustre_root);
+
+ if (!proc_lustre_dev_root) {
+ CERROR(" !! Cannot create /proc/lustre/devices !! \n");
+ return -EINVAL;
+ }
+ proc_lustre_fs_root=lprocfs_mkdir("mnt_pnt", proc_lustre_root);
+
+ if (!proc_lustre_fs_root) {
+ CERROR(" !! Cannot create /proc/lustre/mnt_pnt !! \n");
+ return -EINVAL;
+ }
+
+ return 0;
+
+}
+
+int lprocfs_dereg_main()
+{
+ lprocfs_remove_all(proc_lustre_root);
+ proc_lustre_root=0;
+ proc_lustre_dev_root=0;
+ proc_lustre_fs_root=0;
+ return 0;
+
+}
+
+
+/*
+ * Needs to go...
+ */
+
+int lprocfs_ll_rd(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ __u64 *temp = (__u64 *)data;
+ int len;
+
+ len = snprintf(page, count, LPU64"\n", *temp);
+
+ return len;
+}
+
+#endif /* LPROC_SNMP */
+
+
+EXPORT_SYMBOL(lprocfs_reg_obd);
+EXPORT_SYMBOL(lprocfs_dereg_obd);
+EXPORT_SYMBOL(lprocfs_reg_main);
+EXPORT_SYMBOL(lprocfs_dereg_main);
+EXPORT_SYMBOL(lprocfs_reg_mnt);
+EXPORT_SYMBOL(lprocfs_dereg_mnt);
+EXPORT_SYMBOL(lprocfs_add_vars);
+EXPORT_SYMBOL(lprocfs_reg_class);
+EXPORT_SYMBOL(lprocfs_dereg_class);
+EXPORT_SYMBOL(lprocfs_ll_rd);
+
+
EXTRA_PROGRAMS = obdecho
LINX=
-obdecho_SOURCES = echo.c $(LINX)
+obdecho_SOURCES = echo.c lproc_echo.c $(LINX)
include $(top_srcdir)/Rules
* and Andreas Dilger <adilger@clusterfs.com>
*/
-static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.41 2002/10/18 22:32:45 pschwan Exp $";
-#define OBDECHO_VERSION "$Revision: 1.41 $"
+static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.42 2002/11/01 17:23:13 thantry Exp $";
+#define OBDECHO_VERSION "$Revision: 1.42 $"
#define EXPORT_SYMTAB
#include <linux/obd_echo.h>
#include <linux/lustre_debug.h>
#include <linux/lustre_dlm.h>
+#include <linux/lprocfs_status.h>
static atomic_t echo_page_rws;
static atomic_t echo_getattrs;
#define ECHO_PROC_STAT "sys/obdecho"
#define ECHO_INIT_OBJID 0x1000000000000000ULL
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
int echo_proc_read(char *page, char **start, off_t off, int count, int *eof,
void *data)
{
RETURN(0);
}
+int echo_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int echo_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+
+}
+
+
struct obd_ops echo_obd_ops = {
+ o_attach: echo_attach,
+ o_detach: echo_detach,
o_connect: echo_connect,
o_disconnect: echo_disconnect,
o_create: echo_create,
static int __init obdecho_init(void)
{
+ int rc;
+
+
printk(KERN_INFO "Echo OBD driver " OBDECHO_VERSION
" info@clusterfs.com\n");
echo_proc_init();
+ rc = class_register_type(&echo_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ OBD_ECHO_DEVICENAME);
+ if (rc) RETURN(rc);
+
+ return 0;
- return class_register_type(&echo_obd_ops, OBD_ECHO_DEVICENAME);
}
static void __exit obdecho_exit(void)
{
+
echo_proc_fini();
class_unregister_type(OBD_ECHO_DEVICENAME);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
-#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+#define DEBUG_SUBSYSTEM S_ECHO
+
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
+
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/fstype", rd_fstype, 0},
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/fstype", rd_fstype, 0},
+ {0}
+};
+
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
simple.c:
test -e simple.c || ln -sf $(top_srcdir)/lib/simple.c
-FILTERC = filter.c
+FILTERC = filter.c lproc_obdfilter.c
obdfilter_SOURCES = $(FILTERC) $(LINX)
dist-hook:
#include <linux/init.h>
#include <linux/random.h>
#include <linux/stringify.h>
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_class_var[];
+extern lprocfs_vars_t status_var_nm_1[];
static kmem_cache_t *filter_open_cache;
static kmem_cache_t *filter_dentry_cache;
RETURN(err);
}
+int filter_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+int filter_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+
+}
static struct obd_ops filter_obd_ops = {
+ o_attach: filter_attach,
+ o_detach: filter_detach,
o_get_info: filter_get_info,
o_setup: filter_setup,
o_cleanup: filter_cleanup,
RETURN(-ENOMEM);
}
- return class_register_type(&filter_obd_ops, OBD_FILTER_DEVICENAME);
+ return class_register_type(&filter_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ OBD_FILTER_DEVICENAME);
}
static void __exit obdfilter_exit(void)
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
+
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
struct obd_device* temp=(struct obd_device*)data;
struct statfs mystats;
- int rc, len=0;
+ int len=0;
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
+ vfs_statfs(temp->u.filter.fo_sb, &mystats);
+
+ len+=snprintf(page, count, "%ld\n", mystats.f_bsize);
return len;
}
-int rd_blktotal(char* page, char **start, off_t off,
+int rd_kbtotal(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct obd_device* temp=(struct obd_device*)data;
struct statfs mystats;
+ int len=0;
+ __u64 result;
- int rc, len=0;
+ vfs_statfs(temp->u.filter.fo_sb, &mystats);
+
+ result=((__u64)(mystats.f_blocks*mystats.f_bsize))>>10;
+
+ len+=snprintf(page, count, LPU64"\n", result);
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks));
return len;
}
-int rd_blkfree(char* page, char **start, off_t off,
+int rd_kbfree(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct obd_device* temp=(struct obd_device*)data;
struct statfs mystats;
- int rc, len=0;
+ int len=0;
+ __u64 result;
+
+ vfs_statfs(temp->u.filter.fo_sb, &mystats);
+ result=((__u64)(mystats.f_bfree*mystats.f_bsize))>>10;
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree));
+ len+=snprintf(page, count, LPU64"\n", result);
return len;
}
-int rd_kbfree(char* page, char **start, off_t off,
+int rd_fstype(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+
+ struct obd_device* temp=(struct obd_device*)data;
+ int len=0;
+
+ len+=snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
+ return len;
+
+}
+int rd_files(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
+
struct obd_device* temp=(struct obd_device*)data;
struct statfs mystats;
- int rc, len=0, blk_size=0;
+ int len=0;
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
- return 0;
- }
- blk_size=mystats.f_bsize;
+ vfs_statfs(temp->u.filter.fo_sb, &mystats);
- len+=snprintf(page, count, LPU64"\n", \
- (__u64)((mystats.f_bfree)/(blk_size*1024)));
+ len+=snprintf(page, count, "%ld\n", mystats.f_files);
return len;
-
}
-int rd_fstype(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
-
struct obd_device* temp=(struct obd_device*)data;
+ struct statfs mystats;
+
int len=0;
- len+=snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
+ vfs_statfs(temp->u.filter.fo_sb, &mystats);
+
+ len+=snprintf(page, count, "%ld\n", mystats.f_ffree);
return len;
+
+}
+
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/blocksize",rd_blksize, 0},
+ {"status/kbytestotal",rd_kbtotal, 0},
+ {"status/kbytesfree", rd_kbfree, 0},
+ {"status/files", rd_files, 0},
+ {"status/filesfree", rd_filesfree, 0},
+ {"status/fstype", rd_fstype, 0},
+ {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_fstype", rd_fstype, 0},
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
EXTRA_PROGRAMS = osc
LINX= obd_pack.c ll_pack.c client.c
-osc_SOURCES = osc_request.c $(LINX)
+osc_SOURCES = osc_request.c lproc_osc.c $(LINX)
obd_pack.c:
test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_objects", rd_numobjects, 0},
- {"snmp/f_objectsfree", rd_objfree, 0},
- {"snmp/f_objectgroups", rd_objgroups, 0},
- {"snmp/ost_server_uuid", rd_server_uuid, 0},
- {"snmp/ost_conn_uuid", rd_conn_uuid, 0},
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/f_blocksize",rd_blksize, 0},
+ {"status/f_blockstotal",rd_blktotal, 0},
+ {"status/f_blocksfree",rd_blkfree, 0},
+ {"status/f_kbytesfree", rd_kbfree, 0},
+ {"status/f_objects", rd_numobjects, 0},
+ {"status/f_objectsfree", rd_objfree, 0},
+ {"status/f_objectgroups", rd_objgroups, 0},
+ {"status/ost_server_uuid", rd_server_uuid, 0},
+ {"status/ost_conn_uuid", rd_conn_uuid, 0},
+ {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
#include <linux/obd_support.h> /* for OBD_FAIL_CHECK */
#include <linux/lustre_lite.h> /* for ll_i2info */
#include <portals/lib-types.h> /* for PTL_MD_MAX_IOV */
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
static int osc_getattr(struct lustre_handle *conn, struct obdo *oa,
struct lov_stripe_md *md)
return err;
}
+int osc_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int osc_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+
+}
struct obd_ops osc_obd_ops = {
+ o_attach: osc_attach,
+ o_detach: osc_detach,
o_setup: client_obd_setup,
o_cleanup: client_obd_cleanup,
o_statfs: osc_statfs,
static int __init osc_init(void)
{
- return class_register_type(&osc_obd_ops, LUSTRE_OSC_NAME);
+ int rc;
+
+ rc = class_register_type(&osc_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ LUSTRE_OSC_NAME);
+ if (rc)
+ RETURN(rc);
+ return 0;
+
}
static void __exit osc_exit(void)
target.c:
test -e target.c || ln -sf $(top_srcdir)/lib/target.c
-ost_SOURCES = ost_handler.c $(LINX)
+ost_SOURCES = ost_handler.c lproc_ost.c $(LINX)
dist-hook:
list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done
*
*/
#define DEBUG_SUBSYSTEM S_OST
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
-/* Required for 64 bit division */
-#include <asm/div64.h>
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
+
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
struct ost_obd *ost=&temp->u.ost;
struct lustre_handle *conn=&ost->ost_conn;
struct obd_statfs mystats;
- int rc, len=0;
+ int len=0;
- rc = obd_statfs(conn, &mystats);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_bsize));
+ obd_statfs(conn, &mystats);
+ len+=snprintf(page, count, "%d\n", mystats.os_bsize);
return len;
}
-int rd_blktotal(char* page, char **start, off_t off,
+int rd_kbtotal(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
-
struct obd_device* temp=(struct obd_device*)data;
struct ost_obd *ost=&temp->u.ost;
struct lustre_handle *conn=&ost->ost_conn;
struct obd_statfs mystats;
- int rc, len=0;
+ int len=0;
+ __u32 blk_size;
+ __u64 result;
- rc = obd_statfs(conn, &mystats);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_blocks));
- return len;
-}
+ obd_statfs(conn, &mystats);
-int rd_blkfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
+ blk_size=mystats.os_bsize;
+ blk_size>>=10;
- struct obd_device* temp=(struct obd_device*)data;
- struct ost_obd *ost=&temp->u.ost;
- struct lustre_handle *conn=&ost->ost_conn;
- struct obd_statfs mystats;
- int rc, len=0;
+ result=mystats.os_blocks;
- rc = obd_statfs(conn, &mystats);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- return 0;
+ while(blk_size>>=1){
+ result<<=1;
}
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_bfree));
+
+ len+=snprintf(page, count, LPU64"\n", result);
return len;
+
}
+
int rd_kbfree(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct ost_obd *ost=&temp->u.ost;
struct lustre_handle *conn=&ost->ost_conn;
struct obd_statfs mystats;
- int rc, len=0;
+ int len=0;
__u32 blk_size;
__u64 result;
- __u32 remainder;
- rc = obd_statfs(conn, &mystats);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- return 0;
- }
+ obd_statfs(conn, &mystats);
+
blk_size=mystats.os_bsize;
- blk_size*=1024;
+ blk_size>>=10;
+
result=mystats.os_bfree;
- remainder=do_div(result, blk_size);
- len+=snprintf(page, count, LPU64"\n", \
- result);
+ while(blk_size>>=1){
+ result<<=1;
+ }
+ len+=snprintf(page, count, LPU64"\n", result);
return len;
-
}
-int rd_numobjects(char* page, char **start, off_t off,
+int rd_files(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct ost_obd *ost=&temp->u.ost;
struct lustre_handle *conn=&ost->ost_conn;
struct obd_statfs mystats;
- int rc, len=0;
+ int len=0;
- rc = obd_statfs(conn, &mystats);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_files));
+ obd_statfs(conn, &mystats);
+
+ len+=snprintf(page, count, LPU64"\n",mystats.os_files);
return len;
}
-int rd_objfree(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
struct ost_obd *ost=&temp->u.ost;
struct lustre_handle *conn=&ost->ost_conn;
struct obd_statfs mystats;
- int rc, len=0;
+ int len=0;
- rc = obd_statfs(conn, &mystats);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_ffree));
+ obd_statfs(conn, &mystats);
+ len+=snprintf(page, count, LPU64"\n", mystats.os_ffree);
return len;
}
return 0;
}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_objects", rd_numobjects, 0},
- {"snmp/f_objectsfree", rd_objfree, 0},
- {"snmp/f_objectgroups", rd_objgroups, 0},
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {"status/blocksize",rd_blksize, 0},
+ {"status/kbytesfree", rd_kbfree, 0},
+ {"status/kbytestotal", rd_kbtotal, 0},
+ {"status/files", rd_files, 0},
+ {"status/filesfree", rd_filesfree, 0},
+ {"status/objectgroups", rd_objgroups, 0},
+ {0}
+};
+
+int rd_numdevices(char* page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
#include <linux/lustre_net.h>
#include <linux/lustre_dlm.h>
#include <linux/init.h>
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
static int ost_destroy(struct ptlrpc_request *req)
{
MOD_DEC_USE_COUNT;
RETURN(0);
}
+int ost_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ /* lprocfs_reg_dev(dev, (lprocfs_group_t*)lprocfs_ptlrpc_nm,
+ sizeof(struct lprofiler_ptlrpc));
+ */
+ lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return 0;
+}
+
+int ost_detach(struct obd_device *dev)
+{
+ /* lprocfs_dereg_dev(dev); */
+ lprocfs_dereg_obd(dev);
+ return 0;
+
+}
+
+
/* use obd ops to offer management infrastructure */
static struct obd_ops ost_obd_ops = {
+ o_attach: ost_attach,
+ o_detach: ost_detach,
o_setup: ost_setup,
o_cleanup: ost_cleanup,
};
static int __init ost_init(void)
{
- class_register_type(&ost_obd_ops, LUSTRE_OST_NAME);
+ int rc;
+
+ rc = class_register_type(&ost_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ LUSTRE_OST_NAME);
+ if (rc) RETURN(rc);
+
return 0;
+
}
static void __exit ost_exit(void)
{
+
class_unregister_type(LUSTRE_OST_NAME);
}
modulefs_DATA = ptlrpc.o
EXTRA_PROGRAMS = ptlrpc
-ptlrpc_SOURCES = recovd.c recover.c connection.c rpc.c events.c service.c client.c niobuf.c pack_generic.c
+ptlrpc_SOURCES = recovd.c recover.c connection.c rpc.c events.c service.c client.c niobuf.c pack_generic.c lproc_ptlrpc.c
include $(top_srcdir)/Rules
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
-
-
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
int rd_uuid(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
int len=0;
- len+=snprintf(page, count, "%s\n", \
+ len+=snprintf(page, count, "%s\n",
((struct obd_device*)data)->obd_uuid);
return len;
}
-int rd_blksize(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-
-}
-int rd_blktotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-
-int rd_blkfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-
-int rd_numobjects(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-
-int rd_objfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-
-int rd_objgroups(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-
-
-int rd_fs_type(char* page, char **start, off_t off,
+lprocfs_vars_t status_var_nm_1[]={
+ {"status/uuid", rd_uuid, 0},
+ {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
int count, int *eof, void *data)
{
- return 0;
-}
-
-int rd_other(char* page, char **start, off_t off, int count, int *eof,
- void *data)
-{
- return 0;
-}
-
-int rd_string(char* page, char **start, off_t off, int count, int *eof,
- void *data)
-{
- printk("Hello string");
- return 0;
-}
-
-int lprocfs_ll_wr(struct file* file, const char *buffer, unsigned long count,
- void *data)
-{
- return 0;
-}
-
-int wr_other(struct file* file, const char *buffer, unsigned long count,
- void *data)
-{
- return 0;
+ struct obd_type* class=(struct obd_type*)data;
+ int len=0;
+ len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+ return len;
}
-int wr_string(struct file* file, const char *buffer, unsigned long count,
- void *data)
-{
- return 0;
-}
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_objects", rd_numobjects, 0},
- {"snmp/f_objectsfree", rd_objfree, 0},
- {"snmp/f_objectgroups", rd_objgroups, 0},
+lprocfs_vars_t status_class_var[]={
+ {"status/num_devices", rd_numdevices, 0},
{0}
};
#include <linux/lustre_ha.h>
#include <linux/lustre_net.h>
#include <linux/init.h>
+#include <linux/lprocfs_status.h>
+
+
extern int ptlrpc_init_portals(void);
extern void ptlrpc_exit_portals(void);
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
{
struct recovd_obd *recovd = &obddev->u.recovd;
{
return class_connect(conn, src, cluuid);
}
+int connmgr_attach(struct obd_device *dev,
+ obd_count len, void *data)
+{
+ int rc;
+ rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+ return rc;
+}
+
+int conmgr_detach(struct obd_device *dev)
+{
+ int rc;
+ rc = lprocfs_dereg_obd(dev);
+ return rc;
+}
/* use obd ops to offer management infrastructure */
static struct obd_ops recovd_obd_ops = {
+ o_attach: connmgr_attach,
+ o_detach: conmgr_detach,
o_setup: connmgr_setup,
o_cleanup: connmgr_cleanup,
o_iocontrol: connmgr_iocontrol,
if (rc)
RETURN(rc);
ptlrpc_init_connection();
- class_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
+ rc = class_register_type(&recovd_obd_ops,
+ (lprocfs_vars_t*)status_class_var,
+ LUSTRE_HA_NAME);
+ if (rc)
+ RETURN(rc);
ptlrpc_put_connection_superhack = ptlrpc_put_connection;
+
+ if (rc)
+ RETURN(rc);
+
return 0;
}