[sheepdog] [PATCH v3 2/6] sheep: make oid_to_vid support any kind of objects
MORITA Kazutaka
morita.kazutaka at gmail.com
Thu May 2 05:55:43 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
get_obj_copy_number() doesn't take into account vmstate objects. This
fixes the problem by changing oid_to_vid() so that it supports any
kind of objects.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
include/sheepdog_proto.h | 8 ++------
sheep/vdi.c | 8 +-------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 8f14105..886b535 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -84,6 +84,7 @@
*/
#define VDI_SPACE_SHIFT 32
+#define SD_VDI_MASK 0x00FFFFFF00000000
#define VDI_BIT (UINT64_C(1) << 63)
#define VMSTATE_BIT (UINT64_C(1) << 62)
#define VDI_ATTR_BIT (UINT64_C(1) << 61)
@@ -292,7 +293,7 @@ static inline uint64_t vid_to_data_oid(uint32_t vid, uint32_t idx)
static inline uint32_t oid_to_vid(uint64_t oid)
{
- return (~VDI_BIT & oid) >> VDI_SPACE_SHIFT;
+ return (oid & SD_VDI_MASK) >> VDI_SPACE_SHIFT;
}
static inline uint64_t vid_to_attr_oid(uint32_t vid, uint32_t attrid)
@@ -300,11 +301,6 @@ static inline uint64_t vid_to_attr_oid(uint32_t vid, uint32_t attrid)
return ((uint64_t)vid << VDI_SPACE_SHIFT) | VDI_ATTR_BIT | attrid;
}
-static inline uint32_t attr_oid_to_vid(uint64_t oid)
-{
- return (~VDI_ATTR_BIT & oid) >> VDI_SPACE_SHIFT;
-}
-
static inline bool vdi_is_snapshot(const struct sd_inode *inode)
{
return !!inode->snap_ctime;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 259eacb..057dd5a 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -88,13 +88,7 @@ int get_vdi_copy_number(uint32_t vid)
int get_obj_copy_number(uint64_t oid, int nr_zones)
{
- uint32_t vid;
- if (is_vdi_attr_obj(oid))
- vid = attr_oid_to_vid(oid);
- else
- vid = oid_to_vid(oid);
-
- return min(get_vdi_copy_number(vid), nr_zones);
+ return min(get_vdi_copy_number(oid_to_vid(oid)), nr_zones);
}
int get_req_copy_number(struct request *req)
--
1.7.9.5
More information about the sheepdog
mailing list