#include <linux/obd_class.h>
#include <linux/obd_cache.h>
-extern struct lprocfs_vars status_var_nm_1[];
-extern struct lprocfs_vars status_class_var[];
-
-static int
-cobd_attach (struct obd_device *dev, obd_count len, void *data)
+static int cobd_attach(struct obd_device *dev, obd_count len, void *data)
{
- return (lprocfs_reg_obd (dev, status_var_nm_1, dev));
+ struct lprocfs_static_vars lvars;
+
+ lprocfs_init_vars(&lvars);
+ return lprocfs_obd_attach(dev, lvars.obd_vars);
}
-static int
-cobd_detach (struct obd_device *dev)
+static int cobd_detach(struct obd_device *dev)
{
- return (lprocfs_dereg_obd (dev));
+ return lprocfs_obd_detach(dev);
}
static int
struct obd_device *target;
struct obd_device *cache;
int rc;
-
+
if (data->ioc_inlbuf1 == NULL ||
data->ioc_inlbuf2 == NULL)
return (-EINVAL);
-
+
target = class_uuid2obd (data->ioc_inlbuf1);
cache = class_uuid2obd (data->ioc_inlbuf2);
if (target == NULL ||
cache == NULL)
return (-EINVAL);
-
- /* don't bother checking attached/setup;
+
+ /* don't bother checking attached/setup;
* obd_connect() should, and it can change underneath us */
rc = obd_connect (&cobd->cobd_target, target, NULL, NULL, NULL);
{
struct cache_obd *cobd = &dev->u.cobd;
int rc;
-
+
if (!list_empty (&dev->obd_exports))
return (-EBUSY);
-
+
rc = obd_disconnect (&cobd->cobd_cache);
if (rc != 0)
CERROR ("error %d disconnecting cache\n", rc);
-
+
rc = obd_disconnect (&cobd->cobd_target);
if (rc != 0)
CERROR ("error %d disconnecting target\n", rc);
cobd_disconnect (struct lustre_handle *conn)
{
int rc = class_disconnect (conn);
-
+
CERROR ("rc %d\n", rc);
return (rc);
}
-static int
+static int
cobd_get_info(struct lustre_handle *conn, obd_count keylen,
void *key, obd_count *vallen, void **val)
{
/* intercept cache utilisation info? */
- return (obd_get_info (&cobd->cobd_target,
+ return (obd_get_info (&cobd->cobd_target,
keylen, key, vallen, val));
}
-static int
+static int
cobd_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
{
struct obd_device *obd = class_conn2obd(conn);
return (obd_statfs (&cobd->cobd_target, osfs));
}
-static int
+static int
cobd_getattr(struct lustre_handle *conn, struct obdo *oa,
struct lov_stripe_md *lsm)
{
return (obd_getattr (&cobd->cobd_target, oa, lsm));
}
-static int
+static int
cobd_open(struct lustre_handle *conn, struct obdo *oa,
struct lov_stripe_md *lsm)
{
return (obd_open (&cobd->cobd_target, oa, lsm));
}
-static int
+static int
cobd_close(struct lustre_handle *conn, struct obdo *oa,
struct lov_stripe_md *lsm)
{
return (obd_close (&cobd->cobd_target, oa, lsm));
}
-static int
+static int
cobd_preprw(int cmd, struct lustre_handle *conn,
int objcount, struct obd_ioobj *obj,
int niocount, struct niobuf_remote *nb,
if ((cmd & OBD_BRW_WRITE) != 0)
return -EOPNOTSUPP;
-
+
cobd = &obd->u.cobd;
- return (obd_preprw (cmd, &cobd->cobd_target,
- objcount, obj,
- niocount, nb,
+ return (obd_preprw (cmd, &cobd->cobd_target,
+ objcount, obj,
+ niocount, nb,
res, desc_private));
}
-static int
+static int
cobd_commitrw(int cmd, struct lustre_handle *conn,
int objcount, struct obd_ioobj *obj,
int niocount, struct niobuf_local *local,
if ((cmd & OBD_BRW_WRITE) != 0)
return -EOPNOTSUPP;
-
+
cobd = &obd->u.cobd;
return (obd_commitrw (cmd, &cobd->cobd_target,
objcount, obj,
desc_private));
}
-static inline int
+static inline int
cobd_brw(int cmd, struct lustre_handle *conn,
struct lov_stripe_md *lsm, obd_count oa_bufs,
struct brw_page *pga, struct obd_brw_set *set)
if ((cmd & OBD_BRW_WRITE) != 0)
return -EOPNOTSUPP;
-
+
cobd = &obd->u.cobd;
- return (obd_brw (cmd, &cobd->cobd_target,
+ return (obd_brw (cmd, &cobd->cobd_target,
lsm, oa_bufs, pga, set));
}
-static int
+static int
cobd_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len,
void *karg, void *uarg)
{
o_iocontrol: cobd_iocontrol,
};
-static int __init
-cobd_init (void)
+static int __init cobd_init(void)
{
- int rc;
-
- printk (KERN_INFO "Lustre Caching OBD driver\n");
-
- rc = class_register_type (&cobd_ops, status_class_var,
- OBD_CACHE_DEVICENAME);
- return (rc);
+ struct lprocfs_static_vars lvars;
+ ENTRY;
+
+ printk(KERN_INFO "Lustre Caching OBD driver\n");
+
+ lprocfs_init_vars(&lvars);
+ RETURN(class_register_type(&cobd_ops, lvars.module_vars,
+ OBD_CACHE_DEVICENAME));
}
-static void __exit
-cobd_exit (void)
+static void __exit cobd_exit(void)
{
- class_unregister_type (OBD_CACHE_DEVICENAME);
+ class_unregister_type(OBD_CACHE_DEVICENAME);
}
MODULE_AUTHOR("Cluster Filesystems Inc. <info@clusterfs.com>");
module_init(cobd_init);
module_exit(cobd_exit);
-
-
* Common STATUS namespace
*/
-static int rd_uuid (char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct obd_device* dev = (struct obd_device*)data;
-
- return (snprintf(page, count, "%s\n", dev->obd_uuid));
-}
-
static int rd_target (char *page, char **start, off_t off, int count,
int *eof, void *data)
{
struct obd_device *dev = (struct obd_device*)data;
- struct cache_obd *cobd = &dev->u.cobd;
- struct lustre_handle *conn = &cobd->cobd_target;
+ struct lustre_handle *conn = &dev->u.cobd.cobd_target;
struct obd_export *exp;
int rc;
rc = snprintf (page, count, "not set up\n");
else {
exp = class_conn2export (conn);
- LASSERT (exp != NULL);
+ LASSERT(exp != NULL);
rc = snprintf(page, count, "%s\n", exp->exp_obd->obd_uuid);
}
return (rc);
int *eof, void *data)
{
struct obd_device *dev = (struct obd_device*)data;
- struct cache_obd *cobd = &dev->u.cobd;
- struct lustre_handle *conn = &cobd->cobd_cache;
+ struct lustre_handle *conn = &dev->u.cobd.cobd_cache;
struct obd_export *exp;
int rc;
return (rc);
}
-struct lprocfs_vars status_var_nm_1[] = {
- {"status/uuid", rd_uuid, 0, 0},
- {"status/target_uuid", rd_target, 0, 0},
- {"status/cache_uuid", rd_cache, 0, 0},
- {0}
+#ifndef LPROCFS
+struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
+struct lprocfs_vars lprocfs_module_vars[] = { {0} };
+#else
+struct lprocfs_vars lprocfs_obd_vars[] = {
+ { "uuid", lprocfs_rd_uuid, 0, 0 },
+ { "target_uuid", rd_target, 0, 0 },
+ { "cache_uuid", rd_cache, 0, 0 },
+ { 0 }
};
-int rd_numrefs(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct obd_type* class = (struct obd_type*)data;
-
- return (snprintf(page, count, "%d\n", class->typ_refcnt));
-}
-
-struct lprocfs_vars status_class_var[] = {
- {"status/num_refs", rd_numrefs, 0, 0},
- {0}
+struct lprocfs_vars lprocfs_module_vars[] = {
+ { "num_refs", lprocfs_rd_numrefs, 0, 0 },
+ { 0 }
};
+#endif /* LPROCFS */
+
+LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)
#define EXPORT_SYMTAB
#include <linux/lustre_net.h>
#include <linux/obd_support.h>
+#include <linux/obd_class.h>
void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src)
{
sfs->f_namelen = osfs->os_namelen;
}
+int obd_self_statfs(struct obd_device *obd, struct statfs *sfs)
+{
+ struct lustre_handle conn;
+ struct obd_export *export, *my_export = NULL;
+ struct obd_statfs osfs = { 0 };
+ int rc;
+ ENTRY;
+
+ if (list_empty(&obd->obd_exports)) {
+ export = my_export = class_new_export(obd);
+ if (export == NULL)
+ RETURN(-ENOMEM);
+ } else
+ export = list_entry(obd->obd_exports.next, typeof(*export),
+ exp_obd_chain);
+ conn.addr = (unsigned long)export;
+ conn.cookie = export->exp_cookie;
+
+ rc = obd_statfs(&conn, &osfs);
+ if (!rc)
+ statfs_unpack(sfs, &osfs);
+
+ if (my_export)
+ class_destroy_export(my_export);
+ RETURN(rc);
+}
+
EXPORT_SYMBOL(obd_statfs_pack);
EXPORT_SYMBOL(obd_statfs_unpack);
EXPORT_SYMBOL(statfs_pack);
EXPORT_SYMBOL(statfs_unpack);
+EXPORT_SYMBOL(obd_self_statfs);