Whamcloud - gitweb
Fix problem with multiple connections to the same local device.
authoradilger <adilger>
Tue, 16 Jul 2002 11:52:07 +0000 (11:52 +0000)
committeradilger <adilger>
Tue, 16 Jul 2002 11:52:07 +0000 (11:52 +0000)
The problem was that we stored the remote export addr+cookie in the
device array.  When we disconnected any connection, it would drop the
remote export from the most recent connection.

What we do now is store the remote export addr+cookie in the local
export/import struct and always use that (the old mdc_connh and osc_connh
are gone).  We could do some further cleanup of the API at this point,
but I will leave it until there is some discussion on the matter.  I was
able to successfully do multiple simultaneous connect and disconnect steps,
as well as run multi-thread test_getattrs with the change.  I'm just doing
a full runregression-net test.

I'm still not 100% confident that this is what Peter wants, so I tagged
the pre-commit tree with "before_rconn" to make it easy to generate
a diff (I will also tag the post-commit with "after_rconn").

12 files changed:
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/llite/namei.c
lustre/llite/super.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/osc/osc_request.c
lustre/ptlrpc/pack_generic.c

index ee8c12d..c58786f 100644 (file)
@@ -141,10 +141,9 @@ int mds_lock_callback(struct lustre_handle *lockh, struct ldlm_lock_desc *desc,
 int mds_reint(int offset, struct ptlrpc_request *req);
 
 /* mdc/mdc_request.c */
-static inline struct mdc_obd *mdc_conn2mdc(struct lustre_handle *conn)
-{
-        return &class_conn2obd(conn)->u.mdc;
-}
+extern int mdc_con2cl(struct lustre_handle *conn, struct ptlrpc_client **cl,
+                      struct ptlrpc_connection **connection,
+                      struct lustre_handle **rconn);
 
 int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                struct lookup_intent *it, int lock_mode, struct inode *dir,
index 0e5e6fd..ca9d7e9 100644 (file)
@@ -59,7 +59,6 @@ struct mds_client_info;
 struct mds_server_data;
 
 struct mdc_obd {
-        struct lustre_handle mdc_connh;
         struct ptlrpc_client *mdc_client;
         struct ptlrpc_client *mdc_ldlm_client;
         struct ptlrpc_connection *mdc_conn;
@@ -68,7 +67,6 @@ struct mdc_obd {
 };
 
 struct osc_obd {
-        struct lustre_handle osc_connh;
         struct ptlrpc_client *osc_client;
         struct ptlrpc_client *osc_ldlm_client;
         struct ptlrpc_connection *osc_conn;
@@ -160,6 +158,7 @@ struct lov_tgt_desc {
 };
 
 struct lov_obd {
+        struct lustre_handle mdc_connh;
         struct obd_device *mdcobd;
         struct lov_desc desc;
         int bufsize; 
index b9782dd..17ceba3 100644 (file)
@@ -64,6 +64,8 @@ extern void proc_lustre_remove_obd_entry(const char* name,
 #ifdef __KERNEL__
 extern struct obd_export *class_conn2export(struct lustre_handle *conn);
 extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
+extern int class_import2export(struct lustre_handle *conn,
+                               struct lustre_handle *imp);
 
 struct obd_export {
         __u64 export_cookie;
@@ -78,7 +80,7 @@ struct obd_export {
 
 struct obd_import {
         __u64 import_cookie;
-        struct lustre_handle import_export; /* client handle */ 
+        struct lustre_handle import_export; /* server handle */ 
         struct list_head import_chain;
         struct obd_device *import_obd;
         unsigned int import_id;
index 3760033..df8edbd 100644 (file)
@@ -178,6 +178,7 @@ static struct dentry *ll_lookup2(struct inode * dir, struct dentry *dentry,
                 memcpy(&lli->lli_intent_lock_handle, &lockh, sizeof(lockh));
 
                 ino = ll_inode_by_name(dir, dentry, &type);
+#warning FIXME: handle negative inode case (see old ll_lookup)
 
                 err = mdc_getattr(&sbi->ll_mdc_conn, ino, type,
                                   OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
index bf3a8ba..a1c8f8d 100644 (file)
@@ -143,6 +143,7 @@ static struct super_block * ll_read_super(struct super_block *sb,
                 CERROR("OST %s: not setup or attached\n", ost);
                 GOTO(out_free, sb = NULL);
         }
+#warning error: need to set obd->u.lov.mdc_connh from sbi->ll_mdc_conn
         err = obd_connect(&sbi->ll_osc_conn, obd);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", ost, err);
@@ -187,7 +188,7 @@ static struct super_block * ll_read_super(struct super_block *sb,
         err = ll_commitcbd_setup(sbi);
         if (err) {
                 CERROR("failed to start commit callback daemon: rc = %d\n",err);
-                GOTO(out_mdc, sb = NULL);
+                GOTO(out_request, sb = NULL);
         }
 
         md.body = lustre_msg_buf(request->rq_repmsg, 0);
@@ -213,12 +214,11 @@ out_dev:
 
 out_cdb:
         ll_commitcbd_cleanup(sbi);
-out_mdc:
-        obd_disconnect(&sbi->ll_mdc_conn);
-        obd_disconnect(&sbi->ll_osc_conn);
-out_disc:
+out_request:
         ptlrpc_free_req(request);
         obd_disconnect(&sbi->ll_osc_conn);
+out_mdc:
+        obd_disconnect(&sbi->ll_mdc_conn);
 out_free:
         OBD_FREE(sbi, sizeof(*sbi));
 
index 4f7363f..c8d89bd 100644 (file)
@@ -26,43 +26,42 @@ extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
 /* obd methods */
 
-static int lov_getinfo(struct obd_device *obd, 
-                       struct lov_desc *desc, 
-                       uuid_t **uuids, 
-                       struct ptlrpc_request **request)
+static int lov_getinfo(struct obd_device *obd, struct lov_desc *desc,
+                       uuid_t **uuids, struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_status_req *streq;
-        struct lov_obd *lov = &obd->u.lov; 
+        struct lov_obd *lov = &obd->u.lov;
         struct mdc_obd *mdc = &lov->mdcobd->u.mdc;
         int rc, size[2] = {sizeof(*streq)};
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+#warning error: need to set lov->mdc_connh somewhere!!!!
+        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &lov->mdc_connh,
                                MDS_LOVINFO, 1, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
-        
+
         *request = req;
         streq = lustre_msg_buf(req->rq_reqmsg, 0);
         streq->flags = HTON__u32(MDS_STATUS_LOV);
         streq->repbuf = HTON__u32(8000);
-        
-        /* prepare for reply */ 
+
+        /* prepare for reply */
         req->rq_level = LUSTRE_CONN_CON;
-        size[0] = sizeof(*desc); 
-        size[1] = 8000; 
+        size[0] = sizeof(*desc);
+        size[1] = 8000;
         req->rq_replen = lustre_msg_size(2, size);
-        
+
         rc = ptlrpc_queue_wait(req);
         rc = ptlrpc_check_status(req, rc);
 
         if (!rc) {
                 memcpy(desc, lustre_msg_buf(req->rq_repmsg, 0), sizeof(*desc));
                 *uuids = lustre_msg_buf(req->rq_repmsg, 1);
-                lov_unpackdesc(desc); 
+                lov_unpackdesc(desc);
         }
-        mdc->mdc_max_mdsize = sizeof(*desc) + 
+        mdc->mdc_max_mdsize = sizeof(*desc) +
                 desc->ld_tgt_count * sizeof(uuid_t);
 
         EXIT;
index 6b7fd21..c735ece 100644 (file)
@@ -49,14 +49,17 @@ int mdc_setattr(struct lustre_handle *conn,
                 struct inode *inode, struct iattr *iattr,
                 struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct mds_rec_setattr *rec;
         struct ptlrpc_request *req;
         int rc, size = sizeof(*rec);
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_REINT, 1, &size, NULL);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
+                               MDS_REINT, 1, &size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -76,11 +79,13 @@ 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 *md,
+               __u32 gid, __u64 time, __u64 rdev, struct lov_stripe_md *smd,
                struct ptlrpc_request **request)
 {
         struct mds_rec_create *rec;
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *req;
         int rc, size[3] = {sizeof(struct mds_rec_create), namelen + 1, 0};
         char *tmp, *bufs[3] = {NULL, NULL, NULL};
@@ -88,22 +93,22 @@ int mdc_create(struct lustre_handle *conn,
         ENTRY;
 
         if (S_ISREG(mode)) {
-                if (!md) {
+                if (!smd) {
                         CERROR("File create, but no md (%ld, %*s)\n",
                                dir->i_ino, namelen, name); 
                         LBUG();
                 }
-                size[2] = md->lmd_size;
-                bufs[2] = (char *)md;
+                size[2] = smd->lmd_size;
+                bufs[2] = (char *)smd;
                 bufcount = 3;
         } else if (S_ISLNK(mode)) {
                 size[2] = tgtlen + 1;
                 bufcount = 3;
         }
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_REINT,
-                              bufcount, size, bufs);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
+                               MDS_REINT, bufcount, size, bufs);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -114,7 +119,7 @@ int mdc_create(struct lustre_handle *conn,
 
         if (S_ISREG(mode)) {
                 tmp = lustre_msg_buf(req->rq_reqmsg, 2);
-                memcpy(tmp, md, md->lmd_size);
+                memcpy(tmp, smd, smd->lmd_size);
         } else if (S_ISLNK(mode)) {
                 tmp = lustre_msg_buf(req->rq_reqmsg, 2);
                 LOGL0(tgt, tgtlen, tmp);
@@ -144,13 +149,16 @@ int mdc_unlink(struct lustre_handle *conn,
                struct inode *dir, struct inode *child, const char *name,
                int namelen, struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *req;
         int rc, size[2] = {sizeof(struct mds_rec_unlink), namelen + 1};
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_REINT, 2, size, NULL);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
+                               MDS_REINT, 2, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -171,13 +179,16 @@ int mdc_link(struct lustre_handle *conn,
              struct dentry *src, struct inode *dir, const char *name,
              int namelen, struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *req;
         int rc, size[2] = {sizeof(struct mds_rec_link), namelen + 1};
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                              MDS_REINT, 2, size, NULL);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
+                               MDS_REINT, 2, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -199,14 +210,17 @@ int mdc_rename(struct lustre_handle *conn,
                int oldlen, const char *new, int newlen,
                struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *req;
         int rc, size[3] = {sizeof(struct mds_rec_rename), oldlen + 1,
                            newlen + 1};
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh, 
-                              MDS_REINT, 3, size, NULL);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
+                               MDS_REINT, 3, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
index 8c8af77..f72b0eb 100644 (file)
 
 extern int mds_queue_req(struct ptlrpc_request *);
 
+int mdc_con2cl(struct lustre_handle *conn, struct ptlrpc_client **cl,
+                struct ptlrpc_connection **connection,
+                struct lustre_handle **rconn)
+{
+        struct obd_export *export;
+        struct mdc_obd *mdc;
+
+        export = class_conn2export(conn);
+        if (!export)
+                return -EINVAL;
+
+        mdc = &export->export_obd->u.mdc;
+
+        *cl = mdc->mdc_client;
+        *connection = mdc->mdc_conn;
+        *rconn = &export->export_import;
+
+        return 0;
+}
+
+static int mdc_con2dlmcl(struct lustre_handle *conn, struct ptlrpc_client **cl,
+                         struct ptlrpc_connection **connection,
+                         struct lustre_handle **rconn)
+{
+        struct obd_export *export;
+        struct mdc_obd *mdc;
+
+        export = class_conn2export(conn);
+        if (!export)
+                return -EINVAL;
+
+        mdc = &export->export_obd->u.mdc;
+
+        *cl = mdc->mdc_ldlm_client;
+        *connection = mdc->mdc_conn;
+        *rconn = &export->export_import;
+
+        return 0;
+}
+
 
 int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid,
                   __u64 *last_committed, __u64 *last_rcvd,
@@ -40,11 +80,14 @@ int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid,
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         int rc, size = sizeof(*body);
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
                               MDS_GETSTATUS, 1, &size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
@@ -84,13 +127,16 @@ int mdc_getattr(struct lustre_handle *conn,
                 obd_id ino, int type, unsigned long valid, size_t ea_size,
                 struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *req;
         struct mds_body *body;
         int rc, size[2] = {sizeof(*body), 0}, bufcount = 1;
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
                                MDS_GETATTR, 1, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
@@ -100,6 +146,7 @@ int mdc_getattr(struct lustre_handle *conn,
         body->valid = valid;
 
         if (S_ISREG(type)) {
+                struct mdc_obd *mdc = &class_conn2obd(conn)->u.mdc;
                 bufcount = 2;
                 size[1] = mdc->mdc_max_mdsize;
         } else if (valid & OBD_MD_LINKNAME) {
@@ -165,13 +212,15 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
 {
         struct ptlrpc_request *req;
         struct obd_device *obddev = class_conn2obd(conn);
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         __u64 res_id[RES_NAME_SIZE] = {dir->i_ino};
         int size[5] = {sizeof(struct ldlm_request), sizeof(struct ldlm_intent)};
         int rc, flags;
         int repsize[3] = {sizeof(struct ldlm_reply), 
                           sizeof(struct mds_body),
-                          mdc->mdc_max_mdsize};
+                          obddev->u.mdc.mdc_max_mdsize};
         struct ldlm_reply *dlm_rep;
         struct ldlm_intent *lit;
         ENTRY;
@@ -192,13 +241,13 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 break;
         }
 
+        mdc_con2dlmcl(conn, &cl, &connection, &rconn);
         if (it->it_op & (IT_MKDIR | IT_CREAT | IT_SYMLINK | IT_MKNOD)) {
                 size[2] = sizeof(struct mds_rec_create);
                 size[3] = de->d_name.len + 1;
                 size[4] = tgtlen + 1;
-                req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                       &mdc->mdc_connh, LDLM_ENQUEUE, 5, size,
-                                       NULL);
+                req = ptlrpc_prep_req2(cl, connection, rconn,
+                                       LDLM_ENQUEUE, 5, size, NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -217,9 +266,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[2] = sizeof(struct mds_rec_rename);
                 size[3] = old_de->d_name.len + 1;
                 size[4] = de->d_name.len + 1;
-                req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                       &mdc->mdc_connh, LDLM_ENQUEUE, 5, size,
-                                       NULL);
+                req = ptlrpc_prep_req2(cl, connection, rconn,
+                                       LDLM_ENQUEUE, 5, size, NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -235,8 +283,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
         } else if (it->it_op == IT_UNLINK || it->it_op == IT_RMDIR) {
                 size[2] = sizeof(struct mds_rec_unlink);
                 size[3] = de->d_name.len + 1;
-                req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                &mdc->mdc_connh, LDLM_ENQUEUE, 4, size, NULL);
+                req = ptlrpc_prep_req2(cl, connection, rconn,
+                                       LDLM_ENQUEUE, 4, size, NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -255,9 +303,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 size[2] = sizeof(struct mds_body);
                 size[3] = de->d_name.len + 1;
 
-                req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                       &mdc->mdc_connh, LDLM_ENQUEUE, 4, size,
-                                       NULL);
+                req = ptlrpc_prep_req2(cl, connection, rconn,
+                                       LDLM_ENQUEUE, 4, size, NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -269,10 +316,10 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 mds_getattr_pack(req, 2, dir, de->d_name.name, de->d_name.len);
 
                 /* get ready for the reply */
-                 req->rq_replen = lustre_msg_size(3, repsize);
+                req->rq_replen = lustre_msg_size(3, repsize);
         } else if (it->it_op == IT_READDIR) {
-                req = ptlrpc_prep_req2(mdc->mdc_ldlm_client, mdc->mdc_conn,
-                                &mdc->mdc_connh, LDLM_ENQUEUE, 1, size, NULL);
+                req = ptlrpc_prep_req2(cl, connection, rconn,
+                                       LDLM_ENQUEUE, 1, size, NULL);
                 if (!req)
                         RETURN(-ENOMEM);
 
@@ -283,7 +330,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 RETURN(-1);
         }
 #warning FIXME: the data here needs to be different if a lock was granted for a different inode
-        rc = ldlm_cli_enqueue(mdc->mdc_ldlm_client, mdc->mdc_conn, NULL, req,
+        rc = ldlm_cli_enqueue(cl, connection, NULL, req,
                               obddev->obd_namespace, NULL, res_id, lock_type,
                               NULL, 0, lock_mode, &flags,
                               (void *)mdc_lock_callback, data, datalen, lockh);
@@ -305,21 +352,24 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
 }
 
 int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
-             struct lov_stripe_md *md, 
-             __u64 cookie, __u64 *fh, struct ptlrpc_request **request)
+             struct lov_stripe_md *smd, __u64 cookie, __u64 *fh,
+             struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct mds_body *body;
         int rc, size[2] = {sizeof(*body)}, bufcount = 1;
         struct ptlrpc_request *req;
         ENTRY;
 
-        if (md != NULL) {
+        if (smd != NULL) {
                 bufcount = 2;
-                size[1] = md->lmd_size;
+                size[1] = smd->lmd_size;
         }
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
                                MDS_OPEN, bufcount, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
@@ -331,8 +381,8 @@ int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
         body->flags = HTON__u32(flags);
         body->extra = cookie;
 
-        if (md != NULL)
-                memcpy(lustre_msg_buf(req->rq_reqmsg, 1), md, md->lmd_size);
+        if (smd != NULL)
+                memcpy(lustre_msg_buf(req->rq_reqmsg, 1), smd, smd->lmd_size);
 
         req->rq_replen = lustre_msg_size(1, size);
 
@@ -353,12 +403,15 @@ int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
 int mdc_close(struct lustre_handle *conn, 
               obd_id ino, int type, __u64 fh, struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct mds_body *body;
         int rc, size = sizeof(*body);
         struct ptlrpc_request *req;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
                                MDS_CLOSE, 1, &size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
@@ -381,7 +434,9 @@ int mdc_close(struct lustre_handle *conn,
 int mdc_readpage(struct lustre_handle *conn, obd_id ino, int type, __u64 offset,
                  char *addr, struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *req = NULL;
         struct ptlrpc_bulk_desc *desc = NULL;
         struct ptlrpc_bulk_page *bulk = NULL;
@@ -391,11 +446,12 @@ int mdc_readpage(struct lustre_handle *conn, obd_id ino, int type, __u64 offset,
 
         CDEBUG(D_INODE, "inode: %ld\n", (long)ino);
 
-        desc = ptlrpc_prep_bulk(mdc->mdc_conn);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        desc = ptlrpc_prep_bulk(connection);
         if (desc == NULL)
                 GOTO(out, rc = -ENOMEM);
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+        req = ptlrpc_prep_req2(cl, connection, rconn,
                                MDS_READPAGE, 1, &size, NULL);
         if (!req)
                 GOTO(out2, rc = -ENOMEM);
@@ -439,13 +495,16 @@ int mdc_readpage(struct lustre_handle *conn, obd_id ino, int type, __u64 offset,
 int mdc_statfs(struct lustre_handle *conn, struct statfs *sfs,
                struct ptlrpc_request **request)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct obd_statfs *osfs;
         struct ptlrpc_request *req;
         int rc, size = sizeof(*osfs);
         ENTRY;
 
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        req = ptlrpc_prep_req2(cl, connection, rconn,
                                MDS_STATFS, 0, NULL, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
@@ -473,8 +532,9 @@ static int mdc_ioctl(long cmd, struct lustre_handle *conn, int len, void *karg,
 #if 0
         /* FIXME XXX : This should use the new ioc_data to pass args in */
         int err = 0;
-        struct ptlrpc_client cl;
-        struct ptlrpc_connection *conn;
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *request;
 
         ENTRY;
@@ -489,12 +549,8 @@ static int mdc_ioctl(long cmd, struct lustre_handle *conn, int len, void *karg,
 
         ptlrpc_init_client(NULL, NULL, 
                            MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, &cl);
-        connection = ptlrpc_uuid_to_connection("mds");
-        if (!connection) {
-                CERROR("cannot create client\n");
-                RETURN(-EINVAL);
-        }
 
+        mdc_con2cl(conn, &cl, &connection, &rconn);
         switch (cmd) {
         case IOC_REQUEST_GETATTR: {
                 CERROR("-- getting attr for ino %lu\n", arg);
@@ -641,7 +697,7 @@ static int mdc_setup(struct obd_device *obddev, obd_count len, void *buf)
                            mdc->mdc_ldlm_client);
         mdc->mdc_client->cli_name = "mdc";
         mdc->mdc_ldlm_client->cli_name = "ldlm";
-        mdc->mdc_max_mdsize = sizeof(struct lov_stripe_md); 
+        mdc->mdc_max_mdsize = sizeof(struct lov_stripe_md);
         /* XXX get recovery hooked in here again */
         //ptlrpc_init_client(ptlrpc_connmgr, ll_recover,...
 
@@ -699,14 +755,17 @@ static int mdc_connect(struct lustre_handle *conn, struct obd_device *obd)
 
         request->rq_level = LUSTRE_CONN_NEW;
         request->rq_replen = lustre_msg_size(0, NULL);
+        /* Sending our local connection info breaks for local connections
+        request->rq_reqmsg->addr = conn->addr;
+        request->rq_reqmsg->cookie = conn->cookie;
+         */
 
         rc = ptlrpc_queue_wait(request);
         rc = ptlrpc_check_status(request, rc);
         if (rc)
                 GOTO(out, rc);
 
-        mdc->mdc_connh.addr = request->rq_repmsg->addr;
-        mdc->mdc_connh.cookie = request->rq_repmsg->cookie;
+        class_import2export(conn, (struct lustre_handle *)request->rq_repmsg);
 
         EXIT;
  out:
@@ -721,15 +780,18 @@ static int mdc_connect(struct lustre_handle *conn, struct obd_device *obd)
 
 static int mdc_disconnect(struct lustre_handle *conn)
 {
-        struct mdc_obd *mdc = mdc_conn2mdc(conn);
+        struct ptlrpc_client *cl;
+        struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct obd_device *obd = class_conn2obd(conn);
         struct ptlrpc_request *request;
         int rc;
         ENTRY;
 
         ldlm_namespace_free(obd->obd_namespace);
-        request = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, 
-                                   &mdc->mdc_connh, MDS_DISCONNECT, 0, NULL, NULL);
+        mdc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
+                                   MDS_DISCONNECT, 0, NULL, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
index 4f73c90..493f5be 100644 (file)
@@ -473,11 +473,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
         case OBD_IOC_BRW_WRITE:
                 rw = OBD_BRW_WRITE;
         case OBD_IOC_BRW_READ: {
-                /* FIXME: use a better ioctl data struct than obd_ioctl_data.
-                 *        We don't really support multiple-obdo I/Os here,
-                 *        for example offset and count are not per-obdo.
-                 */
-                struct lov_stripe_md *md;
+                struct lov_stripe_md smd;
                 obd_count       pages = 0;
                 struct page     **bufs = NULL;
                 obd_size        *counts = NULL;
@@ -502,7 +498,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                         GOTO(brw_free, err = -ENOMEM);
                 }
 
-                md = &data->ioc_obdo1;
+                memset(&smd, 0, sizeof(smd));
+                smd.lmd_object_id = data->ioc_obdo1.o_id;
 
                 from = (&data->ioc_pbuf1)[0];
                 off = data->ioc_offset;
@@ -527,7 +524,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                         flags[j] = 0;
                 }
 
-                err = obd_brw(rw, &conn, md, j, bufs, counts, offsets, flags,
+                err = obd_brw(rw, &conn, &smd, j, bufs, counts, offsets, flags,
                               NULL);
 
                 EXIT;
@@ -590,6 +587,7 @@ EXPORT_SYMBOL(class_uuid2dev);
 EXPORT_SYMBOL(class_uuid2obd);
 EXPORT_SYMBOL(class_connect);
 EXPORT_SYMBOL(class_conn2export);
+EXPORT_SYMBOL(class_import2export);
 EXPORT_SYMBOL(class_conn2obd);
 EXPORT_SYMBOL(class_disconnect);
 //EXPORT_SYMBOL(class_multi_setup);
index 966eb17..8d1db77 100644 (file)
@@ -223,13 +223,16 @@ struct obd_export *class_conn2export(struct lustre_handle *conn)
         struct obd_export * export;
 
         if (!conn)
+               RETURN(NULL);
+
+       if (conn->addr == -1)   /* this means assign a new connection */
                 RETURN(NULL);
 
-        if (!conn->addr || conn->addr == -1 ) { 
+        if (!conn->addr) {
                 fixme();
                 RETURN(NULL);
         }
-              
+
         export = (struct obd_export *) (unsigned long)conn->addr;
         if (!kmem_cache_validate(export_cachep, (void *)export))
                 RETURN(NULL);
@@ -263,15 +266,30 @@ int class_connect (struct lustre_handle *conn, struct obd_device *obd)
 
         memset(export, 0, sizeof(*export));
         get_random_bytes(&export->export_cookie, sizeof(__u64));
-        export->export_obd = obd; 
+        export->export_obd = obd;
         export->export_import.addr = conn->addr;
         export->export_import.cookie = conn->cookie;
-        
+
         list_add(&(export->export_chain), export->export_obd->obd_exports.prev);
         conn->addr = (__u64) (unsigned long)export;
         conn->cookie = export->export_cookie;
+       CDEBUG(D_IOCTL, "connect: addr %Lx cookie %Lx\n",
+              (long long)conn->addr, (long long)conn->cookie);
         return 0;
-} 
+}
+
+int class_import2export(struct lustre_handle *conn, struct lustre_handle *imp)
+{
+       struct obd_export *export = class_conn2export(conn);
+
+       if (!export)
+               return -EINVAL;
+
+        export->export_import.addr = imp->addr;
+        export->export_import.cookie = imp->cookie;
+
+       return 0;
+}
 
 int class_disconnect(struct lustre_handle *conn)
 {
@@ -283,7 +301,9 @@ int class_disconnect(struct lustre_handle *conn)
                 CDEBUG(D_IOCTL, "disconnect: attempting to free "
                        "nonexistent client %Lx\n", conn->addr);
                 RETURN(-EINVAL);
-        }
+        } else
+               CDEBUG(D_IOCTL, "disconnect: addr %Lx cookie %Lx\n",
+                      (long long)conn->addr, (long long)conn->cookie);
         list_del(&export->export_chain);
         kmem_cache_free(export_cachep, export);
 
index 8b341c0..1a68cb1 100644 (file)
 #include <linux/obd_lov.h>
 
 static void osc_con2cl(struct lustre_handle *conn, struct ptlrpc_client **cl,
-                       struct ptlrpc_connection **connection)
+                       struct ptlrpc_connection **connection,
+                       struct lustre_handle **rconn)
 {
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
+        struct obd_export *export = class_conn2export(conn);
+        struct osc_obd *osc = &export->export_obd->u.osc;
         *cl = osc->osc_client;
         *connection = osc->osc_conn;
+        *rconn = &export->export_import;
 }
 
 static void osc_con2dlmcl(struct lustre_handle *conn, struct ptlrpc_client **cl,
-                          struct ptlrpc_connection **connection)
+                          struct ptlrpc_connection **connection,
+                          struct lustre_handle **rconn)
 {
         struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         *cl = osc->osc_ldlm_client;
@@ -66,6 +70,11 @@ static int osc_connect(struct lustre_handle *conn, struct obd_device *obd)
 
         request->rq_level = LUSTRE_CONN_NEW;
         request->rq_replen = lustre_msg_size(0, NULL);
+        request->rq_reqmsg->addr = -1;
+        /* Sending our local connection info breaks for local connections
+        request->rq_reqmsg->addr = conn->addr;
+        request->rq_reqmsg->cookie = conn->cookie;
+         */
 
         rc = ptlrpc_queue_wait(request);
         rc = ptlrpc_check_status(request, rc);
@@ -77,9 +86,7 @@ static int osc_connect(struct lustre_handle *conn, struct obd_device *obd)
         /* XXX eventually maybe more refinement */
         osc->osc_conn->c_level = LUSTRE_CONN_FULL;
 
-        /* XXX: Make this a handle */
-        osc->osc_connh.addr = request->rq_repmsg->addr;
-        osc->osc_connh.cookie = request->rq_repmsg->cookie;
+        class_import2export(conn, (struct lustre_handle *)request->rq_repmsg);
 
         EXIT;
  out:
@@ -97,13 +104,13 @@ static int osc_disconnect(struct lustre_handle *conn)
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
+        struct lustre_handle *rconn;
         int rc;
         ENTRY;
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
-                                  OST_DISCONNECT, 0, NULL, NULL);
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
+                                   OST_DISCONNECT, 0, NULL, NULL);
         if (!request)
                 RETURN(-ENOMEM);
         request->rq_replen = lustre_msg_size(0, NULL);
@@ -124,14 +131,14 @@ static int osc_getattr(struct lustre_handle *conn, struct obdo *oa)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_GETATTR, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -165,14 +172,14 @@ static int osc_open(struct lustre_handle *conn, struct obdo *oa,
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_OPEN, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -204,14 +211,14 @@ static int osc_close(struct lustre_handle *conn, struct obdo *oa,
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_CLOSE, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -244,14 +251,14 @@ static int osc_setattr(struct lustre_handle *conn, struct obdo *oa)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                   OST_SETATTR, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -276,7 +283,7 @@ static int osc_create(struct lustre_handle *conn, struct obdo *oa,
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
@@ -297,8 +304,8 @@ static int osc_create(struct lustre_handle *conn, struct obdo *oa,
                 (*ea)->lmd_size = oa->o_easize;
         }
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                   OST_CREATE, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -331,7 +338,7 @@ static int osc_punch(struct lustre_handle *conn, struct obdo *oa,
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
@@ -340,8 +347,8 @@ static int osc_punch(struct lustre_handle *conn, struct obdo *oa,
                 CERROR("oa NULL\n");
                 RETURN(-EINVAL);
         }
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_PUNCH, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -373,7 +380,7 @@ static int osc_destroy(struct lustre_handle *conn, struct obdo *oa,
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
+        struct lustre_handle *rconn;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
@@ -382,8 +389,8 @@ static int osc_destroy(struct lustre_handle *conn, struct obdo *oa,
                 CERROR("oa NULL\n");
                 RETURN(-EINVAL);
         }
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_DESTROY, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -449,9 +456,9 @@ static int osc_brw_read(struct lustre_handle *conn, struct lov_stripe_md *md,
 {
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *request = NULL;
         struct ptlrpc_bulk_desc *desc = NULL;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ost_body *body;
         int rc, j, size[3] = {sizeof(*body)};
         void *iooptr, *nioptr;
@@ -461,8 +468,8 @@ static int osc_brw_read(struct lustre_handle *conn, struct lov_stripe_md *md,
         size[1] = sizeof(struct obd_ioobj);
         size[2] = page_count * sizeof(struct niobuf_remote);
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_BRW, 3, size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -553,9 +560,9 @@ static int osc_brw_write(struct lustre_handle *conn,
 {
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct ptlrpc_request *request = NULL;
         struct ptlrpc_bulk_desc *desc = NULL;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ost_body *body;
         struct niobuf_local *local = NULL;
         struct niobuf_remote *remote;
@@ -567,8 +574,8 @@ static int osc_brw_write(struct lustre_handle *conn,
         size[1] = sizeof(struct obd_ioobj);
         size[2] = page_count * sizeof(*remote);
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_BRW, 3, size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
@@ -694,16 +701,16 @@ static int osc_brw(int cmd, struct lustre_handle *conn,
                                     offset, flags, (bulk_callback_t)callback);
 }
 
-static int osc_enqueue(struct lustre_handle *oconn,
+static int osc_enqueue(struct lustre_handle *conn,
                        struct lustre_handle *parent_lock, __u64 *res_id,
                        __u32 type, void *extentp, int extent_len, __u32 mode,
                        int *flags, void *callback, void *data, int datalen,
                        struct lustre_handle *lockh)
 {
-        struct obd_device *obddev = class_conn2obd(oconn);
-        struct osc_obd *osc = &obddev->u.osc;
-        struct ptlrpc_connection *conn;
+        struct obd_device *obddev = class_conn2obd(conn);
+        struct ptlrpc_connection *connection;
         struct ptlrpc_client *cl;
+        struct lustre_handle *rconn;
         struct ldlm_extent *extent = extentp;
         int rc;
         __u32 mode2;
@@ -714,7 +721,7 @@ static int osc_enqueue(struct lustre_handle *oconn,
         extent->end = (extent->end + PAGE_SIZE - 1) & PAGE_MASK;
 
         /* Next, search for already existing extent locks that will cover us */
-        osc_con2dlmcl(oconn, &cl, &conn);
+        osc_con2dlmcl(conn, &cl, &connection, &rconn);
         rc = ldlm_lock_match(obddev->obd_namespace, res_id, type, extent,
                              sizeof(extent), mode, lockh);
         if (rc == 1) {
@@ -744,16 +751,14 @@ static int osc_enqueue(struct lustre_handle *oconn,
                 if (mode == LCK_PR)
                         return 0;
 
-                rc = ldlm_cli_convert(cl, lockh, &osc->osc_connh,
-                                      mode, &flags);
+                rc = ldlm_cli_convert(cl, lockh, rconn, mode, &flags);
                 if (rc)
                         LBUG();
 
                 return rc;
         }
 
-        rc = ldlm_cli_enqueue(cl, conn, &osc->osc_connh,
-                              NULL, obddev->obd_namespace,
+        rc = ldlm_cli_enqueue(cl, connection, rconn, NULL,obddev->obd_namespace,
                               parent_lock, res_id, type, extent, sizeof(extent),
                               mode, flags, callback, data, datalen, lockh);
         return rc;
@@ -857,14 +862,14 @@ static int osc_statfs(struct lustre_handle *conn, struct statfs *sfs)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
-        struct osc_obd *osc = &class_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
+        struct lustre_handle *rconn;
         struct obd_statfs *osfs;
         int rc, size = sizeof(*osfs);
         ENTRY;
 
-        osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+        osc_con2cl(conn, &cl, &connection, &rconn);
+        request = ptlrpc_prep_req2(cl, connection, rconn,
                                    OST_STATFS, 0, NULL, NULL);
         if (!request)
                 RETURN(-ENOMEM);
index d896e66..51c061a 100644 (file)
@@ -109,6 +109,12 @@ void *lustre_msg_buf(struct lustre_msg *m, int n)
 {
         int i, offset;
 
+        if (!m) {
+                CERROR("no message buffer!\n");
+                LBUG();
+                return NULL;
+        }
+
         if (n < 0 || n >= m->bufcount) {
                 CERROR("referencing bad sub buffer!\n");
                 LBUG();