Whamcloud - gitweb
LU-5061 obd: add lnb_ prefix to members of struct niobuf_local
[fs/lustre-release.git] / lustre / obdecho / echo.c
index 67f9a0b..389167b 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2010, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  * Author: Andreas Dilger <adilger@clusterfs.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
 #define DEBUG_SUBSYSTEM S_ECHO
 
 #include <obd_support.h>
 
 #include "echo_internal.h"
 
-#define ECHO_INIT_OBJID      0x1000000000000000ULL
+/* The echo objid needs to be below 2^32, because regular FID numbers are
+ * limited to 2^32 objects in f_oid for the FID_SEQ_ECHO range. b=23335 */
+#define ECHO_INIT_OID        0x10000000ULL
 #define ECHO_HANDLE_MAGIC    0xabcd0123fedc9876ULL
 
-#define ECHO_PERSISTENT_PAGES (ECHO_PERSISTENT_SIZE >> CFS_PAGE_SHIFT)
-static cfs_page_t *echo_persistent_pages[ECHO_PERSISTENT_PAGES];
+#define ECHO_PERSISTENT_PAGES (ECHO_PERSISTENT_SIZE >> PAGE_CACHE_SHIFT)
+static struct page *echo_persistent_pages[ECHO_PERSISTENT_PAGES];
 
 enum {
         LPROC_ECHO_READ_BYTES = 1,
@@ -108,17 +106,18 @@ static int echo_destroy_export(struct obd_export *exp)
 
  static __u64 echo_next_id(struct obd_device *obddev)
 {
-        obd_id id;
+       obd_id id;
 
-        spin_lock(&obddev->u.echo.eo_lock);
-        id = ++obddev->u.echo.eo_lastino;
-        spin_unlock(&obddev->u.echo.eo_lock);
+       spin_lock(&obddev->u.echo.eo_lock);
+       id = ++obddev->u.echo.eo_lastino;
+       spin_unlock(&obddev->u.echo.eo_lock);
 
-        return id;
+       return id;
 }
 
-int echo_create(struct obd_export *exp, struct obdo *oa,
-                struct lov_stripe_md **ea, struct obd_trans_info *oti)
+static int echo_create(const struct lu_env *env, struct obd_export *exp,
+                      struct obdo *oa, struct lov_stripe_md **ea,
+                      struct obd_trans_info *oti)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -138,15 +137,17 @@ int echo_create(struct obd_export *exp, struct obdo *oa,
                 return -EINVAL;
         }
 
-        oa->o_id = echo_next_id(obd);
-        oa->o_valid = OBD_MD_FLID;
+       ostid_set_seq_echo(&oa->o_oi);
+       ostid_set_id(&oa->o_oi, echo_next_id(obd));
+       oa->o_valid = OBD_MD_FLID;
 
-        return 0;
+       return 0;
 }
 
-int echo_destroy(struct obd_export *exp, struct obdo *oa,
-                 struct lov_stripe_md *ea, struct obd_trans_info *oti,
-                 struct obd_export *md_exp, void *capa)
+static int echo_destroy(const struct lu_env *env, struct obd_export *exp,
+                       struct obdo *oa, struct lov_stripe_md *ea,
+                       struct obd_trans_info *oti, struct obd_export *md_exp,
+                       void *capa)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -162,18 +163,20 @@ int echo_destroy(struct obd_export *exp, struct obdo *oa,
                 RETURN(-EINVAL);
         }
 
-        if (oa->o_id > obd->u.echo.eo_lastino || oa->o_id < ECHO_INIT_OBJID) {
-                CERROR("bad destroy objid: "LPX64"\n", oa->o_id);
-                RETURN(-EINVAL);
-        }
+       if (ostid_id(&oa->o_oi) > obd->u.echo.eo_lastino ||
+           ostid_id(&oa->o_oi) < ECHO_INIT_OID) {
+               CERROR("bad destroy objid: "DOSTID"\n", POSTID(&oa->o_oi));
+               RETURN(-EINVAL);
+       }
 
         RETURN(0);
 }
 
-static int echo_getattr(struct obd_export *exp, struct obd_info *oinfo)
+static int echo_getattr(const struct lu_env *env, struct obd_export *exp,
+                        struct obd_info *oinfo)
 {
-        struct obd_device *obd = class_exp2obd(exp);
-        obd_id id = oinfo->oi_oa->o_id;
+       struct obd_device *obd = class_exp2obd(exp);
+       obd_id id = ostid_id(&oinfo->oi_oa->o_oi);
 
         ENTRY;
         if (!obd) {
@@ -188,14 +191,15 @@ static int echo_getattr(struct obd_export *exp, struct obd_info *oinfo)
                 RETURN(-EINVAL);
         }
 
-        obdo_cpy_md(oinfo->oi_oa, &obd->u.echo.eo_oa, oinfo->oi_oa->o_valid);
-        oinfo->oi_oa->o_id = id;
+       obdo_cpy_md(oinfo->oi_oa, &obd->u.echo.eo_oa, oinfo->oi_oa->o_valid);
+       ostid_set_seq_echo(&oinfo->oi_oa->o_oi);
+       ostid_set_id(&oinfo->oi_oa->o_oi, id);
 
-        RETURN(0);
+       RETURN(0);
 }
 
-static int echo_setattr(struct obd_export *exp, struct obd_info *oinfo,
-                        struct obd_trans_info *oti)
+static int echo_setattr(const struct lu_env *env, struct obd_export *exp,
+                        struct obd_info *oinfo, struct obd_trans_info *oti)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -214,7 +218,7 @@ static int echo_setattr(struct obd_export *exp, struct obd_info *oinfo,
 
         memcpy(&obd->u.echo.eo_oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
 
-        if (oinfo->oi_oa->o_id & 4) {
+        if (ostid_id(&oinfo->oi_oa->o_oi) & 4) {
                 /* Save lock to force ACKed reply */
                 ldlm_lock_addref (&obd->u.echo.eo_nl_lock, LCK_NL);
                 oti->oti_ack_locks[0].mode = LCK_NL;
@@ -225,11 +229,11 @@ static int echo_setattr(struct obd_export *exp, struct obd_info *oinfo,
 }
 
 static void
-echo_page_debug_setup(cfs_page_t *page, int rw, obd_id id,
-                      __u64 offset, int len)
+echo_page_debug_setup(struct page *page, int rw, obd_id id,
+                     __u64 offset, int len)
 {
-        int   page_offset = offset & ~CFS_PAGE_MASK;
-        char *addr        = ((char *)cfs_kmap(page)) + page_offset;
+       int   page_offset = offset & ~CFS_PAGE_MASK;
+       char *addr        = ((char *)kmap(page)) + page_offset;
 
         if (len % OBD_ECHO_BLOCK_SIZE != 0)
                 CERROR("Unexpected block size %d\n", len);
@@ -248,17 +252,17 @@ echo_page_debug_setup(cfs_page_t *page, int rw, obd_id id,
                 len    -= OBD_ECHO_BLOCK_SIZE;
         }
 
-        cfs_kunmap(page);
+       kunmap(page);
 }
 
 static int
-echo_page_debug_check(cfs_page_t *page, obd_id id,
-                      __u64 offset, int len)
+echo_page_debug_check(struct page *page, obd_id id,
+                     __u64 offset, int len)
 {
-        int   page_offset = offset & ~CFS_PAGE_MASK;
-        char *addr        = ((char *)cfs_kmap(page)) + page_offset;
-        int   rc          = 0;
-        int   rc2;
+       int   page_offset = offset & ~CFS_PAGE_MASK;
+       char *addr        = ((char *)kmap(page)) + page_offset;
+       int   rc          = 0;
+       int   rc2;
 
         if (len % OBD_ECHO_BLOCK_SIZE != 0)
                 CERROR("Unexpected block size %d\n", len);
@@ -275,9 +279,9 @@ echo_page_debug_check(cfs_page_t *page, obd_id id,
                 len    -= OBD_ECHO_BLOCK_SIZE;
         }
 
-        cfs_kunmap(page);
+       kunmap(page);
 
-        return (rc);
+       return rc;
 }
 
 /* This allows us to verify that desc_private is passed unmolested */
@@ -287,53 +291,58 @@ static int echo_map_nb_to_lb(struct obdo *oa, struct obd_ioobj *obj,
                              struct niobuf_remote *nb, int *pages,
                              struct niobuf_local *lb, int cmd, int *left)
 {
-        int gfp_mask = (obj->ioo_id & 1) ? CFS_ALLOC_HIGHUSER : CFS_ALLOC_STD;
-        int ispersistent = obj->ioo_id == ECHO_PERSISTENT_OBJID;
-        int debug_setup = (!ispersistent &&
-                           (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
-                           (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
-        struct niobuf_local *res = lb;
-        obd_off offset = nb->offset;
-        int len = nb->len;
-
-        while (len > 0) {
-                int plen = CFS_PAGE_SIZE - (offset & (CFS_PAGE_SIZE-1));
-                if (len < plen)
-                        plen = len;
+       int gfp_mask = (ostid_id(&obj->ioo_oid) & 1) ?
+                       GFP_HIGHUSER : GFP_IOFS;
+       int ispersistent = ostid_id(&obj->ioo_oid) == ECHO_PERSISTENT_OBJID;
+       int debug_setup = (!ispersistent &&
+                          (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
+                          (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
+       struct niobuf_local *res = lb;
+       obd_off offset = nb->offset;
+       int len = nb->len;
+
+       while (len > 0) {
+               int plen = PAGE_CACHE_SIZE - (offset & (PAGE_CACHE_SIZE-1));
+               if (len < plen)
+                       plen = len;
 
                 /* check for local buf overflow */
                 if (*left == 0)
                         return -EINVAL;
 
-                res->offset = offset;
-                res->len = plen;
-                LASSERT((res->offset & ~CFS_PAGE_MASK) + res->len <= CFS_PAGE_SIZE);
-
-
-                if (ispersistent &&
-                    (res->offset >> CFS_PAGE_SHIFT) < ECHO_PERSISTENT_PAGES) {
-                        res->page = echo_persistent_pages[res->offset >>
-                                CFS_PAGE_SHIFT];
-                        /* Take extra ref so __free_pages() can be called OK */
-                        cfs_get_page (res->page);
-                } else {
-                        OBD_PAGE_ALLOC(res->page, gfp_mask);
-                        if (res->page == NULL) {
-                                CERROR("can't get page for id " LPU64"\n",
-                                       obj->ioo_id);
-                                return -ENOMEM;
-                        }
-                }
-
-                CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n",
-                       res->page, res->offset, res->len);
-
-                if (cmd & OBD_BRW_READ)
-                        res->rc = res->len;
-
-                if (debug_setup)
-                        echo_page_debug_setup(res->page, cmd, obj->ioo_id,
-                                              res->offset, res->len);
+               res->lnb_file_offset = offset;
+               res->lnb_len = plen;
+               LASSERT((res->lnb_file_offset & ~CFS_PAGE_MASK) +
+                       res->lnb_len <= PAGE_CACHE_SIZE);
+
+               if (ispersistent &&
+                   ((res->lnb_file_offset >> PAGE_CACHE_SHIFT) <
+                     ECHO_PERSISTENT_PAGES)) {
+                       res->lnb_page =
+                               echo_persistent_pages[res->lnb_file_offset >>
+                                                     PAGE_CACHE_SHIFT];
+                       /* Take extra ref so __free_pages() can be called OK */
+                       get_page(res->lnb_page);
+               } else {
+                       OBD_PAGE_ALLOC(res->lnb_page, gfp_mask);
+                       if (res->lnb_page == NULL) {
+                               CERROR("can't get page for id " DOSTID"\n",
+                                      POSTID(&obj->ioo_oid));
+                               return -ENOMEM;
+                       }
+               }
+
+               CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n",
+                      res->lnb_page, res->lnb_file_offset, res->lnb_len);
+
+               if (cmd & OBD_BRW_READ)
+                       res->lnb_rc = res->lnb_len;
+
+               if (debug_setup)
+                       echo_page_debug_setup(res->lnb_page, cmd,
+                                             ostid_id(&obj->ioo_oid),
+                                             res->lnb_file_offset,
+                                             res->lnb_len);
 
                 offset += plen;
                 len -= plen;
@@ -347,51 +356,57 @@ static int echo_map_nb_to_lb(struct obdo *oa, struct obd_ioobj *obj,
 }
 
 static int echo_finalize_lb(struct obdo *oa, struct obd_ioobj *obj,
-                            struct niobuf_remote *rb, int *pgs,
-                            struct niobuf_local *lb, int verify)
+                           struct niobuf_remote *rb, int *pgs,
+                           struct niobuf_local *lb, int verify)
 {
-        struct niobuf_local *res = lb;
-        obd_off start  = rb->offset >> CFS_PAGE_SHIFT;
-        obd_off end    = (rb->offset + rb->len + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
-        int     count  = (int)(end - start);
-        int     rc     = 0;
-        int     i;
-
-        for (i = 0; i < count; i++, (*pgs) ++, res++) {
-                cfs_page_t *page = res->page;
-                void       *addr;
-
-                if (page == NULL) {
-                        CERROR("null page objid "LPU64":%p, buf %d/%d\n",
-                               obj->ioo_id, page, i, obj->ioo_bufcnt);
-                        return -EFAULT;
-                }
-
-                addr = cfs_kmap(page);
-
-                CDEBUG(D_PAGE, "$$$$ use page %p, addr %p@"LPU64"\n",
-                       res->page, addr, res->offset);
-
-                if (verify) {
-                        int vrc = echo_page_debug_check(page, obj->ioo_id,
-                                                        res->offset, res->len);
-                        /* check all the pages always */
-                        if (vrc != 0 && rc == 0)
-                                rc = vrc;
-                }
-
-                cfs_kunmap(page);
-                /* NB see comment above regarding persistent pages */
-                OBD_PAGE_FREE(page);
-        }
-
-        return rc;
+       struct niobuf_local *res = lb;
+       obd_off start  = rb->offset >> PAGE_CACHE_SHIFT;
+       obd_off end    = (rb->offset + rb->len + PAGE_CACHE_SIZE - 1) >>
+                        PAGE_CACHE_SHIFT;
+       int     count  = (int)(end - start);
+       int     rc     = 0;
+       int     i;
+
+       for (i = 0; i < count; i++, (*pgs) ++, res++) {
+               struct page *page = res->lnb_page;
+               void       *addr;
+
+               if (page == NULL) {
+                       CERROR("null page objid "LPU64":%p, buf %d/%d\n",
+                              ostid_id(&obj->ioo_oid), page, i,
+                              obj->ioo_bufcnt);
+                       return -EFAULT;
+               }
+
+               addr = kmap(page);
+
+               CDEBUG(D_PAGE, "$$$$ use page %p, addr %p@"LPU64"\n",
+                      res->lnb_page, addr, res->lnb_file_offset);
+
+               if (verify) {
+                       int vrc = echo_page_debug_check(page,
+                                                       ostid_id(&obj->ioo_oid),
+                                                       res->lnb_file_offset,
+                                                       res->lnb_len);
+                       /* check all the pages always */
+                       if (vrc != 0 && rc == 0)
+                               rc = vrc;
+               }
+
+               kunmap(page);
+               /* NB see comment above regarding persistent pages */
+               OBD_PAGE_FREE(page);
+       }
+
+       return rc;
 }
 
-int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
-                int objcount, struct obd_ioobj *obj, struct niobuf_remote *nb,
-                int *pages, struct niobuf_local *res,
-                struct obd_trans_info *oti, struct lustre_capa *unused)
+static int echo_preprw(const struct lu_env *env, int cmd,
+                      struct obd_export *export, struct obdo *oa,
+                      int objcount, struct obd_ioobj *obj,
+                      struct niobuf_remote *nb, int *pages,
+                      struct niobuf_local *res, struct obd_trans_info *oti,
+                      struct lustre_capa *unused)
 {
         struct obd_device *obd;
         int tot_bytes = 0;
@@ -431,7 +446,7 @@ int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
                 }
         }
 
-        atomic_add(*pages, &obd->u.echo.eo_prep);
+       atomic_add(*pages, &obd->u.echo.eo_prep);
 
         if (cmd & OBD_BRW_READ)
                 lprocfs_counter_add(obd->obd_stats, LPROC_ECHO_READ_BYTES,
@@ -441,7 +456,7 @@ int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
                                     tot_bytes);
 
         CDEBUG(D_PAGE, "%d pages allocated after prep\n",
-               atomic_read(&obd->u.echo.eo_prep));
+              atomic_read(&obd->u.echo.eo_prep));
 
         RETURN(0);
 
@@ -453,21 +468,23 @@ preprw_cleanup:
          */
         CERROR("cleaning up %u pages (%d obdos)\n", *pages, objcount);
         for (i = 0; i < *pages; i++) {
-                cfs_kunmap(res[i].page);
-                /* NB if this is a persistent page, __free_pages will just
-                 * lose the extra ref gained above */
-                OBD_PAGE_FREE(res[i].page);
-                res[i].page = NULL;
-                atomic_dec(&obd->u.echo.eo_prep);
-        }
-
-        return rc;
+               kunmap(res[i].lnb_page);
+               /* NB if this is a persistent page, __free_pages will just
+                * lose the extra ref gained above */
+               OBD_PAGE_FREE(res[i].lnb_page);
+               res[i].lnb_page = NULL;
+               atomic_dec(&obd->u.echo.eo_prep);
+       }
+
+       return rc;
 }
 
-int echo_commitrw(int cmd, struct obd_export *export, struct obdo *oa,
-                  int objcount, struct obd_ioobj *obj,
-                  struct niobuf_remote *rb, int niocount,
-                  struct niobuf_local *res, struct obd_trans_info *oti, int rc)
+static int echo_commitrw(const struct lu_env *env, int cmd,
+                        struct obd_export *export, struct obdo *oa,
+                        int objcount, struct obd_ioobj *obj,
+                        struct niobuf_remote *rb, int niocount,
+                        struct niobuf_local *res, struct obd_trans_info *oti,
+                        int rc)
 {
         struct obd_device *obd;
         int pgs = 0;
@@ -496,69 +513,77 @@ int echo_commitrw(int cmd, struct obd_export *export, struct obdo *oa,
 
         LASSERT(oti == NULL || oti->oti_handle == (void *)DESC_PRIV);
 
-        for (i = 0; i < objcount; i++, obj++) {
-                int verify = (rc == 0 &&
-                              obj->ioo_id != ECHO_PERSISTENT_OBJID &&
-                              (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
-                              (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
-                int j;
-
-                for (j = 0 ; j < obj->ioo_bufcnt ; j++, rb++) {
-                        int vrc = echo_finalize_lb(oa, obj, rb, &pgs, &res[pgs], verify);
+       for (i = 0; i < objcount; i++, obj++) {
+               int verify = (rc == 0 &&
+                            ostid_id(&obj->ioo_oid) != ECHO_PERSISTENT_OBJID &&
+                             (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
+                             (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
+               int j;
 
-                        if (vrc == 0)
-                                continue;
+               for (j = 0 ; j < obj->ioo_bufcnt ; j++, rb++) {
+                       int vrc = echo_finalize_lb(oa, obj, rb, &pgs, &res[pgs],
+                                                  verify);
+                       if (vrc == 0)
+                               continue;
 
-                        if (vrc == -EFAULT)
-                                GOTO(commitrw_cleanup, rc = vrc);
+                       if (vrc == -EFAULT)
+                               GOTO(commitrw_cleanup, rc = vrc);
 
-                        if (rc == 0)
-                                rc = vrc;
-                }
+                       if (rc == 0)
+                               rc = vrc;
+               }
 
-        }
+       }
 
-        atomic_sub(pgs, &obd->u.echo.eo_prep);
+       atomic_sub(pgs, &obd->u.echo.eo_prep);
 
         CDEBUG(D_PAGE, "%d pages remain after commit\n",
-               atomic_read(&obd->u.echo.eo_prep));
+              atomic_read(&obd->u.echo.eo_prep));
         RETURN(rc);
 
 commitrw_cleanup:
-        atomic_sub(pgs, &obd->u.echo.eo_prep);
+       atomic_sub(pgs, &obd->u.echo.eo_prep);
 
         CERROR("cleaning up %d pages (%d obdos)\n",
                niocount - pgs - 1, objcount);
 
-        while (pgs ++ < niocount) {
-                cfs_page_t *page = res[pgs].page;
+        while (pgs < niocount) {
+               struct page *page = res[pgs++].lnb_page;
 
                 if (page == NULL)
                         continue;
 
                 /* NB see comment above regarding persistent pages */
                 OBD_PAGE_FREE(page);
-                atomic_dec(&obd->u.echo.eo_prep);
+               atomic_dec(&obd->u.echo.eo_prep);
         }
         return rc;
 }
 
+LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
+static struct lprocfs_seq_vars lprocfs_echo_obd_vars[] = {
+       { .name =       "uuid",
+         .fops =       &echo_uuid_fops         },
+       { 0 }
+};
+
 static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-        struct lprocfs_static_vars lvars;
-        int                        rc;
-        int                        lock_flags = 0;
-        struct ldlm_res_id         res_id = {.name = {1}};
-        char                       ns_name[48];
-        ENTRY;
+       int                     rc;
+       __u64                   lock_flags = 0;
+       struct ldlm_res_id      res_id = {.name = {1}};
+       char                    ns_name[48];
+       ENTRY;
 
-        spin_lock_init(&obd->u.echo.eo_lock);
-        obd->u.echo.eo_lastino = ECHO_INIT_OBJID;
+        obd->u.echo.eo_obt.obt_magic = OBT_MAGIC;
+       spin_lock_init(&obd->u.echo.eo_lock);
+        obd->u.echo.eo_lastino = ECHO_INIT_OID;
 
         sprintf(ns_name, "echotgt-%s", obd->obd_uuid.uuid);
         obd->obd_namespace = ldlm_namespace_new(obd, ns_name,
                                                 LDLM_NAMESPACE_SERVER,
-                                                LDLM_NAMESPACE_MODEST);
+                                                LDLM_NAMESPACE_MODEST,
+                                                LDLM_NS_TYPE_OST);
         if (obd->obd_namespace == NULL) {
                 LBUG();
                 RETURN(-ENOMEM);
@@ -566,12 +591,12 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 
         rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN,
                                     NULL, LCK_NL, &lock_flags, NULL,
-                                    ldlm_completion_ast, NULL, NULL,
-                                    0, NULL, NULL, &obd->u.echo.eo_nl_lock);
+                                   ldlm_completion_ast, NULL, NULL, 0,
+                                   LVB_T_NONE, NULL, &obd->u.echo.eo_nl_lock);
         LASSERT (rc == ELDLM_OK);
 
-        lprocfs_echo_init_vars(&lvars);
-        if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0 &&
+       obd->obd_vars = lprocfs_echo_obd_vars;
+       if (lprocfs_seq_obd_setup(obd) == 0 &&
             lprocfs_alloc_obd_stats(obd, LPROC_ECHO_LAST) == 0) {
                 lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_READ_BYTES,
                                      LPROCFS_CNTR_AVGMINMAX,
@@ -588,29 +613,29 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 
 static int echo_cleanup(struct obd_device *obd)
 {
-        int leaked;
-        ENTRY;
+       int leaked;
+       ENTRY;
 
-        lprocfs_obd_cleanup(obd);
-        lprocfs_free_obd_stats(obd);
+       lprocfs_obd_cleanup(obd);
+       lprocfs_free_obd_stats(obd);
 
-        ldlm_lock_decref (&obd->u.echo.eo_nl_lock, LCK_NL);
+       ldlm_lock_decref(&obd->u.echo.eo_nl_lock, LCK_NL);
 
-        /* XXX Bug 3413; wait for a bit to ensure the BL callback has
-         * happened before calling ldlm_namespace_free() */
-        cfs_schedule_timeout (CFS_TASK_UNINT, cfs_time_seconds(1));
+       /* XXX Bug 3413; wait for a bit to ensure the BL callback has
+        * happened before calling ldlm_namespace_free() */
+       schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE, cfs_time_seconds(1));
 
-        ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force);
-        obd->obd_namespace = NULL;
+       ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force);
+       obd->obd_namespace = NULL;
 
-        leaked = atomic_read(&obd->u.echo.eo_prep);
-        if (leaked != 0)
-                CERROR("%d prep/commitrw pages leaked\n", leaked);
+       leaked = atomic_read(&obd->u.echo.eo_prep);
+       if (leaked != 0)
+               CERROR("%d prep/commitrw pages leaked\n", leaked);
 
-        RETURN(0);
+       RETURN(0);
 }
 
-static struct obd_ops echo_obd_ops = {
+struct obd_ops echo_obd_ops = {
         .o_owner           = THIS_MODULE,
         .o_connect         = echo_connect,
         .o_disconnect      = echo_disconnect,
@@ -626,11 +651,7 @@ static struct obd_ops echo_obd_ops = {
         .o_cleanup         = echo_cleanup
 };
 
-extern int echo_client_init(void);
-extern void echo_client_exit(void);
-
-static void
-echo_persistent_pages_fini (void)
+void echo_persistent_pages_fini(void)
 {
         int     i;
 
@@ -641,72 +662,26 @@ echo_persistent_pages_fini (void)
                 }
 }
 
-static int
-echo_persistent_pages_init (void)
-{
-        cfs_page_t *pg;
-        int          i;
-
-        for (i = 0; i < ECHO_PERSISTENT_PAGES; i++) {
-                int gfp_mask = (i < ECHO_PERSISTENT_PAGES/2) ?
-                        CFS_ALLOC_STD : CFS_ALLOC_HIGHUSER;
-
-                OBD_PAGE_ALLOC(pg, gfp_mask);
-                if (pg == NULL) {
-                        echo_persistent_pages_fini ();
-                        return (-ENOMEM);
-                }
-
-                memset (cfs_kmap (pg), 0, CFS_PAGE_SIZE);
-                cfs_kunmap (pg);
-
-                echo_persistent_pages[i] = pg;
-        }
-
-        return (0);
-}
-
-static int __init obdecho_init(void)
+int echo_persistent_pages_init(void)
 {
-        struct lprocfs_static_vars lvars;
-        int rc;
-
-        ENTRY;
-        LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
-
-        LASSERT(CFS_PAGE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
+       struct page *pg;
+       int          i;
 
-        lprocfs_echo_init_vars(&lvars);
+       for (i = 0; i < ECHO_PERSISTENT_PAGES; i++) {
+               int gfp_mask = (i < ECHO_PERSISTENT_PAGES/2) ?
+                       GFP_IOFS : GFP_HIGHUSER;
 
-        rc = echo_persistent_pages_init ();
-        if (rc != 0)
-                goto failed_0;
+               OBD_PAGE_ALLOC(pg, gfp_mask);
+               if (pg == NULL) {
+                       echo_persistent_pages_fini();
+                       return -ENOMEM;
+               }
 
-        rc = class_register_type(&echo_obd_ops, NULL, lvars.module_vars,
-                                 LUSTRE_ECHO_NAME, NULL);
-        if (rc != 0)
-                goto failed_1;
+               memset (kmap (pg), 0, PAGE_CACHE_SIZE);
+               kunmap (pg);
 
-        rc = echo_client_init();
-        if (rc == 0)
-                RETURN (0);
-
-        class_unregister_type(LUSTRE_ECHO_NAME);
- failed_1:
-        echo_persistent_pages_fini ();
- failed_0:
-        RETURN(rc);
-}
+               echo_persistent_pages[i] = pg;
+       }
 
-static void /*__exit*/ obdecho_exit(void)
-{
-        echo_client_exit();
-        class_unregister_type(LUSTRE_ECHO_NAME);
-        echo_persistent_pages_fini ();
+       return 0;
 }
-
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre Testing Echo OBD driver");
-MODULE_LICENSE("GPL");
-
-cfs_module(obdecho, "1.0.0", obdecho_init, obdecho_exit);