Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-24 Thread Christoph Hellwig
On Fri, Mar 09, 2012 at 02:36:50PM -0600, Richard Laager wrote: I'm not sure if fallocate() and/or BLKDISCARD always guarantee that the discard has made it to stable storage. If they don't, does O_DIRECT or O_DSYNC on open() cause them to make any such guarantee? If not, should you be calling

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-12 Thread Paolo Bonzini
Il 09/03/2012 21:36, Richard Laager ha scritto: fallocate() only supports files. In my patch, I was fstat()ing the fd just after opening it and caching an is_device boolean. Then, when doing discards, if !is_device, call fallocate(), else (i.e. for devices) do the following (note: untested

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Chris Wedgwood
This will enable discard on more filesystems, including ext4. i think this should default to off for preallocated files this will punch holes all over the place and reallocation will cause fragmentation (guests will free and reallocat blocks normally) xfs has a mechanism to convert to

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Paolo Bonzini
Il 09/03/2012 09:20, Chris Wedgwood ha scritto: for preallocated files this will punch holes all over the place and reallocation will cause fragmentation (guests will free and reallocat blocks normally) SEEK_HOLE could provide a very simple heuristic to detect preallocated files (unfortunately

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Chris Wedgwood
SEEK_HOLE could provide a very simple heuristic to detect preallocated files (unfortunately ext4 does not implement SEEK_HOLE yet). SEEK_HOLE is a weird (confusing and no intuitive) API (IMO). There is FIEMAP or whatever it's called which seems somewhat saner. XFS specific there is also

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Paolo Bonzini
Il 09/03/2012 09:35, Chris Wedgwood ha scritto: SEEK_HOLE could provide a very simple heuristic to detect preallocated files (unfortunately ext4 does not implement SEEK_HOLE yet). SEEK_HOLE is a weird (confusing and no intuitive) API (IMO). There is FIEMAP or whatever it's called which

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Stefan Hajnoczi
On Thu, Mar 8, 2012 at 5:15 PM, Paolo Bonzini pbonz...@redhat.com wrote: This will enable discard on more filesystems, including ext4. Signed-off-by: Paolo Bonzini pbonz...@redhat.com ---  block/raw-posix.c |   29 -  1 files changed, 24 insertions(+), 5

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Paolo Bonzini
Il 09/03/2012 11:31, Stefan Hajnoczi ha scritto: +#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.

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Stefan Hajnoczi
On Fri, Mar 9, 2012 at 10:43 AM, Paolo Bonzini pbonz...@redhat.com wrote: Il 09/03/2012 11:31, Stefan Hajnoczi ha scritto: +#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);

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Paolo Bonzini
Il 09/03/2012 11:53, Stefan Hajnoczi ha scritto: 1) require a new-enough kernel and only use fallocate; return a NULL aiocb if !has_discard and convert it to ENOTSUP. 2) extract now from my threads branch the work to generalize posix-aio-compat into a more flexible threadpool, and move

Re: [Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-09 Thread Richard Laager
I was just working on this as well, though your implementation is *far* more complete than mine. (I was only looking at making changes to the discard implementation in block/raw-posix.c.) I've got several comments, which I've separated by logical topic... BLKDISCARD

[Qemu-devel] [RFC PATCH 14/17] block: support FALLOC_FL_PUNCH_HOLE trimming

2012-03-08 Thread Paolo Bonzini
This will enable discard on more filesystems, including ext4. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- 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