From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, benoit@irqsave.net, stefanha@redhat.com,
mreitz@redhat.com
Subject: [Qemu-devel] [PATCH v4 05/10] block: Use bdrv_nb_sectors() in bdrv_co_get_block_status()
Date: Wed, 4 Jun 2014 13:51:46 +0200 [thread overview]
Message-ID: <1401882711-30508-6-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1401882711-30508-1-git-send-email-armbru@redhat.com>
Instead of bdrv_getlength().
Replace variables length, length2 by total_sectors, nb_sectors2.
Bonus: use total_sectors instead of the slightly unclean
bs->total_sectors.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
---
block.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index c73dcba..65e563a 100644
--- a/block.c
+++ b/block.c
@@ -3927,21 +3927,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_nb_sectors(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;
}
@@ -3976,8 +3976,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_nb_sectors(bs2);
+ if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) {
ret |= BDRV_BLOCK_ZERO;
}
}
--
1.9.3
next prev parent reply other threads:[~2014-06-04 11:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 11:51 [Qemu-devel] [PATCH v4 00/10] Clean up around bdrv_getlength() Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 01/10] raw-posix: Fix raw_getlength() to always return -errno on error Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 02/10] block: New bdrv_nb_sectors() Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 03/10] block: Use bdrv_nb_sectors() in bdrv_make_zero() Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 04/10] block: Use bdrv_nb_sectors() in bdrv_aligned_preadv() Markus Armbruster
2014-06-04 11:51 ` Markus Armbruster [this message]
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 06/10] block: Use bdrv_nb_sectors() in img_convert() Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 07/10] block: Use bdrv_nb_sectors() where sectors, not bytes are wanted Markus Armbruster
2014-06-04 12:26 ` Benoît Canet
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 08/10] block: Drop superfluous aligning of bdrv_getlength()'s value Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 09/10] qemu-img: Make img_convert() get image size just once per image Markus Armbruster
2014-06-04 11:51 ` [Qemu-devel] [PATCH v4 10/10] block: Avoid bdrv_get_geometry() where errors should be detected Markus Armbruster
2014-06-04 12:24 ` Benoît Canet
2014-06-04 13:20 ` Markus Armbruster
2014-06-04 13:28 ` Benoît Canet
2014-06-04 13:30 ` Benoît Canet
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=1401882711-30508-6-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=benoit@irqsave.net \
--cc=kwolf@redhat.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).