[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] glusterfs: fix max_discard

From: Denis V. Lunev
Subject: Re: [Qemu-devel] [PATCH 1/2] glusterfs: fix max_discard
Date: Mon, 2 Feb 2015 23:09:48 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 02/02/15 22:58, Peter Lieven wrote:
Am 02.02.2015 um 19:29 schrieb Denis V. Lunev:
qemu_gluster_co_discard calculates size to discard as follows
     size_t size = nb_sectors * BDRV_SECTOR_SIZE;
     ret = glfs_discard_async(s->fd, offset, size, &gluster_finish_aiocb, acb);

glfs_discard_async is declared as follows:
   int glfs_discard_async (glfs_fd_t *fd, off_t length, size_t lent,
                           glfs_io_cbk fn, void *data) __THROW
This is problematic on i686 as sizeof(size_t) == 4.

Set bl_max_discard to SIZE_MAX >> BDRV_SECTOR_BITS to avoid overflow
on i386.

Signed-off-by: Denis V. Lunev <address@hidden>
CC: Kevin Wolf <address@hidden>
CC: Peter Lieven <address@hidden>
  block/gluster.c | 11 +++++++++++
  1 file changed, 11 insertions(+)

diff --git a/block/gluster.c b/block/gluster.c
index 1eb3a8c..47bf92d 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -622,6 +622,13 @@ out:
      return ret;
+static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
+    bs->bl.max_discard = SIZE_MAX >> BDRV_SECTOR_BITS;
I would write:

bs->bl.max_discard = MIN(SIZE_MAX >> BDRV_SECTOR_BITS, INT_MAX);

without the condition.


ok, respinned


reply via email to

[Prev in Thread] Current Thread [Next in Thread]