Whamcloud - gitweb
add a branch and its table named "b_iam" for "Index API Module" from #colibri
[fs/lustre-release.git] / lustre / cmobd / cm_oss_reint.c
index 1859063..c460ffb 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/lustre_lib.h>
 #include <linux/lustre_net.h>
 #include <linux/lustre_idl.h>
+#include <linux/lustre_dlm.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_log.h>
 #include <linux/lustre_cmobd.h>
@@ -62,6 +63,7 @@ int cmobd_dummy_lsm(struct lov_stripe_md **lsmp, int stripe_cnt,
                         (*lsmp)->lsm_object_gr = oa->o_gr;
                 }
                 (*lsmp)->lsm_oinfo[i].loi_ost_idx = i;
+                (*lsmp)->lsm_oinfo[i].loi_ost_gen = 1;
                 (*lsmp)->lsm_stripe_size = stripe_size;
         }
         RETURN(0);
@@ -77,27 +79,19 @@ void cmobd_free_lsm(struct lov_stripe_md **lsmp)
 /* reintegration functions */
 static int cmobd_setattr_reint(struct obd_device *obd, void *rec)
 {
-        struct obdo *oa = (struct obdo*)rec;
+        int rc = 0;
+        struct lov_stripe_md *lsm;
         struct cm_obd *cmobd = &obd->u.cm;
         struct obd_export *exp = cmobd->master_exp;
-        struct lov_stripe_md *lsm;
-        struct lov_obd *lov;
-        int rc;
+        struct obdo *oa = (struct obdo *)rec;
         ENTRY;
         
-        /* 
-         * nevertheless ost is not used anymore and lov should be always present
-         * as a object storage export, using ost is still possible (just
-         * deprecated) and we should make sure here, that this is really
-         * lov. --umka.
-         */
-        lov = &cmobd->master_exp->exp_obd->u.lov;
-        rc = cmobd_dummy_lsm(&lsm, lov->desc.ld_tgt_count, oa, 
-                             (__u32)lov->desc.ld_default_stripe_size);
+        rc = cmobd_dummy_lsm(&lsm, cmobd->master_desc.ld_tgt_count, oa, 
+                             (__u32)cmobd->master_desc.ld_default_stripe_size);
         if (rc)
                 GOTO(out, rc);
 
-        rc = obd_setattr(exp, oa, lsm, NULL);
+        rc = obd_setattr(exp, oa, lsm, NULL, NULL);
 
         cmobd_free_lsm(&lsm);
 out:
@@ -106,40 +100,35 @@ out:
 
 static int cmobd_create_reint(struct obd_device *obd, void *rec)
 {
-        struct obdo *oa = (struct obdo *)rec;
         struct cm_obd *cmobd = &obd->u.cm;
         struct obd_export *exp = cmobd->master_exp;
-        struct lov_stripe_md *lsm;
+        struct obdo *oa = (struct obdo *)rec;
         struct obd_trans_info oti = { 0 };
-        struct lov_obd *lov;
+        struct lov_stripe_md *lsm;
         int rc;
         ENTRY;
          
-        /* 
-         * nevertheless ost is not used anymore and lov should be always present
-         * as a object storage export, using ost is still possible (just
-         * deprecated) and we should make sure here, that this is really
-         * lov. --umka.
-         */
-        lov = &cmobd->master_exp->exp_obd->u.lov;
-        rc = cmobd_dummy_lsm(&lsm, lov->desc.ld_tgt_count, oa,
-                             (__u32)lov->desc.ld_default_stripe_size);
+        rc = cmobd_dummy_lsm(&lsm, cmobd->master_desc.ld_tgt_count, oa,
+                             (__u32)cmobd->master_desc.ld_default_stripe_size);
         if (rc)
                 GOTO(out, rc);
         if (cmobd->master_group != oa->o_gr) {
                 int group = oa->o_gr;
                 int valsize = sizeof(group);
-                rc = obd_set_info(exp, strlen("mds_conn"), "mds_conn",
-                                  valsize, &group);
+
+                rc = obd_set_info(exp, strlen("mds_conn"),
+                                  "mds_conn", valsize, &group);
                 if (rc)
-                        GOTO(out, rc = -EINVAL);
+                        GOTO(out, rc);
                 cmobd->master_group = oa->o_gr;
         }
-        rc = obd_create(exp, oa, &lsm, &oti);
 
+        oti.oti_flags |= OBD_MODE_CROW;
+        rc = obd_create(exp, oa, NULL, 0, &lsm, &oti);
         cmobd_free_lsm(&lsm);
+        EXIT;
 out:
-        RETURN(rc);
+        return rc;
 }
 
 /* direct cut-n-paste of filter_blocking_ast() */
@@ -147,7 +136,7 @@ static int cache_blocking_ast(struct ldlm_lock *lock,
                               struct ldlm_lock_desc *desc,
                               void *data, int flag)
 {
-        int do_ast;
+        int rc, do_ast;
         ENTRY;
 
         if (flag == LDLM_CB_CANCELING) {
@@ -156,25 +145,24 @@ static int cache_blocking_ast(struct ldlm_lock *lock,
         }
 
         /* XXX layering violation!  -phil */
-        l_lock(&lock->l_resource->lr_namespace->ns_lock);
-        /* Get this: if filter_blocking_ast is racing with ldlm_intent_policy,
+        lock_res_and_lock(lock);
+        
+        /* get this: if filter_blocking_ast() is racing with ldlm_intent_policy,
          * such that filter_blocking_ast is called just before l_i_p takes the
          * ns_lock, then by the time we get the lock, we might not be the
          * correct blocking function anymore.  So check, and return early, if
          * so. */
         if (lock->l_blocking_ast != cache_blocking_ast) {
-                l_unlock(&lock->l_resource->lr_namespace->ns_lock);
+                unlock_res_and_lock(lock);
                 RETURN(0);
         }
 
         lock->l_flags |= LDLM_FL_CBPENDING;
         do_ast = (!lock->l_readers && !lock->l_writers);
-        l_unlock(&lock->l_resource->lr_namespace->ns_lock);
+        unlock_res_and_lock(lock);
 
         if (do_ast) {
                 struct lustre_handle lockh;
-                int rc;
-
                 LDLM_DEBUG(lock, "already unused, calling ldlm_cli_cancel");
                 ldlm_lock2handle(lock, &lockh);
                 rc = ldlm_cli_cancel(&lockh);
@@ -224,14 +212,12 @@ static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa,
         ldlm_policy_data_t policy;
         struct lov_stripe_md *lsm;
         int flags = 0, err, rc = 0;
-        struct lov_obd *lov;
         ENTRY;
 
         /* XXX for debug write replay without smfs and kml */
         res_id.name[0]= oa->o_id;
         res_id.name[1]= oa->o_gr;
-        policy.l_extent.start = extent->start;
-        policy.l_extent.end = extent->end;
+        policy.l_extent = *extent;
         
         /* get extent read lock on the source replay file */
         rc = ldlm_cli_enqueue(NULL, NULL, cache->obd_namespace, res_id,
@@ -241,23 +227,9 @@ static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa,
         if (rc != ELDLM_OK)
                 RETURN(rc);
         
-        /* 
-         * nevertheless ost is not used anymore and lov should be always present
-         * as a object storage export, using ost is still possible (just
-         * deprecated) and we should make sure here, that this is really
-         * lov. --umka.
-         */
-        lov = &cmobd->master_exp->exp_obd->u.lov;
-
         /* construct the pseudo lsm */
-
-        /*
-         * it is not good to access lov fields like @desc directly. This is
-         * layering violation. It should be accessed via some interface method,
-         * like llite does. --umka
-         */
-        rc = cmobd_dummy_lsm(&lsm, lov->desc.ld_tgt_count, oa,
-                             (__u32)lov->desc.ld_default_stripe_size);
+        rc = cmobd_dummy_lsm(&lsm, cmobd->master_desc.ld_tgt_count, oa,
+                             (__u32)cmobd->master_desc.ld_default_stripe_size);
         if (rc)
                 GOTO(out_lock, rc);
         
@@ -273,8 +245,8 @@ static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa,
         rc = obd_cancel(cmobd->master_exp, lsm, LCK_PW, &lockh_dst);
         if (rc)
                 GOTO(out_lsm, rc);
-        /* XXX in fact, I just want to cancel the only lockh_dst 
-         *     instantly. */
+
+        /* XXX in fact, I just want to cancel the only lockh_dst instantly. */
         rc = obd_cancel_unused(cmobd->master_exp, lsm, 0, NULL);
         if (err)
                 rc = err;
@@ -287,23 +259,25 @@ out_lock:
 
 static int cmobd_write_reint(struct obd_device *obd, void *rec)
 {
-        struct cm_obd *cmobd = &obd->u.cm;
-        struct obd_device *cache = cmobd->cache_exp->exp_obd;
         struct obdo *oa = (struct obdo *)rec;
+        struct cm_obd *cmobd = &obd->u.cm;
         struct ldlm_extent *extent = NULL; 
+        char *extents_buf = NULL;
+        struct obd_device *cache;
+        int rc = 0, ext_num = 0;
         unsigned long csb, ino;
-        char   *extents_buf = NULL;
-        int    size = 0, rc = 0, ext_num = 0; 
+        __u32 size = 0;
         ENTRY;
 
         size = sizeof(csb);
-
         obd_get_info(cmobd->cache_exp, strlen("cache_sb") + 1,
                      "cache_sb", &size, &csb); 
  
         ino = *(int*)(&oa->o_inline[0]);
-        rc = fsfilt_get_ino_write_extents(cache, (struct super_block *)csb, ino,
-                                          &extents_buf, &ext_num);
+        
+        cache = cmobd->cache_exp->exp_obd;
+        rc = fsfilt_get_ino_write_extents(cache, (struct super_block *)csb,
+                                          ino, &extents_buf, &ext_num);
         if (rc)
                 GOTO(out, rc);   
         extent = (struct ldlm_extent *)extents_buf;