Whamcloud - gitweb
bca3d91f7a43852c0d4638ce57f2872aa219fb37
[fs/lustre-release.git] / lustre / obdecho / echo.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2010, 2011, Whamcloud, Inc.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/obdecho/echo.c
37  *
38  * Author: Peter Braam <braam@clusterfs.com>
39  * Author: Andreas Dilger <adilger@clusterfs.com>
40  */
41
42 #define DEBUG_SUBSYSTEM S_ECHO
43
44 #include <obd_support.h>
45 #include <obd_class.h>
46 #include <lustre_debug.h>
47 #include <lustre_dlm.h>
48 #include <lprocfs_status.h>
49
50 #include "echo_internal.h"
51
52 /* The echo objid needs to be below 2^32, because regular FID numbers are
53  * limited to 2^32 objects in f_oid for the FID_SEQ_ECHO range. b=23335 */
54 #define ECHO_INIT_OID        0x10000000ULL
55 #define ECHO_HANDLE_MAGIC    0xabcd0123fedc9876ULL
56
57 #define ECHO_PERSISTENT_PAGES (ECHO_PERSISTENT_SIZE >> CFS_PAGE_SHIFT)
58 static cfs_page_t *echo_persistent_pages[ECHO_PERSISTENT_PAGES];
59
60 enum {
61         LPROC_ECHO_READ_BYTES = 1,
62         LPROC_ECHO_WRITE_BYTES = 2,
63         LPROC_ECHO_LAST = LPROC_ECHO_WRITE_BYTES +1
64 };
65
66 static int echo_connect(const struct lu_env *env,
67                         struct obd_export **exp, struct obd_device *obd,
68                         struct obd_uuid *cluuid, struct obd_connect_data *data,
69                         void *localdata)
70 {
71         struct lustre_handle conn = { 0 };
72         int rc;
73
74         data->ocd_connect_flags &= ECHO_CONNECT_SUPPORTED;
75         rc = class_connect(&conn, obd, cluuid);
76         if (rc) {
77                 CERROR("can't connect %d\n", rc);
78                 return rc;
79         }
80         *exp = class_conn2export(&conn);
81
82         return 0;
83 }
84
85 static int echo_disconnect(struct obd_export *exp)
86 {
87         LASSERT (exp != NULL);
88
89         return server_disconnect_export(exp);
90 }
91
92 static int echo_init_export(struct obd_export *exp)
93 {
94         return ldlm_init_export(exp);
95 }
96
97 static int echo_destroy_export(struct obd_export *exp)
98 {
99         ENTRY;
100
101         target_destroy_export(exp);
102         ldlm_destroy_export(exp);
103
104         RETURN(0);
105 }
106
107  static __u64 echo_next_id(struct obd_device *obddev)
108 {
109         obd_id id;
110
111         cfs_spin_lock(&obddev->u.echo.eo_lock);
112         id = ++obddev->u.echo.eo_lastino;
113         cfs_spin_unlock(&obddev->u.echo.eo_lock);
114
115         return id;
116 }
117
118 static int echo_create(const struct lu_env *env, struct obd_export *exp,
119                        struct obdo *oa, struct lov_stripe_md **ea,
120                        struct obd_trans_info *oti)
121 {
122         struct obd_device *obd = class_exp2obd(exp);
123
124         if (!obd) {
125                 CERROR("invalid client cookie "LPX64"\n",
126                        exp->exp_handle.h_cookie);
127                 return -EINVAL;
128         }
129
130         if (!(oa->o_mode && S_IFMT)) {
131                 CERROR("echo obd: no type!\n");
132                 return -ENOENT;
133         }
134
135         if (!(oa->o_valid & OBD_MD_FLTYPE)) {
136                 CERROR("invalid o_valid "LPX64"\n", oa->o_valid);
137                 return -EINVAL;
138         }
139
140         oa->o_id = echo_next_id(obd);
141         oa->o_valid = OBD_MD_FLID;
142
143         return 0;
144 }
145
146 static int echo_destroy(const struct lu_env *env, struct obd_export *exp,
147                         struct obdo *oa, struct lov_stripe_md *ea,
148                         struct obd_trans_info *oti, struct obd_export *md_exp,
149                         void *capa)
150 {
151         struct obd_device *obd = class_exp2obd(exp);
152
153         ENTRY;
154         if (!obd) {
155                 CERROR("invalid client cookie "LPX64"\n",
156                        exp->exp_handle.h_cookie);
157                 RETURN(-EINVAL);
158         }
159
160         if (!(oa->o_valid & OBD_MD_FLID)) {
161                 CERROR("obdo missing FLID valid flag: "LPX64"\n", oa->o_valid);
162                 RETURN(-EINVAL);
163         }
164
165         if (oa->o_id > obd->u.echo.eo_lastino || oa->o_id < ECHO_INIT_OID) {
166                 CERROR("bad destroy objid: "LPX64"\n", oa->o_id);
167                 RETURN(-EINVAL);
168         }
169
170         RETURN(0);
171 }
172
173 static int echo_getattr(const struct lu_env *env, struct obd_export *exp,
174                         struct obd_info *oinfo)
175 {
176         struct obd_device *obd = class_exp2obd(exp);
177         obd_id id = oinfo->oi_oa->o_id;
178
179         ENTRY;
180         if (!obd) {
181                 CERROR("invalid client cookie "LPX64"\n",
182                        exp->exp_handle.h_cookie);
183                 RETURN(-EINVAL);
184         }
185
186         if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) {
187                 CERROR("obdo missing FLID valid flag: "LPX64"\n",
188                        oinfo->oi_oa->o_valid);
189                 RETURN(-EINVAL);
190         }
191
192         obdo_cpy_md(oinfo->oi_oa, &obd->u.echo.eo_oa, oinfo->oi_oa->o_valid);
193         oinfo->oi_oa->o_id = id;
194
195         RETURN(0);
196 }
197
198 static int echo_setattr(const struct lu_env *env, struct obd_export *exp,
199                         struct obd_info *oinfo, struct obd_trans_info *oti)
200 {
201         struct obd_device *obd = class_exp2obd(exp);
202
203         ENTRY;
204         if (!obd) {
205                 CERROR("invalid client cookie "LPX64"\n",
206                        exp->exp_handle.h_cookie);
207                 RETURN(-EINVAL);
208         }
209
210         if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) {
211                 CERROR("obdo missing FLID valid flag: "LPX64"\n",
212                        oinfo->oi_oa->o_valid);
213                 RETURN(-EINVAL);
214         }
215
216         memcpy(&obd->u.echo.eo_oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
217
218         if (oinfo->oi_oa->o_id & 4) {
219                 /* Save lock to force ACKed reply */
220                 ldlm_lock_addref (&obd->u.echo.eo_nl_lock, LCK_NL);
221                 oti->oti_ack_locks[0].mode = LCK_NL;
222                 oti->oti_ack_locks[0].lock = obd->u.echo.eo_nl_lock;
223         }
224
225         RETURN(0);
226 }
227
228 static void
229 echo_page_debug_setup(cfs_page_t *page, int rw, obd_id id,
230                       __u64 offset, int len)
231 {
232         int   page_offset = offset & ~CFS_PAGE_MASK;
233         char *addr        = ((char *)cfs_kmap(page)) + page_offset;
234
235         if (len % OBD_ECHO_BLOCK_SIZE != 0)
236                 CERROR("Unexpected block size %d\n", len);
237
238         while (len > 0) {
239                 if (rw & OBD_BRW_READ)
240                         block_debug_setup(addr, OBD_ECHO_BLOCK_SIZE,
241                                           offset, id);
242                 else
243                         block_debug_setup(addr, OBD_ECHO_BLOCK_SIZE,
244                                           0xecc0ecc0ecc0ecc0ULL,
245                                           0xecc0ecc0ecc0ecc0ULL);
246
247                 addr   += OBD_ECHO_BLOCK_SIZE;
248                 offset += OBD_ECHO_BLOCK_SIZE;
249                 len    -= OBD_ECHO_BLOCK_SIZE;
250         }
251
252         cfs_kunmap(page);
253 }
254
255 static int
256 echo_page_debug_check(cfs_page_t *page, obd_id id,
257                       __u64 offset, int len)
258 {
259         int   page_offset = offset & ~CFS_PAGE_MASK;
260         char *addr        = ((char *)cfs_kmap(page)) + page_offset;
261         int   rc          = 0;
262         int   rc2;
263
264         if (len % OBD_ECHO_BLOCK_SIZE != 0)
265                 CERROR("Unexpected block size %d\n", len);
266
267         while (len > 0) {
268                 rc2 = block_debug_check("echo", addr, OBD_ECHO_BLOCK_SIZE,
269                                         offset, id);
270
271                 if (rc2 != 0 && rc == 0)
272                         rc = rc2;
273
274                 addr   += OBD_ECHO_BLOCK_SIZE;
275                 offset += OBD_ECHO_BLOCK_SIZE;
276                 len    -= OBD_ECHO_BLOCK_SIZE;
277         }
278
279         cfs_kunmap(page);
280
281         return (rc);
282 }
283
284 /* This allows us to verify that desc_private is passed unmolested */
285 #define DESC_PRIV 0x10293847
286
287 static int echo_map_nb_to_lb(struct obdo *oa, struct obd_ioobj *obj,
288                              struct niobuf_remote *nb, int *pages,
289                              struct niobuf_local *lb, int cmd, int *left)
290 {
291         int gfp_mask = (obj->ioo_id & 1) ? CFS_ALLOC_HIGHUSER : CFS_ALLOC_STD;
292         int ispersistent = obj->ioo_id == ECHO_PERSISTENT_OBJID;
293         int debug_setup = (!ispersistent &&
294                            (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
295                            (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
296         struct niobuf_local *res = lb;
297         obd_off offset = nb->offset;
298         int len = nb->len;
299
300         while (len > 0) {
301                 int plen = CFS_PAGE_SIZE - (offset & (CFS_PAGE_SIZE-1));
302                 if (len < plen)
303                         plen = len;
304
305                 /* check for local buf overflow */
306                 if (*left == 0)
307                         return -EINVAL;
308
309                 res->offset = offset;
310                 res->len = plen;
311                 LASSERT((res->offset & ~CFS_PAGE_MASK) + res->len <= CFS_PAGE_SIZE);
312
313
314                 if (ispersistent &&
315                     (res->offset >> CFS_PAGE_SHIFT) < ECHO_PERSISTENT_PAGES) {
316                         res->page = echo_persistent_pages[res->offset >>
317                                 CFS_PAGE_SHIFT];
318                         /* Take extra ref so __free_pages() can be called OK */
319                         cfs_get_page (res->page);
320                 } else {
321                         OBD_PAGE_ALLOC(res->page, gfp_mask);
322                         if (res->page == NULL) {
323                                 CERROR("can't get page for id " LPU64"\n",
324                                        obj->ioo_id);
325                                 return -ENOMEM;
326                         }
327                 }
328
329                 CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n",
330                        res->page, res->offset, res->len);
331
332                 if (cmd & OBD_BRW_READ)
333                         res->rc = res->len;
334
335                 if (debug_setup)
336                         echo_page_debug_setup(res->page, cmd, obj->ioo_id,
337                                               res->offset, res->len);
338
339                 offset += plen;
340                 len -= plen;
341                 res++;
342
343                 (*left)--;
344                 (*pages)++;
345         }
346
347         return 0;
348 }
349
350 static int echo_finalize_lb(struct obdo *oa, struct obd_ioobj *obj,
351                             struct niobuf_remote *rb, int *pgs,
352                             struct niobuf_local *lb, int verify)
353 {
354         struct niobuf_local *res = lb;
355         obd_off start  = rb->offset >> CFS_PAGE_SHIFT;
356         obd_off end    = (rb->offset + rb->len + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
357         int     count  = (int)(end - start);
358         int     rc     = 0;
359         int     i;
360
361         for (i = 0; i < count; i++, (*pgs) ++, res++) {
362                 cfs_page_t *page = res->page;
363                 void       *addr;
364
365                 if (page == NULL) {
366                         CERROR("null page objid "LPU64":%p, buf %d/%d\n",
367                                obj->ioo_id, page, i, obj->ioo_bufcnt);
368                         return -EFAULT;
369                 }
370
371                 addr = cfs_kmap(page);
372
373                 CDEBUG(D_PAGE, "$$$$ use page %p, addr %p@"LPU64"\n",
374                        res->page, addr, res->offset);
375
376                 if (verify) {
377                         int vrc = echo_page_debug_check(page, obj->ioo_id,
378                                                         res->offset, res->len);
379                         /* check all the pages always */
380                         if (vrc != 0 && rc == 0)
381                                 rc = vrc;
382                 }
383
384                 cfs_kunmap(page);
385                 /* NB see comment above regarding persistent pages */
386                 OBD_PAGE_FREE(page);
387         }
388
389         return rc;
390 }
391
392 static int echo_preprw(const struct lu_env *env, int cmd,
393                        struct obd_export *export, struct obdo *oa,
394                        int objcount, struct obd_ioobj *obj,
395                        struct niobuf_remote *nb, int *pages,
396                        struct niobuf_local *res, struct obd_trans_info *oti,
397                        struct lustre_capa *unused)
398 {
399         struct obd_device *obd;
400         int tot_bytes = 0;
401         int rc = 0;
402         int i, left;
403         ENTRY;
404
405         obd = export->exp_obd;
406         if (obd == NULL)
407                 RETURN(-EINVAL);
408
409         /* Temp fix to stop falling foul of osc_announce_cached() */
410         oa->o_valid &= ~(OBD_MD_FLBLOCKS | OBD_MD_FLGRANT);
411
412         memset(res, 0, sizeof(*res) * *pages);
413
414         CDEBUG(D_PAGE, "%s %d obdos with %d IOs\n",
415                cmd == OBD_BRW_READ ? "reading" : "writing", objcount, *pages);
416
417         if (oti)
418                 oti->oti_handle = (void *)DESC_PRIV;
419
420         left = *pages;
421         *pages = 0;
422
423         for (i = 0; i < objcount; i++, obj++) {
424                 int j;
425
426                 for (j = 0 ; j < obj->ioo_bufcnt ; j++, nb++) {
427
428                         rc = echo_map_nb_to_lb(oa, obj, nb, pages,
429                                                res + *pages, cmd, &left);
430                         if (rc)
431                                 GOTO(preprw_cleanup, rc);
432
433                         tot_bytes += nb->len;
434                 }
435         }
436
437         cfs_atomic_add(*pages, &obd->u.echo.eo_prep);
438
439         if (cmd & OBD_BRW_READ)
440                 lprocfs_counter_add(obd->obd_stats, LPROC_ECHO_READ_BYTES,
441                                     tot_bytes);
442         else
443                 lprocfs_counter_add(obd->obd_stats, LPROC_ECHO_WRITE_BYTES,
444                                     tot_bytes);
445
446         CDEBUG(D_PAGE, "%d pages allocated after prep\n",
447                cfs_atomic_read(&obd->u.echo.eo_prep));
448
449         RETURN(0);
450
451 preprw_cleanup:
452         /* It is possible that we would rather handle errors by  allow
453          * any already-set-up pages to complete, rather than tearing them
454          * all down again.  I believe that this is what the in-kernel
455          * prep/commit operations do.
456          */
457         CERROR("cleaning up %u pages (%d obdos)\n", *pages, objcount);
458         for (i = 0; i < *pages; i++) {
459                 cfs_kunmap(res[i].page);
460                 /* NB if this is a persistent page, __free_pages will just
461                  * lose the extra ref gained above */
462                 OBD_PAGE_FREE(res[i].page);
463                 res[i].page = NULL;
464                 cfs_atomic_dec(&obd->u.echo.eo_prep);
465         }
466
467         return rc;
468 }
469
470 static int echo_commitrw(const struct lu_env *env, int cmd,
471                          struct obd_export *export, struct obdo *oa,
472                          int objcount, struct obd_ioobj *obj,
473                          struct niobuf_remote *rb, int niocount,
474                          struct niobuf_local *res, struct obd_trans_info *oti,
475                          int rc)
476 {
477         struct obd_device *obd;
478         int pgs = 0;
479         int i;
480         ENTRY;
481
482         obd = export->exp_obd;
483         if (obd == NULL)
484                 RETURN(-EINVAL);
485
486         if (rc)
487                 GOTO(commitrw_cleanup, rc);
488
489         if ((cmd & OBD_BRW_RWMASK) == OBD_BRW_READ) {
490                 CDEBUG(D_PAGE, "reading %d obdos with %d IOs\n",
491                        objcount, niocount);
492         } else {
493                 CDEBUG(D_PAGE, "writing %d obdos with %d IOs\n",
494                        objcount, niocount);
495         }
496
497         if (niocount && res == NULL) {
498                 CERROR("NULL res niobuf with niocount %d\n", niocount);
499                 RETURN(-EINVAL);
500         }
501
502         LASSERT(oti == NULL || oti->oti_handle == (void *)DESC_PRIV);
503
504         for (i = 0; i < objcount; i++, obj++) {
505                 int verify = (rc == 0 &&
506                               obj->ioo_id != ECHO_PERSISTENT_OBJID &&
507                               (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
508                               (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
509                 int j;
510
511                 for (j = 0 ; j < obj->ioo_bufcnt ; j++, rb++) {
512                         int vrc = echo_finalize_lb(oa, obj, rb, &pgs, &res[pgs], verify);
513
514                         if (vrc == 0)
515                                 continue;
516
517                         if (vrc == -EFAULT)
518                                 GOTO(commitrw_cleanup, rc = vrc);
519
520                         if (rc == 0)
521                                 rc = vrc;
522                 }
523
524         }
525
526         cfs_atomic_sub(pgs, &obd->u.echo.eo_prep);
527
528         CDEBUG(D_PAGE, "%d pages remain after commit\n",
529                cfs_atomic_read(&obd->u.echo.eo_prep));
530         RETURN(rc);
531
532 commitrw_cleanup:
533         cfs_atomic_sub(pgs, &obd->u.echo.eo_prep);
534
535         CERROR("cleaning up %d pages (%d obdos)\n",
536                niocount - pgs - 1, objcount);
537
538         while (pgs < niocount) {
539                 cfs_page_t *page = res[pgs++].page;
540
541                 if (page == NULL)
542                         continue;
543
544                 /* NB see comment above regarding persistent pages */
545                 OBD_PAGE_FREE(page);
546                 cfs_atomic_dec(&obd->u.echo.eo_prep);
547         }
548         return rc;
549 }
550
551 static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
552 {
553         struct lprocfs_static_vars lvars;
554         int                        rc;
555         int                        lock_flags = 0;
556         struct ldlm_res_id         res_id = {.name = {1}};
557         char                       ns_name[48];
558         ENTRY;
559
560         obd->u.echo.eo_obt.obt_magic = OBT_MAGIC;
561         cfs_spin_lock_init(&obd->u.echo.eo_lock);
562         obd->u.echo.eo_lastino = ECHO_INIT_OID;
563
564         sprintf(ns_name, "echotgt-%s", obd->obd_uuid.uuid);
565         obd->obd_namespace = ldlm_namespace_new(obd, ns_name,
566                                                 LDLM_NAMESPACE_SERVER,
567                                                 LDLM_NAMESPACE_MODEST,
568                                                 LDLM_NS_TYPE_OST);
569         if (obd->obd_namespace == NULL) {
570                 LBUG();
571                 RETURN(-ENOMEM);
572         }
573
574         rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN,
575                                     NULL, LCK_NL, &lock_flags, NULL,
576                                     ldlm_completion_ast, NULL, NULL, 0, NULL,
577                                     &obd->u.echo.eo_nl_lock);
578         LASSERT (rc == ELDLM_OK);
579
580         lprocfs_echo_init_vars(&lvars);
581         if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0 &&
582             lprocfs_alloc_obd_stats(obd, LPROC_ECHO_LAST) == 0) {
583                 lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_READ_BYTES,
584                                      LPROCFS_CNTR_AVGMINMAX,
585                                      "read_bytes", "bytes");
586                 lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_WRITE_BYTES,
587                                      LPROCFS_CNTR_AVGMINMAX,
588                                      "write_bytes", "bytes");
589         }
590
591         ptlrpc_init_client (LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
592                             "echo_ldlm_cb_client", &obd->obd_ldlm_client);
593         RETURN(0);
594 }
595
596 static int echo_cleanup(struct obd_device *obd)
597 {
598         int leaked;
599         ENTRY;
600
601         lprocfs_obd_cleanup(obd);
602         lprocfs_free_obd_stats(obd);
603
604         ldlm_lock_decref(&obd->u.echo.eo_nl_lock, LCK_NL);
605
606         /* XXX Bug 3413; wait for a bit to ensure the BL callback has
607          * happened before calling ldlm_namespace_free() */
608         cfs_schedule_timeout_and_set_state(CFS_TASK_UNINT, cfs_time_seconds(1));
609
610         ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force);
611         obd->obd_namespace = NULL;
612
613         leaked = cfs_atomic_read(&obd->u.echo.eo_prep);
614         if (leaked != 0)
615                 CERROR("%d prep/commitrw pages leaked\n", leaked);
616
617         RETURN(0);
618 }
619
620 struct obd_ops echo_obd_ops = {
621         .o_owner           = THIS_MODULE,
622         .o_connect         = echo_connect,
623         .o_disconnect      = echo_disconnect,
624         .o_init_export     = echo_init_export,
625         .o_destroy_export  = echo_destroy_export,
626         .o_create          = echo_create,
627         .o_destroy         = echo_destroy,
628         .o_getattr         = echo_getattr,
629         .o_setattr         = echo_setattr,
630         .o_preprw          = echo_preprw,
631         .o_commitrw        = echo_commitrw,
632         .o_setup           = echo_setup,
633         .o_cleanup         = echo_cleanup
634 };
635
636 void echo_persistent_pages_fini(void)
637 {
638         int     i;
639
640         for (i = 0; i < ECHO_PERSISTENT_PAGES; i++)
641                 if (echo_persistent_pages[i] != NULL) {
642                         OBD_PAGE_FREE(echo_persistent_pages[i]);
643                         echo_persistent_pages[i] = NULL;
644                 }
645 }
646
647 int echo_persistent_pages_init(void)
648 {
649         cfs_page_t *pg;
650         int          i;
651
652         for (i = 0; i < ECHO_PERSISTENT_PAGES; i++) {
653                 int gfp_mask = (i < ECHO_PERSISTENT_PAGES/2) ?
654                         CFS_ALLOC_STD : CFS_ALLOC_HIGHUSER;
655
656                 OBD_PAGE_ALLOC(pg, gfp_mask);
657                 if (pg == NULL) {
658                         echo_persistent_pages_fini ();
659                         return (-ENOMEM);
660                 }
661
662                 memset (cfs_kmap (pg), 0, CFS_PAGE_SIZE);
663                 cfs_kunmap (pg);
664
665                 echo_persistent_pages[i] = pg;
666         }
667
668         return (0);
669 }