From: Stefan Hajnoczi <stefanha@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
Christoph Hellwig <hch@lst.de>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH 2/2] block: Cache total_sectors to reduce bdrv_getlength calls
Date: Mon, 19 Apr 2010 15:26:06 +0100 [thread overview]
Message-ID: <j2mfbd9d3991004190726z2e1126c4w5505a1691f16eba0@mail.gmail.com> (raw)
In-Reply-To: <4BCC6453.2020605@redhat.com>
On Mon, Apr 19, 2010 at 3:10 PM, Kevin Wolf <kwolf@redhat.com> wrote:
>> @@ -416,9 +417,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
>> }
>>
>> bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR);
>> - if (drv->bdrv_getlength) {
>> - bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
>> - }
>> + bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
>
> Does this hunk make a difference? If drv->bdrv_getlength == NULL, we'll
> just get back the current value.
The if statement could be left as is. I removed it to reduce the
number of places where if (drv->bdrv_getlength) is explicitly checked.
If callers don't know the internals of bdrv_getlength() then it is
easier to extend it without auditing and changing callers.
Having said that, I did add an if (drv->bdrv_getlength) check into
bdrv_truncate...
> But now that you sent this hunk for review, one thing about the existing
> code: We should probably check the return value of bdrv_getlength.
You're right.
I'll clean this up and send a v2.
Stefan
next prev parent reply other threads:[~2010-04-19 14:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-19 12:34 [Qemu-devel] [PATCH 1/2] raw-posix: Use pread/pwrite instead of lseek+read/write Stefan Hajnoczi
2010-04-19 12:34 ` [Qemu-devel] [PATCH 2/2] block: Cache total_sectors to reduce bdrv_getlength calls Stefan Hajnoczi
2010-04-19 14:10 ` [Qemu-devel] " Kevin Wolf
2010-04-19 14:26 ` Stefan Hajnoczi [this message]
2010-04-19 14:31 ` Kevin Wolf
2010-04-20 8:37 ` [Qemu-devel] [PATCH 1/2] raw-posix: Use pread/pwrite instead of lseek+read/write 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=j2mfbd9d3991004190726z2e1126c4w5505a1691f16eba0@mail.gmail.com \
--to=stefanha@gmail.com \
--cc=hch@lst.de \
--cc=jan.kiszka@siemens.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.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).