Whamcloud - gitweb
- the root dentry should not be uhashed, it is always a valid dentry
[fs/lustre-release.git] / lustre / mdc / mdc_reint.c
index b35ed6a..51cacf7 100644 (file)
@@ -40,9 +40,13 @@ static int mdc_reint(struct ptlrpc_request *request, int level)
         rc = ptlrpc_queue_wait(request);
         rc = ptlrpc_check_status(request, rc);
 
-        if (rc)
+        if (rc) {
                 CERROR("error in handling %d\n", rc);
-
+        } else {
+                /* For future resend/replays. */
+                u32 *opcodeptr = lustre_msg_buf(request->rq_reqmsg, 0);
+                *opcodeptr |= REINT_REPLAYING;
+        }
         return rc;
 }
 
@@ -55,7 +59,8 @@ int mdc_setattr(struct lustre_handle *conn,
         int rc, size = sizeof(*rec);
         ENTRY;
 
-        req = ptlrpc_prep_req2(conn, MDS_REINT, 1, &size, NULL);
+        req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 1, &size,
+                              NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -75,44 +80,28 @@ int mdc_setattr(struct lustre_handle *conn,
 int mdc_create(struct lustre_handle *conn,
                struct inode *dir, const char *name, int namelen,
                const char *tgt, int tgtlen, int mode, __u32 uid,
-               __u32 gid, __u64 time, __u64 rdev, struct lov_stripe_md *smd,
+               __u32 gid, __u64 time, __u64 rdev, struct lov_stripe_md *lsm,
                struct ptlrpc_request **request)
 {
-        struct mds_rec_create *rec;
         struct ptlrpc_request *req;
         int rc, size[3] = {sizeof(struct mds_rec_create), namelen + 1, 0};
-        char *tmp;
         int level, bufcount = 2;
         ENTRY;
 
-        if (S_ISREG(mode)) {
-                if (!smd) {
-                        CERROR("File create, but no md (%ld, %*s)\n",
-                               dir->i_ino, namelen, name); 
-                        LBUG();
-                }
-                size[2] = smd->lmd_easize;
-                bufcount = 3;
-        } else if (S_ISLNK(mode)) {
+        if (S_ISLNK(mode)) {
                 size[2] = tgtlen + 1;
                 bufcount = 3;
         }
 
-        req = ptlrpc_prep_req2(conn, MDS_REINT, bufcount, size, NULL);
+        req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, bufcount,
+                              size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
-        /* mds_create_pack fills msg->bufs[1] with name */
-        rec = lustre_msg_buf(req->rq_reqmsg, 0);
+        /* mds_create_pack fills msg->bufs[1] with name
+         * and msg->bufs[2] with tgt, for symlinks */
         mds_create_pack(req, 0, dir, mode, rdev, uid, gid, time,
-                        name, namelen, NULL, 0);
-
-        if (S_ISREG(mode)) {
-                lov_packmd(lustre_msg_buf(req->rq_reqmsg, 2), smd);
-        } else if (S_ISLNK(mode)) {
-                tmp = lustre_msg_buf(req->rq_reqmsg, 2);
-                LOGL0(tgt, tgtlen, tmp);
-        }
+                        name, namelen, tgt, tgtlen);
 
         size[0] = sizeof(struct mds_body);
         req->rq_replen = lustre_msg_size(1, size);
@@ -120,15 +109,15 @@ int mdc_create(struct lustre_handle *conn,
         level = LUSTRE_CONN_FULL;
  resend:
         rc = mdc_reint(req, level);
+        /* Resend if we were told to. */
         if (rc == -ERESTARTSYS) {
-                __u32 *opcode = lustre_msg_buf(req->rq_reqmsg, 0);
                 level = LUSTRE_CONN_RECOVD;
-                CERROR("Lost reply: re-create rep.\n");
                 req->rq_flags = 0;
-                *opcode = NTOH__u32(REINT_RECREATE);
                 goto resend;
         }
 
+        mdc_store_inode_generation(req, 0, 0);
+
         *request = req;
         RETURN(rc);
 }
@@ -141,7 +130,7 @@ int mdc_unlink(struct lustre_handle *conn, struct inode *dir,
         int rc, size[2] = {sizeof(struct mds_rec_unlink), namelen + 1};
         ENTRY;
 
-        req = ptlrpc_prep_req2(conn, MDS_REINT, 2, size, NULL);
+        req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 2, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -166,7 +155,7 @@ int mdc_link(struct lustre_handle *conn,
         int rc, size[2] = {sizeof(struct mds_rec_link), namelen + 1};
         ENTRY;
 
-        req = ptlrpc_prep_req2(conn, MDS_REINT, 2, size, NULL);
+        req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 2, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -193,7 +182,7 @@ int mdc_rename(struct lustre_handle *conn,
                            newlen + 1};
         ENTRY;
 
-        req = ptlrpc_prep_req2(conn, MDS_REINT, 3, size, NULL);
+        req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_REINT, 3, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);