[Sheepdog] [PATCH] sheepdog: fix index calculation of the data object

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue May 11 06:30:14 CEST 2010


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

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 3080b48..5ca4dbb 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -192,6 +192,16 @@ static inline int is_data_obj_writeable(struct sd_inode *inode, unsigned int idx
 	return inode->vdi_id == inode->data_vdi_id[idx];
 }
 
+static inline int is_data_obj(uint64_t oid)
+{
+	return !(VDI_BIT & oid);
+}
+
+static inline uint64_t data_oid_to_idx(uint64_t oid)
+{
+	return oid & (MAX_DATA_OBJS - 1);
+}
+
 static inline uint64_t vid_to_vdi_oid(uint32_t vid)
 {
 	return VDI_BIT | ((uint64_t)vid << VDI_SPACE_SHIFT);
@@ -727,7 +737,9 @@ static void aio_read_response(void *opaque)
 
 	switch (acb->aiocb_type) {
 	case AIOCB_WRITE_UDATA:
-		idx = acb->sector_num * 512 / SD_DATA_OBJ_SIZE;
+		if (!is_data_obj(aio_req->oid))
+			break;
+		idx = data_oid_to_idx(aio_req->oid);
 
 		if (s->inode.data_vdi_id[idx] != s->inode.vdi_id) {
 			s->inode.data_vdi_id[idx] = s->inode.vdi_id;
-- 
1.5.6.5




More information about the sheepdog mailing list