From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/5] block: Use bdrv_nb_sectors() when sectors, not bytes are wanted
Date: Fri, 09 May 2014 18:27:44 +0200 [thread overview]
Message-ID: <87tx8yex33.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1399628898-3241-4-git-send-email-armbru@redhat.com> (Markus Armbruster's message of "Fri, 9 May 2014 11:48:16 +0200")
Markus Armbruster <armbru@redhat.com> writes:
> Instead of bdrv_nb_sectors().
>
> Aside: a few of these callers don't handle errors. I didn't
> investigate whether they should.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
[...]
> diff --git a/block.c b/block.c
> index 44e1f57..1b99cb1 100644
> --- a/block.c
> +++ b/block.c
[...]
> @@ -3848,21 +3845,21 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
> int64_t sector_num,
> int nb_sectors, int *pnum)
> {
> - int64_t length;
> + int64_t total_sectors;
> int64_t n;
> int64_t ret, ret2;
>
> - length = bdrv_getlength(bs);
> - if (length < 0) {
> - return length;
> + total_sectors = bdrv_getlength(bs);
> + if (total_sectors < 0) {
> + return total_sectors;
> }
>
> - if (sector_num >= (length >> BDRV_SECTOR_BITS)) {
> + if (sector_num >= total_sectors) {
> *pnum = 0;
> return 0;
> }
>
> - n = bs->total_sectors - sector_num;
> + n = total_sectors - sector_num;
> if (n < nb_sectors) {
> nb_sectors = n;
> }
> @@ -3893,8 +3890,8 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
> ret |= BDRV_BLOCK_ZERO;
> } else if (bs->backing_hd) {
> BlockDriverState *bs2 = bs->backing_hd;
> - int64_t length2 = bdrv_getlength(bs2);
> - if (length2 >= 0 && sector_num >= (length2 >> BDRV_SECTOR_BITS)) {
> + int64_t nb_sectors2 = bdrv_getlength(bs2);
> + if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {
> ret |= BDRV_BLOCK_ZERO;
> }
> }
[...]
I neglected to actually replace bdrv_getlength() by bdrv_nb_sectors()
here, breaking test 030 (I forgot that make check-block doesn't run all
the tests). With that fixed, the tests pass. Full respin wanted?
next prev parent reply other threads:[~2014-05-09 16:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 9:48 [Qemu-devel] [PATCH 0/5] Clean up around bdrv_getlength() Markus Armbruster
2014-05-09 9:48 ` [Qemu-devel] [PATCH 1/5] raw-posix: Fix raw_getlength() to always return -errno on error Markus Armbruster
2014-05-09 9:48 ` [Qemu-devel] [PATCH 2/5] block: New bdrv_nb_sectors() Markus Armbruster
2014-05-12 11:11 ` Kevin Wolf
2014-05-12 12:36 ` Markus Armbruster
2014-05-12 12:50 ` Eric Blake
2014-05-09 9:48 ` [Qemu-devel] [PATCH 3/5] block: Use bdrv_nb_sectors() when sectors, not bytes are wanted Markus Armbruster
2014-05-09 16:27 ` Markus Armbruster [this message]
2014-05-09 9:48 ` [Qemu-devel] [PATCH 4/5] block: Drop superfluous aligning of bdrv_getlength()'s value Markus Armbruster
2014-05-09 9:48 ` [Qemu-devel] [PATCH 5/5] block: Avoid bdrv_get_geometry() where errors should be detected Markus Armbruster
2014-05-09 12:29 ` [Qemu-devel] [PATCH 0/5] Clean up around bdrv_getlength() Stefan Hajnoczi
2014-05-09 15:30 ` Stefan Hajnoczi
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=87tx8yex33.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=kwolf@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 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.