diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h
index 9e7a12dbcb758fb330d0ea5d38772eb41ac9c3cf..803485896baa5c24e98fd1102f870b8e516e721b 100644
--- a/lustre/include/linux/lustre_idl.h
+++ b/lustre/include/linux/lustre_idl.h
@@ -348,37 +348,38 @@ struct lov_mds_md_v0 {            /* LOV EA mds/wire data (little-endian) */
         struct lov_ost_data_v0 lmm_objects[0];
 } __attribute__((packed));
 
-#define OBD_MD_FLALL    (0xffffffffffffffff)
-#define OBD_MD_FLID     (0x0000000000000001)    /* object ID */
-#define OBD_MD_FLATIME  (0x0000000000000002)    /* access time */
-#define OBD_MD_FLMTIME  (0x0000000000000004)    /* data modification time */
-#define OBD_MD_FLCTIME  (0x0000000000000008)    /* change time */
-#define OBD_MD_FLSIZE   (0x0000000000000010)    /* size */
-#define OBD_MD_FLBLOCKS (0x0000000000000020)    /* allocated blocks count */
-#define OBD_MD_FLBLKSZ  (0x0000000000000040)    /* block size */
-#define OBD_MD_FLMODE   (0x0000000000000080)    /* access bits (mode & ~S_IFMT) */
-#define OBD_MD_FLTYPE   (0x0000000000000100)    /* object type (mode & S_IFMT) */
-#define OBD_MD_FLUID    (0x0000000000000200)    /* user ID */
-#define OBD_MD_FLGID    (0x0000000000000400)    /* group ID */
-#define OBD_MD_FLFLAGS  (0x0000000000000800)    /* flags word */
-#define OBD_MD_FLNLINK  (0x0000000000002000)    /* link count */
-#define OBD_MD_FLGENER  (0x0000000000004000)    /* generation number */
-#define OBD_MD_FLINLINE (0x0000000000008000)    /* inline data */
-#define OBD_MD_FLRDEV   (0x0000000000010000)    /* device number */
-#define OBD_MD_FLEASIZE (0x0000000000020000)    /* extended attribute data */
-#define OBD_MD_LINKNAME (0x0000000000040000)    /* symbolic link target */
-#define OBD_MD_FLHANDLE (0x0000000000080000)    /* file handle */
-#define OBD_MD_FLCKSUM  (0x0000000000100000)    /* bulk data checksum */
-#define OBD_MD_FLQOS    (0x0000000000200000)    /* quality of service stats */
-#define OBD_MD_FLOSCOPQ (0x0000000000400000)    /* osc opaque data */
-#define OBD_MD_FLCOOKIE (0x0000000000800000)    /* log cancellation cookie */
-#define OBD_MD_FLGROUP  (0x0000000001000000)    /* group */
-#define OBD_MD_FLIFID   (0x0000000002000000)    /* ->ost write inline fid */
-#define OBD_MD_FLEPOCH  (0x0000000004000000)    /* ->ost write easize is epoch */
-#define OBD_MD_FLGRANT  (0x0000000008000000)    /* ost preallocation space grant */
-#define OBD_MD_MDS      (0x0000000010000000)    /* where an inode lives on */
-#define OBD_MD_FLDIREA  (0x0000000020000000)    /* dir's extended attribute data */
-#define OBD_MD_REINT    (0x0000000040000000)    /* reintegrate oa */
+#define OBD_MD_FLALL    (0xffffffffffffffffLL)
+#define OBD_MD_FLID     (0x0000000000000001LL)    /* object ID */
+#define OBD_MD_FLATIME  (0x0000000000000002LL)    /* access time */
+#define OBD_MD_FLMTIME  (0x0000000000000004LL)    /* data modification time */
+#define OBD_MD_FLCTIME  (0x0000000000000008LL)    /* change time */
+#define OBD_MD_FLSIZE   (0x0000000000000010LL)    /* size */
+#define OBD_MD_FLBLOCKS (0x0000000000000020LL)    /* allocated blocks count */
+#define OBD_MD_FLBLKSZ  (0x0000000000000040LL)    /* block size */
+#define OBD_MD_FLMODE   (0x0000000000000080LL)    /* access bits (mode & ~S_IFMT) */
+#define OBD_MD_FLTYPE   (0x0000000000000100LL)    /* object type (mode & S_IFMT) */
+#define OBD_MD_FLUID    (0x0000000000000200LL)    /* user ID */
+#define OBD_MD_FLGID    (0x0000000000000400LL)    /* group ID */
+#define OBD_MD_FLFLAGS  (0x0000000000000800LL)    /* flags word */
+#define OBD_MD_FLNLINK  (0x0000000000002000LL)    /* link count */
+#define OBD_MD_FLGENER  (0x0000000000004000LL)    /* generation number */
+#define OBD_MD_FLINLINE (0x0000000000008000LL)    /* inline data */
+#define OBD_MD_FLRDEV   (0x0000000000010000LL)    /* device number */
+#define OBD_MD_FLEASIZE (0x0000000000020000LL)    /* extended attribute data */
+#define OBD_MD_LINKNAME (0x0000000000040000LL)    /* symbolic link target */
+#define OBD_MD_FLHANDLE (0x0000000000080000LL)    /* file handle */
+#define OBD_MD_FLCKSUM  (0x0000000000100000LL)    /* bulk data checksum */
+#define OBD_MD_FLQOS    (0x0000000000200000LL)    /* quality of service stats */
+#define OBD_MD_FLOSCOPQ (0x0000000000400000LL)    /* osc opaque data */
+#define OBD_MD_FLCOOKIE (0x0000000000800000LL)    /* log cancellation cookie */
+#define OBD_MD_FLGROUP  (0x0000000001000000LL)    /* group */
+#define OBD_MD_FLIFID   (0x0000000002000000LL)    /* ->ost write inline fid */
+#define OBD_MD_FLEPOCH  (0x0000000004000000LL)    /* ->ost write easize is epoch */
+#define OBD_MD_FLGRANT  (0x0000000008000000LL)    /* ost preallocation space grant */
+#define OBD_MD_MDS      (0x0000000010000000LL)    /* where an inode lives on */
+#define OBD_MD_FLDIREA  (0x0000000020000000LL)    /* dir's extended attribute data */
+#define OBD_MD_REINT    (0x0000000040000000LL)    /* reintegrate oa */
+#define OBD_MD_FID      (0x0000000080000000LL)    /* reintegrate oa */
 
 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLBLOCKS | OBD_MD_LINKNAME |          \
                            OBD_MD_FLEASIZE | OBD_MD_FLHANDLE |          \
diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
index 2431eaf50db4fe32db198efed6595e2e3a9683d6..95782378093221a04708d9b431cb5e05f613fe7b 100644
--- a/lustre/llite/llite_lib.c
+++ b/lustre/llite/llite_lib.c
@@ -1227,9 +1227,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                                        (struct lov_stripe_md **) &mea);
         }
 
-	/* MDS is supposed to return correct fid always. */
-        LASSERT(id_fid(&body->id1) != 0);
-        id_assign_fid(&lli->lli_id, &body->id1);
+        if (body->valid & OBD_MD_FID)
+                id_assign_fid(&lli->lli_id, &body->id1);
         
 	if (body->valid & OBD_MD_FLID)
 		id_ino(&lli->lli_id) = id_ino(&body->id1);
@@ -1285,6 +1284,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
         inode->i_dev = (kdev_t)id_group(&lli->lli_id);
 #endif
+        LASSERT(id_fid(&lli->lli_id) != 0);
 }
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
@@ -1574,7 +1574,7 @@ int ll_get_fid(struct obd_export *exp, struct lustre_id *idp,
         int rc;
 
         rc = md_getattr_lock(exp, idp, filename, strlen(filename) + 1,
-                             0, 0, &request);
+                             OBD_MD_FID, 0, &request);
         if (rc < 0) {
                 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
                        filename, rc);
diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c
index 1badf65cd38217954dbb87b7959d50701e1155ee..ce3d0f0a88eafc32fe45b4741011e62abc4239bd 100644
--- a/lustre/lmv/lmv_intent.c
+++ b/lustre/lmv/lmv_intent.c
@@ -96,11 +96,12 @@ int lmv_handle_remote_inode(struct obd_export *exp, void *lmm,
                         it->d.lustre.it_lock_mode = 0;
                 }
 
+                LASSERT((body->valid & OBD_MD_FID) != 0);
+                
                 nid = body->id1;
                 it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
-                rc = md_intent_lock(lmv->tgts[id_group(&nid)].ltd_exp, &nid,
-                                    NULL, 0, lmm, lmmsize, NULL, it, flags,
-                                    &req, cb_blocking);
+                rc = md_intent_lock(lmv->tgts[id_group(&nid)].ltd_exp, &nid, NULL,
+                                    0, lmm, lmmsize, NULL, it, flags, &req, cb_blocking);
 
                 /*
                  * llite needs LOOKUP lock to track dentry revocation in order
@@ -112,7 +113,6 @@ int lmv_handle_remote_inode(struct obd_export *exp, void *lmm,
                         memcpy(&it->d.lustre.it_lock_handle, &plock,
                                sizeof(plock));
                         it->d.lustre.it_lock_mode = pmode;
-                        
                 } else if (pmode)
                         ldlm_lock_decref(&plock, pmode);
 
@@ -190,11 +190,19 @@ repeat:
                 RETURN(rc);
         }
 
+        /*
+         * nothing is found, do not access body->id1 as it is zero and thus
+         * pointless.
+         */
+        if (it->d.lustre.it_disposition & DISP_LOOKUP_NEG)
+                RETURN(0);
+
         /* caller may use attrs MDS returns on IT_OPEN lock request so, we have
          * to update them for splitted dir */
         body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body));
         LASSERT(body != NULL);
-
+        LASSERT((body->valid & OBD_MD_FID) != 0);
+        
         cid = &body->id1;
         obj = lmv_grab_obj(obd, cid);
         if (!obj && (mea = lmv_splitted_dir_body(*reqp, 1))) {
@@ -273,9 +281,8 @@ int lmv_intent_getattr(struct obd_export *exp, struct lustre_id *pid,
         }
 
         /* the same about fid returning. */
-        rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name,
-                            len, lmm, lmmsize, cid, it, flags,
-                            reqp, cb_blocking);
+        rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name, len, lmm,
+                            lmmsize, cid, it, flags, reqp, cb_blocking);
         if (rc < 0)
                 RETURN(rc);
        
@@ -306,9 +313,17 @@ int lmv_intent_getattr(struct obd_export *exp, struct lustre_id *pid,
         if (rc < 0)
                 RETURN(rc);
 
+        /*
+         * nothing is found, do not access body->id1 as it is zero and thus
+         * pointless.
+         */
+        if (it->d.lustre.it_disposition & DISP_LOOKUP_NEG)
+                RETURN(0);
+                
         body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body));
         LASSERT(body != NULL);
-        
+        LASSERT((body->valid & OBD_MD_FID) != 0);
+
         cid = &body->id1;
         obj2 = lmv_grab_obj(obd, cid);
 
@@ -367,6 +382,7 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp)
 
         body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body));
         LASSERT(body != NULL);
+        LASSERT((body->valid & OBD_MD_FID) != 0);
 
         obj = lmv_grab_obj(obd, &body->id1);
         LASSERT(obj != NULL);
@@ -546,6 +562,7 @@ repeat:
                 /* wow! this is splitted dir, we'd like to handle it */
                 body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body));
                 LASSERT(body != NULL);
+                LASSERT((body->valid & OBD_MD_FID) != 0);
                 
                 obj = lmv_grab_obj(obd, &body->id1);
                 if (!obj) {
diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c
index 5abd02a9cafd0499e7757634789732211746dcd4..31f6b0487bd5a7e950e19f07193cf4f59fe81424 100644
--- a/lustre/lmv/lmv_obd.c
+++ b/lustre/lmv/lmv_obd.c
@@ -1093,8 +1093,8 @@ repeat:
         CDEBUG(D_OTHER, "getattr_lock for %*s on "DLID4" -> "DLID4"\n",
                namelen, filename, OLID4(id), OLID4(&rid));
 
-        rc = md_getattr_lock(lmv->tgts[id_group(&rid)].ltd_exp, 
-                             &rid, filename, namelen, valid,
+        rc = md_getattr_lock(lmv->tgts[id_group(&rid)].ltd_exp, &rid,
+                             filename, namelen, (valid | OBD_MD_FID),
                              ea_size, request);
         if (rc == 0) {
                 /*
@@ -1104,6 +1104,8 @@ repeat:
                  */
                 body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body));
                 LASSERT(body != NULL);
+                LASSERT((body->valid & OBD_MD_FID) != 0);
+
                 if (body->valid & OBD_MD_MDS) {
                         struct ptlrpc_request *req = NULL;
                         
@@ -1307,6 +1309,7 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data,
                         body = lustre_msg_buf((*request)->rq_repmsg, 0,
                                               sizeof(*body));
                         LASSERT(body != NULL);
+                        LASSERT((body->valid & OBD_MD_FID) != 0);
                         LASSERT(id_group(&body->id1) == id_group(&data->id1));
                 }
         }
diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c
index 861aeb9d7c5fb31b73a828500add99bfde627ab1..2478afce7dcd4eaaf8548ea9f63e7a760d50d320 100644
--- a/lustre/mdc/mdc_locks.c
+++ b/lustre/mdc/mdc_locks.c
@@ -514,6 +514,9 @@ int mdc_intent_lock(struct obd_export *exp, struct lustre_id *pid,
 
                 mdc_id2mdc_data(op_data, pid, cid, name, len, 0);
 
+                if (name != NULL)
+                        op_data->valid |= OBD_MD_FID;
+
                 rc = mdc_enqueue(exp, LDLM_IBITS, it, it_to_lock_mode(it),
                                  op_data, &lockh, lmm, lmmsize,
                                  ldlm_completion_ast, cb_blocking, NULL);
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 68a84520270e0f3ec61a7af1f9740f1f96526933..9efe83a206b4758b8187d201385d10dd08491b43 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -583,6 +583,8 @@ static int mds_getstatus(struct ptlrpc_request *req)
         }
 
         body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
+        body->valid |= OBD_MD_FID;
+        
         memcpy(&body->id1, &mds->mds_rootid, sizeof(body->id1));
 
         /*
@@ -756,13 +758,15 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
         LASSERT(body != NULL);                 /* caller prepped reply */
 
         if (dentry->d_flags & DCACHE_CROSS_REF) {
-                mds_pack_dentry2body(obd, body, dentry);
+                mds_pack_dentry2body(obd, body, dentry,
+                                     (reqbody->valid & OBD_MD_FID) ? 1 : 0);
                 CDEBUG(D_OTHER, "cross reference: "DLID4"\n",
                        OLID4(&body->id1));
                 RETURN(0);
         }
         
-        mds_pack_inode2body(obd, body, inode);
+        mds_pack_inode2body(obd, body, inode,
+                            (reqbody->valid & OBD_MD_FID) ? 1 : 0);
 
         if ((S_ISREG(inode->i_mode) && (reqbody->valid & OBD_MD_FLEASIZE)) ||
             (S_ISDIR(inode->i_mode) && (reqbody->valid & OBD_MD_FLDIREA))) {
@@ -1262,6 +1266,7 @@ static int mds_sync(struct ptlrpc_request *req, int offset)
         } else {
                 /* just any file to grab fsync method - "file" arg unused */
                 struct file *file = mds->mds_rcvd_filp;
+                struct mds_body *rep_body;
                 struct dentry *de;
 
                 de = mds_id2dentry(obd, &body->id1, NULL);
@@ -1272,8 +1277,9 @@ static int mds_sync(struct ptlrpc_request *req, int offset)
                 if (rc)
                         GOTO(out, rc);
 
-                body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
-                mds_pack_inode2body(obd, body, de->d_inode);
+                rep_body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep_body));
+                mds_pack_inode2body(obd, rep_body, de->d_inode,
+                                    (body->valid & OBD_MD_FID) ? 1 : 0);
                 l_dput(de);
         }
 
@@ -1766,7 +1772,7 @@ repeat:
                 obdo_from_inode(&repbody->oa, new->d_inode, FILTER_VALID_FLAGS);
                 repbody->oa.o_id = new->d_inode->i_ino;
                 repbody->oa.o_generation = new->d_inode->i_generation;
-                repbody->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGENER;
+                repbody->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FID;
 
                 if ((body->oa.o_flags & OBD_FL_RECREATE_OBJS) ||
                     lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c
index c71cd36a5b900c7362588957012143856fc51cc0..ed41934fd224873732c960ccf893d7e3eb26d44e 100644
--- a/lustre/mds/mds_fs.c
+++ b/lustre/mds/mds_fs.c
@@ -476,7 +476,7 @@ int mds_fs_setup_rootid(struct obd_device *obd)
         inode = dentry->d_inode;
         LASSERT(dentry->d_inode);
 
-        rc = mds_pack_inode2id(obd, &mds->mds_rootid, inode);
+        rc = mds_pack_inode2id(obd, &mds->mds_rootid, inode, 1);
         if (rc < 0) {
                 if (rc != -ENODATA)
                         GOTO(out_dentry, rc);
diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h
index b0bbf193b1d20e0e936ac139f8e864481eb37402..be2fcfc3277f458b891cc2174bb6abe69379d8d1 100644
--- a/lustre/mds/mds_internal.h
+++ b/lustre/mds/mds_internal.h
@@ -207,16 +207,16 @@ int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
                 struct mds_body *, struct inode *, int lock);
 
 int mds_pack_inode2id(struct obd_device *, struct lustre_id *,
-                      struct inode *);
+                      struct inode *, int);
 
 void mds_pack_inode2body(struct obd_device *, struct mds_body *,
-                         struct inode *);
+                         struct inode *, int);
 
 void mds_pack_dentry2id(struct obd_device *, struct lustre_id *,
-                        struct dentry *);
+                        struct dentry *, int);
 
 void mds_pack_dentry2body(struct obd_device *, struct mds_body *b,
-                          struct dentry *);
+                          struct dentry *, int);
 #endif
 
 /* mds/mds_lmv.c */
diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c
index 33f80006a0b5b265c9eaad411613df6537d4f6ea..c29851234f461c2336a00e216eca6bd623e5da58 100644
--- a/lustre/mds/mds_lib.c
+++ b/lustre/mds/mds_lib.c
@@ -160,37 +160,48 @@ void groups_from_buffer(struct group_info *ginfo, __u32 *gids)
 
 void mds_pack_dentry2id(struct obd_device *obd,
                         struct lustre_id *id,
-                        struct dentry *dentry)
+                        struct dentry *dentry,
+                        int fid)
 {
         id_ino(id) = dentry->d_inum;
         id_gen(id) = dentry->d_generation;
-        id_fid(id) = dentry->d_fid;
-        id_group(id) = dentry->d_mdsnum;
+        
+        if (fid) {
+                id_fid(id) = dentry->d_fid;
+                id_group(id) = dentry->d_mdsnum;
+        }
 }
 
 void mds_pack_dentry2body(struct obd_device *obd,
                           struct mds_body *b,
-                          struct dentry *dentry)
+                          struct dentry *dentry,
+                          int fid)
 {
         b->valid |= OBD_MD_FLID | OBD_MD_FLGENER |
                 OBD_MD_MDS;
 
-        mds_pack_dentry2id(obd, &b->id1, dentry);
+        if (fid)
+                b->valid |= OBD_MD_FID;
+        
+        mds_pack_dentry2id(obd, &b->id1, dentry, fid);
 }
 
 int mds_pack_inode2id(struct obd_device *obd,
                       struct lustre_id *id,
-                      struct inode *inode)
+                      struct inode *inode,
+                      int fid)
 {
         int rc = 0;
         ENTRY;
-        
-        /* we have to avoid deadlock. */
-        if (!down_trylock(&inode->i_sem)) {
-                rc = mds_read_inode_sid(obd, inode, id);
-                up(&inode->i_sem);
-        } else {
-                rc = mds_read_inode_sid(obd, inode, id);
+
+        if (fid) {
+                /* we have to avoid deadlock. */
+                if (!down_trylock(&inode->i_sem)) {
+                        rc = mds_read_inode_sid(obd, inode, id);
+                        up(&inode->i_sem);
+                } else {
+                        rc = mds_read_inode_sid(obd, inode, id);
+                }
         }
 
         if (rc == 0) {
@@ -203,7 +214,7 @@ int mds_pack_inode2id(struct obd_device *obd,
 
 /* Note that we can copy all of the fields, just some will not be "valid" */
 void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b,
-                         struct inode *inode)
+                         struct inode *inode, int fid)
 {
         b->valid |= OBD_MD_FLID | OBD_MD_FLCTIME | OBD_MD_FLUID |
                 OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLTYPE |
@@ -234,7 +245,11 @@ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b,
         } else {
                 b->nlink = inode->i_nlink;
         }
-        mds_pack_inode2id(obd, &b->id1, inode);
+
+        if (fid)
+                b->valid |= OBD_MD_FID;
+        
+        mds_pack_inode2id(obd, &b->id1, inode, fid);
 }
 
 /* unpacking */
diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c
index 8c21af3df7106eb3c2476006c5ed554e931626f1..3a8fd77a97b6ab9d5ccd44d9032db83e555c60ce 100644
--- a/lustre/mds/mds_open.c
+++ b/lustre/mds/mds_open.c
@@ -527,7 +527,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                 GOTO(out_dput, 0);
 
         /* get lock (write for O_CREAT, read otherwise) */
-        mds_pack_inode2body(obd, body, dchild->d_inode);
+        mds_pack_inode2body(obd, body, dchild->d_inode, 1);
         if (S_ISREG(dchild->d_inode->i_mode)) {
                 rc = mds_pack_md(obd, req->rq_repmsg, 2, body,
                                  dchild->d_inode, 1);
@@ -721,7 +721,9 @@ static int mds_open_by_id(struct ptlrpc_request *req,
         if (dchild->d_inode != NULL) {
                 up(&pending_dir->i_sem);
                 mds_inode_set_orphan(dchild->d_inode);
-                mds_pack_inode2body(req2obd(req), body, dchild->d_inode);
+                mds_pack_inode2body(req2obd(req), body,
+                                    dchild->d_inode, 1);
+                
                 intent_set_disposition(rep, DISP_LOOKUP_EXECD);
                 intent_set_disposition(rep, DISP_LOOKUP_POS);
                 CWARN("Orphan %s found and opened in PENDING directory\n",
@@ -739,7 +741,9 @@ static int mds_open_by_id(struct ptlrpc_request *req,
         if (IS_ERR(dchild))
                 RETURN(PTR_ERR(dchild));
 
-        mds_pack_inode2body(req2obd(req), body, dchild->d_inode);
+        mds_pack_inode2body(req2obd(req), body,
+                            dchild->d_inode, 1);
+        
         intent_set_disposition(rep, DISP_LOOKUP_EXECD);
         intent_set_disposition(rep, DISP_LOOKUP_POS);
 
@@ -977,7 +981,7 @@ got_child:
                 ldlm_policy_data_t policy;
                 int flags = 0;
 
-                mds_pack_dentry2body(obd, body, dchild);
+                mds_pack_dentry2body(obd, body, dchild, 1);
                 intent_set_disposition(rep, DISP_LOOKUP_POS);
 
                 CDEBUG(D_OTHER, "cross reference: "DLID4"\n",
@@ -1129,7 +1133,7 @@ got_child:
 
                 acc_mode = 0;           /* Don't check for permissions */
         }
-        mds_pack_inode2body(obd, body, dchild->d_inode);
+        mds_pack_inode2body(obd, body, dchild->d_inode, 1);
 	
         LASSERTF(!mds_inode_is_orphan(dchild->d_inode),
                  "dchild %*s (%p) inode %p\n", dchild->d_name.len,
@@ -1480,11 +1484,16 @@ int mds_close(struct ptlrpc_request *req, int offset)
         /* child i_alloc_sem protects orphan_dec_test && is_orphan race */
         DOWN_WRITE_I_ALLOC_SEM(inode); /* mds_mfd_close drops this */
         if (mds_inode_is_orphan(inode) && mds_orphan_open_count(inode) == 1) {
-                body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
-                LASSERT(body != NULL);
+                struct mds_body *rep_body;
 
-                mds_pack_inode2body(obd, body, inode);
-                mds_pack_md(obd, req->rq_repmsg, 1, body, 
+                rep_body = lustre_msg_buf(req->rq_repmsg, 0,
+                                          sizeof (*rep_body));
+                LASSERT(rep_body != NULL);
+
+                mds_pack_inode2body(obd, rep_body, inode,
+                                    (body->valid & OBD_MD_FID) ? 1 : 0);
+                
+                mds_pack_md(obd, req->rq_repmsg, 1, rep_body, 
 			    inode, MDS_PACK_MD_LOCK);
         }
         spin_lock(&med->med_open_lock);
diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c
index 4f2e7fdcd8cdfe46779b55d744a0f1405a5b8000..43e957e42f95e3b9f55a32519bb0f2b07cc4e76b 100644
--- a/lustre/mds/mds_reint.c
+++ b/lustre/mds/mds_reint.c
@@ -357,7 +357,7 @@ static void reconstruct_reint_setattr(struct mds_update_record *rec,
         }
 
         body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
-        mds_pack_inode2body(req2obd(req), body, de->d_inode);
+        mds_pack_inode2body(req2obd(req), body, de->d_inode, 1);
 
         /* Don't return OST-specific attributes if we didn't just set them */
         if (rec->ur_iattr.ia_valid & ATTR_SIZE)
@@ -465,7 +465,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         }
 
         body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
-        mds_pack_inode2body(obd, body, inode);
+        mds_pack_inode2body(obd, body, inode, 1);
 
         /* Don't return OST-specific attributes if we didn't just set them */
         if (rec->ur_iattr.ia_valid & ATTR_SIZE)
@@ -551,14 +551,14 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset,
         if ((child->d_flags & DCACHE_CROSS_REF)) {
                 LASSERTF(child->d_inode == NULL, "BUG 3869\n");
                 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
-                mds_pack_dentry2body(req2obd(req), body, child);
+                mds_pack_dentry2body(req2obd(req), body, child, 1);
         } else if (child->d_inode == NULL) {
                 DEBUG_REQ(D_ERROR, req, "parent "DLID4" name %s mode %o",
                           OLID4(rec->ur_id1), rec->ur_name, rec->ur_mode);
                 LASSERTF(child->d_inode != NULL, "BUG 3869\n");
         } else {
                 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
-                mds_pack_inode2body(req2obd(req), body, child->d_inode);
+                mds_pack_inode2body(req2obd(req), body, child->d_inode, 1);
         }
         l_dput(parent);
         l_dput(child);
@@ -843,7 +843,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                         /* fill reply */
                         body = lustre_msg_buf(req->rq_repmsg,
                                               0, sizeof(*body));
-                        body->valid |= OBD_MD_FLID | OBD_MD_MDS;
+                        body->valid |= OBD_MD_FLID | OBD_MD_MDS | OBD_MD_FID;
 
                         obdo2id(&body->id1, oa);
 	                obdo_free(oa);
@@ -991,7 +991,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                         MD_COUNTER_INCREMENT(obd, create);
 
                 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
-                mds_pack_inode2body(obd, body, inode);
+                mds_pack_inode2body(obd, body, inode, 1);
         }
 
         EXIT;
@@ -1820,7 +1820,7 @@ static int mds_reint_unlink_remote(struct mds_update_record *rec,
                 RETURN(-ENOMEM);
         
         memset(op_data, 0, sizeof(*op_data));
-        mds_pack_dentry2id(obd, &op_data->id1, dchild);
+        mds_pack_dentry2id(obd, &op_data->id1, dchild, 1);
         op_data->create_mode = rec->ur_mode;
 
         DEBUG_REQ(D_INODE, req, "unlink %*s (remote inode "DLID4")",
@@ -2031,7 +2031,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
                         down(&mds->mds_pending_dir->d_inode->i_sem);
                         cleanup_phase = 5; /* up(&pending_dir->i_sem) */
                 } else if (S_ISREG(child_inode->i_mode)) {
-                        mds_pack_inode2body(obd, body, child_inode);
+                        mds_pack_inode2body(obd, body, child_inode, 0);
                         mds_pack_md(obd, req->rq_repmsg, offset + 1,
                                     body, child_inode, MDS_PACK_MD_LOCK);
                 }
@@ -2827,7 +2827,7 @@ static int mds_check_for_rename(struct obd_device *obd,
                         RETURN(-ENOMEM);
                 }
                 memset(op_data, 0, sizeof(*op_data));
-                mds_pack_dentry2id(obd, &op_data->id1, dentry);
+                mds_pack_dentry2id(obd, &op_data->id1, dentry, 1);
 
                 it.it_op = IT_UNLINK;
                 rc = md_enqueue(mds->mds_md_exp, LDLM_IBITS, &it, LCK_EX,
@@ -3067,7 +3067,7 @@ static int mds_reint_rename_to_remote(struct mds_update_record *rec, int offset,
         if (de_old->d_flags & DCACHE_CROSS_REF) {
                 LASSERT(de_old->d_inode == NULL);
                 CDEBUG(D_OTHER, "request to move remote name\n");
-                mds_pack_dentry2id(obd, &op_data->id1, de_old);
+                mds_pack_dentry2id(obd, &op_data->id1, de_old, 1);
         } else if (de_old->d_inode == NULL) {
                 /* oh, source doesn't exist */
                 OBD_FREE(op_data, sizeof(*op_data));
@@ -3233,6 +3233,12 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
 
         }
         
+        /* check if inodes point to each other. */
+        if (!(de_old->d_flags & DCACHE_CROSS_REF) &&
+            !(de_new->d_flags & DCACHE_CROSS_REF) &&
+            old_inode == new_inode)
+                GOTO(cleanup, rc = 0);
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
         /*
          * check if we are moving old entry into its child. 2.6 does not check
@@ -3242,12 +3248,6 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
                 GOTO(cleanup, rc = -EINVAL);
 #endif
         
-        /* check if inodes point to each other. */
-        if (!(de_old->d_flags & DCACHE_CROSS_REF) &&
-            !(de_new->d_flags & DCACHE_CROSS_REF) &&
-            old_inode == new_inode)
-                GOTO(cleanup, rc = 0);
-
         /*
          * if we are about to remove the target at first, pass the EA of that
          * inode to client to perform and cleanup on OST.
@@ -3269,7 +3269,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
                         down(&mds->mds_pending_dir->d_inode->i_sem);
                         cleanup_phase = 3; /* up(&pending_dir->i_sem) */
                 } else if (S_ISREG(new_inode->i_mode)) {
-                        mds_pack_inode2body(obd, body, new_inode);
+                        mds_pack_inode2body(obd, body, new_inode, 0);
                         mds_pack_md(obd, req->rq_repmsg, 1, body, 
                                     new_inode, MDS_PACK_MD_LOCK);
                  }
@@ -3281,8 +3281,8 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
         if (de_old->d_flags & DCACHE_CROSS_REF) {
                 struct lustre_id old_id;
 
-                mds_pack_dentry2id(obd, &old_id, de_old);
-                
+                mds_pack_dentry2id(obd, &old_id, de_old, 1);
+
                 rc = mds_add_local_dentry(rec, offset, req, &old_id,
                                           de_tgtdir, de_new, 1);
                 if (rc)