qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] block: add discard support
Date: Thu, 02 Dec 2010 13:12:13 +0100	[thread overview]
Message-ID: <4CF78D1D.3060107@redhat.com> (raw)
In-Reply-To: <20101201153514.GA6310@lst.de>

Am 01.12.2010 16:35, schrieb Christoph Hellwig:
> Add a new bdrv_discard method to free blocks in a mapping image, and a new
> drive property to set the granularity for these discard.  If no discard
> granularity support is set discard support is disabled.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c	2010-11-25 16:17:32.922003704 +0100
> +++ qemu/block.c	2010-11-29 14:10:21.793255565 +0100
> @@ -1499,6 +1499,15 @@ int bdrv_has_zero_init(BlockDriverState
>      return 1;
>  }
>  
> +int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
> +{
> +    if (!bs->drv)
> +        return -ENOMEDIUM;
> +    if (!bs->drv->bdrv_discard)
> +        return 0;

Missing braces.

> +    return bs->drv->bdrv_discard(bs, sector_num, nb_sectors);
> +}
> +
>  /*
>   * Returns true iff the specified sector is present in the disk image. Drivers
>   * not implementing the functionality are assumed to not support backing files,
> Index: qemu/block.h
> ===================================================================
> --- qemu.orig/block.h	2010-11-25 16:17:32.929004193 +0100
> +++ qemu/block.h	2010-11-29 14:07:00.267003145 +0100
> @@ -146,6 +146,7 @@ int bdrv_flush(BlockDriverState *bs);
>  void bdrv_flush_all(void);
>  void bdrv_close_all(void);
>  
> +int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
>  int bdrv_has_zero_init(BlockDriverState *bs);
>  int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
>  	int *pnum);
> Index: qemu/block_int.h
> ===================================================================
> --- qemu.orig/block_int.h	2010-11-25 16:17:32.935003774 +0100
> +++ qemu/block_int.h	2010-11-29 14:09:31.926264704 +0100
> @@ -73,6 +73,8 @@ struct BlockDriver {
>          BlockDriverCompletionFunc *cb, void *opaque);
>      BlockDriverAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs,
>          BlockDriverCompletionFunc *cb, void *opaque);
> +    int (*bdrv_discard)(BlockDriverState *bs, int64_t sector_num,
> +                        int nb_sectors);
>  
>      int (*bdrv_aio_multiwrite)(BlockDriverState *bs, BlockRequest *reqs,
>          int num_reqs);
> @@ -227,6 +229,7 @@ typedef struct BlockConf {
>      uint16_t logical_block_size;
>      uint16_t min_io_size;
>      uint32_t opt_io_size;
> +    uint32_t discard_granularity;
>  } BlockConf;
>  
>  static inline unsigned int get_physical_block_exp(BlockConf *conf)
> @@ -249,6 +252,8 @@ static inline unsigned int get_physical_
>      DEFINE_PROP_UINT16("physical_block_size", _state,                   \
>                         _conf.physical_block_size, 512),                 \
>      DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0),  \
> -    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0)
> +    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \
> +    DEFINE_PROP_UINT32("discard_granularity", _state, \
> +                       _conf.discard_granularity, 0)

Is there no way to get this value automatically?

At least for non-raw images (and it should be trivial to implement this
in qcow2) I guess we'll want to set it to the cluster size of the image
instead of requiring the user to set this value.

Kevin

  reply	other threads:[~2010-12-02 13:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-25 13:56 [Qemu-devel] [PATCH 0/5] add TRIM/UNMAP support Christoph Hellwig
2010-11-25 13:57 ` [Qemu-devel] [PATCH 1/5] block: add discard support Christoph Hellwig
2010-11-25 14:09   ` malc
2010-11-25 14:45   ` Stefan Hajnoczi
2010-11-25 13:57 ` [Qemu-devel] [PATCH 2/5] scsi-disk: support WRITE SAME (16) with unmap bit Christoph Hellwig
2010-11-25 14:10   ` malc
2010-11-25 13:57 ` [Qemu-devel] [PATCH 3/5] make dma_bdrv_io available to drivers Christoph Hellwig
2010-11-25 13:57 ` [Qemu-devel] [PATCH 4/5] ide: add TRIM support Christoph Hellwig
2010-11-25 14:10   ` malc
2010-11-25 13:57 ` [Qemu-devel] [PATCH 5/5] raw-posix: add discard support Christoph Hellwig
2010-12-01 15:35 ` [Qemu-devel] PATCH 0/5] add TRIM/UNMAP support, v2 Christoph Hellwig
2010-12-01 15:35   ` [Qemu-devel] [PATCH 1/5] block: add discard support Christoph Hellwig
2010-12-02 12:12     ` Kevin Wolf [this message]
2010-12-10 13:38       ` Christoph Hellwig
2010-12-11 12:50         ` Paul Brook
2010-12-13 15:43           ` Christoph Hellwig
2010-12-13 16:17             ` Paul Brook
2010-12-13 16:07         ` [Qemu-devel] " Paolo Bonzini
2010-12-13 16:15           ` Christoph Hellwig
2010-12-13 16:24             ` Paolo Bonzini
2010-12-01 15:35   ` [Qemu-devel] [PATCH 2/5] scsi-disk: support WRITE SAME (16) with unmap bit Christoph Hellwig
2010-12-01 15:35   ` [Qemu-devel] [PATCH 3/5] make dma_bdrv_io available to drivers Christoph Hellwig
2010-12-01 15:35   ` [Qemu-devel] [PATCH 4/5] ide: add TRIM support Christoph Hellwig
2010-12-02 14:07     ` Kevin Wolf
2010-12-10 13:39       ` Christoph Hellwig
2010-12-01 15:35   ` [Qemu-devel] [PATCH 5/5] raw-posix: add discard support Christoph Hellwig
2010-12-02 12:04     ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CF78D1D.3060107@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hch@lst.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).