#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)
{
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));
}
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);
};
/*
- * 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
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);
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);
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);