Whamcloud - gitweb
b=19044
authormanoj <manoj>
Fri, 22 May 2009 23:57:07 +0000 (23:57 +0000)
committermanoj <manoj>
Fri, 22 May 2009 23:57:07 +0000 (23:57 +0000)
r=adilger
r=jinshan.xiong

Fix stripe count when an OST joins after the capsule size is set

lustre/include/obd_support.h
lustre/lov/lov_internal.h
lustre/lov/lov_obd.c
lustre/lov/lov_pack.c
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_lov.c
lustre/mdt/mdt_handler.c
lustre/tests/conf-sanity.sh

index 378b455..5bc65e6 100644 (file)
@@ -200,6 +200,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
 #define OBD_FAIL_MDS_REMOVE_COMMON_EA    0x13e
 #define OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING   0x13f
 #define OBD_FAIL_MDS_LOV_PREP_CREATE     0x141
+#define OBD_FAIL_MDS_REINT_DELAY         0x142
 
 /* CMD */
 #define OBD_FAIL_MDS_IS_SUBDIR_NET       0x180
index 37015e2..f8717a4 100644 (file)
@@ -266,7 +266,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmm,
                struct lov_stripe_md *lsm);
 int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
                  struct lov_mds_md *lmm, int lmm_bytes);
-int lov_setstripe(struct obd_export *exp,
+int lov_setstripe(struct obd_export *exp, int max_lmm_size,
                   struct lov_stripe_md **lsmp, struct lov_user_md *lump);
 int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
               struct lov_user_md *lump);
index b3f873c..8554e85 100644 (file)
@@ -2027,7 +2027,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 break;
         }
         case LL_IOC_LOV_SETSTRIPE:
-                rc = lov_setstripe(exp, karg, uarg);
+                rc = lov_setstripe(exp, len, karg, uarg);
                 break;
         case LL_IOC_LOV_GETSTRIPE:
                 rc = lov_getstripe(exp, karg, uarg);
index 3ba2ac9..ffcdf62 100644 (file)
@@ -391,7 +391,8 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
         RETURN(lsm_size);
 }
 
-static int __lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
+static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
+                           struct lov_stripe_md **lsmp,
                            struct lov_user_md *lump)
 {
         struct obd_device *obd = class_exp2obd(exp);
@@ -457,6 +458,17 @@ static int __lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
         }
         stripe_count = lov_get_stripecnt(lov, lumv1->lmm_stripe_count);
 
+        if (max_lmm_size) {
+                int max_stripes = (max_lmm_size -
+                                   lov_mds_md_size(0, lmm_magic)) /
+                                   sizeof(struct lov_ost_data_v1);
+                if (unlikely(max_stripes < stripe_count)) {
+                        CDEBUG(D_IOCTL, "stripe count reset from %d to %d\n",
+                               stripe_count, max_stripes);
+                        stripe_count = max_stripes;
+                }
+        }
+
         if (lmm_magic == LOV_USER_MAGIC_V3) {
                 struct pool_desc *pool;
 
@@ -507,8 +519,8 @@ static int __lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
  * lmm_stripe_offset, and lmm_stripe_pattern.  lmm_magic must be LOV_MAGIC.
  * @lsmp is a pointer to an in-core stripe MD that needs to be filled in.
  */
-int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
-                  struct lov_user_md *lump)
+int lov_setstripe(struct obd_export *exp, int max_lmm_size,
+                  struct lov_stripe_md **lsmp, struct lov_user_md *lump)
 {
         int rc;
         mm_segment_t seg;
@@ -516,7 +528,7 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
         seg = get_fs();
         set_fs(KERNEL_DS);
 
-        rc = __lov_setstripe(exp, lsmp, lump);
+        rc = __lov_setstripe(exp, max_lmm_size, lsmp, lump);
         set_fs(seg);
         RETURN(rc);
 }
@@ -554,7 +566,7 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
                 }
         }
 
-        rc = lov_setstripe(exp, lsmp, lump);
+        rc = lov_setstripe(exp, 0, lsmp, lump);
         if (rc)
                 RETURN(rc);
 
index 9966c9e..fde65cd 100644 (file)
@@ -1344,7 +1344,7 @@ static int mdd_create_data(const struct lu_env *env, struct md_object *pobj,
 
         if (!md_should_create(spec->sp_cr_flags))
                 RETURN(0);
-
+        lmm_size = ma->ma_lmm_size;
         rc = mdd_lov_create(env, mdd, mdd_pobj, son, &lmm, &lmm_size,
                             spec, attr);
         if (rc)
@@ -1692,6 +1692,7 @@ static int mdd_create(const struct lu_env *env,
          * first.
          */
         if (S_ISREG(attr->la_mode)) {
+                lmm_size = ma->ma_lmm_size;
                 rc = mdd_lov_create(env, mdd, mdd_pobj, son, &lmm, &lmm_size,
                                     spec, attr);
                 if (rc)
index 982313a..5298152 100644 (file)
@@ -397,9 +397,10 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
         int                    rc = 0;
         ENTRY;
 
-        if (!md_should_create(create_flags))
+        if (!md_should_create(create_flags)) {
+                *lmm_size = 0;
                 RETURN(0);
-
+        }
         oti_init(oti, NULL);
 
         /* replay case, has objects already, only get lov from eadata */
@@ -449,7 +450,9 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                                                XATTR_NAME_LOV);
                         if (rc > 0)
                                 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
-                                                   lov_exp, 0, &lsm, _lmm);
+                                                   lov_exp, *lmm_size,
+                                                   &lsm, _lmm);
+
                         if (rc)
                                 GOTO(out_oti, rc);
                 }
index 90623a1..2eb0293 100644 (file)
@@ -1515,6 +1515,8 @@ static int mdt_reint_internal(struct mdt_thread_info *info,
                 GOTO(out_shrink, rc = err_serious(rc));
         }
 
+        OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_REINT_DELAY, 10);
+
         /* for replay no cookkie / lmm need, because client have this already */
         if (info->mti_spec.no_create == 1)  {
                 if (req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER))
index 789ee7e..0f89166 100644 (file)
@@ -1929,6 +1929,28 @@ test_50f() {
 }
 run_test 50f "normal statfs one server in down =========================="
 
+test_51() {
+       local LOCAL_TIMEOUT=20
+
+       reformat
+       start_mds
+       start_ost
+       mount_client $MOUNT
+       check_mount || return 1
+
+       mkdir $MOUNT/d1
+       $LFS setstripe -c -1 $MOUNT/d1
+        #define OBD_FAIL_MDS_REINT_DELAY         0x142
+       do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
+       touch $MOUNT/d1/f1 &
+       local pid=$!
+       sleep 2
+       start_ost2 || return 2
+       wait $pid
+       stop_ost2 || return 3
+       cleanup
+}
+run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
 
 cleanup_gss
 equals_msg `basename $0`: test complete