Whamcloud - gitweb
Remove no-longer-needed inode operations (they previously had extN EA VFS
[fs/lustre-release.git] / lustre / mdc / mdc_request.c
index d747d18..4be6294 100644 (file)
@@ -35,7 +35,8 @@
 extern int mds_queue_req(struct ptlrpc_request *);
 
 int mdc_connect(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
-                struct ll_fid *rootfid, struct ptlrpc_request **request)
+                struct ll_fid *rootfid, __u64 *last_committed, __u64 *last_rcvd,
+                __u32 *last_xid, struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
@@ -47,37 +48,46 @@ int mdc_connect(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
                 GOTO(out, rc = -ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, 0);
+        req->rq_level = LUSTRE_CONN_CON;
         req->rq_replen = lustre_msg_size(1, &size);
 
-        mds_pack_req_body(req); 
+        mds_pack_req_body(req);
         rc = ptlrpc_queue_wait(req);
         rc = ptlrpc_check_status(req, rc);
 
         if (!rc) {
                 mds_unpack_rep_body(req);
                 body = lustre_msg_buf(req->rq_repmsg, 0);
-                memcpy(rootfid, &body->fid1, sizeof(*rootfid)); 
-
-                CDEBUG(D_NET, "root ino: %Ld\n", rootfid->id);
-                
+                memcpy(rootfid, &body->fid1, sizeof(*rootfid));
+                *last_committed = req->rq_repmsg->last_committed;
+                *last_rcvd = req->rq_repmsg->last_rcvd;
+                *last_xid = body->last_xid;
+
+                CDEBUG(D_NET, "root ino=%ld, last_committed=%Lu, last_rcvd=%Lu,"
+                       " last_xid=%d\n",
+                       (unsigned long)rootfid->id,
+                       (unsigned long long)*last_committed,
+                       (unsigned long long)*last_rcvd,
+                       body->last_xid);
         }
 
         EXIT;
  out:
-        *request = req;
+        ptlrpc_free_req(req); 
         return rc;
 }
 
 
 int mdc_getattr(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
-                ino_t ino, int type, int valid, struct ptlrpc_request **request)
+                ino_t ino, int type, unsigned long valid, size_t ea_size,
+                struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
-        int rc, size = sizeof(*body);
+        int rc, size[2] = {sizeof(*body), 0}, bufcount = 1;
         ENTRY;
 
-        req = ptlrpc_prep_req(cl, conn, MDS_GETATTR, 1, &size, NULL);
+        req = ptlrpc_prep_req(cl, conn, MDS_GETATTR, 1, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
@@ -85,7 +95,12 @@ int mdc_getattr(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
         ll_ino2fid(&body->fid1, ino, 0, type);
         body->valid = valid;
 
-        req->rq_replen = lustre_msg_size(1, &size);
+        if (valid & OBD_MD_LINKNAME) {
+                bufcount = 2;
+                size[1] = ea_size;
+        }
+        req->rq_replen = lustre_msg_size(bufcount, size);
+        req->rq_level = LUSTRE_CONN_FULL;
 
         rc = ptlrpc_queue_wait(req);
         rc = ptlrpc_check_status(req, rc);
@@ -103,7 +118,7 @@ int mdc_getattr(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
 }
 
 int mdc_open(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
-             ino_t ino, int type, int flags, __u64 *fh,
+             ino_t ino, int type, int flags, __u64 cookie, __u64 *fh,
              struct ptlrpc_request **request)
 {
         struct mds_body *body;
@@ -114,9 +129,12 @@ int mdc_open(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
+        req->rq_flags |= PTL_RPC_FL_REPLAY;
+        req->rq_level = LUSTRE_CONN_FULL;
         body = lustre_msg_buf(req->rq_reqmsg, 0);
         ll_ino2fid(&body->fid1, ino, 0, type);
         body->flags = HTON__u32(flags);
+        body->objid = cookie; 
 
         req->rq_replen = lustre_msg_size(1, &size);
 
@@ -150,7 +168,8 @@ int mdc_close(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
         ll_ino2fid(&body->fid1, ino, 0, type);
         body->objid = fh;
 
-        req->rq_replen = lustre_msg_size(1, &size);
+        req->rq_level = LUSTRE_CONN_FULL;
+        req->rq_replen = lustre_msg_size(0, NULL);
 
         rc = ptlrpc_queue_wait(req);
         rc = ptlrpc_check_status(req, rc);
@@ -166,36 +185,32 @@ int mdc_readpage(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
                  struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req = NULL;
-        struct ptlrpc_bulk_desc *bulk = NULL;
-        struct niobuf niobuf;
+        struct ptlrpc_bulk_desc *desc = NULL;
+        struct ptlrpc_bulk_page *bulk = NULL;
         struct mds_body *body;
-        int rc, size[2] = {sizeof(*body), sizeof(struct niobuf)};
-        char *bufs[2] = {NULL, (char *)&niobuf};
-
-        niobuf.addr = (__u64) (long) addr;
+        int rc, size = sizeof(*body);
+        ENTRY;
 
-        CDEBUG(D_INODE, "inode: %ld\n", ino);
+        CDEBUG(D_INODE, "inode: %ld\n", (long)ino);
 
-        bulk = ptlrpc_prep_bulk(conn);
-        if (bulk == NULL) {
-                CERROR("%s: cannot init bulk desc\n", __FUNCTION__);
-                rc = -ENOMEM;
-                goto out;
-        }
+        desc = ptlrpc_prep_bulk(conn);
+        if (desc == NULL)
+                GOTO(out, rc = -ENOMEM);
 
-        req = ptlrpc_prep_req(cl, conn, MDS_READPAGE, 2, size, bufs);
+        req = ptlrpc_prep_req(cl, conn, MDS_READPAGE, 1, &size, NULL);
         if (!req)
-                GOTO(out, rc = -ENOMEM);
+                GOTO(out2, rc = -ENOMEM);
 
+        bulk = ptlrpc_prep_bulk_page(desc);
         bulk->b_buflen = PAGE_SIZE;
-        bulk->b_buf = (void *)(long)niobuf.addr;
-        bulk->b_portal = MDS_BULK_PORTAL;
+        bulk->b_buf = addr;
         bulk->b_xid = req->rq_reqmsg->xid;
+        desc->b_portal = MDS_BULK_PORTAL;
 
-        rc = ptlrpc_register_bulk(bulk);
+        rc = ptlrpc_register_bulk(desc);
         if (rc) {
                 CERROR("couldn't setup bulk sink: error %d.\n", rc);
-                GOTO(out, rc);
+                GOTO(out2, rc);
         }
 
         body = lustre_msg_buf(req->rq_reqmsg, 0);
@@ -203,21 +218,20 @@ int mdc_readpage(struct ptlrpc_client *cl, struct ptlrpc_connection *conn,
         body->fid1.f_type = type;
         body->size = offset;
 
-        req->rq_replen = lustre_msg_size(1, size);
-
+        req->rq_replen = lustre_msg_size(1, &size);
+        req->rq_level = LUSTRE_CONN_FULL;
         rc = ptlrpc_queue_wait(req);
         if (rc) {
                 CERROR("error in handling %d\n", rc);
-                ptlrpc_abort_bulk(bulk);
-                GOTO(out, rc);
-        }
+                ptlrpc_abort_bulk(desc);
+        } else
+                mds_unpack_rep_body(req);
 
-        mds_unpack_rep_body(req);
         EXIT;
-
+ out2:
+        ptlrpc_free_bulk(desc);
  out:
         *request = req;
-        ptlrpc_free_bulk(bulk);
         return rc;
 }
 
@@ -242,9 +256,10 @@ static int request_ioctl(struct inode *inode, struct file *file,
                 RETURN(-EINVAL);
         }
 
-        ptlrpc_init_client(NULL, MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, &cl);
+        ptlrpc_init_client(NULL, NULL, 
+                           MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, &cl);
         conn = ptlrpc_uuid_to_connection("mds");
-        if (err) {
+        if (!conn) {
                 CERROR("cannot create client\n");
                 RETURN(-EINVAL);
         }
@@ -252,7 +267,7 @@ static int request_ioctl(struct inode *inode, struct file *file,
         switch (cmd) {
         case IOC_REQUEST_GETATTR: {
                 CERROR("-- getting attr for ino %lu\n", arg);
-                err = mdc_getattr(&cl, conn, arg, S_IFDIR, ~0, &request);
+                err = mdc_getattr(&cl, conn, arg, S_IFDIR, ~0, 0, &request);
                 CERROR("-- done err %d\n", err);
 
                 GOTO(out, err);
@@ -311,11 +326,12 @@ static int request_ioctl(struct inode *inode, struct file *file,
         case IOC_REQUEST_OPEN: {
                 __u64 fh, ino;
                 copy_from_user(&ino, (__u64 *)arg, sizeof(ino));
-                CERROR("-- opening ino %llu\n", ino);
-                err = mdc_open(&cl, conn, ino, S_IFDIR, O_RDONLY, &fh,
+                CERROR("-- opening ino %llu\n", (unsigned long long)ino);
+                err = mdc_open(&cl, conn, ino, S_IFDIR, O_RDONLY, 4711, &fh, 
                                &request);
                 copy_to_user((__u64 *)arg, &fh, sizeof(fh));
-                CERROR("-- done err %d (fh=%Lu)\n", err, fh);
+                CERROR("-- done err %d (fh=%Lu)\n", err,
+                       (unsigned long long)fh);
 
                 GOTO(out, err);
         }
@@ -329,12 +345,13 @@ static int request_ioctl(struct inode *inode, struct file *file,
         }
 
         default:
-                RETURN(-EINVAL);
+                GOTO(out, err = -EINVAL);
         }
 
  out:
         ptlrpc_free_req(request);
         ptlrpc_put_connection(conn);
+        ptlrpc_cleanup_client(&cl);
 
         RETURN(err);
 }