Whamcloud - gitweb
LU-8460 osc: max_pages_per_rpc should be chunk size aligned
[fs/lustre-release.git] / lustre / ofd / ofd_obd.c
index d42e1c5..c47b5bd 100644 (file)
@@ -164,6 +164,7 @@ static int ofd_parse_connect_data(const struct lu_env *env,
        fed->fed_group = data->ocd_group;
 
        data->ocd_connect_flags &= OST_CONNECT_SUPPORTED;
+       data->ocd_connect_flags2 &= OST_CONNECT_SUPPORTED2;
        data->ocd_version = LUSTRE_VERSION_CODE;
 
        /* Kindly make sure the SKIP_ORPHAN flag is from MDS. */
@@ -173,6 +174,26 @@ static int ofd_parse_connect_data(const struct lu_env *env,
        else if (data->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN)
                RETURN(-EPROTO);
 
+       /* Determine optimal brw size before calculating grant */
+       if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_SIZE)) {
+               data->ocd_brw_size = 65536;
+       } else if (OCD_HAS_FLAG(data, BRW_SIZE)) {
+               if (data->ocd_brw_size > ofd->ofd_brw_size)
+                       data->ocd_brw_size = ofd->ofd_brw_size;
+               if (data->ocd_brw_size == 0) {
+                       CERROR("%s: cli %s/%p ocd_connect_flags: "LPX64
+                              " ocd_version: %x ocd_grant: %d ocd_index: %u "
+                              "ocd_brw_size is unexpectedly zero, "
+                              "network data corruption?"
+                              "Refusing connection of this client\n",
+                              exp->exp_obd->obd_name,
+                              exp->exp_client_uuid.uuid,
+                              exp, data->ocd_connect_flags, data->ocd_version,
+                              data->ocd_grant, data->ocd_index);
+                       RETURN(-EPROTO);
+               }
+       }
+
        if (OCD_HAS_FLAG(data, GRANT_PARAM)) {
                /* client is reporting its page size, for future use */
                exp->exp_filter_data.fed_pagebits = data->ocd_grant_blkbits;
@@ -186,8 +207,12 @@ static int ofd_parse_connect_data(const struct lu_env *env,
                data->ocd_grant_max_blks = ofd->ofd_dt_conf.ddp_max_extent_blks;
        }
 
-       if (OCD_HAS_FLAG(data, GRANT))
+       if (OCD_HAS_FLAG(data, GRANT)) {
+               /* Save connect_data we have so far because ofd_grant_connect()
+                * uses it to calculate grant. */
+               exp->exp_connect_data = *data;
                ofd_grant_connect(env, exp, data, new_connection);
+       }
 
        if (data->ocd_connect_flags & OBD_CONNECT_INDEX) {
                struct lr_server_data *lsd = &ofd->ofd_lut.lut_lsd;
@@ -210,24 +235,6 @@ static int ofd_parse_connect_data(const struct lu_env *env,
                        tgt_server_data_update(env, &ofd->ofd_lut, 0);
                }
        }
-       if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_SIZE)) {
-               data->ocd_brw_size = 65536;
-       } else if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
-               data->ocd_brw_size = min(data->ocd_brw_size,
-                                        (__u32)DT_MAX_BRW_SIZE);
-               if (data->ocd_brw_size == 0) {
-                       CERROR("%s: cli %s/%p ocd_connect_flags: "LPX64
-                              " ocd_version: %x ocd_grant: %d ocd_index: %u "
-                              "ocd_brw_size is unexpectedly zero, "
-                              "network data corruption?"
-                              "Refusing connection of this client\n",
-                              exp->exp_obd->obd_name,
-                              exp->exp_client_uuid.uuid,
-                              exp, data->ocd_connect_flags, data->ocd_version,
-                              data->ocd_grant, data->ocd_index);
-                       RETURN(-EPROTO);
-               }
-       }
 
        if (data->ocd_connect_flags & OBD_CONNECT_CKSUM) {
                __u32 cksum_types = data->ocd_cksum_types;