Whamcloud - gitweb
LU-717 ldiskfs: MRP-222 Replace sysname with nodename in MMP
[fs/lustre-release.git] / lustre / lov / lov_ea.c
index 11e2b07..25017a2 100755 (executable)
@@ -177,6 +177,29 @@ static int lsm_destroy_plain(struct lov_stripe_md *lsm, struct obdo *oa,
         return 0;
 }
 
+/* Find minimum stripe maxbytes value.  For inactive or
+ * reconnecting targets use LUSTRE_STRIPE_MAXBYTES. */
+static void lov_tgt_maxbytes(struct lov_tgt_desc *tgt, __u64 *stripe_maxbytes)
+{
+        struct obd_import *imp = tgt->ltd_obd->u.cli.cl_import;
+
+        if (imp == NULL || !tgt->ltd_active) {
+                *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
+                return;
+        }
+
+        cfs_spin_lock(&imp->imp_lock);
+        if (imp->imp_state == LUSTRE_IMP_FULL &&
+           (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_MAXBYTES) &&
+           imp->imp_connect_data.ocd_maxbytes > 0) {
+                if (*stripe_maxbytes > imp->imp_connect_data.ocd_maxbytes)
+                        *stripe_maxbytes = imp->imp_connect_data.ocd_maxbytes;
+        } else {
+                *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
+        }
+        cfs_spin_unlock(&imp->imp_lock);
+}
+
 static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes,
                              int *stripe_count)
 {
@@ -208,8 +231,6 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
         lsm_unpackmd_common(lsm, lmm);
 
         for (i = 0; i < lsm->lsm_stripe_count; i++) {
-                struct obd_import *imp;
-
                 /* XXX LOV STACKING call down to osc_unpackmd() */
                 loi = lsm->lsm_oinfo[i];
                 loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id);
@@ -228,23 +249,10 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
                         return -EINVAL;
                 }
                 /* calculate the minimum stripe max bytes */
-                imp = lov->lov_tgts[loi->loi_ost_idx]->ltd_obd->u.cli.cl_import;
-                if (imp != NULL) {
-                        if (!(imp->imp_connect_data.ocd_connect_flags &
-                              OBD_CONNECT_MAXBYTES)) {
-                                imp->imp_connect_data.ocd_maxbytes =
-                                                         LUSTRE_STRIPE_MAXBYTES;
-                        }
-                        if (stripe_maxbytes>imp->imp_connect_data.ocd_maxbytes){
-                                stripe_maxbytes =
-                                             imp->imp_connect_data.ocd_maxbytes;
-                        }
-                }
+                lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx],
+                                 &stripe_maxbytes);
         }
 
-        /* no ost connected yet */
-        if (stripe_maxbytes == OBD_OBJECT_EOF)
-                stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
         lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count;
 
         return 0;
@@ -299,8 +307,6 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
         strncpy(lsm->lsm_pool_name, lmm->lmm_pool_name, LOV_MAXPOOLNAME);
 
         for (i = 0; i < lsm->lsm_stripe_count; i++) {
-                struct obd_import *imp;
-
                 /* XXX LOV STACKING call down to osc_unpackmd() */
                 loi = lsm->lsm_oinfo[i];
                 loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id);
@@ -319,23 +325,10 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
                         return -EINVAL;
                 }
                 /* calculate the minimum stripe max bytes */
-                imp = lov->lov_tgts[loi->loi_ost_idx]->ltd_obd->u.cli.cl_import;
-                if (imp != NULL) {
-                        if (!(imp->imp_connect_data.ocd_connect_flags &
-                              OBD_CONNECT_MAXBYTES)) {
-                                imp->imp_connect_data.ocd_maxbytes =
-                                                         LUSTRE_STRIPE_MAXBYTES;
-                        }
-                        if (stripe_maxbytes>imp->imp_connect_data.ocd_maxbytes){
-                                stripe_maxbytes =
-                                             imp->imp_connect_data.ocd_maxbytes;
-                        }
-                }
+                lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx],
+                                 &stripe_maxbytes);
         }
 
-        /* no ost connected yet */
-        if (stripe_maxbytes == OBD_OBJECT_EOF)
-                stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
         lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count;
 
         return 0;