From 137e2efc6b471e6c097e49d2f3af0a5598ae361f Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Mon, 17 Apr 2017 12:29:51 -0700 Subject: [PATCH] LU-9340 lov: readahead shouldn't exceed component boundary Otherwise, it will extend the readahead RPC to the next component while the actual lock of that component is not checked. Signed-off-by: Jinshan Xiong Change-Id: Ice743d45f9df5e6fdc83b07aa6af1b182b660c9a Reviewed-on: https://review.whamcloud.com/26677 Tested-by: Jenkins Reviewed-by: Bobi Jam (cherry picked from commit e31e234c06ac798501cdb7ec92269af83157cb21) Reviewed-on: https://review.whamcloud.com/26861 Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- lustre/lov/lov_io.c | 22 +++++++++++++++------- lustre/lov/lov_page.c | 4 +++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 865adf7..73c16e2 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -703,28 +703,36 @@ static int lov_io_read_ahead(const struct lu_env *env, RETURN(rc); /** - * Adjust the stripe index by layout of raid0. ra->cra_end is the + * Adjust the stripe index by layout of comp. ra->cra_end is the * maximum page index covered by an underlying DLM lock. * This function converts cra_end from stripe level to file level, and - * make sure it's not beyond stripe boundary. + * make sure it's not beyond stripe and component boundary. */ - if (r0->lo_nr == 1) /* single stripe file */ - RETURN(0); /* cra_end is stripe level, convert it into file level */ ra_end = ra->cra_end; if (ra_end != CL_PAGE_EOF) - ra_end = lov_stripe_pgoff(loo->lo_lsm, index, ra_end, stripe); + ra->cra_end = lov_stripe_pgoff(loo->lo_lsm, index, + ra_end, stripe); + + /* boundary of current component */ + ra_end = cl_index(obj, (loff_t)lov_lse(loo, index)->lsme_extent.e_end); + if (ra_end != CL_PAGE_EOF && ra->cra_end >= ra_end) + ra->cra_end = ra_end - 1; + + if (r0->lo_nr == 1) /* single stripe file */ + RETURN(0); pps = lov_lse(loo, index)->lsme_stripe_size >> PAGE_SHIFT; CDEBUG(D_READA, DFID " max_index = %lu, pps = %u, index = %u, " "stripe_size = %u, stripe no = %u, start index = %lu\n", - PFID(lu_object_fid(lov2lu(loo))), ra_end, pps, index, + PFID(lu_object_fid(lov2lu(loo))), ra->cra_end, pps, index, lov_lse(loo, index)->lsme_stripe_size, stripe, start); /* never exceed the end of the stripe */ - ra->cra_end = min_t(pgoff_t, ra_end, start + pps - start % pps - 1); + ra->cra_end = min_t(pgoff_t, + ra->cra_end, start + pps - start % pps - 1); RETURN(0); } diff --git a/lustre/lov/lov_page.c b/lustre/lov/lov_page.c index 19a908f..869c0b8 100644 --- a/lustre/lov/lov_page.c +++ b/lustre/lov/lov_page.c @@ -55,7 +55,9 @@ static int lov_comp_page_print(const struct lu_env *env, { struct lov_page *lp = cl2lov_page(slice); - return (*printer)(env, cookie, LUSTRE_LOV_NAME"-page@%p, raid0\n", lp); + return (*printer)(env, cookie, + LUSTRE_LOV_NAME"-page@%p, comp index: %x\n", + lp, lp->lps_index); } static const struct cl_page_operations lov_comp_page_ops = { -- 1.8.3.1