Whamcloud - gitweb
uid == gid is no longer a valid assumption.
[fs/lustre-release.git] / lustre / cmobd / cm_mds_reint.c
index 1c76cef..73b07d5 100644 (file)
@@ -103,7 +103,7 @@ static int cmobd_reint_setattr(struct obd_device *obd, void *record)
          * #249. Will be fixed later. */
 
         /* converting localstore cookie to remote lustre_id. */
-        rc = mds_read_mid(cmobd->cache_obd, &rec->sa_id,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->sa_id,
                           &rec->sa_id, sizeof(rec->sa_id));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "
@@ -132,13 +132,13 @@ static int cmobd_reint_setattr(struct obd_device *obd, void *record)
                 ptlrpc_req_finished(req);
         RETURN(rc);
 }
-
 static int cmobd_reint_create(struct obd_device *obd, void *record)
 {
         struct cm_obd *cmobd = &obd->u.cm;
         struct ptlrpc_request *req = NULL;
         struct mds_kml_pack_info *mkpi;
-        int rc = 0, namelen, datalen;
+        int rc = 0, namelen, datalen, alloc = 0;
         struct mds_rec_create *rec;
         struct mdc_op_data *op_data;
         struct lustre_msg *msg;
@@ -156,12 +156,8 @@ static int cmobd_reint_create(struct obd_device *obd, void *record)
         
         lid = rec->cr_replayid;
 
-        /* zeroing @rec->cr_replayid out in request, as master MDS should create
-         * own inode (with own store cookie). */
-        memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
-
         /* converting local inode store cookie to remote lustre_id. */
-        rc = mds_read_mid(cmobd->cache_obd, &rec->cr_id,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->cr_id,
                           &rec->cr_id, sizeof(rec->cr_id));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "
@@ -172,15 +168,26 @@ static int cmobd_reint_create(struct obd_device *obd, void *record)
         /* getting name to be created and its length */
         name = lustre_msg_string(msg, 1, 0);
         namelen = name ? msg->buflens[1] - 1 : 0;
-
+  
         /* getting misc data (symlink) and its length */
         data = (char *)lustre_msg_buf(msg, 2, 0);
-        datalen = data ? msg->buflens[2] : 0;
-
+        datalen = data ? msg->buflens[2] : 0;       
+
+        if (datalen == 0 && S_ISREG(rec->cr_mode)) {
+                /*Get lov md from inode*/
+                mds_read_md(cmobd->cache_exp->exp_obd, &rec->cr_replayid, 
+                            &data, &datalen);
+                if (datalen > 0)
+                       alloc = 1; 
+        } 
         OBD_ALLOC(op_data, sizeof(*op_data));
-        if (op_data == NULL)
-                RETURN(-ENOMEM);
-        
+        if (op_data == NULL) 
+                GOTO(exit, rc = -ENOMEM);
+        /* zeroing @rec->cr_replayid out in request, as master MDS should create
+         * own inode (with own store cookie). */
+        memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
+       
         /* prepare mdc request data. */
         cmobd_prepare_mdc_data(op_data, &rec->cr_id, &rec->cr_replayid,
                                name, namelen, rec->cr_mode);
@@ -196,12 +203,16 @@ static int cmobd_reint_create(struct obd_device *obd, void *record)
                  * inode EA. */
                 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
 
-                rc = mds_update_mid(cmobd->cache_obd, &lid,
+                rc = mds_update_mid(cmobd->cache_exp->exp_obd, &lid,
                                     &body->id1, sizeof(body->id1));
         }
-
+exit:
         if (req)
                 ptlrpc_req_finished(req);
+        
+        if (alloc == 1)
+                OBD_FREE(data, datalen);
+        
         RETURN(rc);
 }
 
@@ -225,7 +236,7 @@ static int cmobd_reint_unlink(struct obd_device *obd, void *record)
                 RETURN(-EINVAL);
 
         /* converting local store cookie to remote lustre_id. */
-        rc = mds_read_mid(cmobd->cache_obd, &rec->ul_id1,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->ul_id1,
                           &rec->ul_id1, sizeof(rec->ul_id1));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "
@@ -273,7 +284,7 @@ static int cmobd_reint_link(struct obd_device *obd, void *record)
                 RETURN(-EINVAL);
 
         /* converting local store cookie for both ids to remote lustre_id. */
-        rc = mds_read_mid(cmobd->cache_obd, &rec->lk_id1,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->lk_id1,
                           &rec->lk_id1, sizeof(rec->lk_id1));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "
@@ -281,7 +292,7 @@ static int cmobd_reint_link(struct obd_device *obd, void *record)
                 RETURN(rc);
         }
         
-        rc = mds_read_mid(cmobd->cache_obd, &rec->lk_id2,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->lk_id2,
                           &rec->lk_id2, sizeof(rec->lk_id2));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "
@@ -329,7 +340,7 @@ static int cmobd_reint_rename(struct obd_device *obd, void *record)
                 RETURN(-EINVAL);
         
         /* converting local store cookie for both ids to remote lustre_id. */
-        rc = mds_read_mid(cmobd->cache_obd, &rec->rn_id1,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->rn_id1,
                           &rec->rn_id1, sizeof(rec->rn_id1));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "
@@ -337,7 +348,7 @@ static int cmobd_reint_rename(struct obd_device *obd, void *record)
                 RETURN(rc);
         }
         
-        rc = mds_read_mid(cmobd->cache_obd, &rec->rn_id2,
+        rc = mds_read_mid(cmobd->cache_exp->exp_obd, &rec->rn_id2,
                           &rec->rn_id2, sizeof(rec->rn_id2));
         if (rc) {
                 CERROR("Can't read master MDS store cookie "