From 1bc2ebb5a6ab80927fefdd6ad2fee650ba50a929 Mon Sep 17 00:00:00 2001 From: huanghua Date: Sat, 3 Jun 2006 06:51:26 +0000 Subject: [PATCH] added intent support for IT_OPEN. It is a fake support unless the underlying layer is finished. --- lustre/include/lustre/lustre_idl.h | 2 ++ lustre/include/md_object.h | 8 ++++++++ lustre/mdt/mdt_reint.c | 39 ++++++++++++++++++++++++++++++++++---- lustre/ptlrpc/layout.c | 8 ++++++-- lustre/ptlrpc/pack_generic.c | 24 +++++++++++++++++++++++ lustre/ptlrpc/ptlrpc_module.c | 1 + 6 files changed, 76 insertions(+), 6 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index bb0f36e..f64b7fb 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -536,6 +536,7 @@ struct lov_mds_md_v1 { /* LOV EA mds/wire data (little-endian) */ struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */ }; +#define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 16 * sizeof(struct lov_ost_data)) #define OBD_MD_FLID (0x00000001ULL) /* object ID */ #define OBD_MD_FLATIME (0x00000002ULL) /* access time */ @@ -1582,6 +1583,7 @@ struct lov_user_md_join { /* LOV EA user data (host-endian) */ struct lov_user_ost_data_join lmm_objects[0]; /* per-stripe data */ } __attribute__((packed)); +extern void lustre_swab_lov_mds_md(struct lov_mds_md *llm); extern void lustre_swab_lov_user_md(struct lov_user_md *lum); extern void lustre_swab_lov_user_md_objects(struct lov_user_md *lum); extern void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj); diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 50e5786..7b2fdd5 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -178,6 +178,14 @@ static inline int mo_attr_get(const struct lu_context *cx, struct md_object *m, return m->mo_ops->moo_attr_get(cx, m, at); } +static inline int mo_xattr_get(const struct lu_context *cx, + struct md_object *m, + void *buf, int buf_len, const char *name) +{ + return m->mo_ops->moo_xattr_get(cx, m, buf, buf_len, name); +} + + static inline int mo_open(const struct lu_context *cx, struct md_object *m) { return m->mo_ops->moo_open(cx, m); diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 33fd4a2..2b1c1fe 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -209,7 +209,8 @@ static int mdt_reint_open(struct mdt_thread_info *info) struct ldlm_reply *ldlm_rep; struct ptlrpc_request *req = mdt_info_req(info); __u32 mode = info->mti_attr.la_mode; /*save a backup*/ - struct mdt_reint_reply *rep = &info->mti_reint_rep; + struct mdt_body *body = info->mti_reint_rep.mrr_body; + struct lov_mds_md *lmm = info->mti_reint_rep.mrr_md; ENTRY; @@ -272,11 +273,41 @@ static int mdt_reint_open(struct mdt_thread_info *info) if (result != 0) GOTO(out_child, result); - mdt_pack_attr2body(rep->mrr_body, &info->mti_attr); - rep->mrr_body->fid1 = *mdt_object_fid(child); - rep->mrr_body->valid |= OBD_MD_FLID; + mdt_pack_attr2body(body, &info->mti_attr); + body->fid1 = *mdt_object_fid(child); + body->valid |= OBD_MD_FLID; /* To be continued: we should return "struct lov_mds_md" back*/ + lmm = req_capsule_server_get(&info->mti_pill, + &RMF_MDT_MD); + + result = mo_xattr_get(info->mti_ctxt, mdt_object_child(child), + lmm, MAX_MD_SIZE, "lov"); + if (result <= 0) + GOTO(out_child, result = -EINVAL); + + if (S_ISDIR(info->mti_attr.la_mode)) + body->valid |= OBD_MD_FLDIREA; + else + body->valid |= OBD_MD_FLEASIZE; + body->eadatasize = result; + result = 0; + + /* FIXME Let me fake it until the underlying works */ + lmm->lmm_magic = LOV_MAGIC; /* magic number = LOV_MAGIC_V1 */ + lmm->lmm_pattern = LOV_PATTERN_RAID0; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */ + lmm->lmm_object_id = 1; /* LOV object ID */ + lmm->lmm_object_gr = 1; /* LOV object group */ + lmm->lmm_stripe_size = 4096 * 1024; /* size of stripe in bytes */ + lmm->lmm_stripe_count = 1; /* num stripes in use for this object */ + /* per-stripe data */ + lmm->lmm_objects[0].l_object_id = 1; /* OST object ID */ + lmm->lmm_objects[0].l_object_gr = 1; /* OST object group (creating MDS number) */ + lmm->lmm_objects[0].l_ost_gen = 1; /* generation of this l_ost_idx */ + lmm->lmm_objects[0].l_ost_idx = 0; /* OST index in LOV (lov_tgt_desc->tgts) */ + body->eadatasize = sizeof(struct lov_mds_md) + sizeof(struct lov_ost_data); + + /*FIXME add permission checking here */ if (S_ISREG(mode)) diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 330e47f..8ed58f3 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -251,9 +251,13 @@ const struct req_msg_field RMF_LDLM_INTENT = sizeof(struct ldlm_intent), lustre_swab_ldlm_intent); EXPORT_SYMBOL(RMF_LDLM_INTENT); + +/* FIXME XXX by Huang Hua + * to make sure about the size. Refer to MDS. + */ + const struct req_msg_field RMF_MDT_MD = - DEFINE_MSGF("mdt_md", - 0, sizeof(struct lov_mds_md) /* FIXME: See mds */, NULL); + DEFINE_MSGF("mdt_md", 0, MAX_MD_SIZE, lustre_swab_lov_mds_md); EXPORT_SYMBOL(RMF_MDT_MD); const struct req_msg_field RMF_REC_UNLINK = diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index bad1387..d2deec3 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -1022,6 +1022,30 @@ void lustre_swab_lov_user_md_objects(struct lov_user_md *lum) EXIT; } + +void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) +{ + struct lov_ost_data *lod; + int i; + ENTRY; + for (i = 0; i < lmm->lmm_stripe_count; i++) { + lod = &lmm->lmm_objects[i]; + __swab64s(&lod->l_object_id); + __swab64s(&lod->l_object_gr); + __swab32s(&lod->l_ost_gen); + __swab32s(&lod->l_ost_idx); + } + __swab32s(&lmm->lmm_magic); + __swab32s(&lmm->lmm_pattern); + __swab64s(&lmm->lmm_object_id); + __swab64s(&lmm->lmm_object_gr); + __swab32s(&lmm->lmm_stripe_size); + __swab32s(&lmm->lmm_stripe_count); + + EXIT; +} + + void lustre_swab_ldlm_res_id (struct ldlm_res_id *id) { int i; diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index 2b40c0b..aa23c90 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -221,6 +221,7 @@ EXPORT_SYMBOL(lustre_swab_mds_rec_rename); EXPORT_SYMBOL(lustre_swab_mdt_rec_rename); EXPORT_SYMBOL(lustre_swab_lov_desc); EXPORT_SYMBOL(lustre_swab_lov_user_md); +EXPORT_SYMBOL(lustre_swab_lov_mds_md); EXPORT_SYMBOL(lustre_swab_lov_user_md_objects); EXPORT_SYMBOL(lustre_swab_lov_user_md_join); EXPORT_SYMBOL(lustre_swab_ldlm_res_id); -- 1.8.3.1