[lustre-devel] [PATCH 448/622] lustre: llite: Fix page count for unaligned reads

James Simmons jsimmons at infradead.org
Thu Feb 27 13:15:16 PST 2020


From: Patrick Farrell <pfarrell at whamcloud.com>

When a read is unaligned on both the first and last page,
the calculation used to determine count of pages for
readahead misses that we access both of those pages.

Increase the calculated count by 1 in this case.

This case is covered by the generic readahead tests added
in LU-12645.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12367
Lustre-commit: d4a54de84c05 ("LU-12367 llite: Fix page count for unaligned reads")
Signed-off-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35015
Reviewed-by: Wang Shilong <wshilong at ddn.com>
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/llite/vvp_io.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c
index 847fb5e..e676e62 100644
--- a/fs/lustre/llite/vvp_io.c
+++ b/fs/lustre/llite/vvp_io.c
@@ -778,6 +778,14 @@ static int vvp_io_read_start(const struct lu_env *env,
 		vio->vui_ra_valid = true;
 		vio->vui_ra_start = cl_index(obj, pos);
 		vio->vui_ra_count = cl_index(obj, tot + PAGE_SIZE - 1);
+		/* If both start and end are unaligned, we read one more page
+		 * than the index math suggests.
+		 */
+		if (pos % PAGE_SIZE != 0 && (pos + tot) % PAGE_SIZE != 0)
+			vio->vui_ra_count++;
+
+		CDEBUG(D_READA, "tot %ld, ra_start %lu, ra_count %lu\n", tot,
+		       vio->vui_ra_start, vio->vui_ra_count);
 	}
 
 	/* BUG: 5972 */
-- 
1.8.3.1



More information about the lustre-devel mailing list