<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/1 Liu Yuan <span dir="ltr"><<a href="mailto:namei.unix@gmail.com" target="_blank">namei.unix@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5">On Fri, Nov 01, 2013 at 06:03:40PM +0800, Robin Dong wrote:<br>
> Change 'idx' in object cache from uint32_t to uint64_t for working correctly<br>
> on hyper volume.<br>
><br>
> Signed-off-by: Robin Dong <<a href="mailto:sanbai@taobao.com">sanbai@taobao.com</a>><br>
> ---<br>
> include/sheepdog_proto.h | 2 +-<br>
> sheep/object_cache.c | 97 +++++++++++++++++++++++----------------------<br>
> 2 files changed, 51 insertions(+), 48 deletions(-)<br>
><br>
> diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h<br>
> index 62969d2..d6337b5 100644<br>
> --- a/include/sheepdog_proto.h<br>
> +++ b/include/sheepdog_proto.h<br>
> @@ -419,7 +419,7 @@ static inline uint64_t vid_to_vdi_oid(uint32_t vid)<br>
> return VDI_BIT | ((uint64_t)vid << VDI_SPACE_SHIFT);<br>
> }<br>
><br>
> -static inline uint64_t vid_to_data_oid(uint32_t vid, uint32_t idx)<br>
> +static inline uint64_t vid_to_data_oid(uint32_t vid, uint64_t idx)<br>
> {<br>
> return ((uint64_t)vid << VDI_SPACE_SHIFT) | idx;<br>
> }<br>
> diff --git a/sheep/object_cache.c b/sheep/object_cache.c<br>
> index e1968fc..ae4a103 100644<br>
> --- a/sheep/object_cache.c<br>
> +++ b/sheep/object_cache.c<br>
> @@ -16,15 +16,16 @@<br>
> /*<br>
> * Object Cache ID<br>
> *<br>
> - * 0 - 19 (20 bits): data object space<br>
> - * 20 - 27 (8 bits): object flag space<br>
> - * 28 - 31 (4 bits): object type indentifier space<br>
> + * 0 - 31 (32 bits): data object space<br>
> + * 32 - 51 (20 bits): reserved<br>
> + * 52 - 59 (8 bits): object flag space<br>
> + * 60 - 63 (4 bits): object type indentifier space<br>
> */<br>
> -#define CACHE_VDI_SHIFT 31 /* if the entry is identified as VDI object */<br>
> -#define CACHE_CREATE_SHIFT 27 /* If the entry should be created at backend */<br>
> +#define CACHE_VDI_SHIFT 63 /* if the entry is identified as VDI object */<br>
> +#define CACHE_CREATE_SHIFT 59 /* If the entry should be created at backend */<br>
><br>
> -#define CACHE_VDI_BIT (UINT32_C(1) << CACHE_VDI_SHIFT)<br>
> -#define CACHE_CREATE_BIT (UINT32_C(1) << CACHE_CREATE_SHIFT)<br>
> +#define CACHE_VDI_BIT (UINT64_C(1) << CACHE_VDI_SHIFT)<br>
> +#define CACHE_CREATE_BIT (UINT64_C(1) << CACHE_CREATE_SHIFT)<br>
><br>
> #define CACHE_INDEX_MASK (CACHE_CREATE_BIT)<br>
><br>
> @@ -39,7 +40,7 @@ struct global_cache {<br>
> };<br>
><br>
> struct object_cache_entry {<br>
> - uint32_t idx; /* Index of this entry */<br>
> + uint64_t idx; /* Index of this entry */<br>
> refcnt_t refcnt; /* Reference count of this entry */<br>
> uint64_t bmap; /* Each bit represents one dirty block in object */<br>
> struct object_cache *oc; /* Object cache this entry belongs to */<br>
> @@ -97,7 +98,7 @@ static inline int hash(uint64_t vid)<br>
> }<br>
><br>
> /* We should always use this helper to get entry idx */<br>
> -static inline uint32_t entry_idx(const struct object_cache_entry *entry)<br>
> +static inline uint64_t entry_idx(const struct object_cache_entry *entry)<br>
> {<br>
> return entry->idx & ~CACHE_INDEX_MASK;<br>
> }<br>
> @@ -108,15 +109,15 @@ static int object_cache_cmp(const struct object_cache_entry *a,<br>
> return intcmp(entry_idx(a), entry_idx(b));<br>
> }<br>
><br>
> -static inline uint32_t object_cache_oid_to_idx(uint64_t oid)<br>
> +static inline uint64_t object_cache_oid_to_idx(uint64_t oid)<br>
> {<br>
> - uint32_t idx = data_oid_to_idx(oid);<br>
> + uint64_t idx = data_oid_to_idx(oid);<br>
> if (is_vdi_obj(oid))<br>
> - idx |= 1 << CACHE_VDI_SHIFT;<br>
> + idx |= 1ULL << CACHE_VDI_SHIFT;<br>
> return idx;<br>
> }<br>
<br>
</div></div>I guess you need to handle bnode object too. For now seems to me that<br>
vdi_btree_obj and data objects with the same index will overwrite each other.<br>
<br></blockquote><div><br></div><div>VDI_BTREE_BIT is in 60th bit, and the CACHE_VDI_SHIFT is in 63th bit, why they will overwrite each other.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thanks<br>
<span class=""><font color="#888888">Yuan<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--<br>Best Regard<br>Robin Dong
</div></div>