/* given an extent in an lov and a stripe, calculate the extent of the stripe * that is contained within the lov extent. this returns true if the given * stripe does intersect with the lov extent. */ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, obd_off start, obd_off end, obd_off *obd_start, obd_off *obd_end) { int start_side, end_side; start_side = lov_stripe_offset(lsm, start, stripeno, obd_start); end_side = lov_stripe_offset(lsm, end, stripeno, obd_end); CDEBUG(D_INODE, "["LPU64"->"LPU64"] -> [(%d) "LPU64"->"LPU64" (%d)]\n", start, end, start_side, *obd_start, *obd_end, end_side); /* this stripe doesn't intersect the file extent when neither * start or the end intersected the stripe and obd_start and * obd_end got rounded up to the save value. */ if (start_side != 0 && end_side != 0 && *obd_start == *obd_end) return 0; /* as mentioned in the lov_stripe_offset commentary, end * might have been shifted in the wrong direction. This * happens when an end offset is before the stripe when viewed * through the "mod stripe size" math. we detect it being shifted * in the wrong direction and touch it up. * interestingly, this can't underflow since end must be > start * if we passed through the previous check. * (should we assert for that somewhere?) */ if (end_side != 0) (*obd_end)--; return 1; }
int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *vmpage) { struct lov_object *loo = cl2lov(obj); struct lov_layout_raid0 *r0 = lov_r0(loo); struct lov_io *lio = lov_env_io(env); struct cl_page *subpage; struct cl_object *subobj; struct lov_io_sub *sub; struct lov_page *lpg = cl_object_page_slice(obj, page); loff_t offset; u64 suboff; int stripe; int rc; offset = cl_offset(obj, page->cp_index); stripe = lov_stripe_number(loo->lo_lsm, offset); LASSERT(stripe < r0->lo_nr); rc = lov_stripe_offset(loo->lo_lsm, offset, stripe, &suboff); LASSERT(rc == 0); lpg->lps_invalid = 1; cl_page_slice_add(page, &lpg->lps_cl, obj, &lov_page_ops); sub = lov_sub_get(env, lio, stripe); if (IS_ERR(sub)) { rc = PTR_ERR(sub); goto out; } subobj = lovsub2cl(r0->lo_sub[stripe]); subpage = cl_page_find_sub(sub->sub_env, subobj, cl_index(subobj, suboff), vmpage, page); lov_sub_put(sub); if (IS_ERR(subpage)) { rc = PTR_ERR(subpage); goto out; } if (likely(subpage->cp_parent == page)) { lu_ref_add(&subpage->cp_reference, "lov", page); lpg->lps_invalid = 0; rc = 0; } else { CL_PAGE_DEBUG(D_ERROR, env, page, "parent page\n"); CL_PAGE_DEBUG(D_ERROR, env, subpage, "child page\n"); LASSERT(0); } out: return rc; }