Whamcloud - gitweb
Branch b1_4
[fs/lustre-release.git] / lustre / lov / lov_pack.c
index 2c1f4b4..bdf037b 100644 (file)
@@ -108,7 +108,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
 
         if (lsm) {
                 if (lsm->lsm_magic != LOV_MAGIC) {
-                        CERROR("bad mem LOV MAGIC: 0x%08X != 0x%08X\n",
+                        CWARN("bad LOV MAGIC: 0x%08X != 0x%08X\n",
                                lsm->lsm_magic, LOV_MAGIC);
                         RETURN(-EINVAL);
                 }
@@ -300,6 +300,7 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, int pattern)
         (*lsmp)->lsm_xfersize = PTLRPC_MAX_BRW_SIZE * stripe_count;
         (*lsmp)->lsm_pattern = pattern;
         (*lsmp)->lsm_oinfo[0].loi_ost_idx = ~0;
+        (*lsmp)->lsm_oinfo[0].loi_ost_gen = ~0;
 
         for (i = 0, loi = (*lsmp)->lsm_oinfo; i < stripe_count; i++, loi++)
                 loi_init(loi);
@@ -307,12 +308,14 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, int pattern)
         return lsm_size;
 }
 EXPORT_SYMBOL(lov_alloc_memmd);
+
 void lov_free_memmd(struct lov_stripe_md **lsmp)
 {
         OBD_FREE(*lsmp, lov_stripe_md_size((*lsmp)->lsm_stripe_count));
         *lsmp = NULL;
 }
 EXPORT_SYMBOL(lov_free_memmd);
+
 int lov_unpackmd_v0(struct lov_obd *lov, struct lov_stripe_md *lsm,
                     struct lov_mds_md_v0 *lmm)
 {
@@ -337,7 +340,7 @@ int lov_unpackmd_v0(struct lov_obd *lov, struct lov_stripe_md *lsm,
                         le64_to_cpu(lmm->lmm_objects[ost_offset].l_object_id);
                 /* loi->loi_gr = 0; implicit */
                 loi->loi_ost_idx = ost_offset;
-                /* loi->loi_ost_gen = 0; implicit */
+                loi->loi_ost_gen = 1;
                 loi++;
         }
 
@@ -368,8 +371,9 @@ int lov_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
                 loi->loi_gr = le64_to_cpu(lmm->lmm_objects[i].l_object_gr);
                 loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
                 loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
-                if (loi->loi_ost_idx > lov->desc.ld_tgt_count) {
-                        CERROR("OST index %d more than OST count %d\n",
+                if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) {
+                        CERROR("OST index %d more than OST count %d. "
+                               "MDS and client use different OST sets?\n",
                                loi->loi_ost_idx, lov->desc.ld_tgt_count);
                         lov_dump_lmm_v1(D_WARNING, lmm);
                         return -EINVAL;
@@ -500,6 +504,7 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
                 RETURN(rc);
 
         (*lsmp)->lsm_oinfo[0].loi_ost_idx = lum.lmm_stripe_offset;
+        /* XXX - what about loi_ost_gen ? */
         (*lsmp)->lsm_stripe_size = lum.lmm_stripe_size;
         (*lsmp)->lsm_xfersize = lum.lmm_stripe_size * stripe_count;
 
@@ -516,10 +521,20 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
         obd_id last_id = 0;
 
         for (i = 0; i < lump->lmm_stripe_count; i++) {
+                struct lov_tgt_desc *tgt;
                 __u32 len = sizeof(last_id);
-                oexp = lov->tgts[lump->lmm_objects[i].l_ost_idx].ltd_exp;
+
+                tgt = lov->tgts + lump->lmm_objects[i].l_ost_idx;
+                if (!lov_tgt_active(lov, tgt, lump->lmm_objects[i].l_ost_gen)) {
+                        CERROR("Object on ost idx %d: osc inactive.\n",
+                               lump->lmm_objects[i].l_ost_idx);
+                        continue;
+                }
+
+                oexp = tgt->ltd_exp;
                 rc = obd_get_info(oexp, strlen("last_id"), "last_id",
                                   &len, &last_id);
+                lov_tgt_decref(lov, tgt);
                 if (rc)
                         RETURN(rc);
                 if (lump->lmm_objects[i].l_object_id > last_id) {
@@ -538,6 +553,8 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
         for (i = 0; i < lump->lmm_stripe_count; i++) {
                 (*lsmp)->lsm_oinfo[i].loi_ost_idx =
                         lump->lmm_objects[i].l_ost_idx;
+                (*lsmp)->lsm_oinfo[i].loi_ost_gen =
+                        lump->lmm_objects[i].l_ost_gen;
                 (*lsmp)->lsm_oinfo[i].loi_id = lump->lmm_objects[i].l_object_id;
                 (*lsmp)->lsm_oinfo[i].loi_gr = lump->lmm_objects[i].l_object_gr;
         }
@@ -581,7 +598,8 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm,
 
         /* User wasn't expecting this many OST entries */
         if (lum.lmm_stripe_count == 0) {
-                if (copy_to_user(lump, lmmk, sizeof(lum)))
+                rc = copy_to_user(lump, lmmk, sizeof(lum));
+                if (rc)
                         rc = -EFAULT;
         } else if (lum.lmm_stripe_count < lmmk->lmm_stripe_count) {
                 rc = -EOVERFLOW;