From 761e93f471aed74cabd9de75310d7b028875a9f0 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 27 Oct 2014 17:53:04 -0500 Subject: [PATCH] LU-5814 echo: remove userspace LSM handling In lustre/obdecho/echo_client.c, remove handling of lov_stripe_md passed from userspace (since userspace never passes it). Remove the LOV specific code (ed_next_islov) from the echo client (since it doesn't work). Remove echo_get_stripe_off_id() and all calls to it since the stripe count of the passed in lsm is always 0 and the funciton does nothing in this case. Remove the then unused lsm parameters of echo_client_page_debug_setup() and echo_client_page_debug_check(). In the OBD_IOC_GETATTR and OBD_IOC_SETATTR cases of echo_client_iocontrol() do not set the oi_md member of struct obd_info since only LOV OBD methods access it. Signed-off-by: John L. Hammond Change-Id: If5d31ca3bf798d2e4f6c4f63c2012160e50f8cd7 Reviewed-on: http://review.whamcloud.com/12446 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger --- lustre/include/obd.h | 1 - lustre/obdecho/echo_client.c | 213 +++++++++++-------------------------------- 2 files changed, 52 insertions(+), 162 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index d2d0012..6488d08 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -364,7 +364,6 @@ struct echo_client_obd { spinlock_t ec_lock; struct list_head ec_objects; struct list_head ec_locks; - int ec_nstripes; __u64 ec_unique; }; diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 8bdc8f6..d8ea518 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -64,7 +64,6 @@ struct echo_device { struct cl_site ed_site_myself; struct cl_site *ed_site; struct lu_device *ed_next; - int ed_next_islov; int ed_next_ismd; struct lu_client_seq *ed_cl_seq; }; @@ -779,14 +778,19 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, } next = tgt->obd_lu_dev; - if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) { - ed->ed_next_ismd = 1; - } else { - ed->ed_next_ismd = 0; - rc = echo_site_init(env, ed); - if (rc) - GOTO(out, rc); - } + + if (strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME) == 0) { + ed->ed_next_ismd = 1; + } else if (strcmp(tgt->obd_type->typ_name, LUSTRE_OST_NAME) == 0 || + strcmp(tgt->obd_type->typ_name, LUSTRE_OSC_NAME) == 0) { + ed->ed_next_ismd = 0; + rc = echo_site_init(env, ed); + if (rc) + GOTO(out, rc); + } else { + GOTO(out, rc = -EINVAL); + } + cleanup = 3; rc = echo_client_setup(env, obd, cfg); @@ -849,7 +853,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, "Only remote operations are supported. Metadata client " "must be run on server side.\n"); GOTO(out, rc = -EOPNOTSUPP); -#endif +#endif /* HAVE_SERVER_SUPPORT */ } else { /* if echo client is to be stacked upon ost device, the next is * NULL since ost is not a clio device so far */ @@ -868,15 +872,6 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, NULL); if (rc) GOTO(out, rc); - - /* Tricky case, I have to determine the obd type since - * CLIO uses the different parameters to initialize - * objects for lov & osc. */ - if (strcmp(tgt_type_name, LUSTRE_LOV_NAME) == 0) - ed->ed_next_islov = 1; - else - LASSERT(strcmp(tgt_type_name, - LUSTRE_OSC_NAME) == 0); } else LASSERT(strcmp(tgt_type_name, LUSTRE_OST_NAME) == 0); } @@ -1055,18 +1050,11 @@ 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) { - if (!d->ed_next_islov) { - struct lov_oinfo *oinfo = lsm->lsm_oinfo[0]; - LASSERT(oinfo != NULL); - oinfo->loi_oi = lsm->lsm_oi; - conf->eoc_cl.u.coc_oinfo = oinfo; - } else { - struct lustre_md *md; - md = &info->eti_md; - memset(md, 0, sizeof *md); - md->lsm = lsm; - conf->eoc_cl.u.coc_md = md; - } + struct lov_oinfo *oinfo = lsm->lsm_oinfo[0]; + + LASSERT(oinfo != NULL); + oinfo->loi_oi = lsm->lsm_oi; + conf->eoc_cl.u.coc_oinfo = oinfo; } conf->eoc_md = lsmp; @@ -1305,36 +1293,6 @@ out: static obd_id last_object_id; -static int -echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm, - void __user *ulsm, int ulsm_nob) -{ - struct echo_client_obd *ec = ed->ed_ec; - int i; - - if (ulsm_nob < sizeof (*lsm)) - return (-EINVAL); - - if (copy_from_user (lsm, ulsm, sizeof (*lsm))) - return (-EFAULT); - - if (lsm->lsm_stripe_count > ec->ec_nstripes || - lsm->lsm_magic != LOV_MAGIC || - (lsm->lsm_stripe_size & (~CFS_PAGE_MASK)) != 0 || - ((__u64)lsm->lsm_stripe_size * lsm->lsm_stripe_count > ~0UL)) - return (-EINVAL); - - - for (i = 0; i < lsm->lsm_stripe_count; i++) { - if (copy_from_user(lsm->lsm_oinfo[i], - ((struct lov_stripe_md *)ulsm)-> \ - lsm_oinfo[i], - sizeof(lsm->lsm_oinfo[0]))) - return (-EFAULT); - } - return (0); -} - #ifdef HAVE_SERVER_SUPPORT static inline void echo_md_build_name(struct lu_name *lname, char *name, __u64 id) @@ -2130,8 +2088,7 @@ out_env: #endif /* HAVE_SERVER_SUPPORT */ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, - int on_target, struct obdo *oa, void __user *ulsm, - int ulsm_nob, struct obd_trans_info *oti) + struct obdo *oa, struct obd_trans_info *oti) { struct echo_object *eco; struct echo_client_obd *ec = ed->ed_ec; @@ -2140,9 +2097,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, int created = 0; ENTRY; - if ((oa->o_valid & OBD_MD_FLID) == 0 && /* no obj id */ - (on_target || /* set_stripe */ - ec->ec_nstripes != 0)) { /* LOV */ + if ((oa->o_valid & OBD_MD_FLID) == 0) { /* no obj id */ CERROR ("No valid oid\n"); RETURN(-EINVAL); } @@ -2153,32 +2108,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, GOTO(failed, rc); } - if (ulsm != NULL) { - int i, idx; - - rc = echo_copyin_lsm (ed, lsm, ulsm, ulsm_nob); - if (rc != 0) - GOTO(failed, rc); - - if (lsm->lsm_stripe_count == 0) - lsm->lsm_stripe_count = ec->ec_nstripes; - - if (lsm->lsm_stripe_size == 0) - lsm->lsm_stripe_size = PAGE_CACHE_SIZE; - - idx = cfs_rand(); - - /* setup stripes: indices + default ids if required */ - for (i = 0; i < lsm->lsm_stripe_count; i++) { - if (ostid_id(&lsm->lsm_oinfo[i]->loi_oi) == 0) - lsm->lsm_oinfo[i]->loi_oi = lsm->lsm_oi; - - lsm->lsm_oinfo[i]->loi_ost_idx = - (idx + i) % ec->ec_nstripes; - } - } - - /* setup object ID here for !on_target and LOV hint */ + /* setup object ID here */ if (oa->o_valid & OBD_MD_FLID) { LASSERT(oa->o_valid & OBD_MD_FLGROUP); lsm->lsm_oi = oa->o_oi; @@ -2187,19 +2117,18 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, if (ostid_id(&lsm->lsm_oi) == 0) ostid_set_id(&lsm->lsm_oi, ++last_object_id); - rc = 0; - if (on_target) { - /* Only echo objects are allowed to be created */ - LASSERT((oa->o_valid & OBD_MD_FLGROUP) && - (ostid_seq(&oa->o_oi) == FID_SEQ_ECHO)); - rc = obd_create(env, ec->ec_exp, oa, &lsm, oti); - if (rc != 0) { - CERROR("Cannot create objects: rc = %d\n", rc); - GOTO(failed, rc); - } - created = 1; + /* Only echo objects are allowed to be created */ + LASSERT((oa->o_valid & OBD_MD_FLGROUP) && + (ostid_seq(&oa->o_oi) == FID_SEQ_ECHO)); + + rc = obd_create(env, ec->ec_exp, oa, &lsm, oti); + if (rc != 0) { + CERROR("Cannot create objects: rc = %d\n", rc); + GOTO(failed, rc); } + created = 1; + /* See what object ID we were given */ oa->o_oi = lsm->lsm_oi; oa->o_valid |= OBD_MD_FLID; @@ -2266,38 +2195,8 @@ static void echo_put_object(struct echo_object *eco) } static void -echo_get_stripe_off_id (struct lov_stripe_md *lsm, obd_off *offp, obd_id *idp) -{ - unsigned long stripe_count; - unsigned long stripe_size; - unsigned long width; - unsigned long woffset; - int stripe_index; - obd_off offset; - - if (lsm->lsm_stripe_count <= 1) - return; - - offset = *offp; - stripe_size = lsm->lsm_stripe_size; - stripe_count = lsm->lsm_stripe_count; - - /* width = # bytes in all stripes */ - width = stripe_size * stripe_count; - - /* woffset = offset within a width; offset = whole number of widths */ - woffset = do_div (offset, width); - - stripe_index = woffset / stripe_size; - - *idp = ostid_id(&lsm->lsm_oinfo[stripe_index]->loi_oi); - *offp = offset * stripe_size + woffset % stripe_size; -} - -static void -echo_client_page_debug_setup(struct lov_stripe_md *lsm, - struct page *page, int rw, obd_id id, - obd_off offset, obd_off count) +echo_client_page_debug_setup(struct page *page, int rw, obd_id id, + obd_off offset, obd_off count) { char *addr; obd_off stripe_off; @@ -2313,7 +2212,6 @@ echo_client_page_debug_setup(struct lov_stripe_md *lsm, if (rw == OBD_BRW_WRITE) { stripe_off = offset + delta; stripe_id = id; - echo_get_stripe_off_id(lsm, &stripe_off, &stripe_id); } else { stripe_off = 0xdeadbeef00c0ffeeULL; stripe_id = 0xdeadbeef00c0ffeeULL; @@ -2325,9 +2223,9 @@ echo_client_page_debug_setup(struct lov_stripe_md *lsm, kunmap(page); } -static int echo_client_page_debug_check(struct lov_stripe_md *lsm, - struct page *page, obd_id id, - obd_off offset, obd_off count) +static int +echo_client_page_debug_check(struct page *page, obd_id id, obd_off offset, + obd_off count) { obd_off stripe_off; obd_id stripe_id; @@ -2344,7 +2242,6 @@ static int echo_client_page_debug_check(struct lov_stripe_md *lsm, for (rc = delta = 0; delta < PAGE_CACHE_SIZE; delta += OBD_ECHO_BLOCK_SIZE) { stripe_off = offset + delta; stripe_id = id; - echo_get_stripe_off_id (lsm, &stripe_off, &stripe_id); rc2 = block_debug_check("test_brw", addr + delta, OBD_ECHO_BLOCK_SIZE, @@ -2364,7 +2261,6 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, obd_size count, int async, struct obd_trans_info *oti) { - struct lov_stripe_md *lsm = eco->eo_lsm; obd_count npages; struct brw_page *pga; struct brw_page *pgp; @@ -2384,8 +2280,6 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, gfp_mask = ((ostid_id(&oa->o_oi) & 2) == 0) ? GFP_IOFS : GFP_HIGHUSER; LASSERT(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ); - LASSERT(lsm != NULL); - LASSERT(ostid_id(&lsm->lsm_oi) == ostid_id(&oa->o_oi)); if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0) @@ -2424,7 +2318,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, pgp->flag = brw_flags; if (verify) - echo_client_page_debug_setup(lsm, pgp->pg, rw, + echo_client_page_debug_setup(pgp->pg, rw, ostid_id(&oa->o_oi), off, pgp->count); } @@ -2443,7 +2337,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, if (verify) { int vrc; - vrc = echo_client_page_debug_check(lsm, pgp->pg, + vrc = echo_client_page_debug_check(pgp->pg, ostid_id(&oa->o_oi), pgp->off, pgp->count); if (vrc != 0 && rc == 0) @@ -2463,7 +2357,6 @@ static int echo_client_prep_commit(const struct lu_env *env, obd_size batch, struct obd_trans_info *oti, int async) { - struct lov_stripe_md *lsm = eco->eo_lsm; struct obd_ioobj ioo; struct niobuf_local *lnb; struct niobuf_remote *rnb; @@ -2473,8 +2366,7 @@ static int echo_client_prep_commit(const struct lu_env *env, ENTRY; - if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0 || - (lsm != NULL && ostid_id(&lsm->lsm_oi) != ostid_id(&oa->o_oi))) + if (count <= 0 || (count & ~PAGE_CACHE_MASK) != 0) RETURN(-EINVAL); npages = batch >> PAGE_CACHE_SHIFT; @@ -2530,12 +2422,12 @@ static int echo_client_prep_commit(const struct lu_env *env, continue; if (rw == OBD_BRW_WRITE) - echo_client_page_debug_setup(lsm, page, rw, + echo_client_page_debug_setup(page, rw, ostid_id(&oa->o_oi), rnb[i].rnb_offset, rnb[i].rnb_len); else - echo_client_page_debug_check(lsm, page, + echo_client_page_debug_check(page, ostid_id(&oa->o_oi), rnb[i].rnb_offset, rnb[i].rnb_len); @@ -2682,8 +2574,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (!cfs_capable(CFS_CAP_SYS_ADMIN)) GOTO (out, rc = -EPERM); - rc = echo_create_object(env, ed, 1, oa, data->ioc_pbuf1, - data->ioc_plen1, &dummy_oti); + rc = echo_create_object(env, ed, oa, &dummy_oti); GOTO(out, rc); #ifdef HAVE_SERVER_SUPPORT @@ -2759,8 +2650,8 @@ 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, eco->eo_lsm, - &dummy_oti, NULL, NULL); + rc = obd_destroy(env, ec->ec_exp, oa, NULL, + &dummy_oti, NULL, NULL); if (rc == 0) eco->eo_deleted = 1; echo_put_object(eco); @@ -2770,9 +2661,10 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, case OBD_IOC_GETATTR: rc = echo_get_object(&eco, ed, oa); if (rc == 0) { - struct obd_info oinfo = { { { 0 } } }; - oinfo.oi_md = eco->eo_lsm; - oinfo.oi_oa = oa; + struct obd_info oinfo = { + .oi_oa = oa, + }; + rc = obd_getattr(env, ec->ec_exp, &oinfo); echo_put_object(eco); } @@ -2784,9 +2676,9 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = echo_get_object(&eco, ed, oa); if (rc == 0) { - struct obd_info oinfo = { { { 0 } } }; - oinfo.oi_oa = oa; - oinfo.oi_md = eco->eo_lsm; + struct obd_info oinfo = { + .oi_oa = oa, + }; rc = obd_setattr(env, ec->ec_exp, &oinfo, NULL); echo_put_object(eco); @@ -2856,7 +2748,6 @@ static int echo_client_setup(const struct lu_env *env, INIT_LIST_HEAD(&ec->ec_objects); INIT_LIST_HEAD(&ec->ec_locks); ec->ec_unique = 0; - ec->ec_nstripes = 0; if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) { #ifdef HAVE_SERVER_SUPPORT -- 1.8.3.1