From e3233748fab26c74124dfd79dbb3f54b3019cabb Mon Sep 17 00:00:00 2001 From: yury Date: Sat, 9 Sep 2006 11:06:26 +0000 Subject: [PATCH] - fixed ctx using in fld_client (bug found by Tom). In few words, ctx cannot be saved in fld_client struct as it is per-thread; - fixes in split code, after allocating fid in new seq, caller should also setup FLD for it. --- lustre/cmm/cmm_object.c | 7 ++++--- lustre/cmm/cmm_split.c | 10 +++++++++- lustre/cmm/mdc_object.c | 17 +++++++++++++---- lustre/fld/fld_request.c | 29 +++++++++++++---------------- lustre/include/lustre_fld.h | 12 +++++++----- lustre/lmv/lmv_fld.c | 2 +- lustre/lmv/lmv_obd.c | 4 ++-- lustre/mdt/mdt_handler.c | 3 +-- 8 files changed, 50 insertions(+), 34 deletions(-) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 1ad5b99..bdaa115 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -37,7 +37,8 @@ #include "mdc_internal.h" static int cmm_fld_lookup(struct cmm_device *cm, - const struct lu_fid *fid, mdsno_t *mds) + const struct lu_fid *fid, mdsno_t *mds, + const struct lu_context *ctx) { struct lu_site *ls; int rc = 0; @@ -48,7 +49,7 @@ static int cmm_fld_lookup(struct cmm_device *cm, ls = cm->cmm_md_dev.md_lu_dev.ld_site; rc = fld_client_lookup(ls->ls_client_fld, - fid_seq(fid), mds); + fid_seq(fid), mds, ctx); if (rc) { CERROR("can't find mds by seq "LPX64", rc %d\n", fid_seq(fid), rc); @@ -90,7 +91,7 @@ struct lu_object *cmm_object_alloc(const struct lu_context *ctx, cd = lu2cmm_dev(ld); if (cd->cmm_flags & CMM_INITIALIZED) { /* get object location */ - rc = cmm_fld_lookup(lu2cmm_dev(ld), fid, &mdsnum); + rc = cmm_fld_lookup(lu2cmm_dev(ld), fid, &mdsnum, ctx); if (rc) RETURN(NULL); } else diff --git a/lustre/cmm/cmm_split.c b/lustre/cmm/cmm_split.c index 53a7aac..e272de6 100644 --- a/lustre/cmm/cmm_split.c +++ b/lustre/cmm/cmm_split.c @@ -99,6 +99,14 @@ static int cmm_alloc_fid(const struct lu_context *ctx, struct cmm_device *cmm, LASSERT(cmm->cmm_local_num != mc->mc_num); rc = obd_fid_alloc(mc->mc_desc.cl_exp, &fid[i++], NULL); + if (rc > 0) { + struct lu_site *ls; + + ls = cmm->cmm_md_dev.md_lu_dev.ld_site; + rc = fld_client_create(ls->ls_client_fld, + fid_seq(&fid[i]), + mc->mc_num, ctx); + } if (rc < 0) { spin_unlock(&cmm->cmm_tgt_guard); RETURN(rc); @@ -212,7 +220,7 @@ static int cmm_send_split_pages(const struct lu_context *ctx, RETURN(PTR_ERR(obj)); for (i = 0; i < rdpg->rp_npages; i++) { - rc = mdc_send_page(ctx, md_object_next(&obj->cmo_obj), + rc = mdc_send_page(cmm, ctx, md_object_next(&obj->cmo_obj), rdpg->rp_pages[i], hash_end); if (rc) break; diff --git a/lustre/cmm/mdc_object.c b/lustre/cmm/mdc_object.c index ee96208..5f595be 100644 --- a/lustre/cmm/mdc_object.c +++ b/lustre/cmm/mdc_object.c @@ -245,8 +245,8 @@ static int mdc_ref_del(const struct lu_context *ctx, struct md_object *mo, } #ifdef HAVE_SPLIT_SUPPORT -int mdc_send_page(const struct lu_context *ctx, struct md_object *mo, - struct page *page, __u32 end) +int mdc_send_page(struct cmm_device *cm, const struct lu_context *ctx, + struct md_object *mo, struct page *page, __u32 end) { struct mdc_device *mc = md2mdc_dev(md_obj2dev(mo)); struct lu_dirpage *dp; @@ -257,7 +257,7 @@ int mdc_send_page(const struct lu_context *ctx, struct md_object *mo, kmap(page); dp = page_address(page); for (ent = lu_dirent_start(dp); ent != NULL; - ent = lu_dirent_next(ent)) { + ent = lu_dirent_next(ent)) { if (ent->lde_hash < end) { offset = (int)((__u32)ent - (__u32)dp); rc1 = -E2BIG; @@ -266,7 +266,16 @@ int mdc_send_page(const struct lu_context *ctx, struct md_object *mo, /* allocate new fid for each obj */ rc = obd_fid_alloc(mc->mc_desc.cl_exp, &ent->lde_fid, NULL); - if (rc) { + if (rc > 0) { + struct lu_site *ls; + + ls = cm->cmm_md_dev.md_lu_dev.ld_site; + rc = fld_client_create(ls->ls_client_fld, + fid_seq(&ent->lde_fid), + mc->mc_num, ctx); + } + + if (rc < 0) { kunmap(page); RETURN(rc); } diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index aea71fe..39c0dc6 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -270,8 +270,7 @@ static inline int hash_is_sane(int hash) #define FLD_CACHE_THRESHOLD 10 int fld_client_init(struct lu_client_fld *fld, - const char *prefix, int hash, - const struct lu_context *ctx) + const char *prefix, int hash) { #ifdef __KERNEL__ int cache_size, cache_threshold; @@ -287,7 +286,6 @@ int fld_client_init(struct lu_client_fld *fld, } fld->lcf_count = 0; - fld->lcf_ctx = ctx; spin_lock_init(&fld->lcf_lock); fld->lcf_hash = &fld_hash[hash]; INIT_LIST_HEAD(&fld->lcf_targets); @@ -409,7 +407,8 @@ out_req: } int fld_client_create(struct lu_client_fld *fld, - seqno_t seq, mdsno_t mds) + seqno_t seq, mdsno_t mds, + const struct lu_context *ctx) { struct md_fld md_fld = { .mf_seq = seq, .mf_mds = mds }; struct lu_fld_target *target; @@ -421,10 +420,9 @@ int fld_client_create(struct lu_client_fld *fld, #ifdef __KERNEL__ if (target->ft_srv != NULL) { - LASSERT(fld->lcf_ctx != NULL); + LASSERT(ctx != NULL); rc = fld_server_create(target->ft_srv, - fld->lcf_ctx, - seq, mds); + ctx, seq, mds); } else { #endif rc = fld_client_rpc(target->ft_exp, @@ -446,8 +444,8 @@ int fld_client_create(struct lu_client_fld *fld, } EXPORT_SYMBOL(fld_client_create); -int fld_client_delete(struct lu_client_fld *fld, - seqno_t seq) +int fld_client_delete(struct lu_client_fld *fld, seqno_t seq, + const struct lu_context *ctx) { struct md_fld md_fld = { .mf_seq = seq, .mf_mds = 0 }; struct lu_fld_target *target; @@ -461,10 +459,9 @@ int fld_client_delete(struct lu_client_fld *fld, #ifdef __KERNEL__ if (target->ft_srv != NULL) { - LASSERT(fld->lcf_ctx != NULL); + LASSERT(ctx != NULL); rc = fld_server_delete(target->ft_srv, - fld->lcf_ctx, - seq); + ctx, seq); } else { #endif rc = fld_client_rpc(target->ft_exp, @@ -478,7 +475,8 @@ int fld_client_delete(struct lu_client_fld *fld, EXPORT_SYMBOL(fld_client_delete); int fld_client_lookup(struct lu_client_fld *fld, - seqno_t seq, mdsno_t *mds) + seqno_t seq, mdsno_t *mds, + const struct lu_context *ctx) { struct md_fld md_fld = { .mf_seq = seq, .mf_mds = 0 }; struct lu_fld_target *target; @@ -496,10 +494,9 @@ int fld_client_lookup(struct lu_client_fld *fld, #ifdef __KERNEL__ if (target->ft_srv != NULL) { - LASSERT(fld->lcf_ctx != NULL); + LASSERT(ctx != NULL); rc = fld_server_lookup(target->ft_srv, - fld->lcf_ctx, - seq, mds); + ctx, seq, mds); } else { #endif rc = fld_client_rpc(target->ft_exp, diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index a9de9e1..7b21879 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -159,19 +159,21 @@ int fld_server_lookup(struct lu_server_fld *fld, /* Client methods */ int fld_client_init(struct lu_client_fld *fld, - const char *prefix, int hash, - const struct lu_context *ctx); + const char *prefix, int hash); void fld_client_fini(struct lu_client_fld *fld); int fld_client_lookup(struct lu_client_fld *fld, - seqno_t seq, mdsno_t *mds); + seqno_t seq, mdsno_t *mds, + const struct lu_context *ctx); int fld_client_create(struct lu_client_fld *fld, - seqno_t seq, mdsno_t mds); + seqno_t seq, mdsno_t mds, + const struct lu_context *ctx); int fld_client_delete(struct lu_client_fld *fld, - seqno_t seq); + seqno_t seq, + const struct lu_context *ctx); int fld_client_add_target(struct lu_client_fld *fld, struct lu_fld_target *tar); diff --git a/lustre/lmv/lmv_fld.c b/lustre/lmv/lmv_fld.c index 3a4f034..b60e737 100644 --- a/lustre/lmv/lmv_fld.c +++ b/lustre/lmv/lmv_fld.c @@ -53,7 +53,7 @@ int lmv_fld_lookup(struct lmv_obd *lmv, ENTRY; LASSERT(fid_is_sane(fid)); - rc = fld_client_lookup(&lmv->lmv_fld, fid_seq(fid), mds); + rc = fld_client_lookup(&lmv->lmv_fld, fid_seq(fid), mds, NULL); if (rc) { CERROR("error while looking for mds number. Seq "LPU64 ", rc %d\n", fid_seq(fid), rc); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 1a85d34..8bd4538 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -778,7 +778,7 @@ static int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, LASSERT(fid_is_sane(fid)); rc = fld_client_create(&lmv->lmv_fld, fid_seq(fid), - mds); + mds, NULL); if (rc) { CERROR("can't create fld entry, rc %d\n", rc); RETURN(rc); @@ -867,7 +867,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } #endif rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, - LUSTRE_CLI_FLD_HASH_DHT, NULL); + LUSTRE_CLI_FLD_HASH_DHT); if (rc) { CERROR("can't init FLD, err %d\n", rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 02207d2..8b515c9 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2201,8 +2201,7 @@ static int mdt_fld_init(const struct lu_context *ctx, GOTO(out_fld_fini, rc = -ENOMEM); rc = fld_client_init(ls->ls_client_fld, uuid, - LUSTRE_CLI_FLD_HASH_DHT, - ctx); + LUSTRE_CLI_FLD_HASH_DHT); if (rc) { CERROR("can't init FLD, err %d\n", rc); OBD_FREE_PTR(ls->ls_client_fld); -- 1.8.3.1