[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation optio
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option |
Date: |
Thu, 4 Sep 2014 14:35:22 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 29.08.2014 um 10:33 hat Hu Tao geschrieben:
> This patch adds a new option preallocation for raw format, and implements
> full preallocation.
>
> Signed-off-by: Hu Tao <address@hidden>
v12 was better, it wasn't doing only metadata preallocation when you
told it to do full preallocation.
> + if (prealloc == PREALLOC_MODE_FULL) {
> + /* posix_fallocate() doesn't set errno. */
> + result = -posix_fallocate(fd, 0, total_size);
> + if (result != 0) {
> + buf = g_malloc0(65536);
> + int64_t num = 0, left = total_size;
> +
> + while (left > 0) {
> + num = MIN(left, 65536);
> + result = write(fd, buf, num);
> + if (result < 0) {
> + result = -errno;
> + error_setg_errno(errp, -result,
> + "Could not write to the new file");
> + g_free(buf);
> + goto out_close;
> + }
> + left -= num;
> + }
> + fsync(fd);
> + g_free(buf);
> }
This is totally pointless. If the file system doesn't support fallocate,
posix_fallocate() will already try writing zeros.
Having code to write zeros in qemu only makes sense if you implement a
real full preallocation mode, which doesn't use fallocate even when it's
supported.
Please change the code to always write zeros for FULL, and either
reintroduce FALLOC or use METADATA for the fallocate (without a fallback
to zero writing code). In fact, for metadata preallocation we should
probably directly use fallocate(), which has no slow zero-write fallback
in the libc.
Kevin
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Max Reitz, 2014/09/02
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Hu Tao, 2014/09/02
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Hu Tao, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option,
Kevin Wolf <=
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Richard W.M. Jones, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Kevin Wolf, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Richard W.M. Jones, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Daniel P. Berrange, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Kevin Wolf, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Richard W.M. Jones, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Kevin Wolf, 2014/09/04
- Re: [Qemu-devel] [PATCH v13 5/6] raw-posix: Add full preallocation option, Richard W.M. Jones, 2014/09/04