X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=inline;f=lustre%2Fobdecho%2Fecho_client.c;h=e435f5d60f28df33bb0315fbaf26cf1c7b6969ae;hb=9175d6f862039cfbf6b85333d72a9d91e64ea42a;hp=53ffaa2c0a53b6c66458a4e88342ac2761084946;hpb=13e11c1ed85b611ac8d51cf37be35d025d6fb6a1;p=fs%2Flustre-release.git diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 53ffaa2..e435f5d 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -27,7 +27,7 @@ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2013, Intel Corporation. + * Copyright (c) 2011, 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -35,6 +35,11 @@ */ #define DEBUG_SUBSYSTEM S_ECHO + +#include +#ifdef HAVE_UIDGID_HEADER +# include +#endif #include #include @@ -43,11 +48,13 @@ #include #include #include -#include #include #include #include #include +#ifdef HAVE_SERVER_SUPPORT +# include +#endif /* HAVE_SERVER_SUPPORT */ #include "echo_internal.h" @@ -56,31 +63,33 @@ */ struct echo_device { - struct cl_device ed_cl; - struct echo_client_obd *ed_ec; - - 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; + struct cl_device ed_cl; + struct echo_client_obd *ed_ec; + + struct cl_site ed_site_myself; + struct lu_site *ed_site; + struct lu_device *ed_next; + int ed_next_ismd; + struct lu_client_seq *ed_cl_seq; +#ifdef HAVE_SERVER_SUPPORT + struct local_oid_storage *ed_los; + struct lu_fid ed_root_fid; +#endif /* HAVE_SERVER_SUPPORT */ }; struct echo_object { - struct cl_object eo_cl; - struct cl_object_header eo_hdr; - - struct echo_device *eo_dev; + struct cl_object eo_cl; + struct cl_object_header eo_hdr; + 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; + int eo_deleted; }; struct echo_object_conf { - struct cl_object_conf eoc_cl; - struct lov_stripe_md **eoc_md; + struct cl_object_conf eoc_cl; + struct lov_oinfo **eoc_oinfo; }; struct echo_page { @@ -96,6 +105,23 @@ struct echo_lock { atomic_t el_refcount; }; +#ifdef HAVE_SERVER_SUPPORT +static const char echo_md_root_dir_name[] = "ROOT_ECHO"; + +/** + * In order to use the values of members in struct mdd_device, + * we define an alias structure here. + */ +struct echo_md_device { + struct md_device emd_md_dev; + struct obd_export *emd_child_exp; + struct dt_device *emd_child; + struct dt_device *emd_bottom; + struct lu_fid emd_root_fid; + struct lu_fid emd_local_root_fid; +}; +#endif /* HAVE_SERVER_SUPPORT */ + static int echo_client_setup(const struct lu_env *env, struct obd_device *obddev, struct lustre_cfg *lcfg); @@ -160,12 +186,32 @@ struct echo_object_conf *cl2echo_conf(const struct cl_object_conf *c) return container_of(c, struct echo_object_conf, eoc_cl); } +#ifdef HAVE_SERVER_SUPPORT +static inline struct echo_md_device *lu2emd_dev(struct lu_device *d) +{ + return container_of0(d, struct echo_md_device, emd_md_dev.md_lu_dev); +} + +static inline struct lu_device *emd2lu_dev(struct echo_md_device *d) +{ + return &d->emd_md_dev.md_lu_dev; +} + +static inline struct seq_server_site *echo_md_seq_site(struct echo_md_device *d) +{ + return emd2lu_dev(d)->ld_site->ld_seq_site; +} + +static inline struct obd_device *emd2obd_dev(struct echo_md_device *d) +{ + return d->emd_md_dev.md_lu_dev.ld_obd; +} +#endif /* HAVE_SERVER_SUPPORT */ + /** @} 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, obd_off offset, +static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, struct page **pages, int npages, int async); struct echo_thread_info { @@ -174,7 +220,7 @@ struct echo_thread_info { struct cl_2queue eti_queue; struct cl_io eti_io; - struct cl_lock_descr eti_descr; + struct cl_lock eti_lock; struct lu_fid eti_fid; struct lu_fid eti_fid2; #ifdef HAVE_SERVER_SUPPORT @@ -184,7 +230,7 @@ struct echo_thread_info { struct md_attr eti_ma; struct lu_name eti_lname; /* per-thread values, can be re-used */ - void *eti_big_lmm; + void *eti_big_lmm; /* may be vmalloc'd */ int eti_big_lmmsize; char eti_name[20]; struct lu_buf eti_buf; @@ -345,26 +391,8 @@ static void echo_lock_fini(const struct lu_env *env, OBD_SLAB_FREE_PTR(ecl, echo_lock_kmem); } -static void echo_lock_delete(const struct lu_env *env, - const struct cl_lock_slice *slice) -{ - struct echo_lock *ecl = cl2echo_lock(slice); - - LASSERT(list_empty(&ecl->el_chain)); -} - -static int echo_lock_fits_into(const struct lu_env *env, - const struct cl_lock_slice *slice, - const struct cl_lock_descr *need, - const struct cl_io *unused) -{ - return 1; -} - static struct cl_lock_operations echo_lock_ops = { .clo_fini = echo_lock_fini, - .clo_delete = echo_lock_delete, - .clo_fits_into = echo_lock_fits_into }; /** @} echo_lock */ @@ -456,13 +484,15 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, const struct cl_object_conf *cconf = lu2cl_conf(conf); struct echo_object_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; - } else { - eco->eo_lsm = NULL; - } + LASSERT(econf->eoc_oinfo != NULL); + + /* Transfer the oinfo pointer to eco that it won't be + * freed. */ + eco->eo_oinfo = *econf->eoc_oinfo; + *econf->eoc_oinfo = NULL; + } else { + eco->eo_oinfo = NULL; + } eco->eo_dev = ed; atomic_set(&eco->eo_npages, 0); @@ -475,57 +505,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; - - ENTRY; - - /* If export is lov/osc then use their obd method */ - if (ed->ed_next != NULL) - 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 == NULL); - OBD_ALLOC(*lsmp, lsm_size); - if (*lsmp == NULL) - RETURN(-ENOMEM); - - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - if ((*lsmp)->lsm_oinfo[0] == NULL) { - OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); - } - - loi_init((*lsmp)->lsm_oinfo[0]); - (*lsmp)->lsm_maxbytes = LUSTRE_EXT3_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; - - ENTRY; - - /* If export is lov/osc then use their obd method */ - if (ed->ed_next != NULL) - 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); - - LASSERT(*lsmp != NULL); - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); - *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)); @@ -541,8 +520,9 @@ 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); + if (eco->eo_oinfo != NULL) + OBD_FREE_PTR(eco->eo_oinfo); + OBD_SLAB_FREE_PTR(eco, echo_object_kmem); EXIT; } @@ -604,9 +584,6 @@ static struct lu_device_operations echo_device_lu_ops = { /** @} echo_lu_dev_ops */ -static struct cl_device_operations echo_device_cl_ops = { -}; - /** \defgroup echo_init Setup and teardown * * Init and fini functions for echo client. @@ -618,28 +595,30 @@ static int echo_site_init(const struct lu_env *env, struct echo_device *ed) struct cl_site *site = &ed->ed_site_myself; int rc; - /* initialize site */ + /* initialize site */ rc = cl_site_init(site, &ed->ed_cl); if (rc) { - CERROR("Cannot initilize site for echo client(%d)\n", rc); + CERROR("Cannot initialize site for echo client(%d)\n", rc); return rc; } - rc = lu_site_init_finish(&site->cs_lu); - if (rc) - return rc; + rc = lu_site_init_finish(&site->cs_lu); + if (rc) { + cl_site_fini(site); + return rc; + } - ed->ed_site = site; - return 0; + ed->ed_site = &site->cs_lu; + return 0; } static void echo_site_fini(const struct lu_env *env, struct echo_device *ed) { - if (ed->ed_site) { - if (!ed->ed_next_ismd) - cl_site_fini(ed->ed_site); - ed->ed_site = NULL; - } + if (ed->ed_site) { + if (!ed->ed_next_ismd) + lu_site_fini(ed->ed_site); + ed->ed_site = NULL; + } } static void *echo_thread_key_init(const struct lu_context *ctx, @@ -753,6 +732,87 @@ static int echo_fid_fini(struct obd_device *obddev) RETURN(0); } + +static void echo_ed_los_fini(const struct lu_env *env, struct echo_device *ed) +{ + ENTRY; + + if (ed != NULL && ed->ed_next_ismd && ed->ed_los != NULL) { + local_oid_storage_fini(env, ed->ed_los); + ed->ed_los = NULL; + } +} + +static int +echo_md_local_file_create(const struct lu_env *env, struct echo_md_device *emd, + struct local_oid_storage *los, + const struct lu_fid *pfid, const char *name, + __u32 mode, struct lu_fid *fid) +{ + struct dt_object *parent = NULL; + struct dt_object *dto = NULL; + int rc = 0; + ENTRY; + + LASSERT(!fid_is_zero(pfid)); + parent = dt_locate(env, emd->emd_bottom, pfid); + if (unlikely(IS_ERR(parent))) + RETURN(PTR_ERR(parent)); + + /* create local file with @fid */ + dto = local_file_find_or_create_with_fid(env, emd->emd_bottom, fid, + parent, name, mode); + if (IS_ERR(dto)) + GOTO(out_put, rc = PTR_ERR(dto)); + + *fid = *lu_object_fid(&dto->do_lu); + /* since stack is not fully set up the local_storage uses own stack + * and we should drop its object from cache */ + lu_object_put_nocache(env, &dto->do_lu); + + EXIT; +out_put: + lu_object_put(env, &parent->do_lu); + RETURN(rc); +} + +static int +echo_md_root_get(const struct lu_env *env, struct echo_md_device *emd, + struct echo_device *ed) +{ + struct lu_fid fid; + int rc = 0; + ENTRY; + + /* Setup local dirs */ + fid.f_seq = FID_SEQ_LOCAL_NAME; + fid.f_oid = 1; + fid.f_ver = 0; + rc = local_oid_storage_init(env, emd->emd_bottom, &fid, &ed->ed_los); + if (rc != 0) + RETURN(rc); + + lu_echo_root_fid(&fid); + if (echo_md_seq_site(emd)->ss_node_id == 0) { + rc = echo_md_local_file_create(env, emd, ed->ed_los, + &emd->emd_local_root_fid, + echo_md_root_dir_name, S_IFDIR | + S_IRUGO | S_IWUSR | S_IXUGO, + &fid); + if (rc != 0) { + CERROR("%s: create md echo root fid failed: rc = %d\n", + emd2obd_dev(emd)->obd_name, rc); + GOTO(out_los, rc); + } + } + ed->ed_root_fid = fid; + + RETURN(0); +out_los: + echo_ed_los_fini(env, ed); + + RETURN(rc); +} #endif /* HAVE_SERVER_SUPPORT */ static struct lu_device *echo_device_alloc(const struct lu_env *env, @@ -780,7 +840,6 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, GOTO(out, rc); cd->cd_lu_dev.ld_ops = &echo_device_lu_ops; - cd->cd_ops = &echo_device_cl_ops; cleanup = 2; obd = class_name2obd(lustre_cfg_string(cfg, 0)); @@ -795,14 +854,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); @@ -814,10 +878,12 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, if (ed->ed_next_ismd) { #ifdef HAVE_SERVER_SUPPORT - /* Suppose to connect to some Metadata layer */ - struct lu_site *ls; - struct lu_device *ld; - int found = 0; + /* Suppose to connect to some Metadata layer */ + struct lu_site *ls = NULL; + struct lu_device *ld = NULL; + struct md_device *md = NULL; + struct echo_md_device *emd = NULL; + int found = 0; if (next == NULL) { CERROR("%s is not lu device type!\n", @@ -850,22 +916,30 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, GOTO(out, rc = -EINVAL); } - next = ld; - /* For MD echo client, it will use the site in MDS stack */ - ed->ed_site_myself.cs_lu = *ls; - ed->ed_site = &ed->ed_site_myself; - ed->ed_cl.cd_lu_dev.ld_site = &ed->ed_site_myself.cs_lu; + next = ld; + /* For MD echo client, it will use the site in MDS stack */ + ed->ed_site = ls; + ed->ed_cl.cd_lu_dev.ld_site = ls; rc = echo_fid_init(ed, obd->obd_name, lu_site2seq(ls)); if (rc) { CERROR("echo fid init error %d\n", rc); GOTO(out, rc); } + + md = lu2md_dev(next); + emd = lu2emd_dev(&md->md_lu_dev); + rc = echo_md_root_get(env, emd, ed); + if (rc != 0) { + CERROR("%s: get root error: rc = %d\n", + emd2obd_dev(emd)->obd_name, rc); + GOTO(out, rc); + } #else /* !HAVE_SERVER_SUPPORT */ CERROR("Local operations are NOT supported on client side. " "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 */ @@ -878,21 +952,12 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, if (next->ld_site != NULL) GOTO(out, rc = -EBUSY); - next->ld_site = &ed->ed_site->cs_lu; + next->ld_site = ed->ed_site; rc = next->ld_type->ldt_ops->ldto_device_init(env, next, next->ld_type->ldt_name, 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); } @@ -944,18 +1009,9 @@ static void echo_lock_release(const struct lu_env *env, struct echo_lock *ecl, int still_used) { - struct cl_lock *clk = echo_lock2cl(ecl); + struct cl_lock *clk = echo_lock2cl(ecl); - cl_lock_get(clk); - cl_unuse(env, clk); - cl_lock_release(env, clk, "ec enqueue", ecl->el_object); - if (!still_used) { - cl_lock_mutex_get(env, clk); - cl_lock_cancel(env, clk); - cl_lock_delete(env, clk); - cl_lock_mutex_put(env, clk); - } - cl_lock_put(env, clk); + cl_lock_release(env, clk); } static struct lu_device *echo_device_free(const struct lu_env *env, @@ -969,7 +1025,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, CDEBUG(D_INFO, "echo device:%p is going to be freed, next = %p\n", ed, next); - lu_site_purge(env, &ed->ed_site->cs_lu, -1); + lu_site_purge(env, ed->ed_site, -1); /* check if there are objects still alive. * It shouldn't have any object because lu_site_purge would cleanup @@ -982,7 +1038,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, spin_unlock(&ec->ec_lock); /* purge again */ - lu_site_purge(env, &ed->ed_site->cs_lu, -1); + lu_site_purge(env, ed->ed_site, -1); CDEBUG(D_INFO, "Waiting for the reference of echo object to be dropped\n"); @@ -993,9 +1049,9 @@ static struct lu_device *echo_device_free(const struct lu_env *env, spin_unlock(&ec->ec_lock); CERROR("echo_client still has objects at cleanup time, " "wait for 1 second\n"); - schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE, - cfs_time_seconds(1)); - lu_site_purge(env, &ed->ed_site->cs_lu, -1); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(cfs_time_seconds(1)); + lu_site_purge(env, ed->ed_site, -1); spin_lock(&ec->ec_lock); } spin_unlock(&ec->ec_lock); @@ -1007,11 +1063,12 @@ static struct lu_device *echo_device_free(const struct lu_env *env, echo_client_cleanup(d->ld_obd); #ifdef HAVE_SERVER_SUPPORT echo_fid_fini(d->ld_obd); + echo_ed_los_fini(env, ed); #endif while (next && !ed->ed_next_ismd) next = next->ld_type->ldt_ops->ldto_device_free(env, next); - LASSERT(ed->ed_site == lu2cl_site(d->ld_site)); + LASSERT(ed->ed_site == d->ld_site); echo_site_fini(env, ed); cl_device_fini(&ed->ed_cl); OBD_FREE_PTR(ed); @@ -1048,26 +1105,22 @@ 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 echo_object *eco; - struct cl_object *obj; - struct lu_fid *fid; - int refcheck; + struct lu_env *env; + struct echo_thread_info *info; + struct echo_object_conf *conf; + struct echo_object *eco; + struct cl_object *obj; + struct lov_oinfo *oinfo = NULL; + struct lu_fid *fid; + __u16 refcheck; int rc; ENTRY; - 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) != 0, 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) @@ -1080,23 +1133,20 @@ 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; - } - } - conf->eoc_md = lsmp; + OBD_ALLOC_PTR(oinfo); + if (oinfo == NULL) + GOTO(out, eco = ERR_PTR(-ENOMEM)); - fid = &info->eti_fid; - rc = ostid_to_fid(fid, &lsm->lsm_oi, 0); + oinfo->loi_oi = *oi; + conf->eoc_cl.u.coc_oinfo = oinfo; + } + + /* 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, oi, 0); if (rc != 0) GOTO(out, eco = ERR_PTR(rc)); @@ -1114,6 +1164,9 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, } out: + if (oinfo != NULL) + OBD_FREE_PTR(oinfo); + cl_env_put(env, &refcheck); RETURN(eco); } @@ -1122,7 +1175,7 @@ static int cl_echo_object_put(struct echo_object *eco) { struct lu_env *env; struct cl_object *obj = echo_obj2cl(eco); - int refcheck; + __u16 refcheck; ENTRY; env = cl_env_get(&refcheck); @@ -1142,8 +1195,8 @@ static int cl_echo_object_put(struct echo_object *eco) } static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, - obd_off start, obd_off end, int mode, - __u64 *cookie , __u32 enqflags) + u64 start, u64 end, int mode, + __u64 *cookie , __u32 enqflags) { struct cl_io *io; struct cl_lock *lck; @@ -1155,9 +1208,11 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, info = echo_env_info(env); io = &info->eti_io; - descr = &info->eti_descr; - obj = echo_obj2cl(eco); + lck = &info->eti_lock; + obj = echo_obj2cl(eco); + memset(lck, 0, sizeof(*lck)); + descr = &lck->cll_descr; descr->cld_obj = obj; descr->cld_start = cl_index(obj, start); descr->cld_end = cl_index(obj, end); @@ -1165,25 +1220,20 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, descr->cld_enq_flags = enqflags; io->ci_obj = obj; - lck = cl_lock_request(env, io, descr, "ec enqueue", eco); - if (lck) { - struct echo_client_obd *ec = eco->eo_dev->ed_ec; - struct echo_lock *el; + rc = cl_lock_request(env, io, lck); + if (rc == 0) { + struct echo_client_obd *ec = eco->eo_dev->ed_ec; + struct echo_lock *el; - rc = cl_wait(env, lck); - if (rc == 0) { - el = cl2echo_lock(cl_lock_at(lck, &echo_device_type)); - spin_lock(&ec->ec_lock); - if (list_empty(&el->el_chain)) { - list_add(&el->el_chain, &ec->ec_locks); - el->el_cookie = ++ec->ec_unique; - } - atomic_inc(&el->el_refcount); - *cookie = el->el_cookie; - spin_unlock(&ec->ec_lock); - } else { - cl_lock_release(env, lck, "ec enqueue", current); + el = cl2echo_lock(cl_lock_at(lck, &echo_device_type)); + spin_lock(&ec->ec_lock); + if (list_empty(&el->el_chain)) { + list_add(&el->el_chain, &ec->ec_locks); + el->el_cookie = ++ec->ec_unique; } + atomic_inc(&el->el_refcount); + *cookie = el->el_cookie; + spin_unlock(&ec->ec_lock); } RETURN(rc); } @@ -1233,7 +1283,7 @@ static void echo_commit_callback(const struct lu_env *env, struct cl_io *io, cl_page_list_add(&queue->c2_qout, page); } -static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, +static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, struct page **pages, int npages, int async) { struct lu_env *env; @@ -1245,12 +1295,12 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, struct cl_page *clp; struct lustre_handle lh = { 0 }; int page_size = cl_page_size(obj); - int refcheck; int rc; int i; + __u16 refcheck; ENTRY; - LASSERT((offset & ~CFS_PAGE_MASK) == 0); + LASSERT((offset & ~PAGE_MASK) == 0); LASSERT(ed->ed_next != NULL); env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1331,37 +1381,7 @@ out: /** @} echo_exports */ -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); -} +static u64 last_object_id; #ifdef HAVE_SERVER_SUPPORT static inline void echo_md_build_name(struct lu_name *lname, char *name, @@ -1938,22 +1958,16 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, struct echo_device *ed, char *path, int path_len) { - struct lu_device *ld = ed->ed_next; - struct md_device *md = lu2md_dev(ld); - struct echo_thread_info *info = echo_env_info(env); - struct lu_fid *fid = &info->eti_fid; - struct lu_name *lname = &info->eti_lname; - struct lu_object *parent = NULL; - struct lu_object *child = NULL; - int rc = 0; - ENTRY; + struct lu_device *ld = ed->ed_next; + struct echo_thread_info *info = echo_env_info(env); + struct lu_fid *fid = &info->eti_fid; + struct lu_name *lname = &info->eti_lname; + struct lu_object *parent = NULL; + struct lu_object *child = NULL; + int rc = 0; + ENTRY; - /*Only support MDD layer right now*/ - rc = md->md_ops->mdo_root_get(env, md, fid); - if (rc) { - CERROR("get root error: rc = %d\n", rc); - RETURN(ERR_PTR(rc)); - } + *fid = ed->ed_root_fid; /* In the function below, .hs_keycmp resolves to * lu_obj_hop_keycmp() */ @@ -2046,7 +2060,7 @@ static int echo_md_handler(struct echo_device *ed, int command, struct echo_thread_info *info; struct lu_device *ld = ed->ed_next; struct lu_env *env; - int refcheck; + __u16 refcheck; struct lu_object *parent; char *name = NULL; int namelen = data->ioc_plen2; @@ -2158,81 +2172,35 @@ 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 echo_object *eco; - struct echo_client_obd *ec = ed->ed_ec; - struct lov_stripe_md *lsm = NULL; - int rc; - int created = 0; - ENTRY; - - if ((oa->o_valid & OBD_MD_FLID) == 0 && /* no obj id */ - (on_target || /* set_stripe */ - ec->ec_nstripes != 0)) { /* LOV */ - CERROR ("No valid oid\n"); - RETURN(-EINVAL); - } - - rc = echo_alloc_memmd(ed, &lsm); - if (rc < 0) { - CERROR("Cannot allocate md: rc = %d\n", rc); - 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; - } - } + struct echo_object *eco; + struct echo_client_obd *ec = ed->ed_ec; + int created = 0; + int rc; + ENTRY; - /* setup object ID here for !on_target and LOV hint */ - if (oa->o_valid & OBD_MD_FLID) { - LASSERT(oa->o_valid & OBD_MD_FLGROUP); - lsm->lsm_oi = oa->o_oi; + if (!(oa->o_valid & OBD_MD_FLID) || + !(oa->o_valid & OBD_MD_FLGROUP) || + !fid_seq_is_echo(ostid_seq(&oa->o_oi))) { + CERROR("invalid oid "DOSTID"\n", POSTID(&oa->o_oi)); + RETURN(-EINVAL); } - if (ostid_id(&lsm->lsm_oi) == 0) - ostid_set_id(&lsm->lsm_oi, ++last_object_id); + if (ostid_id(&oa->o_oi) == 0) + ostid_set_id(&oa->o_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; + rc = obd_create(env, ec->ec_exp, oa); + if (rc != 0) { + CERROR("Cannot create objects: rc = %d\n", rc); + GOTO(failed, rc); } - /* See what object ID we were given */ - oa->o_oi = lsm->lsm_oi; - oa->o_valid |= OBD_MD_FLID; + created = 1; - eco = cl_echo_object_find(ed, &lsm); + oa->o_valid |= OBD_MD_FLID; + + eco = cl_echo_object_find(ed, &oa->o_oi); if (IS_ERR(eco)) GOTO(failed, rc = PTR_ERR(eco)); cl_echo_object_put(eco); @@ -2240,47 +2208,38 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, CDEBUG(D_INFO, "oa oid "DOSTID"\n", POSTID(&oa->o_oi)); EXIT; - failed: - if (created && rc) - obd_destroy(env, ec->ec_exp, oa, lsm, oti, NULL, NULL); - if (lsm) - echo_free_memmd(ed, &lsm); - if (rc) - CERROR("create object failed with: rc = %d\n", rc); - return (rc); +failed: + if (created && rc != 0) + obd_destroy(env, ec->ec_exp, oa); + + if (rc != 0) + CERROR("create object failed with: rc = %d\n", rc); + + return rc; } static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, - struct obdo *oa) + struct obdo *oa) { - struct lov_stripe_md *lsm = NULL; - struct echo_object *eco; - int rc; - ENTRY; + struct echo_object *eco; + int rc; + ENTRY; - 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"); - RETURN(-EINVAL); - } + if (!(oa->o_valid & OBD_MD_FLID) || + !(oa->o_valid & OBD_MD_FLGROUP) || + ostid_id(&oa->o_oi) == 0) { + CERROR("invalid oid "DOSTID"\n", POSTID(&oa->o_oi)); + RETURN(-EINVAL); + } - rc = echo_alloc_memmd(ed, &lsm); - if (rc < 0) - RETURN(rc); + rc = 0; + eco = cl_echo_object_find(ed, &oa->o_oi); + if (!IS_ERR(eco)) + *ecop = eco; + else + rc = PTR_ERR(eco); - 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); - if (!IS_ERR(eco)) - *ecop = eco; - else - rc = PTR_ERR(eco); - if (lsm) - echo_free_memmd(ed, &lsm); - RETURN(rc); + RETURN(rc); } static void echo_put_object(struct echo_object *eco) @@ -2293,44 +2252,13 @@ static void echo_put_object(struct echo_object *eco) eco->eo_dev->ed_ec->ec_exp->exp_obd->obd_name, rc); } -static void -echo_get_stripe_off_id (struct lov_stripe_md *lsm, obd_off *offp, obd_id *idp) +static void echo_client_page_debug_setup(struct page *page, int rw, u64 id, + u64 offset, u64 count) { - 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) -{ - char *addr; - obd_off stripe_off; - obd_id stripe_id; - int delta; + char *addr; + u64 stripe_off; + u64 stripe_id; + int delta; /* no partial pages on the client */ LASSERT(count == PAGE_CACHE_SIZE); @@ -2341,7 +2269,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; @@ -2353,12 +2280,11 @@ 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, u64 id, u64 offset, u64 count) { - obd_off stripe_off; - obd_id stripe_id; + u64 stripe_off; + u64 stripe_id; char *addr; int delta; int rc; @@ -2372,7 +2298,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, @@ -2388,21 +2313,19 @@ static int echo_client_page_debug_check(struct lov_stripe_md *lsm, } static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, - struct echo_object *eco, obd_off offset, - obd_size count, int async, - struct obd_trans_info *oti) + struct echo_object *eco, u64 offset, + u64 count, int async) { - struct lov_stripe_md *lsm = eco->eo_lsm; - obd_count npages; + size_t npages; struct brw_page *pga; struct brw_page *pgp; struct page **pages; - obd_off off; - int i; + u64 off; + size_t i; int rc; int verify; gfp_t gfp_mask; - int brw_flags = 0; + u32 brw_flags = 0; ENTRY; verify = (ostid_id(&oa->o_oi) != ECHO_PERSISTENT_OBJID && @@ -2412,12 +2335,9 @@ 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) - RETURN(-EINVAL); + if ((count & (~PAGE_MASK)) != 0) + RETURN(-EINVAL); /* XXX think again with misaligned I/O */ npages = count >> PAGE_CACHE_SHIFT; @@ -2435,27 +2355,27 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, RETURN(-ENOMEM); } - for (i = 0, pgp = pga, off = offset; - i < npages; + for (i = 0, pgp = pga, off = offset; + i < npages; i++, pgp++, off += PAGE_CACHE_SIZE) { - LASSERT (pgp->pg == NULL); /* for cleanup */ + LASSERT(pgp->pg == NULL); /* for cleanup */ - rc = -ENOMEM; - OBD_PAGE_ALLOC(pgp->pg, gfp_mask); - if (pgp->pg == NULL) - goto out; + rc = -ENOMEM; + pgp->pg = alloc_page(gfp_mask); + if (pgp->pg == NULL) + goto out; - pages[i] = pgp->pg; + pages[i] = pgp->pg; pgp->count = PAGE_CACHE_SIZE; - pgp->off = off; - pgp->flag = brw_flags; + pgp->off = off; + 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); - } + } /* brw mode can only be used at client */ LASSERT(ed->ed_next != NULL); @@ -2471,13 +2391,13 @@ 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) rc = vrc; } - OBD_PAGE_FREE(pgp->pg); + __free_page(pgp->pg); } OBD_FREE(pga, npages * sizeof(*pga)); OBD_FREE(pages, npages * sizeof(*pages)); @@ -2487,62 +2407,53 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, static int echo_client_prep_commit(const struct lu_env *env, struct obd_export *exp, int rw, struct obdo *oa, struct echo_object *eco, - obd_off offset, obd_size count, - 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; - obd_off off; - obd_size npages, tot_pages; + u64 offset, u64 count, + u64 batch, int async) +{ + struct obd_ioobj ioo; + struct niobuf_local *lnb; + struct niobuf_remote rnb; + u64 off; + u64 npages, tot_pages; int i, ret = 0, brw_flags = 0; 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; tot_pages = count >> PAGE_CACHE_SHIFT; - OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local)); - OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote)); - - if (lnb == NULL || rnb == NULL) - GOTO(out, ret = -ENOMEM); + OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local)); + if (lnb == NULL) + GOTO(out, ret = -ENOMEM); if (rw == OBD_BRW_WRITE && async) brw_flags |= OBD_BRW_ASYNC; - obdo_to_ioobj(oa, &ioo); + obdo_to_ioobj(oa, &ioo); - off = offset; + off = offset; - for(; tot_pages; tot_pages -= npages) { - int lpages; + for (; tot_pages > 0; tot_pages -= npages) { + int lpages; - if (tot_pages < npages) - npages = tot_pages; - - for (i = 0; i < npages; i++, off += PAGE_CACHE_SIZE) { - rnb[i].rnb_offset = off; - rnb[i].rnb_len = PAGE_CACHE_SIZE; - rnb[i].rnb_flags = brw_flags; - } + if (tot_pages < npages) + npages = tot_pages; - ioo.ioo_bufcnt = npages; + rnb.rnb_offset = off; + rnb.rnb_len = npages * PAGE_CACHE_SIZE; + rnb.rnb_flags = brw_flags; + ioo.ioo_bufcnt = 1; + off += npages * PAGE_CACHE_SIZE; lpages = npages; - ret = obd_preprw(env, rw, exp, oa, 1, &ioo, rnb, &lpages, - lnb, oti, NULL); + ret = obd_preprw(env, rw, exp, oa, 1, &ioo, &rnb, &lpages, lnb); if (ret != 0) GOTO(out, ret); - LASSERT(lpages == npages); - for (i = 0; i < lpages; i++) { + for (i = 0; i < lpages; i++) { struct page *page = lnb[i].lnb_page; /* read past eof? */ @@ -2558,42 +2469,36 @@ 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, - ostid_id(&oa->o_oi), - rnb[i].rnb_offset, - rnb[i].rnb_len); + echo_client_page_debug_setup(page, rw, + ostid_id(&oa->o_oi), + lnb[i].lnb_file_offset, + lnb[i].lnb_len); else - echo_client_page_debug_check(lsm, page, - ostid_id(&oa->o_oi), - rnb[i].rnb_offset, - rnb[i].rnb_len); + echo_client_page_debug_check(page, + ostid_id(&oa->o_oi), + lnb[i].lnb_file_offset, + lnb[i].lnb_len); } - ret = obd_commitrw(env, rw, exp, oa, 1, &ioo, - rnb, npages, lnb, oti, ret); + ret = obd_commitrw(env, rw, exp, oa, 1, &ioo, &rnb, npages, lnb, + ret); if (ret != 0) GOTO(out, ret); - /* Reset oti otherwise it would confuse ldiskfs. */ - memset(oti, 0, sizeof(*oti)); - /* Reuse env context. */ lu_context_exit((struct lu_context *)&env->le_ctx); lu_context_enter((struct lu_context *)&env->le_ctx); - } + } out: - if (lnb) - OBD_FREE(lnb, npages * sizeof(struct niobuf_local)); - if (rnb) - OBD_FREE(rnb, npages * sizeof(struct niobuf_remote)); - RETURN(ret); + if (lnb) + OBD_FREE(lnb, npages * sizeof(struct niobuf_local)); + RETURN(ret); } static int echo_client_brw_ioctl(const struct lu_env *env, int rw, struct obd_export *exp, - struct obd_ioctl_data *data, - struct obd_trans_info *dummy_oti) + struct obd_ioctl_data *data) { struct obd_device *obd = class_exp2obd(exp); struct echo_device *ed = obd2echo_dev(obd); @@ -2631,26 +2536,26 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, case 1: /* fall through */ case 2: - rc = echo_client_kbrw(ed, rw, oa, - eco, data->ioc_offset, - data->ioc_count, async, dummy_oti); - break; - case 3: - rc = echo_client_prep_commit(env, ec->ec_exp, rw, oa, - eco, data->ioc_offset, - data->ioc_count, data->ioc_plen1, - dummy_oti, async); - break; - default: - rc = -EINVAL; - } - echo_put_object(eco); - RETURN(rc); + rc = echo_client_kbrw(ed, rw, oa, eco, data->ioc_offset, + data->ioc_count, async); + break; + case 3: + rc = echo_client_prep_commit(env, ec->ec_exp, rw, oa, eco, + data->ioc_offset, data->ioc_count, + data->ioc_plen1, async); + break; + default: + rc = -EINVAL; + } + + echo_put_object(eco); + + RETURN(rc); } static int echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, - void *karg, void *uarg) + void *karg, void __user *uarg) { #ifdef HAVE_SERVER_SUPPORT struct tgt_session_info *tsi; @@ -2660,21 +2565,16 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct echo_client_obd *ec = ed->ed_ec; struct echo_object *eco; struct obd_ioctl_data *data = karg; - struct obd_trans_info dummy_oti; struct lu_env *env; - struct oti_req_ack_lock *ack_lock; struct obdo *oa; struct lu_fid fid; int rw = OBD_BRW_READ; int rc = 0; - int i; #ifdef HAVE_SERVER_SUPPORT struct lu_context echo_session; #endif ENTRY; - memset(&dummy_oti, 0, sizeof(dummy_oti)); - oa = &data->ioc_obdo1; if (!(oa->o_valid & OBD_MD_FLGROUP)) { oa->o_valid |= OBD_MD_FLGROUP; @@ -2710,8 +2610,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); GOTO(out, rc); #ifdef HAVE_SERVER_SUPPORT @@ -2745,7 +2644,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } case OBD_IOC_ECHO_ALLOC_SEQ: { struct lu_env *cl_env; - int refcheck; + __u16 refcheck; __u64 seq; int max_count; @@ -2787,8 +2686,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, eco->eo_lsm, - &dummy_oti, NULL, NULL); + rc = obd_destroy(env, ec->ec_exp, oa); if (rc == 0) eco->eo_deleted = 1; echo_put_object(eco); @@ -2798,10 +2696,7 @@ 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; - rc = obd_getattr(env, ec->ec_exp, &oinfo); + rc = obd_getattr(env, ec->ec_exp, oa); echo_put_object(eco); } GOTO(out, rc); @@ -2812,11 +2707,7 @@ 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; - - rc = obd_setattr(env, ec->ec_exp, &oinfo, NULL); + rc = obd_setattr(env, ec->ec_exp, oa); echo_put_object(eco); } GOTO(out, rc); @@ -2828,7 +2719,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rw = OBD_BRW_WRITE; /* fall through */ case OBD_IOC_BRW_READ: - rc = echo_client_brw_ioctl(env, rw, exp, data, &dummy_oti); + rc = echo_client_brw_ioctl(env, rw, exp, data); GOTO(out, rc); default: @@ -2847,14 +2738,6 @@ out_env: out_alloc: OBD_FREE_PTR(env); - /* XXX this should be in a helper also called by target_send_reply */ - for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4; - i++, ack_lock++) { - if (!ack_lock->mode) - break; - ldlm_lock_decref(&ack_lock->lock, ack_lock->mode); - } - return rc; } @@ -2884,7 +2767,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 @@ -3006,27 +2888,6 @@ static struct obd_ops echo_client_obd_ops = { .o_disconnect = echo_client_disconnect }; -int echo_client_init(void) -{ - int rc; - - rc = lu_kmem_init(echo_caches); - if (rc == 0) { - rc = class_register_type(&echo_client_obd_ops, NULL, true, NULL, - LUSTRE_ECHO_CLIENT_NAME, - &echo_device_type); - if (rc) - lu_kmem_fini(echo_caches); - } - return rc; -} - -void echo_client_exit(void) -{ - class_unregister_type(LUSTRE_ECHO_CLIENT_NAME); - lu_kmem_fini(echo_caches); -} - static int __init obdecho_init(void) { int rc; @@ -3047,7 +2908,14 @@ static int __init obdecho_init(void) goto failed_1; # endif - rc = echo_client_init(); + rc = lu_kmem_init(echo_caches); + if (rc == 0) { + rc = class_register_type(&echo_client_obd_ops, NULL, true, NULL, + LUSTRE_ECHO_CLIENT_NAME, + &echo_device_type); + if (rc) + lu_kmem_fini(echo_caches); + } # ifdef HAVE_SERVER_SUPPORT if (rc == 0) @@ -3061,20 +2929,23 @@ failed_0: RETURN(rc); } -static void /*__exit*/ obdecho_exit(void) +static void __exit obdecho_exit(void) { - echo_client_exit(); + class_unregister_type(LUSTRE_ECHO_CLIENT_NAME); + lu_kmem_fini(echo_caches); -# ifdef HAVE_SERVER_SUPPORT - class_unregister_type(LUSTRE_ECHO_NAME); - echo_persistent_pages_fini(); -# endif +#ifdef HAVE_SERVER_SUPPORT + class_unregister_type(LUSTRE_ECHO_NAME); + echo_persistent_pages_fini(); +#endif } -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre Testing Echo OBD driver"); +MODULE_AUTHOR("OpenSFS, Inc. "); +MODULE_DESCRIPTION("Lustre Echo Client test driver"); +MODULE_VERSION(LUSTRE_VERSION_STRING); MODULE_LICENSE("GPL"); -cfs_module(obdecho, LUSTRE_VERSION_STRING, obdecho_init, obdecho_exit); +module_init(obdecho_init); +module_exit(obdecho_exit); /** @} echo_client */