Whamcloud - gitweb
- except for fixing the segfault in the documentation build, this is
[fs/lustre-release.git] / lustre / mds / mds_reint.c
index a051f0a..6d2659f 100644 (file)
@@ -27,6 +27,8 @@
 #include <linux/lustre_dlm.h>
 #include <linux/obd_class.h>
 
+extern inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req);
+
 struct mds_client_info *mds_uuid_to_mci(struct mds_obd *mds, __u8 *uuid)
 {
         struct list_head *p;
@@ -95,7 +97,7 @@ int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
 static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                              struct ptlrpc_request *req)
 {
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         struct dentry *de;
         void *handle;
         int rc = 0;
@@ -137,7 +139,7 @@ static int mds_reint_recreate(struct mds_update_record *rec, int offset,
                             struct ptlrpc_request *req)
 {
         struct dentry *de = NULL;
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         struct dentry *dchild = NULL;
         struct inode *dir;
         int rc = 0;
@@ -186,11 +188,10 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                             struct ptlrpc_request *req)
 {
         struct dentry *de = NULL;
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         struct dentry *dchild = NULL;
         struct inode *dir;
         void *handle;
-        struct ldlm_lock *lock;
         struct lustre_handle lockh;
         int rc = 0, err, flags, lock_mode, type = rec->ur_mode & S_IFMT;
         __u64 res_id[3] = {0,0,0};
@@ -200,7 +201,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         if (offset)
                 offset = 1;
 
-        if (strcmp(req->rq_obd->obd_type->typ_name, "mds") != 0)
+        if (strcmp(req->rq_export->export_obd->obd_type->typ_name, "mds") != 0)
                 LBUG();
 
         de = mds_fid2dentry(mds, rec->ur_fid1, NULL);
@@ -220,6 +221,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         if (rc == 0) {
                 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
                 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
+                                      (struct lustre_handle *)&mds->mds_connh,
                                       NULL, mds->mds_local_namespace, NULL,
                                       res_id, LDLM_PLAIN, NULL, 0, lock_mode,
                                       &flags, (void *)mds_lock_callback, NULL,
@@ -228,9 +230,6 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                         CERROR("lock enqueue: err: %d\n", rc);
                         GOTO(out_create_de, rc = -EIO);
                 }
-        } else {
-                lock = lustre_handle2object(&lockh);
-                LDLM_DEBUG(lock, "matched");
         }
         ldlm_lock_dump((void *)(unsigned long)lockh.addr);
 
@@ -370,8 +369,7 @@ out_create_commit:
 out_create_dchild:
         l_dput(dchild);
         up(&dir->i_sem);
-        lock = lustre_handle2object(&lockh);
-        ldlm_lock_decref(lock, lock_mode);
+        ldlm_lock_decref(&lockh, lock_mode);
 out_create_de:
         l_dput(de);
         req->rq_status = rc;
@@ -402,13 +400,12 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
 {
         struct dentry *de = NULL;
         struct dentry *dchild = NULL;
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         struct obdo *obdo;
         struct inode *dir, *inode;
         int lock_mode, flags;
         __u64 res_id[3] = {0};
         struct lustre_handle lockh;
-        struct ldlm_lock *lock;
         void *handle;
         int rc = 0;
         int err;
@@ -430,6 +427,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
         if (rc == 0) {
                 LDLM_DEBUG_NOLOCK("enqueue res %Lu", res_id[0]);
                 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
+                                      (struct lustre_handle *)&mds->mds_connh,
                                       NULL, mds->mds_local_namespace, NULL,
                                       res_id, LDLM_PLAIN, NULL, 0, lock_mode,
                                       &flags, (void *)mds_lock_callback, NULL,
@@ -438,10 +436,8 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
                         CERROR("lock enqueue: err: %d\n", rc);
                         GOTO(out_unlink_de, rc = -EIO);
                 }
-        } else {
-                lock = lustre_handle2object(&lockh);
-                LDLM_DEBUG(lock, "matched");
-        }
+        } else
+
         ldlm_lock_dump((void *)(unsigned long)lockh.addr);
 
         down(&dir->i_sem);
@@ -515,14 +511,15 @@ out_unlink_dchild:
         l_dput(dchild);
 out_unlink_de:
         up(&dir->i_sem);
-        lock = lustre_handle2object(&lockh);
-        ldlm_lock_decref(lock, lock_mode);
+        ldlm_lock_decref(&lockh
+, lock_mode);
         if (!rc) { 
                 /* Take an exclusive lock on the resource that we're
                  * about to free, to force everyone to drop their
                  * locks. */
                 LDLM_DEBUG_NOLOCK("getting EX lock res %Lu", res_id[0]);
                 rc = ldlm_cli_enqueue(mds->mds_ldlm_client, mds->mds_ldlm_conn,
+                                      (struct lustre_handle *)&mds->mds_connh,
                                       NULL, mds->mds_local_namespace, NULL, 
                                       res_id,
                                       LDLM_PLAIN, NULL, 0, LCK_EX, &flags,
@@ -537,9 +534,8 @@ out_unlink_de:
         l_dput(de);
 
         if (!rc) { 
-                lock = lustre_handle2object(&lockh);
-                ldlm_lock_decref(lock, LCK_EX);
-                rc = ldlm_cli_cancel(lockh);
+                ldlm_lock_decref(&lockh, LCK_EX);
+                rc = ldlm_cli_cancel(&lockh, NULL);
                 if (rc < 0)
                         CERROR("failed to cancel child inode lock ino "
                                "%Ld: %d\n", res_id[0], rc);
@@ -556,7 +552,7 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
         struct dentry *de_src = NULL;
         struct dentry *de_tgt_dir = NULL;
         struct dentry *dchild = NULL;
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         void *handle;
         int rc = 0;
         int err;
@@ -624,7 +620,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
         struct dentry *de_tgtdir = NULL;
         struct dentry *de_old = NULL;
         struct dentry *de_new = NULL;
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         void *handle;
         int rc = 0;
         int err;
@@ -702,7 +698,7 @@ static mds_reinter reinters[REINT_MAX+1] = {
 int mds_reint_rec(struct mds_update_record *rec, int offset,
                   struct ptlrpc_request *req)
 {
-        struct mds_obd *mds = &req->rq_obd->u.mds;
+        struct mds_obd *mds = mds_req2mds(req);
         struct obd_run_ctxt saved;
 
         int rc;