Whamcloud - gitweb
LU-7990 ofd: add a parameter to adjust preferred brw size 67/19367/8
authorJinshan Xiong <jinshan.xiong@intel.com>
Fri, 9 May 2014 01:24:19 +0000 (18:24 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 25 Apr 2016 04:16:45 +0000 (04:16 +0000)
Add parameter ofd_device::ofd_brw_size to set the
preferred BRW size of an OST.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: Gu Zheng <gzheng@ddn.com>
Change-Id: Iab9b26fb1e1c1af8de10d2c96da69151a0a654f5
Reviewed-on: http://review.whamcloud.com/19367
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ofd/lproc_ofd.c
lustre/ofd/ofd_dev.c
lustre/ofd/ofd_internal.h
lustre/ofd/ofd_obd.c

index 05d1deb..76de817 100644 (file)
@@ -504,6 +504,46 @@ LPROC_SEQ_FOPS(ofd_syncjournal);
 
 /* This must be longer than the longest string below */
 #define SYNC_STATES_MAXLEN 16
+
+static int ofd_brw_size_seq_show(struct seq_file *m, void *data)
+{
+       struct obd_device       *obd = m->private;
+       struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
+       int                      rc;
+
+       rc = seq_printf(m, "%u\n", ofd->ofd_brw_size / ONE_MB_BRW_SIZE);
+       return rc;
+}
+
+static ssize_t
+ofd_brw_size_seq_write(struct file *file, const char __user *buffer,
+                      size_t count, loff_t *off)
+{
+       struct seq_file         *m = file->private_data;
+       struct obd_device       *obd = m->private;
+       struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
+       int                      val;
+       int                      rc;
+
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc)
+               return rc;
+
+       if (val < 0)
+               return -EINVAL;
+
+       val = val * ONE_MB_BRW_SIZE;
+       if (val <= 0 || val > DT_MAX_BRW_SIZE)
+               return -ERANGE;
+
+       spin_lock(&ofd->ofd_flags_lock);
+       ofd->ofd_brw_size = val;
+       spin_unlock(&ofd->ofd_flags_lock);
+
+       return count;
+}
+LPROC_SEQ_FOPS(ofd_brw_size);
+
 static char *sync_on_cancel_states[] = {"never",
                                        "blocking",
                                        "always" };
@@ -909,6 +949,8 @@ struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
          .fops =       &ofd_degraded_fops              },
        { .name =       "sync_journal",
          .fops =       &ofd_syncjournal_fops           },
+       { .name =       "brw_size",
+         .fops =       &ofd_brw_size_fops              },
        { .name =       "sync_on_lock_cancel",
          .fops =       &ofd_sync_lock_cancel_fops      },
        { .name =       "instance",
index e95052b..c9de7e9 100644 (file)
@@ -2843,6 +2843,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        ofd_slc_set(m);
        m->ofd_grant_compat_disable = 0;
        m->ofd_soft_sync_limit = OFD_SOFT_SYNC_LIMIT_DEFAULT;
+       m->ofd_brw_size = ONE_MB_BRW_SIZE;
 
        /* statfs data */
        spin_lock_init(&m->ofd_osfs_lock);
index 662f833..648c859 100644 (file)
@@ -164,6 +164,9 @@ struct ofd_device {
        /* number of clients using grants */
        int                      ofd_tot_granted_clients;
 
+       /* preferred BRW size, decided by storage type and capability */
+       __u32                    ofd_brw_size;
+
        /* ofd mod data: ofd_device wide values */
        int                      ofd_fmd_max_num; /* per ofd ofd_mod_data */
        cfs_duration_t           ofd_fmd_max_age; /* time to fmd expiry */
index d42e1c5..a8b9567 100644 (file)
@@ -173,6 +173,25 @@ 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)) {
+               data->ocd_brw_size = min(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 +205,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 +233,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;