[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw
From: |
Alexander Graf |
Subject: |
Re: [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw |
Date: |
Tue, 19 Jun 2012 14:37:05 +0200 |
On 15.06.2012, at 15:33, Kevin Wolf wrote:
> From: Paolo Bonzini <address@hidden>
>
> Either FIEMAP, or SEEK_DATA+SEEK_HOLE can be used to implement the
> is_allocated callback for raw files. On Linux ext4, btrfs and XFS
> all support it.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/raw-posix.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> block/raw.c | 8 ++++
> 2 files changed, 106 insertions(+), 0 deletions(-)
>
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 03fcfcc..bf7700a 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -52,6 +52,10 @@
> #include <sys/param.h>
> #include <linux/cdrom.h>
> #include <linux/fd.h>
> +#include <linux/fs.h>
> +#endif
> +#ifdef CONFIG_FIEMAP
> +#include <linux/fiemap.h>
> #endif
> #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
> #include <sys/disk.h>
> @@ -583,6 +587,99 @@ static int raw_create(const char *filename,
> QEMUOptionParameter *options)
> return result;
> }
>
> +/*
> + * Returns true iff the specified sector is present in the disk image.
> Drivers
> + * not implementing the functionality are assumed to not support backing
> files,
> + * hence all their sectors are reported as allocated.
> + *
> + * If 'sector_num' is beyond the end of the disk image the return value is 0
> + * and 'pnum' is set to 0.
> + *
> + * 'pnum' is set to the number of sectors (including and immediately
> following
> + * the specified sector) that are known to be in the same
> + * allocated/unallocated state.
> + *
> + * 'nb_sectors' is the max value 'pnum' should be set to. If nb_sectors goes
> + * beyond the end of the disk image it will be clamped.
> + */
> +static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs,
> + int64_t sector_num,
> + int nb_sectors, int *pnum)
> +{
> + BDRVRawState *s = bs->opaque;
cc1: warnings being treated as errors
block/raw-posix.c: In function ‘raw_co_is_allocated’:
block/raw-posix.c:609: error: unused variable ‘s’
Alex
- [Qemu-devel] [PULL 00/39] Block patches, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 02/39] qcow2: fix endianness conversion, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw, Kevin Wolf, 2012/06/15
- Re: [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw,
Alexander Graf <=
- [Qemu-devel] [PATCH 08/39] Un-inline fdctrl_init_isa(), Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 05/39] stream: move is_allocated_above to block.c, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 09/39] qemu-img check -r for repairing images, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 06/39] stream: move rate limiting to a separate header file, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 01/39] qcow2: remove a line of unnecessary code, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 07/39] xtensa_lx60: add missing #include "blockdev.h", Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 04/39] stream: tweak usage of bdrv_co_is_allocated, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 12/39] rbd: hook up cache options, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 11/39] qcow2: Support for fixing refcount inconsistencies, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 13/39] sheepdog: add coroutine_fn markers to coroutine functions, Kevin Wolf, 2012/06/15