diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/obdecho/echo_client.c')
-rw-r--r-- | drivers/staging/lustre/lustre/obdecho/echo_client.c | 170 |
1 files changed, 51 insertions, 119 deletions
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 5b29c4a44fe5..505582ff4d1e 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -41,6 +41,7 @@ #include "../include/cl_object.h" #include "../include/lustre_fid.h" #include "../include/lustre_acl.h" +#include "../include/lustre/lustre_ioctl.h" #include "../include/lustre_net.h" #include "echo_internal.h" @@ -64,14 +65,14 @@ struct echo_object { struct echo_device *eo_dev; struct list_head eo_obj_chain; - struct lov_stripe_md *eo_lsm; + struct lov_oinfo *eo_oinfo; atomic_t eo_npages; int eo_deleted; }; struct echo_object_conf { struct cl_object_conf eoc_cl; - struct lov_stripe_md **eoc_md; + struct lov_oinfo **eoc_oinfo; }; struct echo_page { @@ -152,9 +153,6 @@ struct echo_object_conf *cl2echo_conf(const struct cl_object_conf *c) } /** @} echo_helpers */ - -static struct echo_object *cl_echo_object_find(struct echo_device *d, - struct lov_stripe_md **lsm); static int cl_echo_object_put(struct echo_object *eco); static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, struct page **pages, int npages, int async); @@ -413,10 +411,13 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, cconf = lu2cl_conf(conf); econf = cl2echo_conf(cconf); - LASSERT(econf->eoc_md); - eco->eo_lsm = *econf->eoc_md; - /* clear the lsm pointer so that it won't get freed. */ - *econf->eoc_md = NULL; + LASSERT(econf->eoc_oinfo); + /* + * Transfer the oinfo pointer to eco that it won't be + * freed. + */ + eco->eo_oinfo = *econf->eoc_oinfo; + *econf->eoc_oinfo = NULL; eco->eo_dev = ed; atomic_set(&eco->eo_npages, 0); @@ -429,52 +430,6 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, return 0; } -/* taken from osc_unpackmd() */ -static int echo_alloc_memmd(struct echo_device *ed, - struct lov_stripe_md **lsmp) -{ - int lsm_size; - - /* If export is lov/osc then use their obd method */ - if (ed->ed_next) - return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp); - /* OFD has no unpackmd method, do everything here */ - lsm_size = lov_stripe_md_size(1); - - LASSERT(!*lsmp); - *lsmp = kzalloc(lsm_size, GFP_NOFS); - if (!*lsmp) - return -ENOMEM; - - (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS); - if (!(*lsmp)->lsm_oinfo[0]) { - kfree(*lsmp); - return -ENOMEM; - } - - loi_init((*lsmp)->lsm_oinfo[0]); - (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES; - ostid_set_seq_echo(&(*lsmp)->lsm_oi); - - return lsm_size; -} - -static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) -{ - int lsm_size; - - /* If export is lov/osc then use their obd method */ - if (ed->ed_next) - return obd_free_memmd(ed->ed_ec->ec_exp, lsmp); - /* OFD has no unpackmd method, do everything here */ - lsm_size = lov_stripe_md_size(1); - - kfree((*lsmp)->lsm_oinfo[0]); - kfree(*lsmp); - *lsmp = NULL; - return 0; -} - static void echo_object_free(const struct lu_env *env, struct lu_object *obj) { struct echo_object *eco = cl2echo_obj(lu2cl(obj)); @@ -489,8 +444,7 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) lu_object_fini(obj); lu_object_header_fini(obj->lo_header); - if (eco->eo_lsm) - echo_free_memmd(eco->eo_dev, &eco->eo_lsm); + kfree(eco->eo_oinfo); kmem_cache_free(echo_object_kmem, eco); } @@ -864,25 +818,21 @@ static struct lu_device_type echo_device_type = { */ /* Interfaces to echo client obd device */ -static struct echo_object *cl_echo_object_find(struct echo_device *d, - struct lov_stripe_md **lsmp) +static struct echo_object * +cl_echo_object_find(struct echo_device *d, const struct ost_id *oi) { struct lu_env *env; struct echo_thread_info *info; struct echo_object_conf *conf; - struct lov_stripe_md *lsm; + struct lov_oinfo *oinfo = NULL; struct echo_object *eco; struct cl_object *obj; struct lu_fid *fid; int refcheck; int rc; - LASSERT(lsmp); - lsm = *lsmp; - LASSERT(lsm); - LASSERTF(ostid_id(&lsm->lsm_oi) != 0, DOSTID"\n", POSTID(&lsm->lsm_oi)); - LASSERTF(ostid_seq(&lsm->lsm_oi) == FID_SEQ_ECHO, DOSTID"\n", - POSTID(&lsm->lsm_oi)); + LASSERTF(ostid_id(oi), DOSTID "\n", POSTID(oi)); + LASSERTF(ostid_seq(oi) == FID_SEQ_ECHO, DOSTID "\n", POSTID(oi)); /* Never return an object if the obd is to be freed. */ if (echo_dev2cl(d)->cd_lu_dev.ld_obd->obd_stopping) @@ -895,16 +845,24 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, info = echo_env_info(env); conf = &info->eti_conf; if (d->ed_next) { - struct lov_oinfo *oinfo = lsm->lsm_oinfo[0]; + oinfo = kzalloc(sizeof(*oinfo), GFP_NOFS); + if (!oinfo) { + eco = ERR_PTR(-ENOMEM); + goto out; + } - LASSERT(oinfo); - oinfo->loi_oi = lsm->lsm_oi; + oinfo->loi_oi = *oi; conf->eoc_cl.u.coc_oinfo = oinfo; } - conf->eoc_md = lsmp; + + /* + * If echo_object_init() is successful then ownership of oinfo + * is transferred to the object. + */ + conf->eoc_oinfo = &oinfo; fid = &info->eti_fid; - rc = ostid_to_fid(fid, &lsm->lsm_oi, 0); + rc = ostid_to_fid(fid, (struct ost_id *)oi, 0); if (rc != 0) { eco = ERR_PTR(rc); goto out; @@ -927,6 +885,7 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, } out: + kfree(oinfo); cl_env_put(env, &refcheck); return eco; } @@ -1051,7 +1010,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, struct cl_io *io; struct cl_page *clp; struct lustre_handle lh = { 0 }; - int page_size = cl_page_size(obj); + size_t page_size = cl_page_size(obj); int refcheck; int rc; int i; @@ -1145,7 +1104,6 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, { struct echo_object *eco; struct echo_client_obd *ec = ed->ed_ec; - struct lov_stripe_md *lsm = NULL; int rc; int created = 0; @@ -1156,30 +1114,19 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, return -EINVAL; } - rc = echo_alloc_memmd(ed, &lsm); - if (rc < 0) { - CERROR("Cannot allocate md: rc = %d\n", rc); - goto failed; - } - - /* setup object ID here */ - lsm->lsm_oi = oa->o_oi; + if (!ostid_id(&oa->o_oi)) + ostid_set_id(&oa->o_oi, ++last_object_id); - if (ostid_id(&lsm->lsm_oi) == 0) - ostid_set_id(&lsm->lsm_oi, ++last_object_id); - - rc = obd_create(env, ec->ec_exp, oa, &lsm, oti); + rc = obd_create(env, ec->ec_exp, oa, oti); if (rc != 0) { CERROR("Cannot create objects: rc = %d\n", rc); goto failed; } created = 1; - /* See what object ID we were given */ - oa->o_oi = lsm->lsm_oi; oa->o_valid |= OBD_MD_FLID; - eco = cl_echo_object_find(ed, &lsm); + eco = cl_echo_object_find(ed, &oa->o_oi); if (IS_ERR(eco)) { rc = PTR_ERR(eco); goto failed; @@ -1190,9 +1137,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, failed: if (created && rc) - obd_destroy(env, ec->ec_exp, oa, lsm, oti, NULL); - if (lsm) - echo_free_memmd(ed, &lsm); + obd_destroy(env, ec->ec_exp, oa, oti); if (rc) CERROR("create object failed with: rc = %d\n", rc); return rc; @@ -1201,32 +1146,21 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, struct obdo *oa) { - struct lov_stripe_md *lsm = NULL; struct echo_object *eco; int rc; - if ((oa->o_valid & OBD_MD_FLID) == 0 || ostid_id(&oa->o_oi) == 0) { - /* disallow use of object id 0 */ - CERROR("No valid oid\n"); + if (!(oa->o_valid & OBD_MD_FLID) || !(oa->o_valid & OBD_MD_FLGROUP) || + !ostid_id(&oa->o_oi)) { + CERROR("invalid oid " DOSTID "\n", POSTID(&oa->o_oi)); return -EINVAL; } - rc = echo_alloc_memmd(ed, &lsm); - if (rc < 0) - return rc; - - lsm->lsm_oi = oa->o_oi; - if (!(oa->o_valid & OBD_MD_FLGROUP)) - ostid_set_seq_echo(&lsm->lsm_oi); - rc = 0; - eco = cl_echo_object_find(ed, &lsm); + eco = cl_echo_object_find(ed, &oa->o_oi); if (!IS_ERR(eco)) *ecop = eco; else rc = PTR_ERR(eco); - if (lsm) - echo_free_memmd(ed, &lsm); return rc; } @@ -1436,13 +1370,12 @@ static int echo_client_prep_commit(const struct lu_env *env, npages = tot_pages; for (i = 0; i < npages; i++, off += PAGE_SIZE) { - rnb[i].offset = off; - rnb[i].len = PAGE_SIZE; - rnb[i].flags = brw_flags; + rnb[i].rnb_offset = off; + rnb[i].rnb_len = PAGE_SIZE; + rnb[i].rnb_flags = brw_flags; } ioo.ioo_bufcnt = npages; - oti->oti_transno = 0; lpages = npages; ret = obd_preprw(env, rw, exp, oa, 1, &ioo, rnb, &lpages, @@ -1452,14 +1385,14 @@ static int echo_client_prep_commit(const struct lu_env *env, LASSERT(lpages == npages); for (i = 0; i < lpages; i++) { - struct page *page = lnb[i].page; + struct page *page = lnb[i].lnb_page; /* read past eof? */ - if (!page && lnb[i].rc == 0) + if (!page && lnb[i].lnb_rc == 0) continue; if (async) - lnb[i].flags |= OBD_BRW_ASYNC; + lnb[i].lnb_flags |= OBD_BRW_ASYNC; if (ostid_id(&oa->o_oi) == ECHO_PERSISTENT_OBJID || (oa->o_valid & OBD_MD_FLFLAGS) == 0 || @@ -1469,13 +1402,13 @@ static int echo_client_prep_commit(const struct lu_env *env, if (rw == OBD_BRW_WRITE) echo_client_page_debug_setup(page, rw, ostid_id(&oa->o_oi), - rnb[i].offset, - rnb[i].len); + rnb[i].rnb_offset, + rnb[i].rnb_len); else echo_client_page_debug_check(page, ostid_id(&oa->o_oi), - rnb[i].offset, - rnb[i].len); + rnb[i].rnb_offset, + rnb[i].rnb_len); } ret = obd_commitrw(env, rw, exp, oa, 1, &ioo, @@ -1613,8 +1546,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = echo_get_object(&eco, ed, oa); if (rc == 0) { - rc = obd_destroy(env, ec->ec_exp, oa, NULL, - &dummy_oti, NULL); + rc = obd_destroy(env, ec->ec_exp, oa, &dummy_oti); if (rc == 0) eco->eo_deleted = 1; echo_put_object(eco); |