All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lan, Tianyu" <tianyu.lan@intel.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "penberg@kernel.org" <penberg@kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"asias.hejun@gmail.com" <asias.hejun@gmail.com>,
	"levinsasha928@gmail.com" <levinsasha928@gmail.com>,
	"prasadjoshi124@gmail.com" <prasadjoshi124@gmail.com>
Subject: RE: [RFC v2 PATCH] kvm tools, qcow: Add the support for copy-on-write clusters
Date: Sat, 19 Nov 2011 10:09:05 +0800	[thread overview]
Message-ID: <625BA99ED14B2D499DC4E29D8138F1506860C491FF@shsmsx502.ccr.corp.intel.com> (raw)
In-Reply-To: <4EC62F14.6090505@redhat.com>

Hi Kevin:
	Thanks for your review. The following means that there should be a fsync after updating 
metadata(refcunt block, l1 table and l2 table).

Thanks 
Tianyu Lan

-----Original Message-----
> +		/*write l2 table*/
> +		l2t->dirty = 1;
> +		if (qcow_l2_cache_write(q, l2t) < 0)
>  			goto free_cache;

You need to make sure that the refcount update is written first (e.g.
with fsync), otherwise you risk corruption when the host crashes in the middle.

>  
> -		if (cache_table(q, l2t) < 0) {
> -			if (ftruncate(q->fd, f_sz) < 0)
> -				goto free_cache;
> +		/* Update the l1 talble */
> +		l1t->l1_table[l1t_idx] = cpu_to_be64(l2t_new_offset
> +			| QCOW2_OFLAG_COPIED);
>  
> -			goto free_cache;
> -		}
> +		if (pwrite_in_full(q->fd, l1t->l1_table,
> +			l1t->table_size * sizeof(u64),
> +			header->l1_table_offset) < 0)
> +			goto error;

Likewise, the L1 table write must be ordered against the L2 write.

goto error is using the wrong label.

>  
> -		/* Update the in-core entry */
> -		l1t->l1_table[l1t_idx] = cpu_to_be64(l2t_offset);
> +		/*cache l2 table*/
> +		cache_table(q, l2t);

After so many explicit comments, you can probably guess what's wrong here...

  reply	other threads:[~2011-11-19  2:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18  8:47 [RFC v2 PATCH] kvm tools, qcow: Add the support for copy-on-write clusters Lan Tianyu
2011-11-18 10:10 ` Kevin Wolf
2011-11-19  2:09   ` Lan, Tianyu [this message]
2011-11-19 15:30     ` Lan, Tianyu
2011-11-19 16:26       ` Sasha Levin
2011-11-20  6:14         ` Lan, Tianyu
2011-11-20  6:23           ` Sasha Levin
2011-11-20  7:03             ` Lan, Tianyu
2011-11-20 10:59             ` Pekka Enberg
2011-11-21  8:30               ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=625BA99ED14B2D499DC4E29D8138F1506860C491FF@shsmsx502.ccr.corp.intel.com \
    --to=tianyu.lan@intel.com \
    --cc=asias.hejun@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=levinsasha928@gmail.com \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.