Whamcloud - gitweb
LU-3338 llite: Limit reply buffer size
[fs/lustre-release.git] / lustre / lmv / lmv_obd.c
index 26ee849..b6397d4 100644 (file)
@@ -362,7 +362,7 @@ static void lmv_set_timeouts(struct obd_device *obd)
 }
 
 static int lmv_init_ea_size(struct obd_export *exp, int easize,
-                            int def_easize, int cookiesize)
+                           int def_easize, int cookiesize, int def_cookiesize)
 {
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd          *lmv = &obd->u.lmv;
@@ -383,11 +383,15 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
                 lmv->max_cookiesize = cookiesize;
                 change = 1;
         }
-        if (change == 0)
-                RETURN(0);
+       if (lmv->max_def_cookiesize < def_cookiesize) {
+               lmv->max_def_cookiesize = def_cookiesize;
+               change = 1;
+       }
+       if (change == 0)
+               RETURN(0);
 
-        if (lmv->connected == 0)
-                RETURN(0);
+       if (lmv->connected == 0)
+               RETURN(0);
 
        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
                struct lmv_tgt_desc *tgt = lmv->tgts[i];
@@ -398,7 +402,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
                }
 
                rc = md_init_ea_size(tgt->ltd_exp, easize, def_easize,
-                                    cookiesize);
+                                    cookiesize, def_cookiesize);
                if (rc) {
                        CERROR("%s: obd_init_ea_size() failed on MDT target %d:"
                               " rc = %d.\n", obd->obd_name, i, rc);
@@ -486,12 +490,12 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
         tgt->ltd_exp = mdc_exp;
         lmv->desc.ld_active_tgt_count++;
 
-        md_init_ea_size(tgt->ltd_exp, lmv->max_easize,
-                        lmv->max_def_easize, lmv->max_cookiesize);
+       md_init_ea_size(tgt->ltd_exp, lmv->max_easize, lmv->max_def_easize,
+                       lmv->max_cookiesize, lmv->max_def_cookiesize);
 
-        CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n",
-                mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
-                cfs_atomic_read(&obd->obd_refcount));
+       CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n",
+               mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
+               atomic_read(&obd->obd_refcount));
 
 #ifdef __KERNEL__
        lmv_proc_dir = obd->obd_proc_private;
@@ -614,16 +618,15 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                        lmv->desc.ld_tgt_count--;
                        memset(tgt, 0, sizeof(*tgt));
                        spin_unlock(&lmv->lmv_lock);
-                } else {
-                        int easize = sizeof(struct lmv_stripe_md) +
-                                     lmv->desc.ld_tgt_count *
-                                     sizeof(struct lu_fid);
-                        lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
-                }
-        }
+               } else {
+                       int easize = sizeof(struct lmv_stripe_md) +
+                               lmv->desc.ld_tgt_count * sizeof(struct lu_fid);
+                       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0);
+               }
+       }
 
-        lmv_init_unlock(lmv);
-        RETURN(rc);
+       lmv_init_unlock(lmv);
+       RETURN(rc);
 }
 
 int lmv_check_connect(struct obd_device *obd)
@@ -675,7 +678,7 @@ int lmv_check_connect(struct obd_device *obd)
        class_export_put(lmv->exp);
        lmv->connected = 1;
        easize = lmv_mds_md_size(lmv->desc.ld_tgt_count, LMV_MAGIC);
-       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
+       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0);
        lmv_init_unlock(lmv);
        RETURN(0);
 
@@ -2685,12 +2688,16 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
                        if (!obd_get_info(env, tgt->ltd_exp, keylen, key,
                                          vallen, val, NULL))
                                RETURN(0);
-                }
-                RETURN(-EINVAL);
-        } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) {
-                rc = lmv_check_connect(obd);
-                if (rc)
-                        RETURN(rc);
+               }
+               RETURN(-EINVAL);
+       } else if (KEY_IS(KEY_MAX_EASIZE) ||
+                  KEY_IS(KEY_DEFAULT_EASIZE) ||
+                  KEY_IS(KEY_MAX_COOKIESIZE) ||
+                  KEY_IS(KEY_DEFAULT_COOKIESIZE) ||
+                  KEY_IS(KEY_CONN_DATA)) {
+               rc = lmv_check_connect(obd);
+               if (rc)
+                       RETURN(rc);
 
                /*
                 * Forwarding this request to first MDS, it should know LOV