Пример #1
0
static int lov_llog_origin_connect(struct llog_ctxt *ctxt,
                                   struct llog_logid *logid,
                                   struct llog_gen *gen,
                                   struct obd_uuid *uuid)
{
        struct obd_device *obd = ctxt->loc_obd;
        struct lov_obd *lov = &obd->u.lov;
        int i, rc = 0, err = 0;
        ENTRY;

        obd_getref(obd);
        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                struct obd_device *child;
                struct llog_ctxt *cctxt;

                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
                        continue;
                if (uuid && !obd_uuid_equals(uuid, &lov->lov_tgts[i]->ltd_uuid))
                        continue;
                CDEBUG(D_CONFIG, "connect %d/%d\n", i, lov->desc.ld_tgt_count);
                child = lov->lov_tgts[i]->ltd_exp->exp_obd;
                cctxt = llog_get_context(child, ctxt->loc_idx);
                rc = llog_connect(cctxt, logid, gen, uuid);
                llog_ctxt_put(cctxt);

                if (rc) {
                        CERROR("error osc_llog_connect tgt %d (%d)\n", i, rc);
                        if (!err)
                                err = rc;
                }
        }
        obd_putref(obd);

        RETURN(err);
}
Пример #2
0
static int lov_process_config(const struct lu_env *env,
			      struct lu_device *d, struct lustre_cfg *cfg)
{
	struct obd_device *obd = d->ld_obd;
	int cmd;
	int rc;
	int gen;
	__u32 index;

	obd_getref(obd);

	cmd = cfg->lcfg_command;
	rc = lov_process_config_base(d->ld_obd, cfg, &index, &gen);
	if (rc == 0) {
		switch (cmd) {
		case LCFG_LOV_ADD_OBD:
		case LCFG_LOV_ADD_INA:
			rc = lov_cl_add_target(env, d, index);
			if (rc != 0)
				lov_del_target(d->ld_obd, index, NULL, 0);
			break;
		case LCFG_LOV_DEL_OBD:
			lov_cl_del_target(env, d, index);
			break;
		}
	}
	obd_putref(obd);
	return rc;
}
Пример #3
0
int lov_quota_adjust_qunit(struct obd_export *exp,
                           struct quota_adjust_qunit *oqaq,
                           struct lustre_quota_ctxt *qctxt,
                           struct ptlrpc_request_set *rqset)
{
        struct obd_device *obd = class_exp2obd(exp);
        struct lov_obd *lov = &obd->u.lov;
        int i, err, rc = 0;
        unsigned no_set = 0;
        ENTRY;

        if (!QAQ_IS_ADJBLK(oqaq)) {
                CERROR("bad qaq_flags %x for lov obd.\n", oqaq->qaq_flags);
                RETURN(-EFAULT);
        }


        if (rqset == NULL) {
                rqset = ptlrpc_prep_set();
                if (!rqset)
                        RETURN(-ENOMEM);
                no_set = 1;
        }

        obd_getref(obd);
        for (i = 0; i < lov->desc.ld_tgt_count; i++) {

                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) {
                        CDEBUG(D_HA, "ost %d is inactive\n", i);
                        continue;
                }

                err = obd_quota_adjust_qunit(lov->lov_tgts[i]->ltd_exp, oqaq,
                                             NULL, rqset);
                if (err) {
                        if (lov->lov_tgts[i]->ltd_active && !rc)
                                rc = err;
                        continue;
                }
        }

        err = ptlrpc_set_wait(rqset);
        if (!rc)
                rc = err;

        /* Destroy the set if none was provided by the caller */
        if (no_set)
                ptlrpc_set_destroy(rqset);

        obd_putref(obd);
        RETURN(rc);
}
Пример #4
0
int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
                  struct obd_device *disk_obd, int *index)
{
        struct lov_obd *lov = &obd->u.lov;
        struct obd_device *child;
        int i, rc = 0;
        ENTRY;

        LASSERT(olg == &obd->obd_olg);
	rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd,
			&lov_mds_ost_orig_logops);
	if (rc)
		RETURN(rc);

	rc = llog_setup(NULL, obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd,
			&lov_size_repl_logops);
        if (rc)
                GOTO(err_cleanup, rc);

        obd_getref(obd);
        /* count may not match lov->desc.ld_tgt_count during dynamic ost add */
        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                if (!lov->lov_tgts[i])
                        continue;

                if (index && i != *index)
                        continue;

                child = lov->lov_tgts[i]->ltd_obd;
                rc = obd_llog_init(child, &child->obd_olg, disk_obd, &i);
                if (rc)
                        CERROR("error osc_llog_init idx %d osc '%s' tgt '%s' "
                               "(rc=%d)\n", i, child->obd_name,
                               disk_obd->obd_name, rc);
                rc = 0;
        }
        obd_putref(obd);
        GOTO(err_cleanup, rc);
err_cleanup:
        if (rc) {
                struct llog_ctxt *ctxt =
                        llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
                if (ctxt)
			llog_cleanup(NULL, ctxt);
                ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
                if (ctxt)
			llog_cleanup(NULL, ctxt);
        }
        return rc;
}
Пример #5
0
static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev,
			     __u32 index)
{
	struct obd_device    *obd = dev->ld_obd;
	struct lov_device    *ld  = lu2lov_dev(dev);
	struct lov_tgt_desc  *tgt;
	struct lovsub_device *lsd;
	struct cl_device     *cl;
	int rc;

	obd_getref(obd);

	tgt = obd->u.lov.lov_tgts[index];
	LASSERT(tgt != NULL);
	LASSERT(tgt->ltd_obd != NULL);

	if (!tgt->ltd_obd->obd_set_up) {
		CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid));
		return -EINVAL;
	}

	rc = lov_expand_targets(env, ld);
	if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) {
		LASSERT(dev->ld_site != NULL);

		cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type,
				   tgt->ltd_obd->obd_lu_dev);
		if (!IS_ERR(cl)) {
			lsd = cl2lovsub_dev(cl);
			lsd->acid_idx = index;
			lsd->acid_super = ld;
			ld->ld_target[index] = lsd;
		} else {
			CERROR("add failed (%d), deleting %s\n", rc,
			       obd_uuid2str(&tgt->ltd_uuid));
			lov_cl_del_target(env, dev, index);
			rc = PTR_ERR(cl);
		}
	}
	obd_putref(obd);
	return rc;
}
Пример #6
0
/* the replicators commit callback */
static int lov_llog_repl_cancel(const struct lu_env *env,
				struct llog_ctxt *ctxt,
				struct lov_stripe_md *lsm,
				int count, struct llog_cookie *cookies,
				int flags)
{
        struct lov_obd *lov;
        struct obd_device *obd = ctxt->loc_obd;
        int rc = 0, i;
        ENTRY;

        LASSERT(lsm != NULL);
        LASSERT(count == lsm->lsm_stripe_count);

        lov = &obd->u.lov;
        obd_getref(obd);
        for (i = 0; i < count; i++, cookies++) {
                struct lov_oinfo *loi = lsm->lsm_oinfo[i];
                struct obd_device *child =
                        lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd;
                struct llog_ctxt *cctxt =
                        llog_get_context(child, ctxt->loc_idx);
                int err;

		err = llog_cancel(env, cctxt, NULL, 1, cookies, flags);
		llog_ctxt_put(cctxt);
		if (err && lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
			CERROR("%s: objid "DOSTID" subobj "DOSTID
			       " on OST idx %d: rc = %d\n",
			       obd->obd_name, POSTID(&lsm->lsm_oi),
			       POSTID(&loi->loi_oi), loi->loi_ost_idx, err);
			if (!rc)
				rc = err;
		}
	}
	obd_putref(obd);
	RETURN(rc);
}
Пример #7
0
int lov_quota_check(struct obd_device *unused, struct obd_export *exp,
                    struct obd_quotactl *oqctl)
{
        struct obd_device *obd = class_exp2obd(exp);
        struct lov_obd *lov = &obd->u.lov;
        int i, rc = 0;
        ENTRY;

        obd_getref(obd);

        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                if (!lov->lov_tgts[i])
                        continue;

                if (!lov->lov_tgts[i]->ltd_active) {
                        CERROR("lov idx %d inactive\n", i);
                        rc = -EIO;
                        goto out;
                }
        }

        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                int err;

                if (!lov->lov_tgts[i])
                        continue;

                err = obd_quotacheck(lov->lov_tgts[i]->ltd_exp, oqctl);
                if (err && !rc)
                        rc = err;
        }

out:
        obd_putref(obd);

        RETURN(rc);
}