The object map is used when checking the consistency of data objects. This patch limits the number of the maps and save the consumption of a memory.
Signed-off-by: MORITA Kazutaka <[email protected]> --- sheep/sdnet.c | 17 ++++++++++++++--- sheep/sheep_priv.h | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sheep/sdnet.c b/sheep/sdnet.c index 7c588cb..a40694d 100644 --- a/sheep/sdnet.c +++ b/sheep/sdnet.c @@ -143,11 +143,15 @@ static void __done(struct work *work, int idx) } else if (req->rp.result == SD_RES_SUCCESS && req->check_consistency) { struct sd_obj_req *obj_hdr = (struct sd_obj_req *)&req->rq; uint32_t vdi_id = oid_to_vid(obj_hdr->oid); - struct data_object_bmap *bmap; + struct data_object_bmap *bmap, *n; + int nr_bmaps = 0; - list_for_each_entry(bmap, &sys->consistent_obj_list, list) { + list_for_each_entry_safe(bmap, n, &sys->consistent_obj_list, list) { + nr_bmaps++; if (bmap->vdi_id == vdi_id) { set_bit(data_oid_to_idx(obj_hdr->oid), bmap->dobjs); + list_del(&bmap->list); + list_add_tail(&bmap->list, &sys->consistent_obj_list); goto done; } } @@ -158,8 +162,15 @@ static void __done(struct work *work, int idx) } dprintf("allocate a new object map\n"); bmap->vdi_id = vdi_id; - list_add(&bmap->list, &sys->consistent_obj_list); + list_add_tail(&bmap->list, &sys->consistent_obj_list); set_bit(data_oid_to_idx(obj_hdr->oid), bmap->dobjs); + if (nr_bmaps >= MAX_DATA_OBJECT_BMAPS) { + /* the first entry is the least recently used one */ + bmap = list_first_entry(&sys->consistent_obj_list, + struct data_object_bmap, list); + list_del(&bmap->list); + free(bmap); + } } else if (is_access_local(req->entry, req->nr_vnodes, ((struct sd_obj_req *)&req->rq)->oid, copies) && req->rp.result == SD_RES_EIO) { diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h index 67c651b..74741fa 100644 --- a/sheep/sheep_priv.h +++ b/sheep/sheep_priv.h @@ -90,6 +90,8 @@ struct request { struct work work; }; +#define MAX_DATA_OBJECT_BMAPS 64 + struct data_object_bmap { uint32_t vdi_id; DECLARE_BITMAP(dobjs, MAX_DATA_OBJS); -- 1.7.2.5 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
