From 94efc0f46185fedbb4c1c9ff8b1d281b8d846d59 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Mon, 9 Dec 2013 23:41:26 -0800 Subject: [PATCH] LU-4201 llite: clip page correctly for vvp_io_commit_sync The original code was wrong which clipped page incorrectly for partial pages started with zero. Signed-off-by: Jinshan Xiong Change-Id: I66ec542d5282fdfd68fe59f8056aca292b318c00 Reviewed-on: http://review.whamcloud.com/8531 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: wangdi --- lustre/llite/vvp_io.c | 16 +++++++++------- lustre/tests/sanity.sh | 4 ++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 7522a48..ceb5ba6 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -622,14 +622,16 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io, if (plist->pl_nr == 0) RETURN(0); - if (from != 0) { + if (from > 0 || to != PAGE_SIZE) { page = cl_page_list_first(plist); - cl_page_clip(env, page, from, - plist->pl_nr == 1 ? to : PAGE_SIZE); - } - if (to != PAGE_SIZE && plist->pl_nr > 1) { - page = cl_page_list_last(plist); - cl_page_clip(env, page, 0, to); + if (plist->pl_nr == 1) { + cl_page_clip(env, page, from, to); + } else if (from > 0) { + cl_page_clip(env, page, from, PAGE_SIZE); + } else { + page = cl_page_list_last(plist); + cl_page_clip(env, page, 0, to); + } } cl_2queue_init(queue); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index ff16f9b..33919d9 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -11241,6 +11241,10 @@ test_219() { dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3 $LCTL set_param fail_loc=0x411 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc + + # LU-4201 + dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1 + $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size" } run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND" -- 1.8.3.1