All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "lan,Tianyu" <tianyu.lan@intel.com>
Cc: Pekka Enberg <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 PATCH] kvm tools, qcow: Add support for growing refcount blocks
Date: Tue, 13 Dec 2011 09:57:56 +0100	[thread overview]
Message-ID: <4EE71394.6070906@redhat.com> (raw)
In-Reply-To: <1323747673.2585.96.camel@lantianyu-ws>

Am 13.12.2011 04:41, schrieb lan,Tianyu:
> On 一, 2011-12-12 at 19:15 +0800, Kevin Wolf wrote:
>> Am 12.12.2011 11:58, schrieb Pekka Enberg:
>>> On Mon, 12 Dec 2011, Kevin Wolf wrote:
>>>>> @@ -667,14 +722,11 @@ static struct qcow_refcount_block *qcow_read_refcount_block(struct qcow *q, u64
>>>>>
>>>>>  	rft_idx = clust_idx >> (header->cluster_bits - QCOW_REFCOUNT_BLOCK_SHIFT);
>>>>>  	if (rft_idx >= rft->rf_size)
>>>>> -		return NULL;
>>>>> +		return (void *)-ENOSPC;
>>>>
>>>> Is this allowed style in kvm-tool? :-/
>>>
>>> It needs to use ERR_PTR() and related macros but otherwise I don't see a 
>>> big problem with it.
>>
>> Can you be sure that it never clashes with a valid allocation when you
>> use this in userspace?
>>
>> But yes, at least using appropriate functions should be required. And
>> this means that you can't only check for -ENOSPC, but you need to check
>> for all possible error codes (IS_ERR_VALUE() I guess).
> The qcow_read_refcount_block() is invoiked in the two places
> qcow_get_refcount() and update_cluster_refcount() and will only return
> NULL or -ENOSPC.
> 
> In the qcow_get_refcount(), when qcow_read_refcount_block() returned
> -ENOSPEC(no refcount block is available.), returning zero which means
> the cluster is not in use and the refcount block can be grew in the
> update_cluster_refcount().  
> 
> In the update_cluster_refcount(), when qcow_read_refcount_block()
> returned -ENOSPEC, it is necessary to grow the refcount blocks.
> 
> So the ENOSPEC should be specially dealt with.  
> 
> Does this make sense? :)

I'm not saying that your code won't work today, just that it's brittle.
If someone adds a different error return code somewhere and doesn't
check if all callers properly deal with error codes, it will break.

Kevin

  reply	other threads:[~2011-12-13  8:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12  2:03 [RFC PATCH] kvm tools, qcow: Add support for growing refcount blocks Lan Tianyu
2011-12-12  9:55 ` Kevin Wolf
2011-12-12 10:58   ` Pekka Enberg
2011-12-12 11:15     ` Kevin Wolf
2011-12-12 11:17       ` Kevin Wolf
2011-12-13  3:41       ` lan,Tianyu
2011-12-13  8:57         ` Kevin Wolf [this message]
2011-12-13  9:14           ` Pekka Enberg
2011-12-14  1:22           ` lan,Tianyu
2011-12-13  3:16     ` lan,Tianyu
2011-12-13  9:13       ` Pekka Enberg
2011-12-13  3:05   ` lan,Tianyu
2011-12-13  9:03     ` 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=4EE71394.6070906@redhat.com \
    --to=kwolf@redhat.com \
    --cc=asias.hejun@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    --cc=tianyu.lan@intel.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.