Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[fs/lustre-release.git] / lustre / obdecho / echo.c
index a9886ed..00163bb 100644 (file)
@@ -116,7 +116,7 @@ static u64 echo_next_id(struct obd_device *obddev)
 }
 
 static int echo_create(const struct lu_env *env, struct obd_export *exp,
-                      struct obdo *oa, struct obd_trans_info *oti)
+                      struct obdo *oa)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -144,7 +144,7 @@ static int echo_create(const struct lu_env *env, struct obd_export *exp,
 }
 
 static int echo_destroy(const struct lu_env *env, struct obd_export *exp,
-                       struct obdo *oa, struct obd_trans_info *oti)
+                       struct obdo *oa)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -170,59 +170,50 @@ static int echo_destroy(const struct lu_env *env, struct obd_export *exp,
 }
 
 static int echo_getattr(const struct lu_env *env, struct obd_export *exp,
-                        struct obd_info *oinfo)
+                       struct obdo *oa)
 {
        struct obd_device *obd = class_exp2obd(exp);
-       u64 id = ostid_id(&oinfo->oi_oa->o_oi);
+       u64 id = ostid_id(&oa->o_oi);
 
-        ENTRY;
-        if (!obd) {
-                CERROR("invalid client cookie "LPX64"\n",
-                       exp->exp_handle.h_cookie);
-                RETURN(-EINVAL);
-        }
+       ENTRY;
+       if (!obd) {
+               CERROR("invalid client cookie "LPX64"\n",
+                      exp->exp_handle.h_cookie);
+               RETURN(-EINVAL);
+       }
 
-        if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) {
-                CERROR("obdo missing FLID valid flag: "LPX64"\n",
-                       oinfo->oi_oa->o_valid);
-                RETURN(-EINVAL);
-        }
+       if (!(oa->o_valid & OBD_MD_FLID)) {
+               CERROR("obdo missing FLID valid flag: "LPX64"\n", oa->o_valid);
+               RETURN(-EINVAL);
+       }
 
-       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);
+       obdo_cpy_md(oa, &obd->u.echo.eo_oa, oa->o_valid);
+       ostid_set_seq_echo(&oa->o_oi);
+       ostid_set_id(&oa->o_oi, id);
 
        RETURN(0);
 }
 
 static int echo_setattr(const struct lu_env *env, struct obd_export *exp,
-                        struct obd_info *oinfo, struct obd_trans_info *oti)
+                       struct obdo *oa)
 {
-        struct obd_device *obd = class_exp2obd(exp);
-
-        ENTRY;
-        if (!obd) {
-                CERROR("invalid client cookie "LPX64"\n",
-                       exp->exp_handle.h_cookie);
-                RETURN(-EINVAL);
-        }
+       struct obd_device *obd = class_exp2obd(exp);
 
-        if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) {
-                CERROR("obdo missing FLID valid flag: "LPX64"\n",
-                       oinfo->oi_oa->o_valid);
-                RETURN(-EINVAL);
-        }
+       ENTRY;
+       if (!obd) {
+               CERROR("invalid client cookie "LPX64"\n",
+                      exp->exp_handle.h_cookie);
+               RETURN(-EINVAL);
+       }
 
-        memcpy(&obd->u.echo.eo_oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
+       if (!(oa->o_valid & OBD_MD_FLID)) {
+               CERROR("obdo missing FLID valid flag: "LPX64"\n", oa->o_valid);
+               RETURN(-EINVAL);
+       }
 
-        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;
-                oti->oti_ack_locks[0].lock = obd->u.echo.eo_nl_lock;
-        }
+       obd->u.echo.eo_oa = *oa;
 
-        RETURN(0);
+       RETURN(0);
 }
 
 static void
@@ -281,9 +272,6 @@ echo_page_debug_check(struct page *page, u64 id,
        return rc;
 }
 
-/* This allows us to verify that desc_private is passed unmolested */
-#define DESC_PRIV 0x10293847
-
 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)
@@ -321,7 +309,7 @@ static int echo_map_nb_to_lb(struct obdo *oa, struct obd_ioobj *obj,
                        /* Take extra ref so __free_pages() can be called OK */
                        get_page(res->lnb_page);
                } else {
-                       OBD_PAGE_ALLOC(res->lnb_page, gfp_mask);
+                       res->lnb_page = alloc_page(gfp_mask);
                        if (res->lnb_page == NULL) {
                                CERROR("can't get page for id " DOSTID"\n",
                                       POSTID(&obj->ioo_oid));
@@ -392,7 +380,7 @@ static int echo_finalize_lb(struct obdo *oa, struct obd_ioobj *obj,
 
                kunmap(page);
                /* NB see comment above regarding persistent pages */
-               OBD_PAGE_FREE(page);
+               __free_page(page);
        }
 
        return rc;
@@ -402,7 +390,7 @@ 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 niobuf_local *res)
 {
         struct obd_device *obd;
         int tot_bytes = 0;
@@ -422,9 +410,6 @@ static int echo_preprw(const struct lu_env *env, int cmd,
         CDEBUG(D_PAGE, "%s %d obdos with %d IOs\n",
                cmd == OBD_BRW_READ ? "reading" : "writing", objcount, *pages);
 
-        if (oti)
-                oti->oti_handle = (void *)DESC_PRIV;
-
         left = *pages;
         *pages = 0;
 
@@ -465,9 +450,9 @@ preprw_cleanup:
         CERROR("cleaning up %u pages (%d obdos)\n", *pages, objcount);
         for (i = 0; i < *pages; i++) {
                kunmap(res[i].lnb_page);
-               /* NB if this is a persistent page, __free_pages will just
+               /* NB if this is a persistent page, __free_page() will just
                 * lose the extra ref gained above */
-               OBD_PAGE_FREE(res[i].lnb_page);
+               __free_page(res[i].lnb_page);
                res[i].lnb_page = NULL;
                atomic_dec(&obd->u.echo.eo_prep);
        }
@@ -479,8 +464,7 @@ 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 niobuf_local *res, int rc)
 {
         struct obd_device *obd;
         int pgs = 0;
@@ -507,8 +491,6 @@ static int echo_commitrw(const struct lu_env *env, int cmd,
                 RETURN(-EINVAL);
         }
 
-        LASSERT(oti == NULL || oti->oti_handle == (void *)DESC_PRIV);
-
        for (i = 0; i < objcount; i++, obj++) {
                int verify = (rc == 0 &&
                             ostid_id(&obj->ioo_oid) != ECHO_PERSISTENT_OBJID &&
@@ -540,20 +522,20 @@ static int echo_commitrw(const struct lu_env *env, int cmd,
 commitrw_cleanup:
        atomic_sub(pgs, &obd->u.echo.eo_prep);
 
-        CERROR("cleaning up %d pages (%d obdos)\n",
-               niocount - pgs - 1, objcount);
+       CERROR("cleaning up %d pages (%d obdos)\n",
+              niocount - pgs - 1, objcount);
 
-        while (pgs < niocount) {
+       while (pgs < niocount) {
                struct page *page = res[pgs++].lnb_page;
 
-                if (page == NULL)
-                        continue;
+               if (page == NULL)
+                       continue;
 
-                /* NB see comment above regarding persistent pages */
-                OBD_PAGE_FREE(page);
+               /* NB see comment above regarding persistent pages */
+               __free_page(page);
                atomic_dec(&obd->u.echo.eo_prep);
-        }
-        return rc;
+       }
+       return rc;
 }
 
 LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
@@ -619,7 +601,8 @@ static int echo_cleanup(struct obd_device *obd)
 
        /* 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));
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       schedule_timeout(cfs_time_seconds(1));
 
        ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force);
        obd->obd_namespace = NULL;
@@ -649,13 +632,13 @@ struct obd_ops echo_obd_ops = {
 
 void echo_persistent_pages_fini(void)
 {
-        int     i;
+       int i;
 
-        for (i = 0; i < ECHO_PERSISTENT_PAGES; i++)
-                if (echo_persistent_pages[i] != NULL) {
-                        OBD_PAGE_FREE(echo_persistent_pages[i]);
-                        echo_persistent_pages[i] = NULL;
-                }
+       for (i = 0; i < ECHO_PERSISTENT_PAGES; i++)
+               if (echo_persistent_pages[i] != NULL) {
+                       __free_page(echo_persistent_pages[i]);
+                       echo_persistent_pages[i] = NULL;
+               }
 }
 
 int echo_persistent_pages_init(void)
@@ -667,7 +650,7 @@ int echo_persistent_pages_init(void)
                gfp_t gfp_mask = (i < ECHO_PERSISTENT_PAGES/2) ?
                        GFP_IOFS : GFP_HIGHUSER;
 
-               OBD_PAGE_ALLOC(pg, gfp_mask);
+               pg = alloc_page(gfp_mask);
                if (pg == NULL) {
                        echo_persistent_pages_fini();
                        return -ENOMEM;