From: Michael S. Tsirkin Date: Mon, 29 Nov 2010 08:19:07 +0000 (+0200) Subject: vhost: correctly set bits of dirty pages X-Git-Tag: v2.6.37-rc6~14^2~6^2 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=e4dde731ae70072338352c6f8fb75fd04a42cf8d;p=~shefty%2Frdma-dev.git vhost: correctly set bits of dirty pages 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 Signed-off-by: Michael S. Tsirkin --- diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 94701ff3a23..159c77a5746 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -884,6 +884,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; @@ -897,7 +898,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; }