From 3b495cb95e6c28dca923343164301fc3870762a7 Mon Sep 17 00:00:00 2001 From: yury Date: Fri, 23 Jun 2006 11:16:04 +0000 Subject: [PATCH] - removed cmm_special_fid(); - some trivial fixes in cmm; - added locking in fld sefrver side when modifying/reading index. --- lustre/cmm/cmm_object.c | 28 +++++++--------------------- lustre/fld/fld_handler.c | 4 ++-- lustre/fld/fld_index.c | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 4ef52b1..e28677c 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -36,14 +36,6 @@ #include "cmm_internal.h" #include "mdc_internal.h" -/* XXX: fix later this hack. It exists because OSD produces fids with like this: - seq = ROOT_SEQ + 1, etc. */ -static int cmm_special_fid(const struct lu_fid *fid) -{ - struct lu_range *space = (struct lu_range *)&LUSTRE_SEQ_SPACE_RANGE; - return !range_within(space, fid_seq(fid)); -} - static int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid, mdsno_t *mds) { @@ -52,25 +44,19 @@ static int cmm_fld_lookup(struct cmm_device *cm, LASSERT(fid_is_sane(fid)); - /* XXX: is this correct? We need this to prevent FLD lookups while CMM - * did not initialized yet all MDCs. */ - if (cmm_special_fid(fid)) - *mds = 0; - else { - rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), mds); - if (rc) { - CERROR("can't find mds by seq "LPU64", rc %d\n", - fid_seq(fid), rc); - RETURN(rc); - } + rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), mds); + if (rc) { + CERROR("can't find mds by seq "LPU64", rc %d\n", + fid_seq(fid), rc); + RETURN(rc); } if (*mds > cm->cmm_tgt_count) { - CERROR("Got invalid mdsno: %u (max: %u)\n", + CERROR("Got invalid mdsno: "LPU64" (max: %u)\n", *mds, cm->cmm_tgt_count); rc = -EINVAL; } else { - CDEBUG(D_INFO, "CMM: got MDS %u for sequence: "LPU64"\n", + CDEBUG(D_INFO, "CMM: got MDS "LPU64" for sequence: "LPU64"\n", *mds, fid_seq(fid)); } diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 7771db7..00e7e2c 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -111,12 +111,12 @@ static void __exit fld_mod_exit(void) static int fld_server_handle(struct lu_server_fld *fld, const struct lu_context *ctx, - __u32 opts, struct md_fld *mf) + __u32 opc, struct md_fld *mf) { int rc; ENTRY; - switch (opts) { + switch (opc) { case FLD_CREATE: rc = fld_index_handle_insert(fld, ctx, mf->mf_seq, mf->mf_mds); diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index 7b55422..6ed09f7 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -60,10 +60,9 @@ static const struct dt_index_features fld_index_features = { }; /* - * number of blocks to reserve for particular operations. Should be function - * of ... something. Stub for now. + * number of blocks to reserve for particular operations. Should be function of + * ... something. Stub for now. */ - enum { FLD_TXN_INDEX_INSERT_CREDITS = 10, FLD_TXN_INDEX_DELETE_CREDITS = 10 @@ -144,9 +143,12 @@ int fld_index_handle_insert(struct lu_server_fld *fld, th = dt->dd_ops->dt_trans_start(ctx, dt, &txn); + dt_obj->do_ops->do_object_lock(ctx, dt_obj, DT_WRITE_LOCK); rc = dt_obj->do_index_ops->dio_insert(ctx, dt_obj, fld_rec(ctx, mds), fld_key(ctx, seq), th); + dt_obj->do_ops->do_object_unlock(ctx, dt_obj, DT_WRITE_LOCK); + dt->dd_ops->dt_trans_stop(ctx, th); RETURN(rc); @@ -165,8 +167,12 @@ int fld_index_handle_delete(struct lu_server_fld *fld, txn.tp_credits = FLD_TXN_INDEX_DELETE_CREDITS; th = dt->dd_ops->dt_trans_start(ctx, dt, &txn); + + dt_obj->do_ops->do_object_lock(ctx, dt_obj, DT_WRITE_LOCK); rc = dt_obj->do_index_ops->dio_delete(ctx, dt_obj, fld_key(ctx, seq), th); + dt_obj->do_ops->do_object_unlock(ctx, dt_obj, DT_WRITE_LOCK); + dt->dd_ops->dt_trans_stop(ctx, th); RETURN(rc); @@ -181,8 +187,11 @@ int fld_index_handle_lookup(struct lu_server_fld *fld, int rc; ENTRY; + dt_obj->do_ops->do_object_lock(ctx, dt_obj, DT_READ_LOCK); rc = dt_obj->do_index_ops->dio_lookup(ctx, dt_obj, rec, fld_key(ctx, seq)); + dt_obj->do_ops->do_object_unlock(ctx, dt_obj, DT_READ_LOCK); + if (rc == 0) *mds = be64_to_cpu(*(__u64 *)rec); RETURN(rc); -- 1.8.3.1