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