]> Pileus Git - ~andy/linux/commitdiff
vhost: correctly set bits of dirty pages
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 29 Nov 2010 08:19:07 +0000 (10:19 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 9 Dec 2010 13:39:17 +0000 (15:39 +0200)
Fix two bugs in dirty page logging:
When counting pages we should increase address by 1 instead of
VHOST_PAGE_SIZE. Make log_write() correctly process requests
that cross pages with write_address not starting at page boundary.

Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c

index 916cdbc279e09949283da8c86e08118dca7579ea..4c256d15c249971cdda20792ed7828cdde1c672e 100644 (file)
@@ -885,6 +885,7 @@ static int log_write(void __user *log_base,
        int r;
        if (!write_length)
                return 0;
+       write_length += write_address % VHOST_PAGE_SIZE;
        write_address /= VHOST_PAGE_SIZE;
        for (;;) {
                u64 base = (u64)(unsigned long)log_base;
@@ -898,7 +899,7 @@ static int log_write(void __user *log_base,
                if (write_length <= VHOST_PAGE_SIZE)
                        break;
                write_length -= VHOST_PAGE_SIZE;
-               write_address += VHOST_PAGE_SIZE;
+               write_address += 1;
        }
        return r;
 }