[sheepdog] [PATCH 4/8] object cache: add object cache tree for every VDI

Liu Yuan namei.unix at gmail.com
Tue Jul 17 04:16:44 CEST 2012


On 07/09/2012 02:29 PM, levin li wrote:
> static int check_cache_object_sanity(struct object_cache *cache, uint32_t idx)
> +{
> +	struct strbuf idx_buf;
> +	unsigned data_length;
> +	struct stat st;
> +	int ret = SD_RES_SUCCESS;
> +
> +	strbuf_init(&idx_buf, PATH_MAX);
> +	strbuf_addstr(&idx_buf, cache_dir);
> +	strbuf_addf(&idx_buf, "/%06"PRIx32"/%08"PRIx32, cache->vid, idx);
> +
> +	if (stat(idx_buf.buf, &st) < 0) {
> +		ret = unlink(idx_buf.buf);
> +		eprintf("%m\n");
> +		goto out;
> +	}
> +
> +	if (idx_has_vdi_bit(idx))
> +		data_length = SD_INODE_SIZE;
> +	else
> +		data_length = SD_DATA_OBJ_SIZE;
> +
> +	if (data_length != st.st_size) {
> +		eprintf("inconsistent data length\n");
> +		ret = unlink(idx_buf.buf);
> +	}
> +
> +out:
> +	strbuf_release(&idx_buf);
> +	return ret;
> +}

What is it for? Do you ever met problems that data_length isn't correct?
I think this duplicate the file system functions and useless.

Thanks,
Yuan




More information about the sheepdog mailing list