X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosp%2Fosp_md_object.c;h=e331bfaf53ed3573a21b106bdf560cbd9c5a5b1c;hb=3ca197b4aa3b2fc11da9a946db597e73a62fe149;hp=6a265ddc9c49ee43083f921c700107d65adcf5e4;hpb=8abb5a19e4375f194f3f7d304ad46ec7120e733f;p=fs%2Flustre-release.git diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index 6a265dd..e331bfa 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -64,19 +64,16 @@ int osp_md_declare_object_create(const struct lu_env *env, osi->osi_obdo.o_valid = 0; obdo_from_la(&osi->osi_obdo, attr, attr->la_valid); lustre_set_wire_obdo(NULL, &osi->osi_obdo, &osi->osi_obdo); - obdo_cpu_to_le(&osi->osi_obdo, &osi->osi_obdo); bufs[0] = (char *)&osi->osi_obdo; buf_count = 1; fid1 = (struct lu_fid *)lu_object_fid(&dt->do_lu); if (hint != NULL && hint->dah_parent) { struct lu_fid *fid2; - struct lu_fid *tmp_fid = &osi->osi_fid; fid2 = (struct lu_fid *)lu_object_fid(&hint->dah_parent->do_lu); - fid_cpu_to_le(tmp_fid, fid2); - sizes[1] = sizeof(*tmp_fid); - bufs[1] = (char *)tmp_fid; + sizes[1] = sizeof(*fid2); + bufs[1] = (char *)fid2; buf_count++; } @@ -222,7 +219,6 @@ static void osp_md_ah_init(const struct lu_env *env, { LASSERT(ah); - memset(ah, 0, sizeof(*ah)); ah->dah_parent = parent; ah->dah_mode = child_mode; } @@ -249,7 +245,6 @@ int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, obdo_from_la(&osi->osi_obdo, (struct lu_attr *)attr, attr->la_valid); lustre_set_wire_obdo(NULL, &osi->osi_obdo, &osi->osi_obdo); - obdo_cpu_to_le(&osi->osi_obdo, &osi->osi_obdo); buf = (char *)&osi->osi_obdo; fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); @@ -377,7 +372,8 @@ static int osp_md_index_lookup(const struct lu_env *env, struct dt_object *dt, } fid = lbuf->lb_buf; - fid_le_to_cpu(fid, fid); + if (ptlrpc_rep_need_swab(req)) + lustre_swab_lu_fid(fid); if (!fid_is_sane(fid)) { CERROR("%s: lookup "DFID" %s invalid fid "DFID"\n", dt_dev->dd_lu_dev.ld_obd->obd_name, @@ -604,8 +600,7 @@ static int osp_md_object_lock(const struct lu_env *env, struct ldlm_enqueue_info *einfo, ldlm_policy_data_t *policy) { - struct osp_thread_info *info = osp_env_info(env); - struct ldlm_res_id *res_id = &info->osi_resid; + struct ldlm_res_id *res_id; struct dt_device *dt_dev = lu2dt_dev(dt->do_lu.lo_dev); struct osp_device *osp = dt2osp_dev(dt_dev); struct ptlrpc_request *req; @@ -613,7 +608,8 @@ static int osp_md_object_lock(const struct lu_env *env, __u64 flags = 0; ldlm_mode_t mode; - fid_build_reg_res_name(lu_object_fid(&dt->do_lu), res_id); + res_id = einfo->ei_res_id; + LASSERT(res_id != NULL); mode = ldlm_lock_match(osp->opd_obd->obd_namespace, LDLM_FL_BLOCK_GRANTED, res_id, @@ -673,3 +669,47 @@ struct dt_object_operations osp_md_obj_ops = { .do_object_lock = osp_md_object_lock, .do_object_unlock = osp_md_object_unlock, }; + +static ssize_t osp_md_declare_write(const struct lu_env *env, + struct dt_object *dt, + const struct lu_buf *buf, + loff_t pos, struct thandle *th) +{ + struct dt_update_request *update; + struct lu_fid *fid; + int sizes[2] = {buf->lb_len, sizeof(pos)}; + const char *bufs[2] = {(char *)buf->lb_buf, + (char *)&pos}; + ssize_t rc; + + update = out_find_create_update_loc(th, dt); + if (IS_ERR(update)) { + CERROR("%s: Get OSP update buf failed: rc = %d\n", + dt->do_lu.lo_dev->ld_obd->obd_name, + (int)PTR_ERR(update)); + return PTR_ERR(update); + } + + pos = cpu_to_le64(pos); + bufs[1] = (char *)&pos; + fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); + rc = out_insert_update(env, update, OUT_WRITE, fid, + ARRAY_SIZE(sizes), sizes, bufs); + + return rc; + +} + +static ssize_t osp_md_write(const struct lu_env *env, struct dt_object *dt, + const struct lu_buf *buf, loff_t *pos, + struct thandle *handle, + struct lustre_capa *capa, int ignore_quota) +{ + return buf->lb_len; +} + +/* These body operation will be used to write symlinks during migration etc */ +struct dt_body_operations osp_md_body_ops = { + .dbo_declare_write = osp_md_declare_write, + .dbo_write = osp_md_write, +};