- LASSERT(rqset->set_interpret == NULL);
- rqset->set_interpret = lov_setattr_interpret;
- rqset->set_arg = (void *)set;
-
- RETURN(0);
-}
-
-static int lov_punch_interpret(struct ptlrpc_request_set *rqset,
- void *data, int rc)
-{
- struct lov_request_set *lovset = (struct lov_request_set *)data;
- int err;
- ENTRY;
-
- if (rc)
- lovset->set_completes = 0;
- err = lov_fini_punch_set(lovset);
- RETURN(rc ? rc : err);
-}
-
-/* FIXME: maybe we'll just make one node the authoritative attribute node, then
- * we can send this 'punch' to just the authoritative node and the nodes
- * that the punch will affect. */
-static int lov_punch(struct obd_export *exp, struct obd_info *oinfo,
- struct obd_trans_info *oti,
- struct ptlrpc_request_set *rqset)
-{
- struct lov_request_set *set;
- struct lov_obd *lov;
- cfs_list_t *pos;
- struct lov_request *req;
- int rc = 0;
- ENTRY;
-
- LASSERT(oinfo);
- ASSERT_LSM_MAGIC(oinfo->oi_md);
-
- if (!exp || !exp->exp_obd)
- RETURN(-ENODEV);
-
- lov = &exp->exp_obd->u.lov;
- rc = lov_prep_punch_set(exp, oinfo, oti, &set);
- if (rc)
- RETURN(rc);
-
- cfs_list_for_each (pos, &set->set_list) {
- req = cfs_list_entry(pos, struct lov_request, rq_link);
-
- rc = obd_punch(lov->lov_tgts[req->rq_idx]->ltd_exp,
- &req->rq_oi, NULL, rqset);
- if (rc) {
- CERROR("error: punch objid "LPX64" subobj "LPX64
- " on OST idx %d: rc = %d\n",
- set->set_oi->oi_oa->o_id,
- req->rq_oi.oi_oa->o_id, req->rq_idx, rc);
- break;
- }
- }
-
- if (rc || cfs_list_empty(&rqset->set_requests)) {
- int err;
- err = lov_fini_punch_set(set);
- RETURN(rc ? rc : err);
- }
-
- LASSERT(rqset->set_interpret == NULL);
- rqset->set_interpret = lov_punch_interpret;
- rqset->set_arg = (void *)set;
-
- RETURN(0);
-}
-
-static int lov_sync(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *lsm, obd_off start, obd_off end,
- void *capa)
-{
- struct lov_request_set *set;
- struct obd_info oinfo;
- struct lov_obd *lov;
- cfs_list_t *pos;
- struct lov_request *req;
- int err = 0, rc = 0;
- ENTRY;
-
- ASSERT_LSM_MAGIC(lsm);
-
- if (!exp->exp_obd)
- RETURN(-ENODEV);
-
- lov = &exp->exp_obd->u.lov;
- rc = lov_prep_sync_set(exp, &oinfo, oa, lsm, start, end, &set);
- if (rc)
- RETURN(rc);
-
- cfs_list_for_each (pos, &set->set_list) {
- req = cfs_list_entry(pos, struct lov_request, rq_link);
-
- rc = obd_sync(lov->lov_tgts[req->rq_idx]->ltd_exp,
- req->rq_oi.oi_oa, NULL,
- req->rq_oi.oi_policy.l_extent.start,
- req->rq_oi.oi_policy.l_extent.end, capa);
- err = lov_update_common_set(set, req, rc);
- if (err) {
- CERROR("error: fsync objid "LPX64" subobj "LPX64
- " on OST idx %d: rc = %d\n",
- set->set_oi->oi_oa->o_id,
- req->rq_oi.oi_oa->o_id, req->rq_idx, rc);
- if (!rc)
- rc = err;
- }
- }
- err = lov_fini_sync_set(set);
- if (!rc)
- rc = err;
- RETURN(rc);
-}
-
-static int lov_brw_check(struct lov_obd *lov, struct obd_info *lov_oinfo,
- obd_count oa_bufs, struct brw_page *pga)
-{
- struct obd_info oinfo = { { { 0 } } };
- int i, rc = 0;
-
- oinfo.oi_oa = lov_oinfo->oi_oa;
-
- /* The caller just wants to know if there's a chance that this
- * I/O can succeed */
- for (i = 0; i < oa_bufs; i++) {
- int stripe = lov_stripe_number(lov_oinfo->oi_md, pga[i].off);
- int ost = lov_oinfo->oi_md->lsm_oinfo[stripe]->loi_ost_idx;
- obd_off start, end;
-
- if (!lov_stripe_intersects(lov_oinfo->oi_md, i, pga[i].off,
- pga[i].off + pga[i].count - 1,
- &start, &end))
- continue;
-
- if (!lov->lov_tgts[ost] || !lov->lov_tgts[ost]->ltd_active) {
- CDEBUG(D_HA, "lov idx %d inactive\n", ost);
- return -EIO;
- }
-
- rc = obd_brw(OBD_BRW_CHECK, lov->lov_tgts[ost]->ltd_exp, &oinfo,
- 1, &pga[i], NULL);
- if (rc)
- break;
- }
- return rc;
-}
-
-static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo,
- obd_count oa_bufs, struct brw_page *pga,
- struct obd_trans_info *oti)
-{
- struct lov_request_set *set;
- struct lov_request *req;
- cfs_list_t *pos;
- struct lov_obd *lov = &exp->exp_obd->u.lov;
- int err, rc = 0;
- ENTRY;
-
- ASSERT_LSM_MAGIC(oinfo->oi_md);
-
- if (cmd == OBD_BRW_CHECK) {
- rc = lov_brw_check(lov, oinfo, oa_bufs, pga);
- RETURN(rc);
- }
-
- rc = lov_prep_brw_set(exp, oinfo, oa_bufs, pga, oti, &set);
- if (rc)
- RETURN(rc);
-
- cfs_list_for_each (pos, &set->set_list) {
- struct obd_export *sub_exp;
- struct brw_page *sub_pga;
- req = cfs_list_entry(pos, struct lov_request, rq_link);
-
- sub_exp = lov->lov_tgts[req->rq_idx]->ltd_exp;
- sub_pga = set->set_pga + req->rq_pgaidx;
- rc = obd_brw(cmd, sub_exp, &req->rq_oi, req->rq_oabufs,
- sub_pga, oti);
- if (rc)
- break;
- lov_update_common_set(set, req, rc);
- }
-
- err = lov_fini_brw_set(set);
- if (!rc)
- rc = err;
- RETURN(rc);
-}
-
-static int lov_enqueue_interpret(struct ptlrpc_request_set *rqset,
- void *data, int rc)
-{
- struct lov_request_set *lovset = (struct lov_request_set *)data;
- ENTRY;
- rc = lov_fini_enqueue_set(lovset, lovset->set_ei->ei_mode, rc, rqset);
- RETURN(rc);
-}
-
-static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo,
- struct ldlm_enqueue_info *einfo,
- struct ptlrpc_request_set *rqset)
-{
- ldlm_mode_t mode = einfo->ei_mode;
- struct lov_request_set *set;
- struct lov_request *req;
- cfs_list_t *pos;
- struct lov_obd *lov;
- ldlm_error_t rc;
- ENTRY;
-
- LASSERT(oinfo);
- ASSERT_LSM_MAGIC(oinfo->oi_md);
- LASSERT(mode == (mode & -mode));
-
- /* we should never be asked to replay a lock this way. */
- LASSERT((oinfo->oi_flags & LDLM_FL_REPLAY) == 0);
-
- if (!exp || !exp->exp_obd)
- RETURN(-ENODEV);
-
- lov = &exp->exp_obd->u.lov;
- rc = lov_prep_enqueue_set(exp, oinfo, einfo, &set);
- if (rc)
- RETURN(rc);
-
- cfs_list_for_each (pos, &set->set_list) {
- req = cfs_list_entry(pos, struct lov_request, rq_link);
-
- rc = obd_enqueue(lov->lov_tgts[req->rq_idx]->ltd_exp,
- &req->rq_oi, einfo, rqset);
- if (rc != ELDLM_OK)
- GOTO(out, rc);
- }
-
- if (rqset && !cfs_list_empty(&rqset->set_requests)) {
- LASSERT(rc == 0);
- LASSERT(rqset->set_interpret == NULL);
- rqset->set_interpret = lov_enqueue_interpret;
- rqset->set_arg = (void *)set;
- RETURN(rc);
- }
-out:
- rc = lov_fini_enqueue_set(set, mode, rc, rqset);
- RETURN(rc);
-}
-
-static int lov_change_cbdata(struct obd_export *exp,
- struct lov_stripe_md *lsm, ldlm_iterator_t it,
- void *data)
-{
- struct lov_obd *lov;
- int rc = 0, i;
- ENTRY;
-
- ASSERT_LSM_MAGIC(lsm);
-
- if (!exp || !exp->exp_obd)
- RETURN(-ENODEV);
-
- lov = &exp->exp_obd->u.lov;
- for (i = 0; i < lsm->lsm_stripe_count; i++) {
- struct lov_stripe_md submd;
- struct lov_oinfo *loi = lsm->lsm_oinfo[i];
-
- if (!lov->lov_tgts[loi->loi_ost_idx]) {
- CDEBUG(D_HA, "lov idx %d NULL \n", loi->loi_ost_idx);
- continue;
- }
-
- LASSERT_SEQ_IS_MDT(loi->loi_seq);
- submd.lsm_object_id = loi->loi_id;
- submd.lsm_object_seq = loi->loi_seq;
- submd.lsm_stripe_count = 0;
- rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp,
- &submd, it, data);
- }
- RETURN(rc);
-}