static obd_count GEN;
static long echo_pages = 0;
-static int echo_connect(struct obd_conn *conn)
+static int echo_connect(struct lustre_handle *conn, struct obd_device *obd)
{
int rc;
MOD_INC_USE_COUNT;
- rc = gen_connect(conn);
+ rc = class_connect(conn, obd);
if (rc)
MOD_DEC_USE_COUNT;
return rc;
}
-static int echo_disconnect(struct obd_conn *conn)
+static int echo_disconnect(struct lustre_handle *conn)
{
int rc;
- rc = gen_disconnect(conn);
+ rc = class_disconnect(conn);
if (!rc)
MOD_DEC_USE_COUNT;
return rc;
}
-static int echo_getattr(struct obd_conn *conn, struct obdo *oa)
+static int echo_getattr(struct lustre_handle *conn, struct obdo *oa)
{
memcpy(oa, &OA, sizeof(*oa));
oa->o_mode = ++GEN;
return 0;
}
-int echo_preprw(int cmd, struct obd_conn *conn, int objcount,
- struct obd_ioobj *obj, int niocount, struct niobuf *nb,
- struct niobuf *res)
+int echo_preprw(int cmd, struct lustre_handle *conn, int objcount,
+ struct obd_ioobj *obj, int niocount, struct niobuf_remote *nb,
+ struct niobuf_local *res, void **desc_private)
{
- struct niobuf *r = res;
+ struct niobuf_local *r = res;
int rc = 0;
int i;
CERROR("can't get new page %d/%d for id %Ld\n",
j, obj->ioo_bufcnt,
(unsigned long long)obj->ioo_id);
- rc = -ENOMEM;
- EXIT;
- goto preprw_cleanup;
+ GOTO(preprw_cleanup, rc = -ENOMEM);
}
echo_pages++;
- /*
- if (cmd == OBD_BRW_READ) {
- __u64 *data = address;
-
- data[0] = obj->ioo_id;
- data[1] = j;
- data[2] = nb->offset;
- data[3] = nb->len;
- }
- */
-
- r->addr = address;
r->offset = nb->offset;
r->page = virt_to_page(address);
+ r->addr = kmap(r->page);
r->len = nb->len;
- // r->flags
}
}
CDEBUG(D_PAGE, "%ld pages allocated after prep\n", echo_pages);
- EXIT;
- return 0;
+ RETURN(0);
preprw_cleanup:
/* It is possible that we would rather handle errors by allow
*/
CERROR("cleaning up %ld pages (%d obdos)\n", (long)(r - res), objcount);
while (r-- > res) {
- unsigned long addr = r->addr;
-
- free_pages(addr, 0);
+ kunmap(r->page);
+ __free_pages(r->page, 0);
echo_pages--;
}
memset(res, 0, sizeof(*res) * niocount);
return rc;
}
-int echo_commitrw(int cmd, struct obd_conn *conn, int objcount,
- struct obd_ioobj *obj, int niocount, struct niobuf *res)
+int echo_commitrw(int cmd, struct lustre_handle *conn, int objcount,
+ struct obd_ioobj *obj, int niocount, struct niobuf_local *res,
+ void *desc_private)
{
- struct niobuf *r = res;
+ struct niobuf_local *r = res;
int rc = 0;
int i;
-
ENTRY;
CDEBUG(D_PAGE, "%s %d obdos with %d IOs\n",
if (niocount && !r) {
CERROR("NULL res niobuf with niocount %d\n", niocount);
- EXIT;
- return -EINVAL;
+ RETURN(-EINVAL);
}
for (i = 0; i < objcount; i++, obj++) {
for (j = 0 ; j < obj->ioo_bufcnt ; j++, r++) {
struct page *page = r->page;
- unsigned long addr = (unsigned long)page_address(page);
+ unsigned long addr;
+
+ if (!page ||
+ !(addr = (unsigned long)page_address(page)) ||
+ !kern_addr_valid(addr)) {
- if (!addr || !kern_addr_valid(addr)) {
CERROR("bad page %p, id %Ld (%d), buf %d/%d\n",
page, (unsigned long long)obj->ioo_id, i,
j, obj->ioo_bufcnt);
- rc = -EFAULT;
- EXIT;
- goto commitrw_cleanup;
+ GOTO(commitrw_cleanup, rc = -EFAULT);
}
- free_pages(addr, 0);
+ kunmap(page);
+ __free_pages(page, 0);
echo_pages--;
}
}
CDEBUG(D_PAGE, "%ld pages remain after commit\n", echo_pages);
- EXIT;
- return 0;
+ RETURN(0);
commitrw_cleanup:
CERROR("cleaning up %ld pages (%d obdos)\n",
niocount - (long)(r - res) - 1, objcount);
while (++r < res + niocount) {
struct page *page = r->page;
- unsigned long addr = (unsigned long)page_address(page);
- free_pages(addr, 0);
+ kunmap(page);
+ __free_pages(page, 0);
echo_pages--;
}
return rc;
{
printk(KERN_INFO "Echo OBD driver v0.001, braam@clusterfs.com\n");
- return obd_register_type(&echo_obd_ops, OBD_ECHO_DEVICENAME);
+ return class_register_type(&echo_obd_ops, OBD_ECHO_DEVICENAME);
}
static void __exit obdecho_exit(void)
{
CERROR("%ld prep/commitrw pages leaked\n", echo_pages);
- obd_unregister_type(OBD_ECHO_DEVICENAME);
+ class_unregister_type(OBD_ECHO_DEVICENAME);
}
-MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
+MODULE_AUTHOR("Cluster Filesystems Inc. <info@clusterfs.com>");
MODULE_DESCRIPTION("Lustre Testing Echo OBD driver v1.0");
MODULE_LICENSE("GPL");