From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOV6g-0001hT-7R for qemu-devel@nongnu.org; Mon, 23 May 2011 09:23:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOV6d-0002xM-Vt for qemu-devel@nongnu.org; Mon, 23 May 2011 09:23:38 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:64745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOV6d-0002x8-TG for qemu-devel@nongnu.org; Mon, 23 May 2011 09:23:35 -0400 Received: by gwb19 with SMTP id 19so2446870gwb.4 for ; Mon, 23 May 2011 06:23:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87wrhhoejb.wl%morita.kazutaka@lab.ntt.co.jp> References: <1305981319-32508-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <87wrhhoejb.wl%morita.kazutaka@lab.ntt.co.jp> Date: Mon, 23 May 2011 14:23:35 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] sheepdog: add data preallocation support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: kwolf@redhat.com, sheepdog@lists.wpkg.org, qemu-devel@nongnu.org On Mon, May 23, 2011 at 12:13 PM, MORITA Kazutaka wrote: > At Mon, 23 May 2011 10:19:13 +0100, > Stefan Hajnoczi wrote: >> >> On Sat, May 21, 2011 at 1:35 PM, MORITA Kazutaka >> wrote: >> > +static int sd_prealloc(uint32_t vid, int64_t vdi_size) >> > +{ >> > + =A0 =A0int fd, ret; >> > + =A0 =A0SheepdogInode *inode; >> > + =A0 =A0char *buf; >> > + =A0 =A0unsigned long idx, max_idx; >> [...] >> > + =A0 =A0max_idx =3D (vdi_size + SD_DATA_OBJ_SIZE - 1) / SD_DATA_OBJ_S= IZE; >> > + >> > + =A0 =A0for (idx =3D 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 suspicio= us. Stefan