diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/osc/osc_cache.c')
-rw-r--r-- | drivers/staging/lustre/lustre/osc/osc_cache.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index d8a95f8fe1ff..e1207c227b79 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -783,6 +783,7 @@ restart: /* pull ext's start back to cover cur */ ext->oe_start = cur->oe_start; ext->oe_grants += chunksize; + LASSERT(*grants >= chunksize); *grants -= chunksize; found = osc_extent_hold(ext); @@ -790,6 +791,7 @@ restart: /* rear merge */ ext->oe_end = cur->oe_end; ext->oe_grants += chunksize; + LASSERT(*grants >= chunksize); *grants -= chunksize; /* try to merge with the next one because we just fill @@ -819,8 +821,8 @@ restart: /* create a new extent */ EASSERT(osc_extent_is_overlapped(obj, cur) == 0, cur); cur->oe_grants = chunksize + cli->cl_extent_tax; + LASSERT(*grants >= cur->oe_grants); *grants -= cur->oe_grants; - LASSERT(*grants >= 0); cur->oe_state = OES_CACHE; found = osc_extent_hold(cur); @@ -849,7 +851,6 @@ restart: out: osc_extent_put(env, cur); - LASSERT(*grants >= 0); return found; } @@ -1219,8 +1220,8 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, ext->oe_end = end_index; ext->oe_grants += chunksize; + LASSERT(*grants >= chunksize); *grants -= chunksize; - LASSERT(*grants >= 0); EASSERTF(osc_extent_is_overlapped(obj, ext) == 0, ext, "overlapped after expanding for %lu.\n", index); @@ -1887,6 +1888,7 @@ struct extent_rpc_data { unsigned int erd_page_count; unsigned int erd_max_pages; unsigned int erd_max_chunks; + unsigned int erd_max_extents; }; static inline unsigned int osc_extent_chunks(const struct osc_extent *ext) @@ -1915,11 +1917,23 @@ static int try_to_add_extent_for_io(struct client_obd *cli, EASSERT((ext->oe_state == OES_CACHE || ext->oe_state == OES_LOCK_DONE), ext); + if (!data->erd_max_extents) + return 0; + chunk_count = osc_extent_chunks(ext); + EASSERTF(data->erd_page_count != 0 || + chunk_count <= data->erd_max_chunks, ext, + "The first extent to be fit in a RPC contains %u chunks, which is over the limit %u.\n", + chunk_count, data->erd_max_chunks); + if (chunk_count > data->erd_max_chunks) return 0; data->erd_max_pages = max(ext->oe_mppr, data->erd_max_pages); + EASSERTF(data->erd_page_count != 0 || + ext->oe_nr_pages <= data->erd_max_pages, ext, + "The first extent to be fit in a RPC contains %u pages, which is over the limit %u.\n", + ext->oe_nr_pages, data->erd_max_pages); if (data->erd_page_count + ext->oe_nr_pages > data->erd_max_pages) return 0; @@ -1943,6 +1957,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli, break; } + data->erd_max_extents--; data->erd_max_chunks -= chunk_count; data->erd_page_count += ext->oe_nr_pages; list_move_tail(&ext->oe_link, data->erd_rpc_list); @@ -1972,10 +1987,12 @@ static inline unsigned int osc_max_write_chunks(const struct client_obd *cli) * * This limitation doesn't apply to ldiskfs, which allows as many * chunks in one RPC as we want. However, it won't have any benefits - * to have too many discontiguous pages in one RPC. Therefore, it - * can only have 256 chunks at most in one RPC. + * to have too many discontiguous pages in one RPC. + * + * An osc_extent won't cover over a RPC size, so the chunks in an + * osc_extent won't bigger than PTLRPC_MAX_BRW_SIZE >> chunkbits. */ - return min(PTLRPC_MAX_BRW_SIZE >> cli->cl_chunkbits, 256); + return PTLRPC_MAX_BRW_SIZE >> cli->cl_chunkbits; } /** @@ -2002,6 +2019,7 @@ static unsigned int get_write_extents(struct osc_object *obj, .erd_page_count = 0, .erd_max_pages = cli->cl_max_pages_per_rpc, .erd_max_chunks = osc_max_write_chunks(cli), + .erd_max_extents = 256, }; LASSERT(osc_object_is_locked(obj)); @@ -2140,6 +2158,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, .erd_page_count = 0, .erd_max_pages = cli->cl_max_pages_per_rpc, .erd_max_chunks = UINT_MAX, + .erd_max_extents = UINT_MAX, }; int rc = 0; |