[Sheepdog] [PATCH] collie: fix offset in vdi_read/vdi_write

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Nov 3 10:57:35 CET 2011


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

diff --git a/collie/vdi.c b/collie/vdi.c
index c582654..c624131 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -1017,8 +1017,9 @@ static int vdi_read(int argc, char **argv)
 	total = min(total, inode->vdi_size - offset);
 	total = roundup(total, 512);
 	idx = offset / SD_DATA_OBJ_SIZE;
+	offset %= SD_DATA_OBJ_SIZE;
 	while (done < total) {
-		len = min(total - done, SD_DATA_OBJ_SIZE - offset % SD_DATA_OBJ_SIZE);
+		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
 
 		if (inode->data_vdi_id[idx]) {
 			oid = vid_to_data_oid(inode->data_vdi_id[idx], idx);
@@ -1115,11 +1116,12 @@ static int vdi_write(int argc, char **argv)
 	total = min(total, inode->vdi_size - offset);
 	total = roundup(total, 512);
 	idx = offset / SD_DATA_OBJ_SIZE;
+	offset %= SD_DATA_OBJ_SIZE;
 	while (done < total) {
 		create = 0;
 		old_oid = 0;
 		flags = 0;
-		len = min(total - done, SD_DATA_OBJ_SIZE - offset % SD_DATA_OBJ_SIZE);
+		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
 
 		if (!inode->data_vdi_id[idx])
 			create = 1;
-- 
1.7.2.5




More information about the sheepdog mailing list