[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE t
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming |
Date: |
Fri, 9 Mar 2012 10:31:57 +0000 |
On Thu, Mar 8, 2012 at 5:15 PM, Paolo Bonzini <address@hidden> wrote:
> This will enable discard on more filesystems, including ext4.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> block/raw-posix.c | 29 ++++++++++++++++++++++++-----
> 1 files changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 2d1bc13..f23d92b 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -52,6 +52,7 @@
> #include <sys/param.h>
> #include <linux/cdrom.h>
> #include <linux/fd.h>
> +#include <linux/falloc.h>
> #endif
> #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
> #include <sys/disk.h>
> @@ -131,6 +132,7 @@ typedef struct BDRVRawState {
> #endif
> uint8_t *aligned_buf;
> unsigned aligned_buf_size;
> + bool has_discard : 1;
> #ifdef CONFIG_XFS
> bool is_xfs : 1;
> #endif
> @@ -257,11 +259,9 @@ static int raw_open_common(BlockDriverState *bs, const
> char *filename,
> }
>
> #ifdef CONFIG_XFS
> - if (platform_test_xfs_fd(s->fd)) {
> - s->is_xfs = 1;
> - }
> + s->is_xfs = platform_test_xfs_fd(s->fd);
> #endif
> -
> + s->has_discard = 1;
> return 0;
>
> out_free_buf:
> @@ -605,15 +605,34 @@ static int xfs_discard(BDRVRawState *s, int64_t
> sector_num, int nb_sectors)
> static coroutine_fn int raw_co_discard(BlockDriverState *bs,
> int64_t sector_num, int nb_sectors)
> {
> -#ifdef CONFIG_XFS
> BDRVRawState *s = bs->opaque;
> + int retval;
>
> + if (s->has_discard == 0) {
> + return -ENOTSUP;
> + }
> +#ifdef CONFIG_XFS
> if (s->is_xfs) {
> return xfs_discard(s, sector_num, nb_sectors);
> }
> #endif
>
> +#ifdef FALLOC_FL_PUNCH_HOLE
> + retval = fallocate(s->fd, FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE,
> + sector_num << 9, (int64_t)nb_sectors << 9);
I'm concerned about introducing blocking syscalls in coroutine code
paths. This needs to be done asynchronously.
Stefan
- Re: [Qemu-devel] [RFC PATCH 07/17] block: make high level discard operation always zero, (continued)
[Qemu-devel] [RFC PATCH 08/17] block: kill the write zeroes operation, Paolo Bonzini, 2012/03/08
[Qemu-devel] [RFC PATCH 15/17] raw: add get_info, Paolo Bonzini, 2012/03/08
[Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming, Paolo Bonzini, 2012/03/08
Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming,
Stefan Hajnoczi <=
Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming, Richard Laager, 2012/03/09
[Qemu-devel] [RFC PATCH 17/17] raw: implement is_allocated, Paolo Bonzini, 2012/03/08
[Qemu-devel] [RFC PATCH 13/17] block: fallback from discard to writes, Paolo Bonzini, 2012/03/08