[Sheepdog] [PATCH] sheepdog: fix calculation of data object id

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Apr 8 09:12:00 CEST 2010


We need to mask VDI_BIT to calculate data object id

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 block/sheepdog.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index a5d335b..18ecd22 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -327,7 +327,7 @@ static inline int after(uint32_t seq1, uint32_t seq2)
 
 static inline int is_data_obj_writeable(struct sd_inode *inode, unsigned int idx)
 {
-	return (inode->oid >> VDI_SPACE_SHIFT) ==
+	return ((inode->oid & ~VDI_BIT) >> VDI_SPACE_SHIFT) ==
 		(inode->data_oid[idx] >> VDI_SPACE_SHIFT);
 }
 
@@ -336,6 +336,11 @@ static inline int is_data_obj(uint64_t oid)
 	return !(VDI_BIT & oid);
 }
 
+static inline uint64_t to_data_oid(uint64_t vdi_oid, unsigned int idx)
+{
+	return (vdi_oid & ~VDI_BIT) | idx;
+}
+
 /*
  * 64 bit FNV-1a non-zero initial basis
  */
@@ -1411,12 +1416,12 @@ static void sd_write_bh_cb(void *p)
 			create = 1;
 			dprintf("update ino (%" PRIu64") %"
 				PRIu64 " %" PRIu64 " %" PRIu64 "\n",
-				inode->oid, oid, inode->oid + idx, idx);
+				inode->oid, oid, to_data_oid(inode->oid, idx), idx);
 			if (oid && !is_data_obj_writeable(inode, idx)) {
 				old_oid = oid;
 				flags = SD_FLAG_CMD_COW;
 			}
-			oid = inode->oid + idx;
+			oid = to_data_oid(inode->oid, idx);
 			acb->oid[i] = oid;
 			dprintf("new oid %lx\n", acb->oid[i]);
 		}
-- 
1.5.6.5




More information about the sheepdog mailing list