From cfbeae97d736152e5bdf8f3e759a260f6ee903d8 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 8 Aug 2019 13:07:21 -0400 Subject: [PATCH 1/1] LU-12043 llite: extend readahead locks for striped file Currently cl_io_read_ahead() can not return locks that cross stripe boundary at one time, thus readahead will stop because of this reason. This is really bad, as we will stop readahead every time we hit stripe boundary, for example default stripe size is 1M, this could hurt performances very much especially with async readahead introduced. So try to use existed locks aggressivly if there is no lock contention, otherwise lock should be not less than requested extent. Change-Id: I8b2dcd0e80138ea530272cab6a665981aa00cca8 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/35438 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Li Xi Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 2 ++ lustre/llite/rw.c | 13 +++++++++++-- lustre/osc/osc_io.c | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 0524f34..4b13504 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -1484,6 +1484,8 @@ struct cl_read_ahead { void (*cra_release)(const struct lu_env *env, void *cbdata); /* Callback data for cra_release routine */ void *cra_cbdata; + /* whether lock is in contention */ + bool cra_contention; }; static inline void cl_read_ahead_release(const struct lu_env *env, diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index cda05f6..0f86103 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -364,6 +364,17 @@ ll_read_ahead_pages(const struct lu_env *env, struct cl_io *io, if (rc < 0) break; + /* Do not shrink the ria_end at any case until + * the minimum end of current read is covered. + * And only shrink the ria_end if the matched + * LDLM lock doesn't cover more. */ + if (page_idx > ra.cra_end || + (ra.cra_contention && + page_idx > ria->ria_end_min)) { + ria->ria_end = ra.cra_end; + break; + } + CDEBUG(D_READA, "idx: %lu, ra: %lu, rpc: %lu\n", page_idx, ra.cra_end, ra.cra_rpc_size); LASSERTF(ra.cra_end >= page_idx, @@ -380,8 +391,6 @@ ll_read_ahead_pages(const struct lu_env *env, struct cl_io *io, ria->ria_end = end - 1; if (ria->ria_end < ria->ria_end_min) ria->ria_end = ria->ria_end_min; - if (ria->ria_end > ra.cra_end) - ria->ria_end = ra.cra_end; } if (page_idx > ria->ria_end) break; diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index 4a1ac52..0d2bf4f 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -91,6 +91,8 @@ static int osc_io_read_ahead(const struct lu_env *env, dlmlock->l_policy_data.l_extent.end); ra->cra_release = osc_read_ahead_release; ra->cra_cbdata = dlmlock; + if (ra->cra_end != CL_PAGE_EOF) + ra->cra_contention = true; result = 0; } -- 1.8.3.1