qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Max Reitz <mreitz@redhat.com>,  John Snow <jsnow@redhat.com>,
	qemu-trivial@nongnu.org, Jeff Cody <codyprime@gmail.com>,
	 qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants
Date: Wed, 27 Mar 2019 13:39:38 +0100	[thread overview]
Message-ID: <CAAdtpL5R4jrZa7M1gcUTN0FgR5nTiM8e-khh5BPyDjON_XWFjw@mail.gmail.com> (raw)
In-Reply-To: <20190327095634.53038-3-sgarzare@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3938 bytes --]

Le mer. 27 mars 2019 10:56, Stefano Garzarella <sgarzare@redhat.com> a
écrit :

> Using IEC binary prefixes in order to make the code more readable,
> with the exception of DEFAULT_LOG_SIZE because it's passed to
> stringify().
>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>  block/vhdx-log.c |  2 +-
>  block/vhdx.c     |  4 ++--
>  block/vhdx.h     | 10 ++++++----
>  3 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/block/vhdx-log.c b/block/vhdx-log.c
> index 3149ff08d8..5e946846f1 100644
> --- a/block/vhdx-log.c
> +++ b/block/vhdx-log.c
> @@ -551,7 +551,7 @@ static int vhdx_log_flush(BlockDriverState *bs,
> BDRVVHDXState *s,
>          }
>          if (file_length < desc_entries->hdr.last_file_offset) {
>              new_file_size = desc_entries->hdr.last_file_offset;
> -            if (new_file_size % (1024*1024)) {
> +            if (new_file_size % (1 * MiB)) {
>                  /* round up to nearest 1MB boundary */
>                  new_file_size = QEMU_ALIGN_UP(new_file_size, MiB);
>                  if (new_file_size > INT64_MAX) {
> diff --git a/block/vhdx.c b/block/vhdx.c
> index 7cd1fc3731..a143a57657 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1175,7 +1175,7 @@ static int vhdx_allocate_block(BlockDriverState *bs,
> BDRVVHDXState *s,
>      *new_offset = current_len;
>
>      /* per the spec, the address for a block is in units of 1MB */
> -    *new_offset = ROUND_UP(*new_offset, 1024 * 1024);
> +    *new_offset = ROUND_UP(*new_offset, 1 * MiB);
>      if (*new_offset > INT64_MAX) {
>          return -EINVAL;
>      }
> @@ -1338,7 +1338,7 @@ static coroutine_fn int
> vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
>              case PAYLOAD_BLOCK_FULLY_PRESENT:
>                  /* if the file offset address is in the header zone,
>                   * there is a problem */
> -                if (sinfo.file_offset < (1024 * 1024)) {
> +                if (sinfo.file_offset < (1 * MiB)) {
>                      ret = -EFAULT;
>                      goto error_bat_restore;
>                  }
> diff --git a/block/vhdx.h b/block/vhdx.h
> index bf72090c8f..0b74924cee 100644
> --- a/block/vhdx.h
> +++ b/block/vhdx.h
> @@ -20,6 +20,8 @@
>  #include "qemu/units.h"
>
>  #define DEFAULT_LOG_SIZE 1048576 /* 1MiB */
> +/* Note: can't use 1 * MiB, because it's passed to stringify() */
> +
>  /* Structures and fields present in the VHDX file */
>
>  /* The header section has the following blocks,
> @@ -32,7 +34,7 @@
>   *
> 0.........64KB...........128KB........192KB..........256KB................1MB
>   */
>
> -#define VHDX_HEADER_BLOCK_SIZE      (64 * 1024)
> +#define VHDX_HEADER_BLOCK_SIZE      (64 * KiB)
>
>  #define VHDX_FILE_ID_OFFSET         0
>  #define VHDX_HEADER1_OFFSET         (VHDX_HEADER_BLOCK_SIZE * 1)
> @@ -81,7 +83,7 @@ typedef struct QEMU_PACKED MSGUID {
>  #define guid_eq(a, b) \
>      (memcmp(&(a), &(b), sizeof(MSGUID)) == 0)
>
> -#define VHDX_HEADER_SIZE (4 * 1024)   /* although the vhdx_header struct
> in disk
> +#define VHDX_HEADER_SIZE (4 * KiB)    /* although the vhdx_header struct
> in disk
>                                           is only 582 bytes, for purposes
> of crc
>                                           the header is the first 4KB of
> the 64KB
>                                           block */
> @@ -157,8 +159,8 @@ typedef struct QEMU_PACKED VHDXRegionTableEntry {
>
>
>  /* ---- LOG ENTRY STRUCTURES ---- */
> -#define VHDX_LOG_MIN_SIZE (1024 * 1024)
> -#define VHDX_LOG_SECTOR_SIZE 4096
> +#define VHDX_LOG_MIN_SIZE (1 * MiB)
> +#define VHDX_LOG_SECTOR_SIZE (4 * KiB)
>  #define VHDX_LOG_HDR_SIZE 64
>  #define VHDX_LOG_SIGNATURE 0x65676f6c
>  typedef struct QEMU_PACKED VHDXLogEntryHeader {
> -- 2.20.1
>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>

[-- Attachment #2: Type: text/html, Size: 4999 bytes --]

  reply	other threads:[~2019-03-27 12:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27  9:56 [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" Stefano Garzarella
2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 1/2] block/vhdx: Remove redundant IEC binary prefixes definition Stefano Garzarella
2019-03-27 12:40   ` Philippe Mathieu-Daudé
2019-03-27 17:16   ` John Snow
2019-03-27 17:23     ` Stefano Garzarella
2019-03-27 20:16     ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
2019-04-11 19:54   ` [Qemu-trivial] " Laurent Vivier
2019-04-11 19:55     ` Laurent Vivier
2019-03-27  9:56 ` [Qemu-trivial] [PATCH v2 2/2] block/vhdx: Use IEC binary prefixes for size constants Stefano Garzarella
2019-03-27 12:39   ` Philippe Mathieu-Daudé [this message]
2019-03-27 17:17   ` [Qemu-trivial] [Qemu-devel] " John Snow
2019-03-28 12:29 ` [Qemu-trivial] [PATCH v2 0/2] block/vhdx: Use IEC binary prefixes from "qemu/units.h" 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=CAAdtpL5R4jrZa7M1gcUTN0FgR5nTiM8e-khh5BPyDjON_XWFjw@mail.gmail.com \
    --to=f4bug@amsat.org \
    --cc=codyprime@gmail.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sgarzare@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).