Whamcloud - gitweb
LU-4201 llite: clip page correctly for vvp_io_commit_sync
[fs/lustre-release.git] / lustre / llite / vvp_io.c
index 7522a48..ceb5ba6 100644 (file)
@@ -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);