-#ifndef log2
-#define log2(n) cfs_ffz(~(n))
-#endif
-
-static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa,
- struct lov_stripe_md **ea,
- struct obd_trans_info *oti)
-{
- struct lov_obd *lov;
- struct obdo *tmp_oa;
- struct obd_uuid *ost_uuid = NULL;
- int rc = 0, i;
- ENTRY;
-
- LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS &&
- src_oa->o_flags == OBD_FL_DELORPHAN);
-
- lov = &export->exp_obd->u.lov;
-
- OBDO_ALLOC(tmp_oa);
- if (tmp_oa == NULL)
- RETURN(-ENOMEM);
-
- if (oti->oti_ost_uuid) {
- ost_uuid = oti->oti_ost_uuid;
- CDEBUG(D_HA, "clearing orphans only for %s\n",
- ost_uuid->uuid);
- }
-
- obd_getref(export->exp_obd);
- for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- struct lov_stripe_md obj_md;
- struct lov_stripe_md *obj_mdp = &obj_md;
- struct lov_tgt_desc *tgt;
- int err;
-
- tgt = lov->lov_tgts[i];
- if (!tgt)
- continue;
-
- /* if called for a specific target, we don't
- care if it is not active. */
- if (!lov->lov_tgts[i]->ltd_active && ost_uuid == NULL) {
- CDEBUG(D_HA, "lov idx %d inactive\n", i);
- continue;
- }
-
- if (ost_uuid && !obd_uuid_equals(ost_uuid, &tgt->ltd_uuid))
- continue;
-
- CDEBUG(D_CONFIG,"Clear orphans for %d:%s\n", i,
- obd_uuid2str(ost_uuid));
-
- memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
-
- LASSERT(lov->lov_tgts[i]->ltd_exp);
- /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
- err = obd_create(NULL, lov->lov_tgts[i]->ltd_exp,
- tmp_oa, &obj_mdp, oti);
- if (err) {
- /* This export will be disabled until it is recovered,
- and then orphan recovery will be completed. */
- CERROR("error in orphan recovery on OST idx %d/%d: "
- "rc = %d\n", i, lov->desc.ld_tgt_count, err);
- rc = err;
- }
-
- if (ost_uuid)
- break;
- }
- obd_putref(export->exp_obd);
-
- OBDO_FREE(tmp_oa);
- RETURN(rc);
-}
-