[Sheepdog] [PATCH] collie: fix calculation of length in vdi_read()/vdi_write()

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Oct 18 01:19:09 CEST 2011


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/vdi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/collie/vdi.c b/collie/vdi.c
index bdc7c50..d08b735 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -1018,7 +1018,7 @@ static int vdi_read(int argc, char **argv)
 	total = roundup(total, 512);
 	idx = offset / SD_DATA_OBJ_SIZE;
 	while (done < total) {
-		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
+		len = min(total - done, SD_DATA_OBJ_SIZE - offset % SD_DATA_OBJ_SIZE);
 
 		if (inode->data_vdi_id[idx]) {
 			oid = vid_to_data_oid(inode->data_vdi_id[idx], idx);
@@ -1119,7 +1119,7 @@ static int vdi_write(int argc, char **argv)
 		create = 0;
 		old_oid = 0;
 		flags = 0;
-		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
+		len = min(total - done, SD_DATA_OBJ_SIZE - offset % SD_DATA_OBJ_SIZE);
 
 		if (!inode->data_vdi_id[idx])
 			create = 1;
-- 
1.7.2.5




More information about the sheepdog mailing list