Block layer patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJXe9ZGAAoJEH8JsnLIjy/WmIkQAKpszWb2lH1/qgnWOzOEoz9s FUiZlf9f2LLIXMFnBFPGVs12SkTJHedsEKo0VG/tfVQdq+xJd8gEHSUZQbH1/vgg ArCQ76Rwc9giCrl4AwZhETbjTtpKlapxuWwDHCNjMYY9F4jndBRC+AZKUkIGAHHJ 8BWrmPgv8ueDZKWpQBfVmm0ItYk0g09UCgCnsiVNkEC9+nN6YQ2OCgDkzQbMj6OQ GxvccTelueIgmC4fQdaAEnsbqK/LyVrnZfz1Y1ilErI8ny7gmiiT5TInQXjsrzAr UVfycyAlVDNDVaUabi3F3b6Rpj9aBOMYsNVySmJKVeWUf2LKNy7v6T+JteFFZ3Qw ULddAnZIlpplL3wrzIklElw+2xz2aJ5n9SoUdzq7xKLLt8asQE6nMNsszjiow+fC LzbyOVP+aLVgOaUBHgt0aFShLHyGIuLAuvtaXk/wxYPDQe0Cyn4qsI41gF/VgnET 7ueIUwgi+AWyihz1uNsqO5RgakNQqN0Ms+LAYEBu7K9t88llv8yoSl0z8Ad+ZzN2 fdjOssU+Q26N/OAInO73W8LjWGR0N0bk0EQa4xlA0zhJKOB52RE7nDnKEchs7Xgp tChW084u9ixlct7u8V/cBWTEVQnW/p9fmD4RZhSE0IrkPfoTY9dmND2adTgyVc1v 7ONXnUCGoHcHVPNMVGG0 =jKrb -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging Block layer patches # gpg: Signature made Tue 05 Jul 2016 16:46:14 BST # gpg: using RSA key 0x7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (43 commits) block/qcow2: Don't use cpu_to_*w() block: Convert bdrv_co_preadv/pwritev to BdrvChild block: Convert bdrv_prwv_co() to BdrvChild block: Convert bdrv_pwrite_zeroes() to BdrvChild block: Convert bdrv_pwrite(v/_sync) to BdrvChild block: Convert bdrv_pread(v) to BdrvChild block: Convert bdrv_write() to BdrvChild block: Convert bdrv_read() to BdrvChild block: Use BlockBackend for I/O in bdrv_commit() block: Move bdrv_commit() to block/commit.c block: Convert bdrv_co_do_readv/writev to BdrvChild block: Convert bdrv_aio_writev() to BdrvChild block: Convert bdrv_aio_readv() to BdrvChild block: Convert bdrv_co_writev() to BdrvChild block: Convert bdrv_co_readv() to BdrvChild vhdx: Some more BlockBackend use in vhdx_create() blkreplay: Convert to byte-based I/O vvfat: Use BdrvChild for s->qcow block/qdev: Fix NULL access when using BB twice block: fix return code for partial write for Linux AIO ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
07bee7f4f4
44 changed files with 842 additions and 651 deletions
|
|
@ -226,33 +226,31 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
|
|||
BlockReopenQueue *queue, Error **errp);
|
||||
void bdrv_reopen_commit(BDRVReopenState *reopen_state);
|
||||
void bdrv_reopen_abort(BDRVReopenState *reopen_state);
|
||||
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
||||
int bdrv_read(BdrvChild *child, int64_t sector_num,
|
||||
uint8_t *buf, int nb_sectors);
|
||||
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
||||
int bdrv_write(BdrvChild *child, int64_t sector_num,
|
||||
const uint8_t *buf, int nb_sectors);
|
||||
int bdrv_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset,
|
||||
int count, BdrvRequestFlags flags);
|
||||
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags);
|
||||
int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
||||
void *buf, int count);
|
||||
int bdrv_preadv(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov);
|
||||
int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
||||
const void *buf, int count);
|
||||
int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov);
|
||||
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset,
|
||||
const void *buf, int count);
|
||||
int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
|
||||
int nb_sectors, QEMUIOVector *qiov);
|
||||
int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
|
||||
int nb_sectors, QEMUIOVector *qiov);
|
||||
int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags);
|
||||
int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes);
|
||||
int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov);
|
||||
int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int bytes);
|
||||
int bdrv_pwritev(BdrvChild *child, int64_t offset, QEMUIOVector *qiov);
|
||||
int bdrv_pwrite_sync(BdrvChild *child, int64_t offset,
|
||||
const void *buf, int count);
|
||||
int coroutine_fn bdrv_co_readv(BdrvChild *child, int64_t sector_num,
|
||||
int nb_sectors, QEMUIOVector *qiov);
|
||||
int coroutine_fn bdrv_co_writev(BdrvChild *child, int64_t sector_num,
|
||||
int nb_sectors, QEMUIOVector *qiov);
|
||||
/*
|
||||
* Efficiently zero a region of the disk image. Note that this is a regular
|
||||
* I/O request like read or write and should have a reasonable size. This
|
||||
* function is not suitable for zeroing the entire image in a single request
|
||||
* because it may allocate memory for the entire region.
|
||||
*/
|
||||
int coroutine_fn bdrv_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
int count, BdrvRequestFlags flags);
|
||||
int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset,
|
||||
int count, BdrvRequestFlags flags);
|
||||
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
|
||||
const char *backing_file);
|
||||
int bdrv_get_backing_file_depth(BlockDriverState *bs);
|
||||
|
|
@ -310,10 +308,10 @@ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
|
|||
const char *node_name, Error **errp);
|
||||
|
||||
/* async block I/O */
|
||||
BlockAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
|
||||
BlockAIOCB *bdrv_aio_readv(BdrvChild *child, int64_t sector_num,
|
||||
QEMUIOVector *iov, int nb_sectors,
|
||||
BlockCompletionFunc *cb, void *opaque);
|
||||
BlockAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
|
||||
BlockAIOCB *bdrv_aio_writev(BdrvChild *child, int64_t sector_num,
|
||||
QEMUIOVector *iov, int nb_sectors,
|
||||
BlockCompletionFunc *cb, void *opaque);
|
||||
BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
|
||||
|
|
@ -362,8 +360,8 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|||
int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
|
||||
int64_t sector_num, int nb_sectors, int *pnum);
|
||||
|
||||
int bdrv_is_read_only(BlockDriverState *bs);
|
||||
int bdrv_is_sg(BlockDriverState *bs);
|
||||
bool bdrv_is_read_only(BlockDriverState *bs);
|
||||
bool bdrv_is_sg(BlockDriverState *bs);
|
||||
bool bdrv_is_inserted(BlockDriverState *bs);
|
||||
int bdrv_media_changed(BlockDriverState *bs);
|
||||
void bdrv_lock_medium(BlockDriverState *bs, bool locked);
|
||||
|
|
@ -390,8 +388,8 @@ BlockDriverState *bdrv_first(BdrvNextIterator *it);
|
|||
BlockDriverState *bdrv_next(BdrvNextIterator *it);
|
||||
|
||||
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs);
|
||||
int bdrv_is_encrypted(BlockDriverState *bs);
|
||||
int bdrv_key_required(BlockDriverState *bs);
|
||||
bool bdrv_is_encrypted(BlockDriverState *bs);
|
||||
bool bdrv_key_required(BlockDriverState *bs);
|
||||
int bdrv_set_key(BlockDriverState *bs, const char *key);
|
||||
void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp);
|
||||
int bdrv_query_missing_keys(void);
|
||||
|
|
|
|||
|
|
@ -324,30 +324,48 @@ struct BlockDriver {
|
|||
};
|
||||
|
||||
typedef struct BlockLimits {
|
||||
/* maximum number of sectors that can be discarded at once */
|
||||
int max_discard;
|
||||
/* Alignment requirement, in bytes, for offset/length of I/O
|
||||
* requests. Must be a power of 2 less than INT_MAX; defaults to
|
||||
* 1 for drivers with modern byte interfaces, and to 512
|
||||
* otherwise. */
|
||||
uint32_t request_alignment;
|
||||
|
||||
/* optimal alignment for discard requests in sectors */
|
||||
int64_t discard_alignment;
|
||||
/* maximum number of bytes that can be discarded at once (since it
|
||||
* is signed, it must be < 2G, if set), should be multiple of
|
||||
* pdiscard_alignment, but need not be power of 2. May be 0 if no
|
||||
* inherent 32-bit limit */
|
||||
int32_t max_pdiscard;
|
||||
|
||||
/* optimal alignment for discard requests in bytes, must be power
|
||||
* of 2, less than max_pdiscard if that is set, and multiple of
|
||||
* bl.request_alignment. May be 0 if bl.request_alignment is good
|
||||
* enough */
|
||||
uint32_t pdiscard_alignment;
|
||||
|
||||
/* maximum number of bytes that can zeroized at once (since it is
|
||||
* signed, it must be < 2G, if set) */
|
||||
* signed, it must be < 2G, if set), should be multiple of
|
||||
* pwrite_zeroes_alignment. May be 0 if no inherent 32-bit limit */
|
||||
int32_t max_pwrite_zeroes;
|
||||
|
||||
/* optimal alignment for write zeroes requests in bytes, must be
|
||||
* power of 2, and less than max_pwrite_zeroes if that is set */
|
||||
* power of 2, less than max_pwrite_zeroes if that is set, and
|
||||
* multiple of bl.request_alignment. May be 0 if
|
||||
* bl.request_alignment is good enough */
|
||||
uint32_t pwrite_zeroes_alignment;
|
||||
|
||||
/* optimal transfer length in sectors */
|
||||
int opt_transfer_length;
|
||||
/* optimal transfer length in bytes (must be power of 2, and
|
||||
* multiple of bl.request_alignment), or 0 if no preferred size */
|
||||
uint32_t opt_transfer;
|
||||
|
||||
/* maximal transfer length in sectors */
|
||||
int max_transfer_length;
|
||||
/* maximal transfer length in bytes (need not be power of 2, but
|
||||
* should be multiple of opt_transfer), or 0 for no 32-bit limit.
|
||||
* For now, anything larger than INT_MAX is clamped down. */
|
||||
uint32_t max_transfer;
|
||||
|
||||
/* memory alignment so that no bounce buffer is needed */
|
||||
/* memory alignment, in bytes so that no bounce buffer is needed */
|
||||
size_t min_mem_alignment;
|
||||
|
||||
/* memory alignment for bounce buffer */
|
||||
/* memory alignment, in bytes, for bounce buffer */
|
||||
size_t opt_mem_alignment;
|
||||
|
||||
/* maximum number of iovec elements */
|
||||
|
|
@ -411,14 +429,15 @@ struct BdrvChild {
|
|||
struct BlockDriverState {
|
||||
int64_t total_sectors; /* if we are reading a disk image, give its
|
||||
size in sectors */
|
||||
int read_only; /* if true, the media is read only */
|
||||
int open_flags; /* flags used to open the file, re-used for re-open */
|
||||
int encrypted; /* if true, the media is encrypted */
|
||||
int valid_key; /* if true, a valid encryption key has been set */
|
||||
int sg; /* if true, the device is a /dev/sg* */
|
||||
int copy_on_read; /* if true, copy read backing sectors into image
|
||||
bool read_only; /* if true, the media is read only */
|
||||
bool encrypted; /* if true, the media is encrypted */
|
||||
bool valid_key; /* if true, a valid encryption key has been set */
|
||||
bool sg; /* if true, the device is a /dev/sg* */
|
||||
bool probed; /* if true, format was probed rather than specified */
|
||||
|
||||
int copy_on_read; /* if nonzero, copy read backing sectors into image.
|
||||
note this is a reference count */
|
||||
bool probed;
|
||||
|
||||
BlockDriver *drv; /* NULL means no media */
|
||||
void *opaque;
|
||||
|
|
@ -453,8 +472,6 @@ struct BlockDriverState {
|
|||
/* I/O Limits */
|
||||
BlockLimits bl;
|
||||
|
||||
/* Alignment requirement for offset/length of I/O requests */
|
||||
unsigned int request_alignment;
|
||||
/* Flags honored during pwrite (so far: BDRV_REQ_FUA) */
|
||||
unsigned int supported_write_flags;
|
||||
/* Flags honored during pwrite_zeroes (so far: BDRV_REQ_FUA,
|
||||
|
|
@ -546,10 +563,10 @@ extern BlockDriver bdrv_qcow2;
|
|||
*/
|
||||
void bdrv_setup_io_funcs(BlockDriver *bdrv);
|
||||
|
||||
int coroutine_fn bdrv_co_preadv(BlockDriverState *bs,
|
||||
int coroutine_fn bdrv_co_preadv(BdrvChild *child,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags);
|
||||
int coroutine_fn bdrv_co_pwritev(BlockDriverState *bs,
|
||||
int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ enum {
|
|||
|
||||
/* Maximum size of a single READ/WRITE data buffer */
|
||||
#define NBD_MAX_BUFFER_SIZE (32 * 1024 * 1024)
|
||||
#define NBD_MAX_SECTORS (NBD_MAX_BUFFER_SIZE / BDRV_SECTOR_SIZE)
|
||||
|
||||
/* Maximum size of an export name. The NBD spec requires 256 and
|
||||
* suggests that servers support up to 4096, but we stick to only the
|
||||
* required size so that we can stack-allocate the names, and because
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
|
|||
BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
|
||||
int count, BdrvRequestFlags flags,
|
||||
BlockCompletionFunc *cb, void *opaque);
|
||||
int blk_make_zero(BlockBackend *blk, BdrvRequestFlags flags);
|
||||
int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count);
|
||||
int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count,
|
||||
BdrvRequestFlags flags);
|
||||
|
|
@ -170,7 +171,7 @@ bool blk_is_available(BlockBackend *blk);
|
|||
void blk_lock_medium(BlockBackend *blk, bool locked);
|
||||
void blk_eject(BlockBackend *blk, bool eject_flag);
|
||||
int blk_get_flags(BlockBackend *blk);
|
||||
int blk_get_max_transfer_length(BlockBackend *blk);
|
||||
uint32_t blk_get_max_transfer(BlockBackend *blk);
|
||||
int blk_get_max_iov(BlockBackend *blk);
|
||||
void blk_set_guest_block_size(BlockBackend *blk, int align);
|
||||
void *blk_try_blockalign(BlockBackend *blk, size_t size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue