Whamcloud - gitweb
LU-7727 mdt: fail FMODE_WRITE open if the client is read only
[fs/lustre-release.git] / lustre / lov / lov_ea.c
index f294d11..05bf270 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -85,7 +85,7 @@ struct lov_stripe_md *lsm_alloc_plain(u16 stripe_count)
        struct lov_oinfo     *loi;
        size_t lsm_size;
        size_t oinfo_ptrs_size;
-       unsigned int i;
+       int i;
 
        LASSERT(stripe_count <= LOV_MAX_STRIPE_COUNT);
 
@@ -116,14 +116,14 @@ err:
 
 void lsm_free_plain(struct lov_stripe_md *lsm)
 {
-        __u16 stripe_count = lsm->lsm_stripe_count;
-        int i;
-
-        for (i = 0; i < stripe_count; i++)
-                OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab,
-                              sizeof(struct lov_oinfo));
-        OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
-                       stripe_count * sizeof(struct lov_oinfo *));
+       __u16 stripe_count = lsm->lsm_stripe_count;
+       int i;
+
+       for (i = 0; i < stripe_count; i++)
+               OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab,
+                             sizeof(struct lov_oinfo));
+       OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
+                      stripe_count * sizeof(struct lov_oinfo *));
 }
 
 /* Find minimum stripe maxbytes value.  For inactive or
@@ -181,17 +181,20 @@ static int lsm_unpackmd_common(struct lov_obd *lov,
                if (lov_oinfo_is_dummy(loi))
                        continue;
 
-               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 &&
+                   !lov2obd(lov)->obd_process_conf) {
+                       CERROR("%s: OST index %d more than OST count %d\n",
+                              (char*)lov->desc.ld_uuid.uuid,
                               loi->loi_ost_idx, lov->desc.ld_tgt_count);
                        lov_dump_lmm_v1(D_WARNING, lmm);
                        return -EINVAL;
                }
 
-               if (!lov->lov_tgts[loi->loi_ost_idx]) {
-                       CERROR("OST index %d missing\n", loi->loi_ost_idx);
+               if (lov->lov_tgts[loi->loi_ost_idx] == NULL) {
+                       CERROR("%s: OST index %d missing\n",
+                              (char*)lov->desc.ld_uuid.uuid, loi->loi_ost_idx);
                        lov_dump_lmm_v1(D_WARNING, lmm);
-                       return -EINVAL;
+                       continue;
                }
 
                stripe_maxbytes = min_t(loff_t, stripe_maxbytes,