int lov_read_and_clear_async_rc(struct cl_object *clob) { struct lu_object *luobj; int rc = 0; luobj = lu_object_locate(&cl_object_header(clob)->coh_lu, &lov_device_type); if (luobj != NULL) { struct lov_object *lov = lu2lov(luobj); lov_conf_freeze(lov); switch (lov->lo_type) { case LLT_RAID0: { struct lov_stripe_md *lsm; int i; lsm = lov->lo_lsm; LASSERT(lsm != NULL); for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_oinfo *loi = lsm->lsm_oinfo[i]; if (loi->loi_ar.ar_rc && !rc) rc = loi->loi_ar.ar_rc; loi->loi_ar.ar_rc = 0; } } case LLT_RELEASED: case LLT_EMPTY: break; default: LBUG(); } lov_conf_thaw(lov); } return rc; }
struct vvp_object *cl_inode2vvp(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct cl_object *obj = lli->lli_clob; struct lu_object *lu; lu = lu_object_locate(obj->co_lu.lo_header, &vvp_device_type); LASSERT(lu); return lu2vvp(lu); }
struct ccc_object *cl_inode2ccc(struct inode *inode) { struct cl_inode_info *lli = cl_i2info(inode); struct cl_object *obj = lli->lli_clob; struct lu_object *lu; LASSERT(obj != NULL); lu = lu_object_locate(obj->co_lu.lo_header, &vvp_device_type); LASSERT(lu != NULL); return lu2ccc(lu); }
struct lov_stripe_md *lov_lsm_get(struct cl_object *clobj) { struct lu_object *luobj; struct lov_stripe_md *lsm = NULL; if (clobj == NULL) return NULL; luobj = lu_object_locate(&cl_object_header(clobj)->coh_lu, &lov_device_type); if (luobj != NULL) lsm = lov_lsm_addref(lu2lov(luobj)); return lsm; }
static struct dt_object *out_get_dt_obj(struct lu_object *obj) { struct mdt_device *mdt; struct dt_device *dt; struct lu_object *bottom_obj; mdt = lu2mdt_dev(obj->lo_dev); dt = mdt->mdt_bottom; bottom_obj = lu_object_locate(obj->lo_header, dt->dd_lu_dev.ld_type); if (bottom_obj == NULL) return ERR_PTR(-ENOENT); return lu2dt_obj(bottom_obj); }
/** * Find the osd object for given fid. * * \param fid need to find the osd object having this fid * * \retval osd_object on success * \retval -ve on error */ struct osd_object *osd_object_find(const struct lu_env *env, struct dt_object *dt, const struct lu_fid *fid) { struct lu_device *ludev = dt->do_lu.lo_dev; struct osd_object *child = NULL; struct lu_object *luch; struct lu_object *lo; /* * at this point topdev might not exist yet * (i.e. MGS is preparing profiles). so we can * not rely on topdev and instead lookup with * our device passed as topdev. this can't work * if the object isn't cached yet (as osd doesn't * allocate lu_header). IOW, the object must be * in the cache, otherwise lu_object_alloc() crashes * -bzzz */ luch = lu_object_find_at(env, ludev, fid, NULL); if (IS_ERR(luch)) return (void *)luch; if (lu_object_exists(luch)) { lo = lu_object_locate(luch->lo_header, ludev->ld_type); if (lo != NULL) child = osd_obj(lo); else LU_OBJECT_DEBUG(D_ERROR, env, luch, "%s: object can't be located "DFID"\n", osd_dev(ludev)->od_svname, PFID(fid)); if (child == NULL) { lu_object_put(env, luch); CERROR("%s: Unable to get osd_object "DFID"\n", osd_dev(ludev)->od_svname, PFID(fid)); child = ERR_PTR(-ENOENT); } } else { LU_OBJECT_DEBUG(D_ERROR, env, luch, "%s: lu_object does not exists "DFID"\n", osd_dev(ludev)->od_svname, PFID(fid)); lu_object_put(env, luch); child = ERR_PTR(-ENOENT); } return child; }
static struct md_object *mdo_locate(const struct lu_env *env, struct md_device *md, const struct lu_fid *fid) { struct lu_object *obj; struct md_object *mdo; obj = lu_object_find(env, &md->md_lu_dev, fid, NULL); if (!IS_ERR(obj)) { obj = lu_object_locate(obj->lo_header, md->md_lu_dev.ld_type); LASSERT(obj != NULL); mdo = lu2md(obj); } else { mdo = ERR_PTR(PTR_ERR(obj)); } return mdo; }
struct ofd_object *ofd_object_find_or_create(const struct lu_env *env, struct ofd_device *ofd, const struct lu_fid *fid, struct lu_attr *attr) { struct ofd_thread_info *info = ofd_info(env); struct lu_object *fo_obj; struct dt_object *dto; ENTRY; info->fti_dof.dof_type = dt_mode_to_dft(S_IFREG); dto = dt_find_or_create(env, ofd->ofd_osd, fid, &info->fti_dof, attr); if (IS_ERR(dto)) RETURN(ERR_CAST(dto)); fo_obj = lu_object_locate(dto->do_lu.lo_header, ofd->ofd_dt_dev.dd_lu_dev.ld_type); RETURN(ofd_obj(fo_obj)); }
static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, struct cl_object *stripe, struct lov_layout_raid0 *r0, int idx) { struct cl_object_header *hdr; struct cl_object_header *subhdr; struct cl_object_header *parent; struct lov_oinfo *oinfo; int result; if (OBD_FAIL_CHECK(OBD_FAIL_LOV_INIT)) { /* For sanity:test_206. * Do not leave the object in cache to avoid accessing * freed memory. This is because osc_object is referring to * lov_oinfo of lsm_stripe_data which will be freed due to * this failure. */ cl_object_kill(env, stripe); cl_object_put(env, stripe); return -EIO; } hdr = cl_object_header(lov2cl(lov)); subhdr = cl_object_header(stripe); oinfo = lov->lo_lsm->lsm_oinfo[idx]; CDEBUG(D_INODE, DFID"@%p[%d] -> "DFID"@%p: ostid: "DOSTID " idx: %d gen: %d\n", PFID(&subhdr->coh_lu.loh_fid), subhdr, idx, PFID(&hdr->coh_lu.loh_fid), hdr, POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, oinfo->loi_ost_gen); /* reuse ->coh_attr_guard to protect coh_parent change */ spin_lock(&subhdr->coh_attr_guard); parent = subhdr->coh_parent; if (parent == NULL) { subhdr->coh_parent = hdr; spin_unlock(&subhdr->coh_attr_guard); subhdr->coh_nesting = hdr->coh_nesting + 1; lu_object_ref_add(&stripe->co_lu, "lov-parent", lov); r0->lo_sub[idx] = cl2lovsub(stripe); r0->lo_sub[idx]->lso_super = lov; r0->lo_sub[idx]->lso_index = idx; result = 0; } else { struct lu_object *old_obj; struct lov_object *old_lov; unsigned int mask = D_INODE; spin_unlock(&subhdr->coh_attr_guard); old_obj = lu_object_locate(&parent->coh_lu, &lov_device_type); LASSERT(old_obj != NULL); old_lov = cl2lov(lu2cl(old_obj)); if (old_lov->lo_layout_invalid) { /* the object's layout has already changed but isn't * refreshed */ lu_object_unhash(env, &stripe->co_lu); result = -EAGAIN; } else { mask = D_ERROR; result = -EIO; } LU_OBJECT_DEBUG(mask, env, &stripe->co_lu, "stripe %d is already owned.\n", idx); LU_OBJECT_DEBUG(mask, env, old_obj, "owned.\n"); LU_OBJECT_HEADER(mask, env, lov2lu(lov), "try to own.\n"); cl_object_put(env, stripe); } return result; }