[sheepdog] [PATCH RESEND 1/6] farm: do cluster-wide snapshot by work queue

MORITA Kazutaka morita.kazutaka at gmail.com
Fri Jun 7 01:00:52 CEST 2013


At Wed,  5 Jun 2013 18:35:09 +0800,
Kai Zhang wrote:
> 
> +static void do_save_object(struct work *work)
> +{
> +	void *sha1_buf, *data_buf;
> +	size_t sha1_size, data_size;
> +	struct snapshot_work *sw;
> +	struct sha1_file_hdr *hdr;
> +
> +	if (uatomic_is_true(&work_error))
> +		return;
> +
> +	sw = container_of(work, struct snapshot_work, work);
> +	data_size = get_objsize(sw->entry.oid);
> +	sha1_size = data_size + sizeof(struct sha1_file_hdr);
> +	hdr = sha1_buf = xmalloc(sha1_size);
> +	data_buf = (char *)sha1_buf + sizeof(struct sha1_file_hdr);

It looks cleaner to introduce a structure for sha1_file.  For example,

struct sha1_file {
       struct sha1_file_hdr hdr;
       uint8_t data[SD_DATA_OBJ_SIZE];
};

> @@ -255,7 +294,13 @@ int farm_save_snapshot(const char *tag)
>  
>  	idx = log_nr + 1;
>  
> -	if (for_each_object_in_tree(fill_trunk_entry, &trunk_entries) < 0)
> +	wq = create_work_queue("save snapshot", WQ_ORDERED);
> +	if (for_each_object_in_tree(queue_save_snapshot_work,
> +				    (void *)&trunk_entries) < 0)

Casting to void * looks unnecessary.

Thanks,

Kazutaka



More information about the sheepdog mailing list