From 13834f5aeef42d3c358574ac59475c0758dce300 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Mon, 8 Aug 2016 17:31:34 +0800 Subject: [PATCH] LU-8460 osc: max_pages_per_rpc should be chunk size aligned max_pages_per_rpc should be chunk size aligned. obd_brw_size need to be at least one block size. Improve the LASSERT() to an LASSERTF() that prints the related parameters to help debug problem. Signed-off-by: Bobi Jam Change-Id: If73b8f05052f96970f3e97015a4642152ace2a38 Reviewed-on: http://review.whamcloud.com/21825 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/ofd/lproc_ofd.c | 3 ++- lustre/ofd/ofd_dev.c | 6 +++++- lustre/ofd/ofd_obd.c | 3 ++- lustre/osc/osc_cache.c | 13 +++++++++---- lustre/osc/osc_request.c | 11 ++++++++--- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index c130194..38093a5 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -533,7 +533,8 @@ ofd_brw_size_seq_write(struct file *file, const char __user *buffer, return -EINVAL; val = val * ONE_MB_BRW_SIZE; - if (val <= 0 || val > DT_MAX_BRW_SIZE) + if (val <= 0 || val > DT_MAX_BRW_SIZE || + val < (1 << ofd->ofd_blockbits)) return -ERANGE; spin_lock(&ofd->ofd_flags_lock); diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 29ed5bd..be51836 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2908,7 +2908,6 @@ 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); @@ -2981,6 +2980,11 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m, } m->ofd_blockbits = fls(osfs->os_bsize) - 1; + if (ONE_MB_BRW_SIZE < (1U << m->ofd_blockbits)) + m->ofd_brw_size = 1U << m->ofd_blockbits; + else + m->ofd_brw_size = ONE_MB_BRW_SIZE; + m->ofd_precreate_batch = OFD_PRECREATE_BATCH_DEFAULT; if (osfs->os_bsize * osfs->os_blocks < OFD_PRECREATE_SMALL_FS) m->ofd_precreate_batch = OFD_PRECREATE_BATCH_SMALL; diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 0613449..c47b5bd 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -178,7 +178,8 @@ static int ofd_parse_connect_data(const struct lu_env *env, 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 > 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 " diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 73a8c84..27a034e 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -647,15 +647,20 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, descr = &olck->ols_cl.cls_lock->cll_descr; LASSERT(descr->cld_mode >= CLM_WRITE); - LASSERT(cli->cl_chunkbits >= PAGE_CACHE_SHIFT); - ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + LASSERTF(cli->cl_chunkbits >= PAGE_SHIFT, + "chunkbits: %u\n", cli->cl_chunkbits); + ppc_bits = cli->cl_chunkbits - PAGE_SHIFT; chunk_mask = ~((1 << ppc_bits) - 1); chunksize = 1 << cli->cl_chunkbits; chunk = index >> ppc_bits; - /* align end to rpc edge, rpc size may not be a power 2 integer. */ + /* align end to RPC edge. */ max_pages = cli->cl_max_pages_per_rpc; - LASSERT((max_pages & ~chunk_mask) == 0); + if ((max_pages & ~chunk_mask) != 0) { + CERROR("max_pages: %#x chunkbits: %u chunk_mask: %#lx\n", + max_pages, cli->cl_chunkbits, chunk_mask); + RETURN(ERR_PTR(-EINVAL)); + } max_end = index - (index % max_pages) + max_pages - 1; max_end = min_t(pgoff_t, max_end, descr->cld_end); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 4e9cf07..1cc95fa 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -937,20 +937,25 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) if (OCD_HAS_FLAG(ocd, GRANT_PARAM)) { u64 size; + int chunk_mask; /* overhead for each extent insertion */ cli->cl_grant_extent_tax = ocd->ocd_grant_tax_kb << 10; /* determine the appropriate chunk size used by osc_extent. */ - cli->cl_chunkbits = max_t(int, PAGE_CACHE_SHIFT, + cli->cl_chunkbits = max_t(int, PAGE_SHIFT, ocd->ocd_grant_blkbits); + /* max_pages_per_rpc must be chunk aligned */ + chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1); + cli->cl_max_pages_per_rpc = (cli->cl_max_pages_per_rpc + + ~chunk_mask) & chunk_mask; /* determine maximum extent size, in #pages */ size = (u64)ocd->ocd_grant_max_blks << ocd->ocd_grant_blkbits; - cli->cl_max_extent_pages = size >> PAGE_CACHE_SHIFT; + cli->cl_max_extent_pages = size >> PAGE_SHIFT; if (cli->cl_max_extent_pages == 0) cli->cl_max_extent_pages = 1; } else { cli->cl_grant_extent_tax = 0; - cli->cl_chunkbits = PAGE_CACHE_SHIFT; + cli->cl_chunkbits = PAGE_SHIFT; cli->cl_max_extent_pages = DT_MAX_BRW_PAGES; } spin_unlock(&cli->cl_loi_list_lock); -- 1.8.3.1