From: Jinshan Xiong Date: Fri, 9 May 2014 01:24:19 +0000 (-0700) Subject: LU-7990 ofd: add a parameter to adjust preferred brw size X-Git-Tag: 2.8.53~40 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=60032c840c3764755861a61a5ffd6d2ccd5446c9 LU-7990 ofd: add a parameter to adjust preferred brw size Add parameter ofd_device::ofd_brw_size to set the preferred BRW size of an OST. Signed-off-by: Jinshan Xiong Signed-off-by: Gu Zheng Change-Id: Iab9b26fb1e1c1af8de10d2c96da69151a0a654f5 Reviewed-on: http://review.whamcloud.com/19367 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Li Xi Reviewed-by: Oleg Drokin --- diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index 05d1deb..76de817 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -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", diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index e95052b..c9de7e9 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -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); diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 662f833..648c859 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -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 */ diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index d42e1c5..a8b9567 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -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;