We no longer need it. Cc: MORITA Kazutaka <morita.kazut...@lab.ntt.co.jp> Cc: Alessandro Bolgia <alessan...@extensys.it> Tested-by: Valerio Pachera <siri...@gmail.com> Signed-off-by: Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp> --- v3: - Keep SD_INODE_HEADER_SIZE as offsetof(struct sd_inode, data_vdi_id), not offsetof(struct sd_inode, __unused). Because hypervolume code depends on the old value.
include/sheepdog_proto.h | 7 ++++++- sheep/gateway.c | 4 ++-- sheep/vdi.c | 46 +++------------------------------------------- 3 files changed, 11 insertions(+), 46 deletions(-) diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h index c3b935f..796d909 100644 --- a/include/sheepdog_proto.h +++ b/include/sheepdog_proto.h @@ -239,7 +239,7 @@ struct sd_inode { uint32_t snap_id; uint32_t vdi_id; uint32_t parent_vdi_id; - uint32_t child_vdi_id[MAX_CHILDREN]; + uint32_t __unused[MAX_CHILDREN]; uint32_t data_vdi_id[SD_INODE_DATA_INDEX]; uint32_t btree_counter; struct generation_reference gref[SD_INODE_DATA_INDEX]; @@ -500,4 +500,9 @@ static inline uint64_t data_oid_to_ledger_oid(uint64_t oid) return LEDGER_BIT | oid; } +static inline uint64_t data_vid_offset(int idx) +{ + return offsetof(struct sd_inode, data_vdi_id[idx]); +} + #endif diff --git a/sheep/gateway.c b/sheep/gateway.c index 1dcc974..c787ec1 100644 --- a/sheep/gateway.c +++ b/sheep/gateway.c @@ -622,9 +622,9 @@ static int update_obj_refcnt(const struct sd_req *hdr, uint32_t *vids, static bool is_data_vid_update(const struct sd_req *hdr) { return is_vdi_obj(hdr->obj.oid) && - SD_INODE_HEADER_SIZE <= hdr->obj.offset && + data_vid_offset(0) <= hdr->obj.offset && hdr->obj.offset + hdr->data_length <= - offsetof(struct sd_inode, gref); + data_vid_offset(SD_INODE_DATA_INDEX); } int gateway_read_obj(struct request *req) diff --git a/sheep/vdi.c b/sheep/vdi.c index 8204bae..4d5d635 100644 --- a/sheep/vdi.c +++ b/sheep/vdi.c @@ -261,17 +261,6 @@ static struct sd_inode *alloc_inode(const struct vdi_iocb *iocb, return new; } -/* Find the first zeroed index to be used for a child vid. */ -static int find_free_idx(uint32_t *vdi_id, size_t max_idx) -{ - for (int i = 0; i < max_idx; i++) { - if (vdi_id[i] == 0) - return i; - } - - return -1; -} - /* Create a fresh vdi */ static int create_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, uint32_t new_vid) @@ -315,7 +304,7 @@ static int clone_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, uint32_t new_vid, uint32_t base_vid) { struct sd_inode *new = NULL, *base = xzalloc(sizeof(*base)); - int ret, idx; + int ret; sd_debug("%s: size %" PRIu64 ", vid %" PRIx32 ", base %" PRIx32 ", " "copies %d, snapid %" PRIu32, iocb->name, iocb->size, new_vid, @@ -328,12 +317,6 @@ static int clone_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, goto out; } - idx = find_free_idx(base->child_vdi_id, ARRAY_SIZE(base->child_vdi_id)); - if (idx < 0) { - ret = SD_RES_FULL_VDI; - goto out; - } - /* TODO: multiple sd_write_object should be performed atomically */ for (int i = 0; i < ARRAY_SIZE(base->gref); i++) { @@ -383,7 +366,7 @@ static int snapshot_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, uint32_t new_vid, uint32_t base_vid) { struct sd_inode *new = NULL, *base = xzalloc(sizeof(*base)); - int ret, idx; + int ret; sd_debug("%s: size %" PRIu64 ", vid %" PRIx32 ", base %" PRIx32 ", " "copies %d, snapid %" PRIu32, iocb->name, iocb->size, new_vid, @@ -396,17 +379,10 @@ static int snapshot_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, goto out; } - idx = find_free_idx(base->child_vdi_id, ARRAY_SIZE(base->child_vdi_id)); - if (idx < 0) { - ret = SD_RES_FULL_VDI; - goto out; - } - /* TODO: multiple sd_write_object should be performed atomically */ /* update a base vdi */ base->snap_ctime = iocb->time; - base->child_vdi_id[idx] = new_vid; for (int i = 0; i < ARRAY_SIZE(base->gref); i++) { if (!base->data_vdi_id[i]) @@ -466,7 +442,7 @@ static int rebase_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, uint32_t new_vid, uint32_t base_vid, uint32_t cur_vid) { struct sd_inode *new = NULL, *base = xzalloc(sizeof(*base)); - int ret, idx; + int ret; sd_debug("%s: size %" PRIu64 ", vid %" PRIx32 ", base %" PRIx32 ", " "cur %" PRIx32 ", copies %d, snapid %" PRIu32, iocb->name, @@ -480,12 +456,6 @@ static int rebase_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, goto out; } - idx = find_free_idx(base->child_vdi_id, ARRAY_SIZE(base->child_vdi_id)); - if (idx < 0) { - ret = SD_RES_FULL_VDI; - goto out; - } - /* TODO: multiple sd_write_object should be performed atomically */ ret = sd_write_object(vid_to_vdi_oid(cur_vid), (char *)&iocb->time, @@ -507,16 +477,6 @@ static int rebase_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid, goto out; } - /* update base vdi */ - ret = sd_write_object(vid_to_vdi_oid(base_vid), (char *)&new_vid, - sizeof(new_vid), - offsetof(struct sd_inode, child_vdi_id[idx]), - false); - if (ret != SD_RES_SUCCESS) { - ret = SD_RES_BASE_VDI_WRITE; - goto out; - } - /* create a new vdi */ new = alloc_inode(iocb, new_snapid, new_vid, base->data_vdi_id, base->gref); -- 1.9.1 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog