Whamcloud - gitweb
LU-6047 obd: remove client Size on MDS support
[fs/lustre-release.git] / lustre / lov / lov_request.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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2014, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #define DEBUG_SUBSYSTEM S_LOV
38
39 #include <libcfs/libcfs.h>
40
41 #include <obd_class.h>
42 #include <lustre/lustre_idl.h>
43
44 #include "lov_internal.h"
45
46 static void lov_init_set(struct lov_request_set *set)
47 {
48         set->set_count = 0;
49         atomic_set(&set->set_completes, 0);
50         atomic_set(&set->set_success, 0);
51         atomic_set(&set->set_finish_checked, 0);
52         set->set_cookies = NULL;
53         INIT_LIST_HEAD(&set->set_list);
54         atomic_set(&set->set_refcount, 1);
55         init_waitqueue_head(&set->set_waitq);
56 }
57
58 void lov_finish_set(struct lov_request_set *set)
59 {
60         struct list_head *pos, *n;
61         struct lov_request *req;
62         ENTRY;
63
64         LASSERT(set != NULL);
65         list_for_each_safe(pos, n, &set->set_list) {
66                 req = list_entry(pos, struct lov_request, rq_link);
67                 list_del_init(&req->rq_link);
68
69                 if (req->rq_oi.oi_oa != NULL)
70                         OBDO_FREE(req->rq_oi.oi_oa);
71
72                 if (req->rq_oi.oi_osfs != NULL)
73                         OBD_FREE_PTR(req->rq_oi.oi_osfs);
74
75                 OBD_FREE_PTR(req);
76         }
77
78         OBD_FREE_PTR(set);
79         EXIT;
80 }
81
82 int lov_set_finished(struct lov_request_set *set, int idempotent)
83 {
84         int completes = atomic_read(&set->set_completes);
85
86         CDEBUG(D_INFO, "check set %d/%d\n", completes, set->set_count);
87
88         if (completes == set->set_count) {
89                 if (idempotent)
90                         return 1;
91                 if (atomic_inc_return(&set->set_finish_checked) == 1)
92                         return 1;
93         }
94         return 0;
95 }
96
97 void lov_update_set(struct lov_request_set *set,
98                     struct lov_request *req, int rc)
99 {
100         req->rq_complete = 1;
101         req->rq_rc = rc;
102
103         atomic_inc(&set->set_completes);
104         if (rc == 0)
105                 atomic_inc(&set->set_success);
106
107         wake_up(&set->set_waitq);
108 }
109
110 int lov_update_common_set(struct lov_request_set *set,
111                           struct lov_request *req, int rc)
112 {
113         struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
114         ENTRY;
115
116         lov_update_set(set, req, rc);
117
118         /* grace error on inactive ost */
119         if (rc && !(lov->lov_tgts[req->rq_idx] &&
120                     lov->lov_tgts[req->rq_idx]->ltd_active))
121                 rc = 0;
122
123         /* FIXME in raid1 regime, should return 0 */
124         RETURN(rc);
125 }
126
127 void lov_set_add_req(struct lov_request *req, struct lov_request_set *set)
128 {
129         list_add_tail(&req->rq_link, &set->set_list);
130         set->set_count++;
131         req->rq_rqset = set;
132 }
133
134 static int lov_check_set(struct lov_obd *lov, int idx)
135 {
136         int rc = 0;
137         mutex_lock(&lov->lov_lock);
138
139         if (lov->lov_tgts[idx] == NULL ||
140             lov->lov_tgts[idx]->ltd_active ||
141             (lov->lov_tgts[idx]->ltd_exp != NULL &&
142              class_exp2cliimp(lov->lov_tgts[idx]->ltd_exp)->imp_connect_tried))
143                 rc = 1;
144
145         mutex_unlock(&lov->lov_lock);
146         return rc;
147 }
148
149 /* Check if the OSC connection exists and is active.
150  * If the OSC has not yet had a chance to connect to the OST the first time,
151  * wait once for it to connect instead of returning an error.
152  */
153 int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx)
154 {
155         wait_queue_head_t waitq;
156         struct l_wait_info lwi;
157         struct lov_tgt_desc *tgt;
158         int rc = 0;
159
160         mutex_lock(&lov->lov_lock);
161
162         tgt = lov->lov_tgts[ost_idx];
163
164         if (unlikely(tgt == NULL))
165                 GOTO(out, rc = 0);
166
167         if (likely(tgt->ltd_active))
168                 GOTO(out, rc = 1);
169
170         if (tgt->ltd_exp && class_exp2cliimp(tgt->ltd_exp)->imp_connect_tried)
171                 GOTO(out, rc = 0);
172
173         mutex_unlock(&lov->lov_lock);
174
175         init_waitqueue_head(&waitq);
176         lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(obd_timeout),
177                                    cfs_time_seconds(1), NULL, NULL);
178
179         rc = l_wait_event(waitq, lov_check_set(lov, ost_idx), &lwi);
180         if (tgt->ltd_active)
181                 return 1;
182
183         return 0;
184
185 out:
186         mutex_unlock(&lov->lov_lock);
187         return rc;
188 }
189
190 static int common_attr_done(struct lov_request_set *set)
191 {
192         struct list_head *pos;
193         struct lov_request *req;
194         struct obdo *tmp_oa;
195         int rc = 0, attrset = 0;
196         ENTRY;
197
198         LASSERT(set->set_oi != NULL);
199
200         if (set->set_oi->oi_oa == NULL)
201                 RETURN(0);
202
203         if (!atomic_read(&set->set_success))
204                 RETURN(-EIO);
205
206         OBDO_ALLOC(tmp_oa);
207         if (tmp_oa == NULL)
208                 GOTO(out, rc = -ENOMEM);
209
210         list_for_each(pos, &set->set_list) {
211                 req = list_entry(pos, struct lov_request, rq_link);
212
213                 if (!req->rq_complete || req->rq_rc)
214                         continue;
215                 if (req->rq_oi.oi_oa->o_valid == 0)   /* inactive stripe */
216                         continue;
217                 lov_merge_attrs(tmp_oa, req->rq_oi.oi_oa,
218                                 req->rq_oi.oi_oa->o_valid,
219                                 set->set_oi->oi_md, req->rq_stripe, &attrset);
220         }
221         if (!attrset) {
222                 CERROR("No stripes had valid attrs\n");
223                 rc = -EIO;
224         }
225
226         tmp_oa->o_oi = set->set_oi->oi_oa->o_oi;
227         memcpy(set->set_oi->oi_oa, tmp_oa, sizeof(*set->set_oi->oi_oa));
228 out:
229         if (tmp_oa)
230                 OBDO_FREE(tmp_oa);
231         RETURN(rc);
232
233 }
234
235 int lov_fini_getattr_set(struct lov_request_set *set)
236 {
237         int rc = 0;
238         ENTRY;
239
240         if (set == NULL)
241                 RETURN(0);
242         LASSERT(set->set_exp);
243         if (atomic_read(&set->set_completes))
244                 rc = common_attr_done(set);
245
246         lov_put_reqset(set);
247
248         RETURN(rc);
249 }
250
251 /* The callback for osc_getattr_async that finilizes a request info when a
252  * response is received. */
253 static int cb_getattr_update(void *cookie, int rc)
254 {
255         struct obd_info *oinfo = cookie;
256         struct lov_request *lovreq;
257         lovreq = container_of(oinfo, struct lov_request, rq_oi);
258         return lov_update_common_set(lovreq->rq_rqset, lovreq, rc);
259 }
260
261 int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
262                          struct lov_request_set **reqset)
263 {
264         struct lov_request_set *set;
265         struct lov_obd *lov = &exp->exp_obd->u.lov;
266         int rc = 0, i;
267         ENTRY;
268
269         OBD_ALLOC(set, sizeof(*set));
270         if (set == NULL)
271                 RETURN(-ENOMEM);
272         lov_init_set(set);
273
274         set->set_exp = exp;
275         set->set_oi = oinfo;
276
277         for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
278                 struct lov_oinfo *loi;
279                 struct lov_request *req;
280
281                 loi = oinfo->oi_md->lsm_oinfo[i];
282                 if (lov_oinfo_is_dummy(loi))
283                         continue;
284
285                 if (!lov_check_and_wait_active(lov, loi->loi_ost_idx)) {
286                         CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
287                         continue;
288                 }
289
290                 OBD_ALLOC(req, sizeof(*req));
291                 if (req == NULL)
292                         GOTO(out_set, rc = -ENOMEM);
293
294                 req->rq_stripe = i;
295                 req->rq_idx = loi->loi_ost_idx;
296
297                 OBDO_ALLOC(req->rq_oi.oi_oa);
298                 if (req->rq_oi.oi_oa == NULL) {
299                         OBD_FREE(req, sizeof(*req));
300                         GOTO(out_set, rc = -ENOMEM);
301                 }
302                 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
303                        sizeof(*req->rq_oi.oi_oa));
304                 req->rq_oi.oi_oa->o_oi = loi->loi_oi;
305                 req->rq_oi.oi_cb_up = cb_getattr_update;
306                 req->rq_oi.oi_capa = oinfo->oi_capa;
307
308                 lov_set_add_req(req, set);
309         }
310         if (!set->set_count)
311                 GOTO(out_set, rc = -EIO);
312         *reqset = set;
313         RETURN(rc);
314 out_set:
315         lov_fini_getattr_set(set);
316         RETURN(rc);
317 }
318
319 int lov_fini_setattr_set(struct lov_request_set *set)
320 {
321         int rc = 0;
322         ENTRY;
323
324         if (set == NULL)
325                 RETURN(0);
326         LASSERT(set->set_exp);
327         if (atomic_read(&set->set_completes)) {
328                 rc = common_attr_done(set);
329                 /* FIXME update qos data here */
330         }
331
332         lov_put_reqset(set);
333         RETURN(rc);
334 }
335
336 int lov_update_setattr_set(struct lov_request_set *set,
337                            struct lov_request *req, int rc)
338 {
339         struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov;
340         struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md;
341         ENTRY;
342
343         lov_update_set(set, req, rc);
344
345         /* grace error on inactive ost */
346         if (rc && !(lov->lov_tgts[req->rq_idx] &&
347                     lov->lov_tgts[req->rq_idx]->ltd_active))
348                 rc = 0;
349
350         if (rc == 0) {
351                 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCTIME)
352                         lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_ctime =
353                                 req->rq_oi.oi_oa->o_ctime;
354                 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLMTIME)
355                         lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_mtime =
356                                 req->rq_oi.oi_oa->o_mtime;
357                 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLATIME)
358                         lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_atime =
359                                 req->rq_oi.oi_oa->o_atime;
360         }
361
362         RETURN(rc);
363 }
364
365 /* The callback for osc_setattr_async that finilizes a request info when a
366  * response is received. */
367 static int cb_setattr_update(void *cookie, int rc)
368 {
369         struct obd_info *oinfo = cookie;
370         struct lov_request *lovreq;
371         lovreq = container_of(oinfo, struct lov_request, rq_oi);
372         return lov_update_setattr_set(lovreq->rq_rqset, lovreq, rc);
373 }
374
375 int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
376                          struct obd_trans_info *oti,
377                          struct lov_request_set **reqset)
378 {
379         struct lov_request_set *set;
380         struct lov_obd *lov = &exp->exp_obd->u.lov;
381         int rc = 0, i;
382         ENTRY;
383
384         OBD_ALLOC(set, sizeof(*set));
385         if (set == NULL)
386                 RETURN(-ENOMEM);
387         lov_init_set(set);
388
389         set->set_exp = exp;
390         set->set_oi = oinfo;
391         if (oti != NULL && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
392                 set->set_cookies = oti->oti_logcookies;
393
394         for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
395                 struct lov_oinfo *loi = oinfo->oi_md->lsm_oinfo[i];
396                 struct lov_request *req;
397
398                 if (lov_oinfo_is_dummy(loi))
399                         continue;
400
401                 if (!lov_check_and_wait_active(lov, loi->loi_ost_idx)) {
402                         CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
403                         continue;
404                 }
405
406                 OBD_ALLOC(req, sizeof(*req));
407                 if (req == NULL)
408                         GOTO(out_set, rc = -ENOMEM);
409                 req->rq_stripe = i;
410                 req->rq_idx = loi->loi_ost_idx;
411
412                 OBDO_ALLOC(req->rq_oi.oi_oa);
413                 if (req->rq_oi.oi_oa == NULL) {
414                         OBD_FREE(req, sizeof(*req));
415                         GOTO(out_set, rc = -ENOMEM);
416                 }
417                 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
418                        sizeof(*req->rq_oi.oi_oa));
419                 req->rq_oi.oi_oa->o_oi = loi->loi_oi;
420                 req->rq_oi.oi_oa->o_stripe_idx = i;
421                 req->rq_oi.oi_cb_up = cb_setattr_update;
422                 req->rq_oi.oi_capa = oinfo->oi_capa;
423
424                 if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE) {
425                         int off = lov_stripe_offset(oinfo->oi_md,
426                                                     oinfo->oi_oa->o_size, i,
427                                                     &req->rq_oi.oi_oa->o_size);
428
429                         if (off < 0 && req->rq_oi.oi_oa->o_size)
430                                 req->rq_oi.oi_oa->o_size--;
431
432                         CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n",
433                                i, req->rq_oi.oi_oa->o_size,
434                                oinfo->oi_oa->o_size);
435                 }
436                 lov_set_add_req(req, set);
437         }
438         if (!set->set_count)
439                 GOTO(out_set, rc = -EIO);
440         *reqset = set;
441         RETURN(rc);
442 out_set:
443         lov_fini_setattr_set(set);
444         RETURN(rc);
445 }
446
447 #define LOV_U64_MAX ((__u64)~0ULL)
448 #define LOV_SUM_MAX(tot, add)                                           \
449         do {                                                            \
450                 if ((tot) + (add) < (tot))                              \
451                         (tot) = LOV_U64_MAX;                            \
452                 else                                                    \
453                         (tot) += (add);                                 \
454         } while(0)
455
456 int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success)
457 {
458         ENTRY;
459
460         if (success) {
461                 __u32 expected_stripes = lov_get_stripecnt(&obd->u.lov,
462                                                            LOV_MAGIC, 0);
463                 if (osfs->os_files != LOV_U64_MAX)
464                         lov_do_div64(osfs->os_files, expected_stripes);
465                 if (osfs->os_ffree != LOV_U64_MAX)
466                         lov_do_div64(osfs->os_ffree, expected_stripes);
467
468                 spin_lock(&obd->obd_osfs_lock);
469                 memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
470                 obd->obd_osfs_age = cfs_time_current_64();
471                 spin_unlock(&obd->obd_osfs_lock);
472                 RETURN(0);
473         }
474
475         RETURN(-EIO);
476 }
477
478 int lov_fini_statfs_set(struct lov_request_set *set)
479 {
480         int rc = 0;
481         ENTRY;
482
483         if (set == NULL)
484                 RETURN(0);
485
486         if (atomic_read(&set->set_completes)) {
487                 rc = lov_fini_statfs(set->set_obd, set->set_oi->oi_osfs,
488                                      atomic_read(&set->set_success));
489         }
490         lov_put_reqset(set);
491         RETURN(rc);
492 }
493
494 void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs,
495                        int success)
496 {
497         int shift = 0, quit = 0;
498         __u64 tmp;
499
500         if (success == 0) {
501                 memcpy(osfs, lov_sfs, sizeof(*lov_sfs));
502         } else {
503                 if (osfs->os_bsize != lov_sfs->os_bsize) {
504                         /* assume all block sizes are always powers of 2 */
505                         /* get the bits difference */
506                         tmp = osfs->os_bsize | lov_sfs->os_bsize;
507                         for (shift = 0; shift <= 64; ++shift) {
508                                 if (tmp & 1) {
509                                         if (quit)
510                                                 break;
511                                         else
512                                                 quit = 1;
513                                         shift = 0;
514                                 }
515                                 tmp >>= 1;
516                         }
517                 }
518
519                 if (osfs->os_bsize < lov_sfs->os_bsize) {
520                         osfs->os_bsize = lov_sfs->os_bsize;
521
522                         osfs->os_bfree  >>= shift;
523                         osfs->os_bavail >>= shift;
524                         osfs->os_blocks >>= shift;
525                 } else if (shift != 0) {
526                         lov_sfs->os_bfree  >>= shift;
527                         lov_sfs->os_bavail >>= shift;
528                         lov_sfs->os_blocks >>= shift;
529                 }
530 #ifdef MIN_DF
531                 /* Sandia requested that df (and so, statfs) only
532                    returned minimal available space on
533                    a single OST, so people would be able to
534                    write this much data guaranteed. */
535                 if (osfs->os_bavail > lov_sfs->os_bavail) {
536                         /* Presumably if new bavail is smaller,
537                            new bfree is bigger as well */
538                         osfs->os_bfree = lov_sfs->os_bfree;
539                         osfs->os_bavail = lov_sfs->os_bavail;
540                 }
541 #else
542                 osfs->os_bfree += lov_sfs->os_bfree;
543                 osfs->os_bavail += lov_sfs->os_bavail;
544 #endif
545                 osfs->os_blocks += lov_sfs->os_blocks;
546                 /* XXX not sure about this one - depends on policy.
547                  *   - could be minimum if we always stripe on all OBDs
548                  *     (but that would be wrong for any other policy,
549                  *     if one of the OBDs has no more objects left)
550                  *   - could be sum if we stripe whole objects
551                  *   - could be average, just to give a nice number
552                  *
553                  * To give a "reasonable" (if not wholly accurate)
554                  * number, we divide the total number of free objects
555                  * by expected stripe count (watch out for overflow).
556                  */
557                 LOV_SUM_MAX(osfs->os_files, lov_sfs->os_files);
558                 LOV_SUM_MAX(osfs->os_ffree, lov_sfs->os_ffree);
559         }
560 }
561
562 /* The callback for osc_statfs_async that finilizes a request info when a
563  * response is received. */
564 static int cb_statfs_update(void *cookie, int rc)
565 {
566         struct obd_info *oinfo = cookie;
567         struct lov_request *lovreq;
568         struct lov_request_set *set;
569         struct obd_statfs *osfs, *lov_sfs;
570         struct lov_obd *lov;
571         struct lov_tgt_desc *tgt;
572         struct obd_device *lovobd, *tgtobd;
573         int success;
574         ENTRY;
575
576         lovreq = container_of(oinfo, struct lov_request, rq_oi);
577         set = lovreq->rq_rqset;
578         lovobd = set->set_obd;
579         lov = &lovobd->u.lov;
580         osfs = set->set_oi->oi_osfs;
581         lov_sfs = oinfo->oi_osfs;
582         success = atomic_read(&set->set_success);
583         /* XXX: the same is done in lov_update_common_set, however
584            lovset->set_exp is not initialized. */
585         lov_update_set(set, lovreq, rc);
586         if (rc)
587                 GOTO(out, rc);
588
589         obd_getref(lovobd);
590         tgt = lov->lov_tgts[lovreq->rq_idx];
591         if (!tgt || !tgt->ltd_active)
592                 GOTO(out_update, rc);
593
594         tgtobd = class_exp2obd(tgt->ltd_exp);
595         spin_lock(&tgtobd->obd_osfs_lock);
596         memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
597         if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
598                 tgtobd->obd_osfs_age = cfs_time_current_64();
599         spin_unlock(&tgtobd->obd_osfs_lock);
600
601 out_update:
602         lov_update_statfs(osfs, lov_sfs, success);
603         obd_putref(lovobd);
604
605 out:
606         if (set->set_oi->oi_flags & OBD_STATFS_PTLRPCD &&
607             lov_set_finished(set, 0)) {
608                 lov_statfs_interpret(NULL, set, set->set_count !=
609                                      atomic_read(&set->set_success));
610         }
611
612         RETURN(0);
613 }
614
615 int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
616                         struct lov_request_set **reqset)
617 {
618         struct lov_request_set *set;
619         struct lov_obd *lov = &obd->u.lov;
620         int rc = 0, i;
621         ENTRY;
622
623         OBD_ALLOC(set, sizeof(*set));
624         if (set == NULL)
625                 RETURN(-ENOMEM);
626         lov_init_set(set);
627
628         set->set_obd = obd;
629         set->set_oi = oinfo;
630
631         /* We only get block data from the OBD */
632         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
633                 struct lov_request *req;
634
635                 if (lov->lov_tgts[i] == NULL ||
636                     (oinfo->oi_flags & OBD_STATFS_NODELAY &&
637                      !lov->lov_tgts[i]->ltd_active)) {
638                         CDEBUG(D_HA, "lov idx %d inactive\n", i);
639                         continue;
640                 }
641
642                 if (!lov->lov_tgts[i]->ltd_active)
643                         lov_check_and_wait_active(lov, i);
644
645                 /* skip targets that have been explicitely disabled by the
646                  * administrator */
647                 if (!lov->lov_tgts[i]->ltd_exp) {
648                         CDEBUG(D_HA, "lov idx %d administratively disabled\n", i);
649                         continue;
650                 }
651
652                 OBD_ALLOC(req, sizeof(*req));
653                 if (req == NULL)
654                         GOTO(out_set, rc = -ENOMEM);
655
656                 OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs));
657                 if (req->rq_oi.oi_osfs == NULL) {
658                         OBD_FREE(req, sizeof(*req));
659                         GOTO(out_set, rc = -ENOMEM);
660                 }
661
662                 req->rq_idx = i;
663                 req->rq_oi.oi_cb_up = cb_statfs_update;
664                 req->rq_oi.oi_flags = oinfo->oi_flags;
665
666                 lov_set_add_req(req, set);
667         }
668         if (!set->set_count)
669                 GOTO(out_set, rc = -EIO);
670         *reqset = set;
671         RETURN(rc);
672 out_set:
673         lov_fini_statfs_set(set);
674         RETURN(rc);
675 }