1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 # define EXPORT_SYMTAB
40 #define DEBUG_SUBSYSTEM S_LOV
43 #include <libcfs/libcfs.h>
45 #include <liblustre.h>
48 #include <obd_class.h>
50 #include <lustre/lustre_idl.h>
52 #include "lov_internal.h"
54 static void lov_init_set(struct lov_request_set *set)
57 set->set_completes = 0;
60 CFS_INIT_LIST_HEAD(&set->set_list);
61 cfs_atomic_set(&set->set_refcount, 1);
62 cfs_waitq_init(&set->set_waitq);
63 cfs_spin_lock_init(&set->set_lock);
66 void lov_finish_set(struct lov_request_set *set)
72 cfs_list_for_each_safe(pos, n, &set->set_list) {
73 struct lov_request *req = cfs_list_entry(pos,
76 cfs_list_del_init(&req->rq_link);
79 OBDO_FREE(req->rq_oi.oi_oa);
81 OBD_FREE(req->rq_oi.oi_md, req->rq_buflen);
82 if (req->rq_oi.oi_osfs)
83 OBD_FREE(req->rq_oi.oi_osfs,
84 sizeof(*req->rq_oi.oi_osfs));
85 OBD_FREE(req, sizeof(*req));
89 int len = set->set_oabufs * sizeof(*set->set_pga);
90 OBD_FREE(set->set_pga, len);
93 lov_llh_put(set->set_lockh);
95 OBD_FREE(set, sizeof(*set));
99 int lov_finished_set(struct lov_request_set *set)
101 CDEBUG(D_INFO, "check set %d/%d\n", set->set_completes,
103 return set->set_completes == set->set_count;
107 void lov_update_set(struct lov_request_set *set,
108 struct lov_request *req, int rc)
110 req->rq_complete = 1;
113 set->set_completes++;
117 cfs_waitq_signal(&set->set_waitq);
120 int lov_update_common_set(struct lov_request_set *set,
121 struct lov_request *req, int rc)
123 struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
126 lov_update_set(set, req, rc);
128 /* grace error on inactive ost */
129 if (rc && !(lov->lov_tgts[req->rq_idx] &&
130 lov->lov_tgts[req->rq_idx]->ltd_active))
133 /* FIXME in raid1 regime, should return 0 */
137 void lov_set_add_req(struct lov_request *req, struct lov_request_set *set)
139 cfs_list_add_tail(&req->rq_link, &set->set_list);
144 extern void osc_update_enqueue(struct lustre_handle *lov_lockhp,
145 struct lov_oinfo *loi, int flags,
146 struct ost_lvb *lvb, __u32 mode, int rc);
148 static int lov_update_enqueue_lov(struct obd_export *exp,
149 struct lustre_handle *lov_lockhp,
150 struct lov_oinfo *loi, int flags, int idx,
153 struct lov_obd *lov = &exp->exp_obd->u.lov;
155 if (rc != ELDLM_OK &&
156 !(rc == ELDLM_LOCK_ABORTED && (flags & LDLM_FL_HAS_INTENT))) {
157 memset(lov_lockhp, 0, sizeof(*lov_lockhp));
158 if (lov->lov_tgts[idx] && lov->lov_tgts[idx]->ltd_active) {
159 /* -EUSERS used by OST to report file contention */
160 if (rc != -EINTR && rc != -EUSERS)
161 CERROR("enqueue objid "LPX64" subobj "
162 LPX64" on OST idx %d: rc %d\n",
163 oid, loi->loi_id, loi->loi_ost_idx, rc);
170 int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc)
172 struct lov_request_set *set = req->rq_rqset;
173 struct lustre_handle *lov_lockhp;
174 struct obd_info *oi = set->set_oi;
175 struct lov_oinfo *loi;
180 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
181 loi = oi->oi_md->lsm_oinfo[req->rq_stripe];
183 /* XXX LOV STACKING: OSC gets a copy, created in lov_prep_enqueue_set
184 * and that copy can be arbitrarily out of date.
186 * The LOV API is due for a serious rewriting anyways, and this
187 * can be addressed then. */
189 lov_stripe_lock(oi->oi_md);
190 osc_update_enqueue(lov_lockhp, loi, oi->oi_flags,
191 &req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb, mode, rc);
192 if (rc == ELDLM_LOCK_ABORTED && (oi->oi_flags & LDLM_FL_HAS_INTENT))
193 memset(lov_lockhp, 0, sizeof *lov_lockhp);
194 rc = lov_update_enqueue_lov(set->set_exp, lov_lockhp, loi, oi->oi_flags,
195 req->rq_idx, oi->oi_md->lsm_object_id, rc);
196 lov_stripe_unlock(oi->oi_md);
197 lov_update_set(set, req, rc);
201 /* The callback for osc_enqueue that updates lov info for every OSC request. */
202 static int cb_update_enqueue(void *cookie, int rc)
204 struct obd_info *oinfo = cookie;
205 struct ldlm_enqueue_info *einfo;
206 struct lov_request *lovreq;
208 lovreq = container_of(oinfo, struct lov_request, rq_oi);
209 einfo = lovreq->rq_rqset->set_ei;
210 return lov_update_enqueue_set(lovreq, einfo->ei_mode, rc);
213 static int enqueue_done(struct lov_request_set *set, __u32 mode)
215 struct lov_request *req;
216 struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
220 /* enqueue/match success, just return */
221 if (set->set_completes && set->set_completes == set->set_success)
224 /* cancel enqueued/matched locks */
225 cfs_list_for_each_entry(req, &set->set_list, rq_link) {
226 struct lustre_handle *lov_lockhp;
228 if (!req->rq_complete || req->rq_rc)
231 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
233 if (!lustre_handle_is_used(lov_lockhp))
236 rc = obd_cancel(lov->lov_tgts[req->rq_idx]->ltd_exp,
237 req->rq_oi.oi_md, mode, lov_lockhp);
238 if (rc && lov->lov_tgts[req->rq_idx] &&
239 lov->lov_tgts[req->rq_idx]->ltd_active)
240 CERROR("cancelling obdjid "LPX64" on OST "
241 "idx %d error: rc = %d\n",
242 req->rq_oi.oi_md->lsm_object_id,
246 lov_llh_put(set->set_lockh);
250 int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc,
251 struct ptlrpc_request_set *rqset)
258 LASSERT(set->set_exp);
259 /* Do enqueue_done only for sync requests and if any request
263 set->set_completes = 0;
264 ret = enqueue_done(set, mode);
265 } else if (set->set_lockh)
266 lov_llh_put(set->set_lockh);
270 RETURN(rc ? rc : ret);
273 int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo,
274 struct ldlm_enqueue_info *einfo,
275 struct lov_request_set **reqset)
277 struct lov_obd *lov = &exp->exp_obd->u.lov;
278 struct lov_request_set *set;
282 OBD_ALLOC(set, sizeof(*set));
290 set->set_lockh = lov_llh_new(oinfo->oi_md);
291 if (set->set_lockh == NULL)
292 GOTO(out_set, rc = -ENOMEM);
293 oinfo->oi_lockh->cookie = set->set_lockh->llh_handle.h_cookie;
295 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
296 struct lov_oinfo *loi;
297 struct lov_request *req;
300 loi = oinfo->oi_md->lsm_oinfo[i];
301 if (!lov_stripe_intersects(oinfo->oi_md, i,
302 oinfo->oi_policy.l_extent.start,
303 oinfo->oi_policy.l_extent.end,
307 if (!lov->lov_tgts[loi->loi_ost_idx] ||
308 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
309 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
313 OBD_ALLOC(req, sizeof(*req));
315 GOTO(out_set, rc = -ENOMEM);
317 req->rq_buflen = sizeof(*req->rq_oi.oi_md) +
318 sizeof(struct lov_oinfo *) +
319 sizeof(struct lov_oinfo);
320 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
321 if (req->rq_oi.oi_md == NULL) {
322 OBD_FREE(req, sizeof(*req));
323 GOTO(out_set, rc = -ENOMEM);
325 req->rq_oi.oi_md->lsm_oinfo[0] =
326 ((void *)req->rq_oi.oi_md) + sizeof(*req->rq_oi.oi_md) +
327 sizeof(struct lov_oinfo *);
329 /* Set lov request specific parameters. */
330 req->rq_oi.oi_lockh = set->set_lockh->llh_handles + i;
331 req->rq_oi.oi_cb_up = cb_update_enqueue;
332 req->rq_oi.oi_flags = oinfo->oi_flags;
334 LASSERT(req->rq_oi.oi_lockh);
336 req->rq_oi.oi_policy.l_extent.gid =
337 oinfo->oi_policy.l_extent.gid;
338 req->rq_oi.oi_policy.l_extent.start = start;
339 req->rq_oi.oi_policy.l_extent.end = end;
341 req->rq_idx = loi->loi_ost_idx;
344 /* XXX LOV STACKING: submd should be from the subobj */
345 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
346 req->rq_oi.oi_md->lsm_object_seq = loi->loi_seq;
347 req->rq_oi.oi_md->lsm_stripe_count = 0;
348 req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms_valid =
350 req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms = loi->loi_kms;
351 req->rq_oi.oi_md->lsm_oinfo[0]->loi_lvb = loi->loi_lvb;
353 lov_set_add_req(req, set);
356 GOTO(out_set, rc = -EIO);
360 lov_fini_enqueue_set(set, einfo->ei_mode, rc, NULL);
364 int lov_update_match_set(struct lov_request_set *set, struct lov_request *req,
374 lov_update_set(set, req, ret);
378 int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags)
385 LASSERT(set->set_exp);
386 rc = enqueue_done(set, mode);
387 if ((set->set_count == set->set_success) &&
388 (flags & LDLM_FL_TEST_LOCK))
389 lov_llh_put(set->set_lockh);
396 int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo,
397 struct lov_stripe_md *lsm, ldlm_policy_data_t *policy,
398 __u32 mode, struct lustre_handle *lockh,
399 struct lov_request_set **reqset)
401 struct lov_obd *lov = &exp->exp_obd->u.lov;
402 struct lov_request_set *set;
406 OBD_ALLOC(set, sizeof(*set));
413 set->set_oi->oi_md = lsm;
414 set->set_lockh = lov_llh_new(lsm);
415 if (set->set_lockh == NULL)
416 GOTO(out_set, rc = -ENOMEM);
417 lockh->cookie = set->set_lockh->llh_handle.h_cookie;
419 for (i = 0; i < lsm->lsm_stripe_count; i++){
420 struct lov_oinfo *loi;
421 struct lov_request *req;
424 loi = lsm->lsm_oinfo[i];
425 if (!lov_stripe_intersects(lsm, i, policy->l_extent.start,
426 policy->l_extent.end, &start, &end))
429 /* FIXME raid1 should grace this error */
430 if (!lov->lov_tgts[loi->loi_ost_idx] ||
431 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
432 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
433 GOTO(out_set, rc = -EIO);
436 OBD_ALLOC(req, sizeof(*req));
438 GOTO(out_set, rc = -ENOMEM);
440 req->rq_buflen = sizeof(*req->rq_oi.oi_md);
441 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
442 if (req->rq_oi.oi_md == NULL) {
443 OBD_FREE(req, sizeof(*req));
444 GOTO(out_set, rc = -ENOMEM);
447 req->rq_oi.oi_policy.l_extent.start = start;
448 req->rq_oi.oi_policy.l_extent.end = end;
449 req->rq_oi.oi_policy.l_extent.gid = policy->l_extent.gid;
451 req->rq_idx = loi->loi_ost_idx;
454 /* XXX LOV STACKING: submd should be from the subobj */
455 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
456 req->rq_oi.oi_md->lsm_object_seq = loi->loi_seq;
457 req->rq_oi.oi_md->lsm_stripe_count = 0;
459 lov_set_add_req(req, set);
462 GOTO(out_set, rc = -EIO);
466 lov_fini_match_set(set, mode, 0);
470 int lov_fini_cancel_set(struct lov_request_set *set)
478 LASSERT(set->set_exp);
480 lov_llh_put(set->set_lockh);
487 int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo,
488 struct lov_stripe_md *lsm, __u32 mode,
489 struct lustre_handle *lockh,
490 struct lov_request_set **reqset)
492 struct lov_request_set *set;
496 OBD_ALLOC(set, sizeof(*set));
503 set->set_oi->oi_md = lsm;
504 set->set_lockh = lov_handle2llh(lockh);
505 if (set->set_lockh == NULL) {
506 CERROR("LOV: invalid lov lock handle %p\n", lockh);
507 GOTO(out_set, rc = -EINVAL);
509 lockh->cookie = set->set_lockh->llh_handle.h_cookie;
511 for (i = 0; i < lsm->lsm_stripe_count; i++){
512 struct lov_request *req;
513 struct lustre_handle *lov_lockhp;
514 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
516 lov_lockhp = set->set_lockh->llh_handles + i;
517 if (!lustre_handle_is_used(lov_lockhp)) {
518 CDEBUG(D_INFO, "lov idx %d subobj "LPX64" no lock\n",
519 loi->loi_ost_idx, loi->loi_id);
523 OBD_ALLOC(req, sizeof(*req));
525 GOTO(out_set, rc = -ENOMEM);
527 req->rq_buflen = sizeof(*req->rq_oi.oi_md);
528 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
529 if (req->rq_oi.oi_md == NULL) {
530 OBD_FREE(req, sizeof(*req));
531 GOTO(out_set, rc = -ENOMEM);
534 req->rq_idx = loi->loi_ost_idx;
537 /* XXX LOV STACKING: submd should be from the subobj */
538 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
539 req->rq_oi.oi_md->lsm_object_seq = loi->loi_seq;
540 req->rq_oi.oi_md->lsm_stripe_count = 0;
542 lov_set_add_req(req, set);
545 GOTO(out_set, rc = -EIO);
549 lov_fini_cancel_set(set);
553 static int create_done(struct obd_export *exp, struct lov_request_set *set,
554 struct lov_stripe_md **lsmp)
556 struct lov_obd *lov = &exp->exp_obd->u.lov;
557 struct obd_trans_info *oti = set->set_oti;
558 struct obdo *src_oa = set->set_oi->oi_oa;
559 struct lov_request *req;
560 struct obdo *ret_oa = NULL;
561 int attrset = 0, rc = 0;
564 LASSERT(set->set_completes);
566 /* try alloc objects on other osts if osc_create fails for
567 * exceptions: RPC failure, ENOSPC, etc */
568 if (set->set_count != set->set_success) {
569 cfs_list_for_each_entry (req, &set->set_list, rq_link) {
573 set->set_completes--;
574 req->rq_complete = 0;
576 rc = qos_remedy_create(set, req);
577 lov_update_create_set(set, req, rc);
581 /* no successful creates */
582 if (set->set_success == 0)
585 if (set->set_count != set->set_success) {
586 set->set_count = set->set_success;
592 GOTO(cleanup, rc = -ENOMEM);
594 cfs_list_for_each_entry(req, &set->set_list, rq_link) {
595 if (!req->rq_complete || req->rq_rc)
597 lov_merge_attrs(ret_oa, req->rq_oi.oi_oa,
598 req->rq_oi.oi_oa->o_valid, set->set_oi->oi_md,
599 req->rq_stripe, &attrset);
601 if (src_oa->o_valid & OBD_MD_FLSIZE &&
602 ret_oa->o_size != src_oa->o_size) {
603 CERROR("original size "LPU64" isn't new object size "LPU64"\n",
604 src_oa->o_size, ret_oa->o_size);
607 ret_oa->o_id = src_oa->o_id;
608 ret_oa->o_seq = src_oa->o_seq;
609 ret_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
610 memcpy(src_oa, ret_oa, sizeof(*src_oa));
613 *lsmp = set->set_oi->oi_md;
617 cfs_list_for_each_entry(req, &set->set_list, rq_link) {
618 struct obd_export *sub_exp;
621 if (!req->rq_complete || req->rq_rc)
624 sub_exp = lov->lov_tgts[req->rq_idx]->ltd_exp;
625 err = obd_destroy(sub_exp, req->rq_oi.oi_oa, NULL, oti, NULL,
628 CERROR("Failed to uncreate objid "LPX64" subobj "
629 LPX64" on OST idx %d: rc = %d\n",
630 src_oa->o_id, req->rq_oi.oi_oa->o_id,
634 obd_free_memmd(exp, &set->set_oi->oi_md);
636 if (oti && set->set_cookies) {
637 oti->oti_logcookies = set->set_cookies;
638 if (!set->set_cookie_sent) {
639 oti_free_cookies(oti);
640 src_oa->o_valid &= ~OBD_MD_FLCOOKIE;
642 src_oa->o_valid |= OBD_MD_FLCOOKIE;
648 int lov_fini_create_set(struct lov_request_set *set,struct lov_stripe_md **lsmp)
655 LASSERT(set->set_exp);
656 if (set->set_completes)
657 rc = create_done(set->set_exp, set, lsmp);
663 int lov_update_create_set(struct lov_request_set *set,
664 struct lov_request *req, int rc)
666 struct obd_trans_info *oti = set->set_oti;
667 struct lov_stripe_md *lsm = set->set_oi->oi_md;
668 struct lov_oinfo *loi;
669 struct lov_obd *lov = &set->set_exp->exp_obd->u.lov;
672 if (rc && lov->lov_tgts[req->rq_idx] &&
673 lov->lov_tgts[req->rq_idx]->ltd_active) {
674 CERROR("error creating fid "LPX64" sub-object"
675 " on OST idx %d/%d: rc = %d\n",
676 set->set_oi->oi_oa->o_id, req->rq_idx,
677 lsm->lsm_stripe_count, rc);
679 CERROR("obd_create returned invalid err %d\n", rc);
684 cfs_spin_lock(&set->set_lock);
685 req->rq_stripe = set->set_success;
686 loi = lsm->lsm_oinfo[req->rq_stripe];
688 lov_update_set(set, req, rc);
689 cfs_spin_unlock(&set->set_lock);
693 loi->loi_id = req->rq_oi.oi_oa->o_id;
694 loi->loi_seq = req->rq_oi.oi_oa->o_seq;
695 loi->loi_ost_idx = req->rq_idx;
698 if (oti && set->set_cookies)
699 ++oti->oti_logcookies;
700 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCOOKIE)
701 set->set_cookie_sent++;
703 lov_update_set(set, req, rc);
704 cfs_spin_unlock(&set->set_lock);
706 CDEBUG(D_INODE, "objid "LPX64" has subobj "LPX64"/"LPU64" at idx %d\n",
707 lsm->lsm_object_id, loi->loi_id, loi->loi_id, req->rq_idx);
711 int cb_create_update(void *cookie, int rc)
713 struct obd_info *oinfo = cookie;
714 struct lov_request *lovreq;
716 lovreq = container_of(oinfo, struct lov_request, rq_oi);
717 rc= lov_update_create_set(lovreq->rq_rqset, lovreq, rc);
718 if (lov_finished_set(lovreq->rq_rqset))
719 lov_put_reqset(lovreq->rq_rqset);
724 int lov_prep_create_set(struct obd_export *exp, struct obd_info *oinfo,
725 struct lov_stripe_md **lsmp, struct obdo *src_oa,
726 struct obd_trans_info *oti,
727 struct lov_request_set **reqset)
729 struct lov_request_set *set;
733 OBD_ALLOC(set, sizeof(*set));
740 set->set_oi->oi_md = *lsmp;
741 set->set_oi->oi_oa = src_oa;
745 rc = qos_prep_create(exp, set);
746 /* qos_shrink_lsm() may have allocated a new lsm */
747 *lsmp = oinfo->oi_md;
749 lov_fini_create_set(set, lsmp);
757 static int common_attr_done(struct lov_request_set *set)
760 struct lov_request *req;
762 int rc = 0, attrset = 0;
765 LASSERT(set->set_oi != NULL);
767 if (set->set_oi->oi_oa == NULL)
770 if (!set->set_success)
775 GOTO(out, rc = -ENOMEM);
777 cfs_list_for_each (pos, &set->set_list) {
778 req = cfs_list_entry(pos, struct lov_request, rq_link);
780 if (!req->rq_complete || req->rq_rc)
782 if (req->rq_oi.oi_oa->o_valid == 0) /* inactive stripe */
784 lov_merge_attrs(tmp_oa, req->rq_oi.oi_oa,
785 req->rq_oi.oi_oa->o_valid,
786 set->set_oi->oi_md, req->rq_stripe, &attrset);
789 CERROR("No stripes had valid attrs\n");
792 if ((set->set_oi->oi_oa->o_valid & OBD_MD_FLEPOCH) &&
793 (set->set_oi->oi_md->lsm_stripe_count != attrset)) {
794 /* When we take attributes of some epoch, we require all the
795 * ost to be active. */
796 CERROR("Not all the stripes had valid attrs\n");
797 GOTO(out, rc = -EIO);
800 tmp_oa->o_id = set->set_oi->oi_oa->o_id;
801 memcpy(set->set_oi->oi_oa, tmp_oa, sizeof(*set->set_oi->oi_oa));
809 static int brw_done(struct lov_request_set *set)
811 struct lov_stripe_md *lsm = set->set_oi->oi_md;
812 struct lov_oinfo *loi = NULL;
814 struct lov_request *req;
817 cfs_list_for_each (pos, &set->set_list) {
818 req = cfs_list_entry(pos, struct lov_request, rq_link);
820 if (!req->rq_complete || req->rq_rc)
823 loi = lsm->lsm_oinfo[req->rq_stripe];
825 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLBLOCKS)
826 loi->loi_lvb.lvb_blocks = req->rq_oi.oi_oa->o_blocks;
832 int lov_fini_brw_set(struct lov_request_set *set)
839 LASSERT(set->set_exp);
840 if (set->set_completes) {
842 /* FIXME update qos data here */
849 int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo,
850 obd_count oa_bufs, struct brw_page *pga,
851 struct obd_trans_info *oti,
852 struct lov_request_set **reqset)
859 struct lov_request_set *set;
860 struct lov_obd *lov = &exp->exp_obd->u.lov;
861 int rc = 0, i, shift;
864 OBD_ALLOC(set, sizeof(*set));
872 set->set_oabufs = oa_bufs;
873 OBD_ALLOC(set->set_pga, oa_bufs * sizeof(*set->set_pga));
875 GOTO(out, rc = -ENOMEM);
877 OBD_ALLOC(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
879 GOTO(out, rc = -ENOMEM);
881 /* calculate the page count for each stripe */
882 for (i = 0; i < oa_bufs; i++) {
883 int stripe = lov_stripe_number(oinfo->oi_md, pga[i].off);
884 info[stripe].count++;
887 /* alloc and initialize lov request */
889 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++){
890 struct lov_oinfo *loi = NULL;
891 struct lov_request *req;
893 if (info[i].count == 0)
896 loi = oinfo->oi_md->lsm_oinfo[i];
897 if (!lov->lov_tgts[loi->loi_ost_idx] ||
898 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
899 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
900 GOTO(out, rc = -EIO);
903 OBD_ALLOC(req, sizeof(*req));
905 GOTO(out, rc = -ENOMEM);
907 OBDO_ALLOC(req->rq_oi.oi_oa);
908 if (req->rq_oi.oi_oa == NULL) {
909 OBD_FREE(req, sizeof(*req));
910 GOTO(out, rc = -ENOMEM);
914 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
915 sizeof(*req->rq_oi.oi_oa));
917 req->rq_oi.oi_oa->o_id = loi->loi_id;
918 req->rq_oi.oi_oa->o_seq = loi->loi_seq;
919 req->rq_oi.oi_oa->o_stripe_idx = i;
921 req->rq_buflen = sizeof(*req->rq_oi.oi_md);
922 OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
923 if (req->rq_oi.oi_md == NULL) {
924 OBDO_FREE(req->rq_oi.oi_oa);
925 OBD_FREE(req, sizeof(*req));
926 GOTO(out, rc = -ENOMEM);
929 req->rq_idx = loi->loi_ost_idx;
932 /* XXX LOV STACKING */
933 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
934 req->rq_oi.oi_md->lsm_object_seq = loi->loi_seq;
935 req->rq_oabufs = info[i].count;
936 req->rq_pgaidx = shift;
937 shift += req->rq_oabufs;
939 /* remember the index for sort brw_page array */
940 info[i].index = req->rq_pgaidx;
942 req->rq_oi.oi_capa = oinfo->oi_capa;
944 lov_set_add_req(req, set);
947 GOTO(out, rc = -EIO);
949 /* rotate & sort the brw_page array */
950 for (i = 0; i < oa_bufs; i++) {
951 int stripe = lov_stripe_number(oinfo->oi_md, pga[i].off);
953 shift = info[stripe].index + info[stripe].off;
954 LASSERT(shift < oa_bufs);
955 set->set_pga[shift] = pga[i];
956 lov_stripe_offset(oinfo->oi_md, pga[i].off, stripe,
957 &set->set_pga[shift].off);
962 OBD_FREE(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
967 lov_fini_brw_set(set);
972 int lov_fini_getattr_set(struct lov_request_set *set)
979 LASSERT(set->set_exp);
980 if (set->set_completes)
981 rc = common_attr_done(set);
988 /* The callback for osc_getattr_async that finilizes a request info when a
989 * response is received. */
990 static int cb_getattr_update(void *cookie, int rc)
992 struct obd_info *oinfo = cookie;
993 struct lov_request *lovreq;
994 lovreq = container_of(oinfo, struct lov_request, rq_oi);
995 return lov_update_common_set(lovreq->rq_rqset, lovreq, rc);
998 int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
999 struct lov_request_set **reqset)
1001 struct lov_request_set *set;
1002 struct lov_obd *lov = &exp->exp_obd->u.lov;
1006 OBD_ALLOC(set, sizeof(*set));
1012 set->set_oi = oinfo;
1014 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
1015 struct lov_oinfo *loi;
1016 struct lov_request *req;
1018 loi = oinfo->oi_md->lsm_oinfo[i];
1019 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1020 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1021 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1022 if (oinfo->oi_oa->o_valid & OBD_MD_FLEPOCH)
1023 /* SOM requires all the OSTs to be active. */
1024 GOTO(out_set, rc = -EIO);
1028 OBD_ALLOC(req, sizeof(*req));
1030 GOTO(out_set, rc = -ENOMEM);
1033 req->rq_idx = loi->loi_ost_idx;
1035 OBDO_ALLOC(req->rq_oi.oi_oa);
1036 if (req->rq_oi.oi_oa == NULL) {
1037 OBD_FREE(req, sizeof(*req));
1038 GOTO(out_set, rc = -ENOMEM);
1040 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
1041 sizeof(*req->rq_oi.oi_oa));
1042 req->rq_oi.oi_oa->o_id = loi->loi_id;
1043 req->rq_oi.oi_oa->o_seq = loi->loi_seq;
1044 req->rq_oi.oi_cb_up = cb_getattr_update;
1045 req->rq_oi.oi_capa = oinfo->oi_capa;
1047 lov_set_add_req(req, set);
1049 if (!set->set_count)
1050 GOTO(out_set, rc = -EIO);
1054 lov_fini_getattr_set(set);
1058 int lov_fini_destroy_set(struct lov_request_set *set)
1064 LASSERT(set->set_exp);
1065 if (set->set_completes) {
1066 /* FIXME update qos data here */
1069 lov_put_reqset(set);
1074 int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
1075 struct obdo *src_oa, struct lov_stripe_md *lsm,
1076 struct obd_trans_info *oti,
1077 struct lov_request_set **reqset)
1079 struct lov_request_set *set;
1080 struct lov_obd *lov = &exp->exp_obd->u.lov;
1084 OBD_ALLOC(set, sizeof(*set));
1090 set->set_oi = oinfo;
1091 set->set_oi->oi_md = lsm;
1092 set->set_oi->oi_oa = src_oa;
1094 if (oti != NULL && src_oa->o_valid & OBD_MD_FLCOOKIE)
1095 set->set_cookies = oti->oti_logcookies;
1097 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1098 struct lov_oinfo *loi;
1099 struct lov_request *req;
1101 loi = lsm->lsm_oinfo[i];
1102 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1103 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1104 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1108 OBD_ALLOC(req, sizeof(*req));
1110 GOTO(out_set, rc = -ENOMEM);
1113 req->rq_idx = loi->loi_ost_idx;
1115 OBDO_ALLOC(req->rq_oi.oi_oa);
1116 if (req->rq_oi.oi_oa == NULL) {
1117 OBD_FREE(req, sizeof(*req));
1118 GOTO(out_set, rc = -ENOMEM);
1120 memcpy(req->rq_oi.oi_oa, src_oa, sizeof(*req->rq_oi.oi_oa));
1121 req->rq_oi.oi_oa->o_id = loi->loi_id;
1122 req->rq_oi.oi_oa->o_seq = loi->loi_seq;
1123 lov_set_add_req(req, set);
1125 if (!set->set_count)
1126 GOTO(out_set, rc = -EIO);
1130 lov_fini_destroy_set(set);
1134 int lov_fini_setattr_set(struct lov_request_set *set)
1141 LASSERT(set->set_exp);
1142 if (set->set_completes) {
1143 rc = common_attr_done(set);
1144 /* FIXME update qos data here */
1147 lov_put_reqset(set);
1151 int lov_update_setattr_set(struct lov_request_set *set,
1152 struct lov_request *req, int rc)
1154 struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov;
1155 struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md;
1158 lov_update_set(set, req, rc);
1160 /* grace error on inactive ost */
1161 if (rc && !(lov->lov_tgts[req->rq_idx] &&
1162 lov->lov_tgts[req->rq_idx]->ltd_active))
1166 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLCTIME)
1167 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_ctime =
1168 req->rq_oi.oi_oa->o_ctime;
1169 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLMTIME)
1170 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_mtime =
1171 req->rq_oi.oi_oa->o_mtime;
1172 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLATIME)
1173 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_atime =
1174 req->rq_oi.oi_oa->o_atime;
1180 /* The callback for osc_setattr_async that finilizes a request info when a
1181 * response is received. */
1182 static int cb_setattr_update(void *cookie, int rc)
1184 struct obd_info *oinfo = cookie;
1185 struct lov_request *lovreq;
1186 lovreq = container_of(oinfo, struct lov_request, rq_oi);
1187 return lov_update_setattr_set(lovreq->rq_rqset, lovreq, rc);
1190 int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
1191 struct obd_trans_info *oti,
1192 struct lov_request_set **reqset)
1194 struct lov_request_set *set;
1195 struct lov_obd *lov = &exp->exp_obd->u.lov;
1199 OBD_ALLOC(set, sizeof(*set));
1206 set->set_oi = oinfo;
1207 if (oti != NULL && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
1208 set->set_cookies = oti->oti_logcookies;
1210 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
1211 struct lov_oinfo *loi = oinfo->oi_md->lsm_oinfo[i];
1212 struct lov_request *req;
1214 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1215 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1216 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1220 OBD_ALLOC(req, sizeof(*req));
1222 GOTO(out_set, rc = -ENOMEM);
1224 req->rq_idx = loi->loi_ost_idx;
1226 OBDO_ALLOC(req->rq_oi.oi_oa);
1227 if (req->rq_oi.oi_oa == NULL) {
1228 OBD_FREE(req, sizeof(*req));
1229 GOTO(out_set, rc = -ENOMEM);
1231 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
1232 sizeof(*req->rq_oi.oi_oa));
1233 req->rq_oi.oi_oa->o_id = loi->loi_id;
1234 req->rq_oi.oi_oa->o_seq= loi->loi_seq;
1235 req->rq_oi.oi_oa->o_stripe_idx = i;
1236 req->rq_oi.oi_cb_up = cb_setattr_update;
1237 req->rq_oi.oi_capa = oinfo->oi_capa;
1239 if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE) {
1240 int off = lov_stripe_offset(oinfo->oi_md,
1241 oinfo->oi_oa->o_size, i,
1242 &req->rq_oi.oi_oa->o_size);
1244 if (off < 0 && req->rq_oi.oi_oa->o_size)
1245 req->rq_oi.oi_oa->o_size--;
1247 CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n",
1248 i, req->rq_oi.oi_oa->o_size,
1249 oinfo->oi_oa->o_size);
1251 lov_set_add_req(req, set);
1253 if (!set->set_count)
1254 GOTO(out_set, rc = -EIO);
1258 lov_fini_setattr_set(set);
1262 int lov_fini_punch_set(struct lov_request_set *set)
1269 LASSERT(set->set_exp);
1270 if (set->set_completes) {
1272 /* FIXME update qos data here */
1273 if (set->set_success)
1274 rc = common_attr_done(set);
1277 lov_put_reqset(set);
1282 int lov_update_punch_set(struct lov_request_set *set,
1283 struct lov_request *req, int rc)
1285 struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov;
1286 struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md;
1289 lov_update_set(set, req, rc);
1291 /* grace error on inactive ost */
1292 if (rc && !lov->lov_tgts[req->rq_idx]->ltd_active)
1296 lov_stripe_lock(lsm);
1297 if (req->rq_oi.oi_oa->o_valid & OBD_MD_FLBLOCKS) {
1298 lsm->lsm_oinfo[req->rq_stripe]->loi_lvb.lvb_blocks =
1299 req->rq_oi.oi_oa->o_blocks;
1302 /* Do we need to update lvb_size here? It needn't because
1303 * it have been done in ll_truncate(). -jay */
1304 lov_stripe_unlock(lsm);
1310 /* The callback for osc_punch that finilizes a request info when a response
1312 static int cb_update_punch(void *cookie, int rc)
1314 struct obd_info *oinfo = cookie;
1315 struct lov_request *lovreq;
1316 lovreq = container_of(oinfo, struct lov_request, rq_oi);
1317 return lov_update_punch_set(lovreq->rq_rqset, lovreq, rc);
1320 int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo,
1321 struct obd_trans_info *oti,
1322 struct lov_request_set **reqset)
1324 struct lov_request_set *set;
1325 struct lov_obd *lov = &exp->exp_obd->u.lov;
1329 OBD_ALLOC(set, sizeof(*set));
1334 set->set_oi = oinfo;
1337 for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
1338 struct lov_oinfo *loi = oinfo->oi_md->lsm_oinfo[i];
1339 struct lov_request *req;
1342 if (!lov_stripe_intersects(oinfo->oi_md, i,
1343 oinfo->oi_policy.l_extent.start,
1344 oinfo->oi_policy.l_extent.end,
1348 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1349 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1350 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1351 GOTO(out_set, rc = -EIO);
1354 OBD_ALLOC(req, sizeof(*req));
1356 GOTO(out_set, rc = -ENOMEM);
1358 req->rq_idx = loi->loi_ost_idx;
1360 OBDO_ALLOC(req->rq_oi.oi_oa);
1361 if (req->rq_oi.oi_oa == NULL) {
1362 OBD_FREE(req, sizeof(*req));
1363 GOTO(out_set, rc = -ENOMEM);
1365 memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
1366 sizeof(*req->rq_oi.oi_oa));
1367 req->rq_oi.oi_oa->o_id = loi->loi_id;
1368 req->rq_oi.oi_oa->o_seq = loi->loi_seq;
1369 req->rq_oi.oi_oa->o_valid |= OBD_MD_FLGROUP;
1371 req->rq_oi.oi_oa->o_stripe_idx = i;
1372 req->rq_oi.oi_cb_up = cb_update_punch;
1374 req->rq_oi.oi_policy.l_extent.start = rs;
1375 req->rq_oi.oi_policy.l_extent.end = re;
1376 req->rq_oi.oi_policy.l_extent.gid = -1;
1378 req->rq_oi.oi_capa = oinfo->oi_capa;
1380 lov_set_add_req(req, set);
1382 if (!set->set_count)
1383 GOTO(out_set, rc = -EIO);
1387 lov_fini_punch_set(set);
1391 int lov_fini_sync_set(struct lov_request_set *set)
1398 LASSERT(set->set_exp);
1399 if (set->set_completes) {
1400 if (!set->set_success)
1402 /* FIXME update qos data here */
1405 lov_put_reqset(set);
1410 int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo,
1411 struct obdo *src_oa, struct lov_stripe_md *lsm,
1412 obd_off start, obd_off end,
1413 struct lov_request_set **reqset)
1415 struct lov_request_set *set;
1416 struct lov_obd *lov = &exp->exp_obd->u.lov;
1420 OBD_ALLOC(set, sizeof(*set));
1426 set->set_oi = oinfo;
1427 set->set_oi->oi_md = lsm;
1428 set->set_oi->oi_oa = src_oa;
1430 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1431 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
1432 struct lov_request *req;
1435 if (!lov->lov_tgts[loi->loi_ost_idx] ||
1436 !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
1437 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1441 if (!lov_stripe_intersects(lsm, i, start, end, &rs, &re))
1444 OBD_ALLOC(req, sizeof(*req));
1446 GOTO(out_set, rc = -ENOMEM);
1448 req->rq_idx = loi->loi_ost_idx;
1450 OBDO_ALLOC(req->rq_oi.oi_oa);
1451 if (req->rq_oi.oi_oa == NULL) {
1452 OBD_FREE(req, sizeof(*req));
1453 GOTO(out_set, rc = -ENOMEM);
1455 memcpy(req->rq_oi.oi_oa, src_oa, sizeof(*req->rq_oi.oi_oa));
1456 req->rq_oi.oi_oa->o_id = loi->loi_id;
1457 req->rq_oi.oi_oa->o_seq = loi->loi_seq;
1458 req->rq_oi.oi_oa->o_stripe_idx = i;
1460 req->rq_oi.oi_policy.l_extent.start = rs;
1461 req->rq_oi.oi_policy.l_extent.end = re;
1462 req->rq_oi.oi_policy.l_extent.gid = -1;
1464 lov_set_add_req(req, set);
1466 if (!set->set_count)
1467 GOTO(out_set, rc = -EIO);
1471 lov_fini_sync_set(set);
1475 #define LOV_U64_MAX ((__u64)~0ULL)
1476 #define LOV_SUM_MAX(tot, add) \
1478 if ((tot) + (add) < (tot)) \
1479 (tot) = LOV_U64_MAX; \
1484 int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success)
1489 __u32 expected_stripes = lov_get_stripecnt(&obd->u.lov, 0);
1491 if (osfs->os_files != LOV_U64_MAX)
1492 do_div(osfs->os_files, expected_stripes);
1493 if (osfs->os_ffree != LOV_U64_MAX)
1494 do_div(osfs->os_ffree, expected_stripes);
1496 cfs_spin_lock(&obd->obd_osfs_lock);
1497 memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
1498 obd->obd_osfs_age = cfs_time_current_64();
1499 cfs_spin_unlock(&obd->obd_osfs_lock);
1506 int lov_fini_statfs_set(struct lov_request_set *set)
1514 if (set->set_completes) {
1515 rc = lov_fini_statfs(set->set_obd, set->set_oi->oi_osfs,
1518 lov_put_reqset(set);
1522 void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs,
1525 int shift = 0, quit = 0;
1529 memcpy(osfs, lov_sfs, sizeof(*lov_sfs));
1531 if (osfs->os_bsize != lov_sfs->os_bsize) {
1532 /* assume all block sizes are always powers of 2 */
1533 /* get the bits difference */
1534 tmp = osfs->os_bsize | lov_sfs->os_bsize;
1535 for (shift = 0; shift <= 64; ++shift) {
1547 if (osfs->os_bsize < lov_sfs->os_bsize) {
1548 osfs->os_bsize = lov_sfs->os_bsize;
1550 osfs->os_bfree >>= shift;
1551 osfs->os_bavail >>= shift;
1552 osfs->os_blocks >>= shift;
1553 } else if (shift != 0) {
1554 lov_sfs->os_bfree >>= shift;
1555 lov_sfs->os_bavail >>= shift;
1556 lov_sfs->os_blocks >>= shift;
1559 /* Sandia requested that df (and so, statfs) only
1560 returned minimal available space on
1561 a single OST, so people would be able to
1562 write this much data guaranteed. */
1563 if (osfs->os_bavail > lov_sfs->os_bavail) {
1564 /* Presumably if new bavail is smaller,
1565 new bfree is bigger as well */
1566 osfs->os_bfree = lov_sfs->os_bfree;
1567 osfs->os_bavail = lov_sfs->os_bavail;
1570 osfs->os_bfree += lov_sfs->os_bfree;
1571 osfs->os_bavail += lov_sfs->os_bavail;
1573 osfs->os_blocks += lov_sfs->os_blocks;
1574 /* XXX not sure about this one - depends on policy.
1575 * - could be minimum if we always stripe on all OBDs
1576 * (but that would be wrong for any other policy,
1577 * if one of the OBDs has no more objects left)
1578 * - could be sum if we stripe whole objects
1579 * - could be average, just to give a nice number
1581 * To give a "reasonable" (if not wholly accurate)
1582 * number, we divide the total number of free objects
1583 * by expected stripe count (watch out for overflow).
1585 LOV_SUM_MAX(osfs->os_files, lov_sfs->os_files);
1586 LOV_SUM_MAX(osfs->os_ffree, lov_sfs->os_ffree);
1590 /* The callback for osc_statfs_async that finilizes a request info when a
1591 * response is received. */
1592 static int cb_statfs_update(void *cookie, int rc)
1594 struct obd_info *oinfo = cookie;
1595 struct lov_request *lovreq;
1596 struct obd_statfs *osfs, *lov_sfs;
1597 struct lov_obd *lov;
1598 struct lov_tgt_desc *tgt;
1599 struct obd_device *lovobd, *tgtobd;
1603 lovreq = container_of(oinfo, struct lov_request, rq_oi);
1604 lovobd = lovreq->rq_rqset->set_obd;
1605 lov = &lovobd->u.lov;
1606 osfs = lovreq->rq_rqset->set_oi->oi_osfs;
1607 lov_sfs = oinfo->oi_osfs;
1608 success = lovreq->rq_rqset->set_success;
1609 /* XXX: the same is done in lov_update_common_set, however
1610 lovset->set_exp is not initialized. */
1611 lov_update_set(lovreq->rq_rqset, lovreq, rc);
1616 tgt = lov->lov_tgts[lovreq->rq_idx];
1617 if (!tgt || !tgt->ltd_active)
1618 GOTO(out_update, rc);
1620 tgtobd = class_exp2obd(tgt->ltd_exp);
1621 cfs_spin_lock(&tgtobd->obd_osfs_lock);
1622 memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
1623 if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
1624 tgtobd->obd_osfs_age = cfs_time_current_64();
1625 cfs_spin_unlock(&tgtobd->obd_osfs_lock);
1628 lov_update_statfs(osfs, lov_sfs, success);
1633 if (lovreq->rq_rqset->set_oi->oi_flags & OBD_STATFS_PTLRPCD &&
1634 lov_finished_set(lovreq->rq_rqset)) {
1635 lov_statfs_interpret(NULL, lovreq->rq_rqset,
1636 lovreq->rq_rqset->set_success !=
1637 lovreq->rq_rqset->set_count);
1638 qos_statfs_done(lov);
1644 int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
1645 struct lov_request_set **reqset)
1647 struct lov_request_set *set;
1648 struct lov_obd *lov = &obd->u.lov;
1652 OBD_ALLOC(set, sizeof(*set));
1658 set->set_oi = oinfo;
1660 /* We only get block data from the OBD */
1661 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
1662 struct lov_request *req;
1664 if (!lov->lov_tgts[i] || (!lov->lov_tgts[i]->ltd_active
1665 && (oinfo->oi_flags & OBD_STATFS_NODELAY))) {
1666 CDEBUG(D_HA, "lov idx %d inactive\n", i);
1670 /* skip targets that have been explicitely disabled by the
1672 if (!lov->lov_tgts[i]->ltd_exp) {
1673 CDEBUG(D_HA, "lov idx %d administratively disabled\n", i);
1677 OBD_ALLOC(req, sizeof(*req));
1679 GOTO(out_set, rc = -ENOMEM);
1681 OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs));
1682 if (req->rq_oi.oi_osfs == NULL) {
1683 OBD_FREE(req, sizeof(*req));
1684 GOTO(out_set, rc = -ENOMEM);
1688 req->rq_oi.oi_cb_up = cb_statfs_update;
1689 req->rq_oi.oi_flags = oinfo->oi_flags;
1691 lov_set_add_req(req, set);
1693 if (!set->set_count)
1694 GOTO(out_set, rc = -EIO);
1698 lov_fini_statfs_set(set);