qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: kwolf@redhat.com, sheepdog@lists.wpkg.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] sheepdog: add data preallocation support
Date: Mon, 23 May 2011 14:23:35 +0100	[thread overview]
Message-ID: <BANLkTi=FiewsP8WGfiV7sSuvszZgQhz7cQ@mail.gmail.com> (raw)
In-Reply-To: <87wrhhoejb.wl%morita.kazutaka@lab.ntt.co.jp>

On Mon, May 23, 2011 at 12:13 PM, MORITA Kazutaka
<morita.kazutaka@lab.ntt.co.jp> wrote:
> At Mon, 23 May 2011 10:19:13 +0100,
> Stefan Hajnoczi wrote:
>>
>> On Sat, May 21, 2011 at 1:35 PM, MORITA Kazutaka
>> <morita.kazutaka@lab.ntt.co.jp> wrote:
>> > +static int sd_prealloc(uint32_t vid, int64_t vdi_size)
>> > +{
>> > +    int fd, ret;
>> > +    SheepdogInode *inode;
>> > +    char *buf;
>> > +    unsigned long idx, max_idx;
>> [...]
>> > +    max_idx = (vdi_size + SD_DATA_OBJ_SIZE - 1) / SD_DATA_OBJ_SIZE;
>> > +
>> > +    for (idx = 0; idx < max_idx; idx++) {
>>
>> Do you want to use uint64_t here instead of unsigned long, which may
>> be too small on 32-bit hosts?
>
> The index of a Sheepdog data object is within 32-bit range, so using
> an unsigned long is safe here.

You are right:

#define MAX_DATA_OBJS (UINT64_C(1) << 20)
#define SD_DATA_OBJ_SIZE (UINT64_C(1) << 22)
#define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)

So the max_idx is MAX_DATA_OBJS, which is <32-bit.  It just looked suspicious.

Stefan

  reply	other threads:[~2011-05-23 13:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-21 12:35 [Qemu-devel] [PATCH] sheepdog: add data preallocation support MORITA Kazutaka
2011-05-23  9:19 ` Stefan Hajnoczi
2011-05-23 11:13   ` MORITA Kazutaka
2011-05-23 13:23     ` Stefan Hajnoczi [this message]
2011-07-01  8:29 ` Kevin Wolf
2011-07-05 18:21   ` MORITA Kazutaka
2011-07-06  7:53     ` Kevin Wolf
2011-07-08 11:06       ` [Qemu-devel] [Sheepdog] " MORITA Kazutaka
2011-07-05 18:38   ` [Qemu-devel] [PATCH v2] sheepdog: add full " MORITA Kazutaka
2011-07-06 11:18     ` 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='BANLkTi=FiewsP8WGfiV7sSuvszZgQhz7cQ@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=sheepdog@lists.wpkg.org \
    /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).