qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 3/3] qcow2: check for NULL l2meta
Date: Tue, 21 Jan 2014 12:04:47 +0100	[thread overview]
Message-ID: <20140121110447.GF3307@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <20140121060255.GC20860@G08FNSTD100614.fnst.cn.fujitsu.com>

Am 21.01.2014 um 07:02 hat Hu Tao geschrieben:
> On Tue, Jan 21, 2014 at 11:33:18AM +0800, Hu Tao wrote:
> > On Mon, Jan 20, 2014 at 04:17:16PM +0100, Kevin Wolf wrote:
> > > Am 20.01.2014 um 04:04 hat Hu Tao geschrieben:
> > > > On Sun, Jan 19, 2014 at 05:18:05PM +0100, Max Reitz wrote:
> > > > > On 30.12.2013 06:29, Hu Tao wrote:
> > > > > >In case of do preallocating metadata with a large cluster size,
> > > > > >qcow2_alloc_cluster_offset() can allocate nothing and returns
> > > > > >a NULL l2meta. This patch checks for it and link2 l2 with only
> > > > > >valid l2meta.
> > > > > >
> > > > > >Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> > > > > >---
> > > > > >  block/qcow2.c | 14 ++++++++------
> > > > > >  1 file changed, 8 insertions(+), 6 deletions(-)
> > > > > >
> > > > > >diff --git a/block/qcow2.c b/block/qcow2.c
> > > > > >index 46860d5..380c240 100644
> > > > > >--- a/block/qcow2.c
> > > > > >+++ b/block/qcow2.c
> > > > > >@@ -1399,18 +1399,20 @@ static int preallocate(BlockDriverState *bs)
> > > > > >      offset = 0;
> > > > > >      while (nb_sectors) {
> > > > > >-        num = MIN(nb_sectors, INT_MAX >> 9);
> > > > > >+        num = MIN(nb_sectors, INT_MAX >> BDRV_SECTOR_BITS);
> > > > > 
> > > > > Well, if you're already adjusting this here, you could also replace
> > > > > the other occurrences of 9 and 512 in this function. ;-)
> > > > > 
> > > > > >          ret = qcow2_alloc_cluster_offset(bs, offset, &num,
> > > > > >                                           &host_offset, &meta);
> > > > > >          if (ret < 0) {
> > > > > >              return ret;
> > > > > >          }
> > > > > >-        ret = qcow2_alloc_cluster_link_l2(bs, meta);
> > > > > >-        if (ret < 0) {
> > > > > >-            qcow2_free_any_clusters(bs, meta->alloc_offset, meta->nb_clusters,
> > > > > >-                                    QCOW2_DISCARD_NEVER);
> > > > > >-            return ret;
> > > > > >+        if (meta) {
> > > > > >+            ret = qcow2_alloc_cluster_link_l2(bs, meta);
> > > > > >+            if (ret < 0) {
> > > > > >+                qcow2_free_any_clusters(bs, meta->alloc_offset,
> > > > > >+                                        meta->nb_clusters, QCOW2_DISCARD_NEVER);
> > > > > >+                return ret;
> > > > > >+            }
> > > > > >          }
> > > > > >          /* There are no dependent requests, but we need to remove our request
> > > > > 
> > > > > But this doesn't make this patch wrong, so:
> > > > > 
> > > > > Reviewed-by: Max Reitz <mreitz@redhat.com>
> > > > 
> > > > Max,
> > > > 
> > > > Thanks for all of you comments!
> > > 
> > > The series looks good in general, but I think the comments are worth
> > > addressing before we merge it. I would also love to see an qemu-iotests
> > > case that tests the cases that would previously crash.
> 
> Should I add the test case into an existing file or create a new file?

The closest existing case I found is 049, which is however more about
option parsing rather than the actual effect of the options. I think a
new file might be better.

If you add a new case, can you please use 079 as its number? There are
several yet unmerged patch series in flight that take the lower numbers.

Kevin

  reply	other threads:[~2014-01-21 11:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30  5:29 [Qemu-devel] [PATCH v1 0/3] qcow2: fix bugs when cluster size is larger than the default value Hu Tao
2013-12-30  5:29 ` [Qemu-devel] [PATCH v1 1/3] qcow2: remove n_start and n_end of qcow2_alloc_cluster_offset() Hu Tao
2014-01-19 16:08   ` Max Reitz
2013-12-30  5:29 ` [Qemu-devel] [PATCH v1 2/3] qcow2: fix offset overflow Hu Tao
2014-01-06  8:35   ` Hu Tao
2014-01-19 16:12   ` Max Reitz
2014-01-20 15:14     ` Kevin Wolf
2013-12-30  5:29 ` [Qemu-devel] [PATCH v1 3/3] qcow2: check for NULL l2meta Hu Tao
2014-01-19 16:18   ` Max Reitz
2014-01-20  3:04     ` Hu Tao
2014-01-20 15:17       ` Kevin Wolf
2014-01-21  3:33         ` Hu Tao
2014-01-21  6:02           ` Hu Tao
2014-01-21 11:04             ` Kevin Wolf [this message]
2014-01-22  3:49               ` Hu Tao
2014-01-13 10:26 ` [Qemu-devel] [PATCH v1 0/3] qcow2: fix bugs when cluster size is larger than the default value Hu Tao

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=20140121110447.GF3307@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).