[sheepdog] [PATCH v1] sheep/http: use INODE_SET_VID_RANGE to accelerate speed of oalloc_free()
Liu Yuan
namei.unix at gmail.com
Wed Feb 19 05:49:23 CET 2014
On Wed, Feb 19, 2014 at 10:19:49AM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai at taobao.com>
>
> Use INODE_SET_VID_RANGE to set vid is more effecient for IO operaion, and,
> after set vid to zero, we only need to REMOVE_OBJ (not DISCARD_OBJ).
>
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
> sheep/http/oalloc.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/sheep/http/oalloc.c b/sheep/http/oalloc.c
> index 55433a0..66d7266 100644
> --- a/sheep/http/oalloc.c
> +++ b/sheep/http/oalloc.c
> @@ -265,8 +265,28 @@ int oalloc_free(uint32_t vid, uint64_t start, uint64_t count)
> char *meta = xvalloc(SD_DATA_OBJ_SIZE);
> struct header *hd;
> uint64_t oid = vid_to_data_oid(vid, 0), i;
> + struct sd_inode *inode = xmalloc(sizeof(struct sd_inode));
> int ret;
>
> + ret = sd_read_object(vid_to_vdi_oid(vid), (char *)inode,
> + sizeof(*inode), 0);
> + if (ret != SD_RES_SUCCESS) {
> + sd_err("failed to read inode, %" PRIx64 ", %s",
> + vid_to_vdi_oid(vid), sd_strerror(ret));
> + goto out;
> + }
> +
> + sd_debug("discard start %"PRIu64" end %"PRIu64, start,
> + start + count - 1);
> + INODE_SET_VID_RANGE(inode, start, (start + count - 1), 0);
> +
> + ret = sd_inode_write(sheep_bnode_writer, inode, 0, false, false);
> + if (ret != SD_RES_SUCCESS) {
> + sd_err("failed to update inode, %" PRIx64", %s",
> + vid_to_vdi_oid(vid), sd_strerror(ret));
> + goto out;
> + }
> +
> ret = sd_read_object(oid, meta, SD_DATA_OBJ_SIZE, 0);
> if (ret != SD_RES_SUCCESS) {
> sd_err("failed to read meta %" PRIx64 ", %s", oid,
> @@ -278,11 +298,11 @@ int oalloc_free(uint32_t vid, uint64_t start, uint64_t count)
> if (ret != SD_RES_SUCCESS)
> goto out;
>
> - /* XXX use aio to speed up discard of objects */
> + /* XXX use aio to speed up remove of objects */
> for (i = 0; i < count; i++) {
> struct sd_req hdr;
>
> - sd_init_req(&hdr, SD_OP_DISCARD_OBJ);
> + sd_init_req(&hdr, SD_OP_REMOVE_OBJ);
You can't simple use REMOVE because oalloc_free() might try to free unallocated
objects.
Thanks
Yuan
More information about the sheepdog
mailing list