1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
6 * This file is part of the Lustre file system, http://www.lustre.org
7 * Lustre is a trademark of Cluster File Systems, Inc.
9 * You may have signed or agreed to another license before downloading
10 * this software. If so, you are bound by the terms and conditions
11 * of that agreement, and the following does not apply to you. See the
12 * LICENSE file included with this distribution for more information.
14 * If you did not agree to a different license, then this copy of Lustre
15 * is open source software; you can redistribute it and/or modify it
16 * under the terms of version 2 of the GNU General Public License as
17 * published by the Free Software Foundation.
19 * In either case, Lustre is distributed in the hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * license text for more details.
26 # define EXPORT_SYMTAB
28 #define DEBUG_SUBSYSTEM S_LOV
31 #include <libcfs/libcfs.h>
33 #include <liblustre.h>
36 #include <obd_class.h>
38 #include <lustre/lustre_idl.h>
40 #include "lov_internal.h"
42 static void lov_init_set(struct lov_request_set *set)
45 set->set_completes = 0;
48 CFS_INIT_LIST_HEAD(&set->set_list);
49 atomic_set(&set->set_refcount, 1);
52 static void lov_finish_set(struct lov_request_set *set)
54 struct list_head *pos, *n;
58 list_for_each_safe(pos, n, &set->set_list) {
59 struct lov_request *req = list_entry(pos, struct lov_request,
61 list_del_init(&req->rq_link);
64 OBDO_FREE(req->rq_oi.oi_oa);
66 OBD_FREE(req->rq_oi.oi_md, req->rq_buflen);
67 if (req->rq_oi.oi_osfs)
68 OBD_FREE(req->rq_oi.oi_osfs,
69 sizeof(*req->rq_oi.oi_osfs));
70 OBD_FREE(req, sizeof(*req));
74 int len = set->set_oabufs * sizeof(*set->set_pga);
75 OBD_FREE(set->set_pga, len);
78 lov_llh_put(set->set_lockh);
80 OBD_FREE(set, sizeof(*set));
84 void lov_update_set(struct lov_request_set *set,
85 struct lov_request *req, int rc)
95 int lov_update_common_set(struct lov_request_set *set,
96 struct lov_request *req, int rc)
98 struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
101 lov_update_set(set, req, rc);
103 /* grace error on inactive ost */
104 if (rc && !(lov->lov_tgts[req->rq_idx] &&
105 lov->lov_tgts[req->rq_idx]->ltd_active))
108 /* FIXME in raid1 regime, should return 0 */
112 void lov_set_add_req(struct lov_request *req, struct lov_request_set *set)
114 list_add_tail(&req->rq_link, &set->set_list);
118 int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc)
120 struct lov_request_set *set = req->rq_rqset;
121 struct lustre_handle *lov_lockhp;
122 struct lov_oinfo *loi;
125 LASSERT(set != NULL);
126 LASSERT(set->set_oi != NULL);
128 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
129 loi = set->set_oi->oi_md->lsm_oinfo[req->rq_stripe];
131 /* XXX LOV STACKING: OSC gets a copy, created in lov_prep_enqueue_set
132 * and that copy can be arbitrarily out of date.
134 * The LOV API is due for a serious rewriting anyways, and this
135 * can be addressed then. */
137 if (rc == ELDLM_OK) {
138 struct ldlm_lock *lock = ldlm_handle2lock(lov_lockhp);
141 LASSERT(lock != NULL);
142 lov_stripe_lock(set->set_oi->oi_md);
143 loi->loi_lvb = req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb;
144 tmp = loi->loi_lvb.lvb_size;
145 /* Extend KMS up to the end of this lock and no further
146 * A lock on [x,y] means a KMS of up to y + 1 bytes! */
147 if (tmp > lock->l_policy_data.l_extent.end)
148 tmp = lock->l_policy_data.l_extent.end + 1;
149 if (tmp >= loi->loi_kms) {
150 LDLM_DEBUG(lock, "lock acquired, setting rss="LPU64
151 ", kms="LPU64, loi->loi_lvb.lvb_size, tmp);
153 loi->loi_kms_valid = 1;
155 LDLM_DEBUG(lock, "lock acquired, setting rss="
156 LPU64"; leaving kms="LPU64", end="LPU64,
157 loi->loi_lvb.lvb_size, loi->loi_kms,
158 lock->l_policy_data.l_extent.end);
160 lov_stripe_unlock(set->set_oi->oi_md);
161 ldlm_lock_allow_match(lock);
163 } else if ((rc == ELDLM_LOCK_ABORTED) &&
164 (set->set_oi->oi_flags & LDLM_FL_HAS_INTENT)) {
165 memset(lov_lockhp, 0, sizeof(*lov_lockhp));
166 lov_stripe_lock(set->set_oi->oi_md);
167 loi->loi_lvb = req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb;
168 lov_stripe_unlock(set->set_oi->oi_md);
169 CDEBUG(D_INODE, "glimpsed, setting rss="LPU64"; leaving"
170 " kms="LPU64"\n", loi->loi_lvb.lvb_size, loi->loi_kms);
173 struct obd_export *exp = set->set_exp;
174 struct lov_obd *lov = &exp->exp_obd->u.lov;
176 memset(lov_lockhp, 0, sizeof(*lov_lockhp));
177 if (lov->lov_tgts[req->rq_idx] &&
178 lov->lov_tgts[req->rq_idx]->ltd_active) {
180 CERROR("enqueue objid "LPX64" subobj "
181 LPX64" on OST idx %d: rc %d\n",
182 set->set_oi->oi_md->lsm_object_id,
183 loi->loi_id, loi->loi_ost_idx, rc);
188 lov_update_set(set, req, rc);
192 /* The callback for osc_enqueue that updates lov info for every OSC request. */
193 static int cb_update_enqueue(struct obd_info *oinfo, int rc)
195 struct ldlm_enqueue_info *einfo;
196 struct lov_request *lovreq;
198 lovreq = container_of(oinfo, struct lov_request, rq_oi);
199 einfo = lovreq->rq_rqset->set_ei;
200 return lov_update_enqueue_set(lovreq, einfo->ei_mode, rc);
203 static int enqueue_done(struct lov_request_set *set, __u32 mode)
205 struct lov_request *req;
206 struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
210 /* enqueue/match success, just return */
211 if (set->set_completes && set->set_completes == set->set_success)
214 /* cancel enqueued/matched locks */
215 list_for_each_entry(req, &set->set_list, rq_link) {
216 struct lustre_handle *lov_lockhp;
218 if (!req->rq_complete || req->rq_rc)
221 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
223 if (!lustre_handle_is_used(lov_lockhp))
226 rc = obd_cancel(lov->lov_tgts[req->rq_idx]->ltd_exp,
227 req->rq_oi.oi_md, mode, lov_lockhp);
228 if (rc && lov->lov_tgts[req->rq_idx] &&
229 lov->lov_tgts[req->rq_idx]->ltd_active)
230 CERROR("cancelling obdjid "LPX64" on OST "
231 "idx %d error: rc = %d\n",
232 req->rq_oi.oi_md->lsm_object_id,
236 lov_llh_put(set->set_lockh);
240 int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc,
241 struct ptlrpc_request_set *rqset)
248 LASSERT(set->set_exp);
249 /* Do enqueue_done only for sync requests and if any request
253 set->set_completes = 0;
254 ret = enqueue_done(set, mode);
255 } else if (set->set_lockh)
256 lov_llh_put(set->set_lockh);
258 if (atomic_dec_and_test(&set->set_refcount))
261 RETURN(rc ? rc : ret);
264 int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo,
265 struct ldlm_enqueue_info *einfo,
266 struct lov_request_set **reqset)
268 struct lov_obd *lov = &exp->exp_obd->u.lov;
269 struct lov_request_set *set;
273 OBD_ALLOC(set, sizeof(*set));
281 set->set_lockh = lov_llh_new(oinfo->oi_md);
282 if (set->set_lockh == NULL)
283 GOTO(out_set, rc = -ENOMEM);
284 oinfo->oi_lockh->cookie = set->set_lockh->llh_handle.h_cookie;
286 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
287 struct lov_oinfo *loi;
288 struct lov_request *req;
291 loi = oinfo->oi_md->lsm_oinfo[i];
292 if (!lov_stripe_intersects(oinfo->oi_md, i,
293 oinfo->oi_policy.l_extent.start,
294 oinfo->oi_policy.l_extent.end,
298 if (!lov->lov_tgts[loi->loi_ost_idx] ||
299 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
300 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
304 OBD_ALLOC(req, sizeof(*req));
306 GOTO(out_set, rc = -ENOMEM);
308 req->rq_buflen = sizeof(*req->rq_oi.oi_md) +
309 sizeof(struct lov_oinfo *) +
310 sizeof(struct lov_oinfo);
311 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
312 if (req->rq_oi.oi_md == NULL) {
313 OBD_FREE(req, sizeof(*req));
314 GOTO(out_set, rc = -ENOMEM);
316 req->rq_oi.oi_md->lsm_oinfo[0] =
317 ((void *)req->rq_oi.oi_md) + sizeof(*req->rq_oi.oi_md) +
318 sizeof(struct lov_oinfo *);
322 /* Set lov request specific parameters. */
323 req->rq_oi.oi_lockh = set->set_lockh->llh_handles + i;
324 req->rq_oi.oi_cb_up = cb_update_enqueue;
325 req->rq_oi.oi_flags = oinfo->oi_flags;
327 LASSERT(req->rq_oi.oi_lockh);
329 req->rq_oi.oi_policy.l_extent.gid =
330 oinfo->oi_policy.l_extent.gid;
331 req->rq_oi.oi_policy.l_extent.start = start;
332 req->rq_oi.oi_policy.l_extent.end = end;
334 req->rq_idx = loi->loi_ost_idx;
337 /* XXX LOV STACKING: submd should be from the subobj */
338 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
339 req->rq_oi.oi_md->lsm_object_gr = oinfo->oi_md->lsm_object_gr;
340 req->rq_oi.oi_md->lsm_stripe_count = 0;
341 req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms_valid =
343 req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms = loi->loi_kms;
344 req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb = loi->loi_lvb;
346 lov_set_add_req(req, set);
349 GOTO(out_set, rc = -EIO);
353 lov_fini_enqueue_set(set, einfo->ei_mode, rc, NULL);
357 int lov_update_match_set(struct lov_request_set *set, struct lov_request *req,
367 lov_update_set(set, req, ret);
371 int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags)
378 LASSERT(set->set_exp);
379 rc = enqueue_done(set, mode);
380 if ((set->set_count == set->set_success) &&
381 (flags & LDLM_FL_TEST_LOCK))
382 lov_llh_put(set->set_lockh);
384 if (atomic_dec_and_test(&set->set_refcount))
390 int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo,
391 struct lov_stripe_md *lsm, ldlm_policy_data_t *policy,
392 __u32 mode, struct lustre_handle *lockh,
393 struct lov_request_set **reqset)
395 struct lov_obd *lov = &exp->exp_obd->u.lov;
396 struct lov_request_set *set;
400 OBD_ALLOC(set, sizeof(*set));
407 set->set_oi->oi_md = lsm;
408 set->set_lockh = lov_llh_new(lsm);
409 if (set->set_lockh == NULL)
410 GOTO(out_set, rc = -ENOMEM);
411 lockh->cookie = set->set_lockh->llh_handle.h_cookie;
413 for (i = 0; i < lsm->lsm_stripe_count; i++){
414 struct lov_oinfo *loi;
415 struct lov_request *req;
418 loi = lsm->lsm_oinfo[i];
419 if (!lov_stripe_intersects(lsm, i, policy->l_extent.start,
420 policy->l_extent.end, &start, &end))
423 /* FIXME raid1 should grace this error */
424 if (!lov->lov_tgts[loi->loi_ost_idx] ||
425 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
426 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
427 GOTO(out_set, rc = -EIO);
430 OBD_ALLOC(req, sizeof(*req));
432 GOTO(out_set, rc = -ENOMEM);
434 req->rq_buflen = sizeof(*req->rq_oi.oi_md);
435 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
436 if (req->rq_oi.oi_md == NULL) {
437 OBD_FREE(req, sizeof(*req));
438 GOTO(out_set, rc = -ENOMEM);
441 req->rq_oi.oi_policy.l_extent.start = start;
442 req->rq_oi.oi_policy.l_extent.end = end;
443 req->rq_oi.oi_policy.l_extent.gid = policy->l_extent.gid;
445 req->rq_idx = loi->loi_ost_idx;
448 /* XXX LOV STACKING: submd should be from the subobj */
449 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
450 req->rq_oi.oi_md->lsm_object_gr = lsm->lsm_object_gr;
451 req->rq_oi.oi_md->lsm_stripe_count = 0;
453 lov_set_add_req(req, set);
456 GOTO(out_set, rc = -EIO);
460 lov_fini_match_set(set, mode, 0);
464 int lov_fini_cancel_set(struct lov_request_set *set)
472 LASSERT(set->set_exp);
474 lov_llh_put(set->set_lockh);
476 if (atomic_dec_and_test(&set->set_refcount))
482 int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo,
483 struct lov_stripe_md *lsm, __u32 mode,
484 struct lustre_handle *lockh,
485 struct lov_request_set **reqset)
487 struct lov_request_set *set;
491 OBD_ALLOC(set, sizeof(*set));
498 set->set_oi->oi_md = lsm;
499 set->set_lockh = lov_handle2llh(lockh);
500 if (set->set_lockh == NULL) {
501 CERROR("LOV: invalid lov lock handle %p\n", lockh);
502 GOTO(out_set, rc = -EINVAL);
504 lockh->cookie = set->set_lockh->llh_handle.h_cookie;
506 for (i = 0; i < lsm->lsm_stripe_count; i++){
507 struct lov_request *req;
508 struct lustre_handle *lov_lockhp;
509 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
511 lov_lockhp = set->set_lockh->llh_handles + i;
512 if (!lustre_handle_is_used(lov_lockhp)) {
513 CDEBUG(D_RPCTRACE,"lov idx %d subobj "LPX64" no lock\n",
514 loi->loi_ost_idx, loi->loi_id);
518 OBD_ALLOC(req, sizeof(*req));
520 GOTO(out_set, rc = -ENOMEM);
522 req->rq_buflen = sizeof(*req->rq_oi.oi_md);
523 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
524 if (req->rq_oi.oi_md == NULL) {
525 OBD_FREE(req, sizeof(*req));
526 GOTO(out_set, rc = -ENOMEM);
529 req->rq_idx = loi->loi_ost_idx;
532 /* XXX LOV STACKING: submd should be from the subobj */
533 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
534 req->rq_oi.oi_md->lsm_object_gr = lsm->lsm_object_gr;
535 req->rq_oi.oi_md->lsm_stripe_count = 0;
537 lov_set_add_req(req, set);
540 GOTO(out_set, rc = -EIO);
544 lov_fini_cancel_set(set);
548 static int create_done(struct obd_export *exp, struct lov_request_set *set,
549 struct lov_stripe_md **lsmp)
551 struct lov_obd *lov = &exp->exp_obd->u.lov;
552 struct obd_trans_info *oti = set->set_oti;
553 struct obdo *src_oa = set->set_oi->oi_oa;
554 struct lov_request *req;
555 struct obdo *ret_oa = NULL;
556 int attrset = 0, rc = 0;
559 LASSERT(set->set_completes);
561 /* try alloc objects on other osts if osc_create fails for
562 * exceptions: RPC failure, ENOSPC, etc */
563 if (set->set_count != set->set_success) {
564 list_for_each_entry (req, &set->set_list, rq_link) {
568 set->set_completes--;
569 req->rq_complete = 0;
571 rc = qos_remedy_create(set, req);
572 lov_update_create_set(set, req, rc);
579 /* no successful creates */
580 if (set->set_success == 0)
583 /* If there was an explicit stripe set, fail. Otherwise, we
584 * got some objects and that's not bad. */
585 if (set->set_count != set->set_success) {
588 set->set_count = set->set_success;
594 GOTO(cleanup, rc = -ENOMEM);
596 list_for_each_entry(req, &set->set_list, rq_link) {
597 if (!req->rq_complete || req->rq_rc)
599 lov_merge_attrs(ret_oa, req->rq_oi.oi_oa,
600 req->rq_oi.oi_oa->o_valid, set->set_oi->oi_md,
601 req->rq_stripe, &attrset);
603 if (src_oa->o_valid & OBD_MD_FLSIZE &&
604 ret_oa->o_size != src_oa->o_size) {
605 CERROR("original size "LPU64" isn't new object size "LPU64"\n",
606 src_oa->o_size, ret_oa->o_size);
609 ret_oa->o_id = src_oa->o_id;
610 ret_oa->o_gr = src_oa->o_gr;
611 ret_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
612 memcpy(src_oa, ret_oa, sizeof(*src_oa));
615 *lsmp = set->set_oi->oi_md;
619 list_for_each_entry(req, &set->set_list, rq_link) {
620 struct obd_export *sub_exp;
623 if (!req->rq_complete || req->rq_rc)
626 sub_exp = lov->lov_tgts[req->rq_idx]->ltd_exp;
627 err = obd_destroy(sub_exp, req->rq_oi.oi_oa, NULL, oti, NULL);
629 CERROR("Failed to uncreate objid "LPX64" subobj "
630 LPX64" on OST idx %d: rc = %d\n",
631 src_oa->o_id, req->rq_oi.oi_oa->o_id,
635 obd_free_memmd(exp, &set->set_oi->oi_md);
637 if (oti && set->set_cookies) {
638 oti->oti_logcookies = set->set_cookies;
639 if (!set->set_cookie_sent) {
640 oti_free_cookies(oti);
641 src_oa->o_valid &= ~OBD_MD_FLCOOKIE;
643 src_oa->o_valid |= OBD_MD_FLCOOKIE;
649 int lov_fini_create_set(struct lov_request_set *set,struct lov_stripe_md **lsmp)
656 LASSERT(set->set_exp);
657 if (set->set_completes)
658 rc = create_done(set->set_exp, set, lsmp);
660 if (atomic_dec_and_test(&set->set_refcount))
666 int lov_update_create_set(struct lov_request_set *set,
667 struct lov_request *req, int rc)
669 struct obd_trans_info *oti = set->set_oti;
670 struct lov_stripe_md *lsm = set->set_oi->oi_md;
671 struct lov_oinfo *loi;
672 struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
675 req->rq_stripe = set->set_success;
676 loi = lsm->lsm_oinfo[req->rq_stripe];
678 if (rc && lov->lov_tgts[req->rq_idx] &&
679 lov->lov_tgts[req->rq_idx]->ltd_active) {
680 CERROR("error creating fid "LPX64" sub-object"
681 " on OST idx %d/%d: rc = %d\n",
682 set->set_oi->oi_oa->o_id, req->rq_idx,
683 lsm->lsm_stripe_count, rc);
685 CERROR("obd_create returned invalid err %d\n", rc);
689 lov_update_set(set, req, rc);
693 loi->loi_id = req->rq_oi.oi_oa->o_id;
694 loi->loi_gr = req->rq_oi.oi_oa->o_gr;
695 loi->loi_ost_idx = req->rq_idx;
696 CDEBUG(D_INODE, "objid "LPX64" has subobj "LPX64"/"LPU64" at idx %d\n",
697 lsm->lsm_object_id, loi->loi_id, loi->loi_id, req->rq_idx);
700 if (oti && set->set_cookies)
701 ++oti->oti_logcookies;
702 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCOOKIE)
703 set->set_cookie_sent++;
708 int lov_prep_create_set(struct obd_export *exp, struct obd_info *oinfo,
709 struct lov_stripe_md **lsmp, struct obdo *src_oa,
710 struct obd_trans_info *oti,
711 struct lov_request_set **reqset)
713 struct lov_request_set *set;
717 OBD_ALLOC(set, sizeof(*set));
724 set->set_oi->oi_md = *lsmp;
725 set->set_oi->oi_oa = src_oa;
728 rc = qos_prep_create(exp, set);
730 lov_fini_create_set(set, lsmp);
736 static int common_attr_done(struct lov_request_set *set)
738 struct list_head *pos;
739 struct lov_request *req;
741 int rc = 0, attrset = 0;
744 LASSERT(set->set_oi != NULL);
746 if (set->set_oi->oi_oa == NULL)
749 if (!set->set_success)
754 GOTO(out, rc = -ENOMEM);
756 list_for_each (pos, &set->set_list) {
757 req = list_entry(pos, struct lov_request, rq_link);
759 if (!req->rq_complete || req->rq_rc)
761 if (req->rq_oi.oi_oa->o_valid == 0) /* inactive stripe */
763 lov_merge_attrs(tmp_oa, req->rq_oi.oi_oa,
764 req->rq_oi.oi_oa->o_valid,
765 set->set_oi->oi_md, req->rq_stripe, &attrset);
768 CERROR("No stripes had valid attrs\n");
771 tmp_oa->o_id = set->set_oi->oi_oa->o_id;
772 memcpy(set->set_oi->oi_oa, tmp_oa, sizeof(*set->set_oi->oi_oa));
780 static int brw_done(struct lov_request_set *set)
782 struct lov_stripe_md *lsm = set->set_oi->oi_md;
783 struct lov_oinfo *loi = NULL;
784 struct list_head *pos;
785 struct lov_request *req;
788 list_for_each (pos, &set->set_list) {
789 req = list_entry(pos, struct lov_request, rq_link);
791 if (!req->rq_complete || req->rq_rc)
794 loi = lsm->lsm_oinfo[req->rq_stripe];
796 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLBLOCKS)
797 loi->loi_lvb.lvb_blocks = req->rq_oi.oi_oa->o_blocks;
803 int lov_fini_brw_set(struct lov_request_set *set)
810 LASSERT(set->set_exp);
811 if (set->set_completes) {
813 /* FIXME update qos data here */
815 if (atomic_dec_and_test(&set->set_refcount))
821 int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo,
822 obd_count oa_bufs, struct brw_page *pga,
823 struct obd_trans_info *oti,
824 struct lov_request_set **reqset)
831 struct lov_request_set *set;
832 struct lov_obd *lov = &exp->exp_obd->u.lov;
833 int rc = 0, i, shift;
836 OBD_ALLOC(set, sizeof(*set));
844 set->set_oabufs = oa_bufs;
845 OBD_ALLOC(set->set_pga, oa_bufs * sizeof(*set->set_pga));
847 GOTO(out, rc = -ENOMEM);
849 OBD_ALLOC(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
851 GOTO(out, rc = -ENOMEM);
853 /* calculate the page count for each stripe */
854 for (i = 0; i < oa_bufs; i++) {
855 int stripe = lov_stripe_number(oinfo->oi_md, pga[i].off);
856 info[stripe].count++;
859 /* alloc and initialize lov request */
861 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++){
862 struct lov_oinfo *loi = NULL;
863 struct lov_request *req;
865 if (info[i].count == 0)
868 loi = oinfo->oi_md->lsm_oinfo[i];
869 if (!lov->lov_tgts[loi->loi_ost_idx] ||
870 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
871 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
872 GOTO(out, rc = -EIO);
875 OBD_ALLOC(req, sizeof(*req));
877 GOTO(out, rc = -ENOMEM);
879 OBDO_ALLOC(req->rq_oi.oi_oa);
880 if (req->rq_oi.oi_oa == NULL) {
881 OBD_FREE(req, sizeof(*req));
882 GOTO(out, rc = -ENOMEM);
886 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
887 sizeof(*req->rq_oi.oi_oa));
889 req->rq_oi.oi_oa->o_id = loi->loi_id;
890 req->rq_oi.oi_oa->o_stripe_idx = i;
892 req->rq_buflen = sizeof(*req->rq_oi.oi_md);
893 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
894 if (req->rq_oi.oi_md == NULL) {
895 OBDO_FREE(req->rq_oi.oi_oa);
896 OBD_FREE(req, sizeof(*req));
897 GOTO(out, rc = -ENOMEM);
900 req->rq_idx = loi->loi_ost_idx;
903 /* XXX LOV STACKING */
904 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
905 req->rq_oi.oi_md->lsm_object_gr = oinfo->oi_md->lsm_object_gr;
906 req->rq_oabufs = info[i].count;
907 req->rq_pgaidx = shift;
908 shift += req->rq_oabufs;
910 /* remember the index for sort brw_page array */
911 info[i].index = req->rq_pgaidx;
913 req->rq_oi.oi_capa = oinfo->oi_capa;
915 lov_set_add_req(req, set);
918 GOTO(out, rc = -EIO);
920 /* rotate & sort the brw_page array */
921 for (i = 0; i < oa_bufs; i++) {
922 int stripe = lov_stripe_number(oinfo->oi_md, pga[i].off);
924 shift = info[stripe].index + info[stripe].off;
925 LASSERT(shift < oa_bufs);
926 set->set_pga[shift] = pga[i];
927 lov_stripe_offset(oinfo->oi_md, pga[i].off, stripe,
928 &set->set_pga[shift].off);
933 OBD_FREE(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
938 lov_fini_brw_set(set);
943 int lov_fini_getattr_set(struct lov_request_set *set)
950 LASSERT(set->set_exp);
951 if (set->set_completes)
952 rc = common_attr_done(set);
954 if (atomic_dec_and_test(&set->set_refcount))
960 /* The callback for osc_getattr_async that finilizes a request info when a
961 * response is recieved. */
962 static int cb_getattr_update(struct obd_info *oinfo, int rc)
964 struct lov_request *lovreq;
965 lovreq = container_of(oinfo, struct lov_request, rq_oi);
966 return lov_update_common_set(lovreq->rq_rqset, lovreq, rc);
969 int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
970 struct lov_request_set **reqset)
972 struct lov_request_set *set;
973 struct lov_obd *lov = &exp->exp_obd->u.lov;
977 OBD_ALLOC(set, sizeof(*set));
985 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
986 struct lov_oinfo *loi;
987 struct lov_request *req;
989 loi = oinfo->oi_md->lsm_oinfo[i];
990 if (!lov->lov_tgts[loi->loi_ost_idx] ||
991 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
992 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
996 OBD_ALLOC(req, sizeof(*req));
998 GOTO(out_set, rc = -ENOMEM);
1001 req->rq_idx = loi->loi_ost_idx;
1003 OBDO_ALLOC(req->rq_oi.oi_oa);
1004 if (req->rq_oi.oi_oa == NULL) {
1005 OBD_FREE(req, sizeof(*req));
1006 GOTO(out_set, rc = -ENOMEM);
1008 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
1009 sizeof(*req->rq_oi.oi_oa));
1010 req->rq_oi.oi_oa->o_id = loi->loi_id;
1011 req->rq_oi.oi_cb_up = cb_getattr_update;
1012 req->rq_oi.oi_capa = oinfo->oi_capa;
1013 req->rq_rqset = set;
1015 lov_set_add_req(req, set);
1017 if (!set->set_count)
1018 GOTO(out_set, rc = -EIO);
1022 lov_fini_getattr_set(set);
1026 int lov_fini_destroy_set(struct lov_request_set *set)
1032 LASSERT(set->set_exp);
1033 if (set->set_completes) {
1034 /* FIXME update qos data here */
1037 if (atomic_dec_and_test(&set->set_refcount))
1038 lov_finish_set(set);
1043 int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
1044 struct obdo *src_oa, struct lov_stripe_md *lsm,
1045 struct obd_trans_info *oti,
1046 struct lov_request_set **reqset)
1048 struct lov_request_set *set;
1049 struct lov_obd *lov = &exp->exp_obd->u.lov;
1053 OBD_ALLOC(set, sizeof(*set));
1059 set->set_oi = oinfo;
1060 set->set_oi->oi_md = lsm;
1061 set->set_oi->oi_oa = src_oa;
1063 if (oti != NULL && src_oa->o_valid & OBD_MD_FLCOOKIE)
1064 set->set_cookies = oti->oti_logcookies;
1066 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1067 struct lov_oinfo *loi;
1068 struct lov_request *req;
1070 loi = lsm->lsm_oinfo[i];
1071 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1072 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1073 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1077 OBD_ALLOC(req, sizeof(*req));
1079 GOTO(out_set, rc = -ENOMEM);
1082 req->rq_idx = loi->loi_ost_idx;
1084 OBDO_ALLOC(req->rq_oi.oi_oa);
1085 if (req->rq_oi.oi_oa == NULL) {
1086 OBD_FREE(req, sizeof(*req));
1087 GOTO(out_set, rc = -ENOMEM);
1089 memcpy(req->rq_oi.oi_oa, src_oa, sizeof(*req->rq_oi.oi_oa));
1090 req->rq_oi.oi_oa->o_id = loi->loi_id;
1091 lov_set_add_req(req, set);
1093 if (!set->set_count)
1094 GOTO(out_set, rc = -EIO);
1098 lov_fini_destroy_set(set);
1102 int lov_fini_setattr_set(struct lov_request_set *set)
1109 LASSERT(set->set_exp);
1110 if (set->set_completes) {
1111 rc = common_attr_done(set);
1112 /* FIXME update qos data here */
1115 if (atomic_dec_and_test(&set->set_refcount))
1116 lov_finish_set(set);
1120 int lov_update_setattr_set(struct lov_request_set *set,
1121 struct lov_request *req, int rc)
1123 struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov;
1124 struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md;
1127 lov_update_set(set, req, rc);
1129 /* grace error on inactive ost */
1130 if (rc && !(lov->lov_tgts[req->rq_idx] &&
1131 lov->lov_tgts[req->rq_idx]->ltd_active))
1135 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCTIME)
1136 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_ctime =
1137 req->rq_oi.oi_oa->o_ctime;
1138 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLMTIME)
1139 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_mtime =
1140 req->rq_oi.oi_oa->o_mtime;
1141 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLATIME)
1142 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_atime =
1143 req->rq_oi.oi_oa->o_atime;
1149 /* The callback for osc_setattr_async that finilizes a request info when a
1150 * response is recieved. */
1151 static int cb_setattr_update(struct obd_info *oinfo, int rc)
1153 struct lov_request *lovreq;
1154 lovreq = container_of(oinfo, struct lov_request, rq_oi);
1155 return lov_update_setattr_set(lovreq->rq_rqset, lovreq, rc);
1158 int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
1159 struct obd_trans_info *oti,
1160 struct lov_request_set **reqset)
1162 struct lov_request_set *set;
1163 struct lov_obd *lov = &exp->exp_obd->u.lov;
1167 OBD_ALLOC(set, sizeof(*set));
1174 set->set_oi = oinfo;
1175 if (oti != NULL && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
1176 set->set_cookies = oti->oti_logcookies;
1178 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
1179 struct lov_oinfo *loi = oinfo->oi_md->lsm_oinfo[i];
1180 struct lov_request *req;
1182 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1183 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1184 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1188 OBD_ALLOC(req, sizeof(*req));
1190 GOTO(out_set, rc = -ENOMEM);
1192 req->rq_idx = loi->loi_ost_idx;
1194 OBDO_ALLOC(req->rq_oi.oi_oa);
1195 if (req->rq_oi.oi_oa == NULL) {
1196 OBD_FREE(req, sizeof(*req));
1197 GOTO(out_set, rc = -ENOMEM);
1199 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
1200 sizeof(*req->rq_oi.oi_oa));
1201 req->rq_oi.oi_oa->o_id = loi->loi_id;
1202 LASSERT(!(req->rq_oi.oi_oa->o_valid & OBD_MD_FLGROUP)
1203 || req->rq_oi.oi_oa->o_gr>0);
1204 req->rq_oi.oi_oa->o_stripe_idx = i;
1205 req->rq_oi.oi_cb_up = cb_setattr_update;
1206 req->rq_oi.oi_capa = oinfo->oi_capa;
1207 req->rq_rqset = set;
1209 if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE) {
1210 int off = lov_stripe_offset(oinfo->oi_md,
1211 oinfo->oi_oa->o_size, i,
1212 &req->rq_oi.oi_oa->o_size);
1214 if (off < 0 && req->rq_oi.oi_oa->o_size)
1215 req->rq_oi.oi_oa->o_size--;
1217 CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n",
1218 i, req->rq_oi.oi_oa->o_size,
1219 oinfo->oi_oa->o_size);
1221 lov_set_add_req(req, set);
1223 if (!set->set_count)
1224 GOTO(out_set, rc = -EIO);
1228 lov_fini_setattr_set(set);
1232 int lov_fini_punch_set(struct lov_request_set *set)
1239 LASSERT(set->set_exp);
1240 if (set->set_completes) {
1242 /* FIXME update qos data here */
1243 if (set->set_success)
1244 rc = common_attr_done(set);
1247 if (atomic_dec_and_test(&set->set_refcount))
1248 lov_finish_set(set);
1253 int lov_update_punch_set(struct lov_request_set *set,
1254 struct lov_request *req, int rc)
1256 struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov;
1257 struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md;
1260 lov_update_set(set, req, rc);
1262 /* grace error on inactive ost */
1263 if (rc && !lov->lov_tgts[req->rq_idx]->ltd_active)
1267 lov_stripe_lock(lsm);
1268 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLBLOCKS) {
1269 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_blocks =
1270 req->rq_oi.oi_oa->o_blocks;
1273 /* Do we need to update lvb_size here? It needn't because
1274 * it have been done in ll_truncate(). -jay */
1275 lov_stripe_unlock(lsm);
1281 /* The callback for osc_punch that finilizes a request info when a response
1283 static int cb_update_punch(struct obd_info *oinfo, int rc)
1285 struct lov_request *lovreq;
1286 lovreq = container_of(oinfo, struct lov_request, rq_oi);
1287 return lov_update_punch_set(lovreq->rq_rqset, lovreq, rc);
1290 int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo,
1291 struct obd_trans_info *oti,
1292 struct lov_request_set **reqset)
1294 struct lov_request_set *set;
1295 struct lov_obd *lov = &exp->exp_obd->u.lov;
1299 OBD_ALLOC(set, sizeof(*set));
1304 set->set_oi = oinfo;
1307 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
1308 struct lov_oinfo *loi = oinfo->oi_md->lsm_oinfo[i];
1309 struct lov_request *req;
1312 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1313 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1314 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1318 if (!lov_stripe_intersects(oinfo->oi_md, i,
1319 oinfo->oi_policy.l_extent.start,
1320 oinfo->oi_policy.l_extent.end,
1324 OBD_ALLOC(req, sizeof(*req));
1326 GOTO(out_set, rc = -ENOMEM);
1328 req->rq_idx = loi->loi_ost_idx;
1330 OBDO_ALLOC(req->rq_oi.oi_oa);
1331 if (req->rq_oi.oi_oa == NULL) {
1332 OBD_FREE(req, sizeof(*req));
1333 GOTO(out_set, rc = -ENOMEM);
1335 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
1336 sizeof(*req->rq_oi.oi_oa));
1337 req->rq_oi.oi_oa->o_id = loi->loi_id;
1338 req->rq_oi.oi_oa->o_gr = loi->loi_gr;
1339 req->rq_oi.oi_oa->o_valid |= OBD_MD_FLGROUP;
1341 req->rq_oi.oi_oa->o_stripe_idx = i;
1342 req->rq_oi.oi_cb_up = cb_update_punch;
1343 req->rq_rqset = set;
1345 req->rq_oi.oi_policy.l_extent.start = rs;
1346 req->rq_oi.oi_policy.l_extent.end = re;
1347 req->rq_oi.oi_policy.l_extent.gid = -1;
1349 req->rq_oi.oi_capa = oinfo->oi_capa;
1351 lov_set_add_req(req, set);
1353 if (!set->set_count)
1354 GOTO(out_set, rc = -EIO);
1358 lov_fini_punch_set(set);
1362 int lov_fini_sync_set(struct lov_request_set *set)
1369 LASSERT(set->set_exp);
1370 if (set->set_completes) {
1371 if (!set->set_success)
1373 /* FIXME update qos data here */
1376 if (atomic_dec_and_test(&set->set_refcount))
1377 lov_finish_set(set);
1382 int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo,
1383 struct obdo *src_oa, struct lov_stripe_md *lsm,
1384 obd_off start, obd_off end,
1385 struct lov_request_set **reqset)
1387 struct lov_request_set *set;
1388 struct lov_obd *lov = &exp->exp_obd->u.lov;
1392 OBD_ALLOC(set, sizeof(*set));
1398 set->set_oi = oinfo;
1399 set->set_oi->oi_md = lsm;
1400 set->set_oi->oi_oa = src_oa;
1402 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1403 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
1404 struct lov_request *req;
1407 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1408 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1409 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1413 if (!lov_stripe_intersects(lsm, i, start, end, &rs, &re))
1416 OBD_ALLOC(req, sizeof(*req));
1418 GOTO(out_set, rc = -ENOMEM);
1420 req->rq_idx = loi->loi_ost_idx;
1422 OBDO_ALLOC(req->rq_oi.oi_oa);
1423 if (req->rq_oi.oi_oa == NULL) {
1424 OBD_FREE(req, sizeof(*req));
1425 GOTO(out_set, rc = -ENOMEM);
1427 memcpy(req->rq_oi.oi_oa, src_oa, sizeof(*req->rq_oi.oi_oa));
1428 req->rq_oi.oi_oa->o_id = loi->loi_id;
1429 req->rq_oi.oi_oa->o_stripe_idx = i;
1431 req->rq_oi.oi_policy.l_extent.start = rs;
1432 req->rq_oi.oi_policy.l_extent.end = re;
1433 req->rq_oi.oi_policy.l_extent.gid = -1;
1435 lov_set_add_req(req, set);
1437 if (!set->set_count)
1438 GOTO(out_set, rc = -EIO);
1442 lov_fini_sync_set(set);
1446 #define LOV_U64_MAX ((__u64)~0ULL)
1447 #define LOV_SUM_MAX(tot, add) \
1449 if ((tot) + (add) < (tot)) \
1450 (tot) = LOV_U64_MAX; \
1455 int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success)
1460 __u32 expected_stripes = lov_get_stripecnt(&obd->u.lov, 0);
1462 if (osfs->os_files != LOV_U64_MAX)
1463 do_div(osfs->os_files, expected_stripes);
1464 if (osfs->os_ffree != LOV_U64_MAX)
1465 do_div(osfs->os_ffree, expected_stripes);
1467 spin_lock(&obd->obd_osfs_lock);
1468 memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
1469 obd->obd_osfs_age = get_jiffies_64();
1470 spin_unlock(&obd->obd_osfs_lock);
1477 int lov_fini_statfs_set(struct lov_request_set *set)
1485 if (set->set_completes) {
1486 rc = lov_fini_statfs(set->set_obd, set->set_oi->oi_osfs,
1490 if (atomic_dec_and_test(&set->set_refcount))
1491 lov_finish_set(set);
1496 void lov_update_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1497 struct obd_statfs *lov_sfs, int success)
1499 int shift = 0, quit = 0;
1501 spin_lock(&obd->obd_osfs_lock);
1502 memcpy(&obd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
1503 obd->obd_osfs_age = get_jiffies_64();
1504 spin_unlock(&obd->obd_osfs_lock);
1507 memcpy(osfs, lov_sfs, sizeof(*lov_sfs));
1509 if (osfs->os_bsize != lov_sfs->os_bsize) {
1510 /* assume all block sizes are always powers of 2 */
1511 /* get the bits difference */
1512 tmp = osfs->os_bsize | lov_sfs->os_bsize;
1513 for (shift = 0; shift <= 64; ++shift) {
1525 if (osfs->os_bsize < lov_sfs->os_bsize) {
1526 osfs->os_bsize = lov_sfs->os_bsize;
1528 osfs->os_bfree >>= shift;
1529 osfs->os_bavail >>= shift;
1530 osfs->os_blocks >>= shift;
1531 } else if (shift != 0) {
1532 lov_sfs->os_bfree >>= shift;
1533 lov_sfs->os_bavail >>= shift;
1534 lov_sfs->os_blocks >>= shift;
1537 /* Sandia requested that df (and so, statfs) only
1538 returned minimal available space on
1539 a single OST, so people would be able to
1540 write this much data guaranteed. */
1541 if (osfs->os_bavail > lov_sfs->os_bavail) {
1542 /* Presumably if new bavail is smaller,
1543 new bfree is bigger as well */
1544 osfs->os_bfree = lov_sfs->os_bfree;
1545 osfs->os_bavail = lov_sfs->os_bavail;
1548 osfs->os_bfree += lov_sfs->os_bfree;
1549 osfs->os_bavail += lov_sfs->os_bavail;
1551 osfs->os_blocks += lov_sfs->os_blocks;
1552 /* XXX not sure about this one - depends on policy.
1553 * - could be minimum if we always stripe on all OBDs
1554 * (but that would be wrong for any other policy,
1555 * if one of the OBDs has no more objects left)
1556 * - could be sum if we stripe whole objects
1557 * - could be average, just to give a nice number
1559 * To give a "reasonable" (if not wholly accurate)
1560 * number, we divide the total number of free objects
1561 * by expected stripe count (watch out for overflow).
1563 LOV_SUM_MAX(osfs->os_files, lov_sfs->os_files);
1564 LOV_SUM_MAX(osfs->os_ffree, lov_sfs->os_ffree);
1568 /* The callback for osc_statfs_async that finilizes a request info when a
1569 * response is recieved. */
1570 static int cb_statfs_update(struct obd_info *oinfo, int rc)
1572 struct lov_request *lovreq;
1573 struct obd_statfs *osfs, *lov_sfs;
1574 struct obd_device *obd;
1575 struct lov_obd *lov;
1579 lovreq = container_of(oinfo, struct lov_request, rq_oi);
1580 lov = &lovreq->rq_rqset->set_obd->u.lov;
1581 obd = class_exp2obd(lov->lov_tgts[lovreq->rq_idx]->ltd_exp);
1583 osfs = lovreq->rq_rqset->set_oi->oi_osfs;
1584 lov_sfs = oinfo->oi_osfs;
1586 success = lovreq->rq_rqset->set_success;
1588 /* XXX: the same is done in lov_update_common_set, however
1589 lovset->set_exp is not initialized. */
1590 lov_update_set(lovreq->rq_rqset, lovreq, rc);
1592 if (rc && !(lov->lov_tgts[lovreq->rq_idx] &&
1593 lov->lov_tgts[lovreq->rq_idx]->ltd_active))
1598 lov_update_statfs(obd, osfs, lov_sfs, success);
1604 int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
1605 struct lov_request_set **reqset)
1607 struct lov_request_set *set;
1608 struct lov_obd *lov = &obd->u.lov;
1612 OBD_ALLOC(set, sizeof(*set));
1618 set->set_oi = oinfo;
1620 /* We only get block data from the OBD */
1621 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
1622 struct lov_request *req;
1624 if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) {
1625 CDEBUG(D_HA, "lov idx %d inactive\n", i);
1629 OBD_ALLOC(req, sizeof(*req));
1631 GOTO(out_set, rc = -ENOMEM);
1633 OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs));
1634 if (req->rq_oi.oi_osfs == NULL) {
1635 OBD_FREE(req, sizeof(*req));
1636 GOTO(out_set, rc = -ENOMEM);
1640 req->rq_oi.oi_cb_up = cb_statfs_update;
1641 req->rq_rqset = set;
1643 lov_set_add_req(req, set);
1645 if (!set->set_count)
1646 GOTO(out_set, rc = -EIO);
1650 lov_fini_statfs_set(set);