Statistics
| Branch: | Revision:

root / block / cow.c @ cc84d90f

History | View | Annotate | Download (11.1 kB)

# Date Author Comment
d5124c00 09/12/2013 11:12 am Max Reitz

bdrv: Use "Error" for creating images

Add an Error ** parameter to BlockDriver.bdrv_create to allow more
specific error messages.

Signed-off-by: Max Reitz <>

34b5d2c6 09/12/2013 11:12 am Max Reitz

block: Error parameter for open functions

Add an Error ** parameter to bdrv_open, bdrv_file_open and associated
functions to allow more specific error messages.

Signed-off-by: Max Reitz <>

cc84d90f 09/12/2013 11:12 am Max Reitz

block: Error parameter for create functions

Add an Error ** parameter to bdrv_create and its associated functions to
allow more specific error messages.

Signed-off-by: Max Reitz <>

015a1036 09/12/2013 11:12 am Max Reitz

bdrv: Use "Error" for opening images

Add an Error ** parameter to BlockDriver.bdrv_open and
BlockDriver.bdrv_file_open to allow more specific error messages.

Signed-off-by: Max Reitz <>

d663640c 09/06/2013 04:25 pm Paolo Bonzini

block: expect errors from bdrv_co_is_allocated

Some bdrv_is_allocated callers do not expect errors, but the fallback
in qcow2.c might make other callers trip on assertion failures or
infinite loops.

Fix the callers to always look for errors.

Cc: ...

b6b8a333 09/06/2013 04:25 pm Paolo Bonzini

block: introduce bdrv_get_block_status API

For now, bdrv_get_block_status is just another name for bdrv_is_allocated.
The next patches will add more flags.

This also touches all block drivers with a mostly mechanical rename. The
sole exception is cow; because it calls cow_co_is_allocated from the read...

4bc74be9 09/06/2013 04:25 pm Paolo Bonzini

block: return get_block_status data and flags for formats

Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Stefan Hajnoczi <>

4f6fd349 09/06/2013 04:25 pm Fam Zheng

block: make bdrv_delete() static

Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is no
longer public and should be called by bdrv_unref() if refcnt is
decreased to 0.

This is an identical change because effectively, there's no multiple
reference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...

276cbc7f 09/06/2013 04:25 pm Paolo Bonzini

cow: make reads go at a decent speed

Do not do two reads for each sector; load each sector of the bitmap
and use bitmap operations to process it.

Writes are still dog slow!

Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>...

26ae9804 09/06/2013 04:25 pm Paolo Bonzini

cow: make writes go at a less indecent speed

Only sync once per write, rather than once per sector.

Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Stefan Hajnoczi <>

e641c1e8 09/06/2013 04:25 pm Paolo Bonzini

cow: do not call bdrv_co_is_allocated

As we change bdrv_is_allocated to gather more information from bs and
bs->file, it will become a bit slower. It is still appropriate for online
jobs, but not for reads/writes. Call the internal function instead.

Reviewed-by: Eric Blake <>...

3ac21627 06/28/2013 02:52 pm Peter Lieven

block: change default of .has_zero_init to 0

.has_zero_init defaults to 1 for all formats and protocols.

this is a dangerous default since this means that all
new added drivers need to manually overwrite it to 0 if
they do not ensure that a device is zero initialized...

787e4a85 03/22/2013 06:51 pm Kevin Wolf

block: Add options QDict to bdrv_file_open() prototypes

The new parameter is unused yet.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>

1a86938f 03/15/2013 05:07 pm Kevin Wolf

block: Add options QDict to .bdrv_open()

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Stefan Hajnoczi <>

15bac0d5 01/25/2013 07:18 pm Stefan Weil

block: Use error code EMEDIUMTYPE for wrong format in some block drivers

This improves error reports for bochs, cow, qcow, qcow2, qed and vmdk
when a file with the wrong format is selected.

Signed-off-by: Stefan Weil <>
Reviewed-by: Eric Blake <>...

1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

737e150e 12/19/2012 09:31 am Paolo Bonzini

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

4e35b92a 04/19/2012 04:48 pm Stefan Weil

block: Fix spelling in comment (ineffcient -> inefficient)

Signed-off-by: Stefan Weil <>
Signed-off-by: Kevin Wolf <>

29cdb251 04/05/2012 03:54 pm Paolo Bonzini

block: push recursive flushing up from drivers

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

16d2fc00 12/15/2011 01:40 pm Li Zhi Hui

block/cow: Return real error code

Signed-off-by: Li Zhi Hui <>
Signed-off-by: Kevin Wolf <>

eb5d5bea 12/05/2011 05:39 pm Anthony Liguori

Merge remote-tracking branch 'kwolf/for-anthony' into staging

e94d1387 12/05/2011 03:51 pm Stefan Hajnoczi

cow: use bdrv_co_is_allocated()

Now that bdrv_co_is_allocated() is available we can use it instead of
the synchronous bdrv_is_allocated() interface. This is a follow-up that
Kevin Wolf <> pointed out after applying the series that
introduces bdrv_co_is_allocated()....

81145834 12/05/2011 03:51 pm Stefan Hajnoczi

cow: convert to .bdrv_co_is_allocated()

The cow block driver does not keep internal state for cluster lookups.
This means it is safe to perform cluster lookups in coroutine context
without risk of race conditions that corrupt internal state.

Signed-off-by: Stefan Hajnoczi <>...

3535a9c6 12/05/2011 03:51 pm Li Zhi Hui

block: Use bdrv functions to replace file operation in cow.c

Since common file operation functions lack of error detection,
so change them to bdrv series functions.

Signed-off-by: Li Zhi Hui <>
Reviewed-by: Stefan Hajnoczi <>...

9b2260cb 12/02/2011 12:50 pm Dong Xu Wang

fix spelling in block sub directory

Cc: Kevin Wolf <>
Signed-off-by: Dong Xu Wang <>
Signed-off-by: Stefan Hajnoczi <>

c68b89ac 11/11/2011 03:02 pm Kevin Wolf

block: Rename bdrv_co_flush to bdrv_co_flush_to_disk

There are two different types of flush that you can do: Flushing one level up
to the OS (i.e. writing data to the host page cache) or flushing it all the way
down to the disk. The existing functions flush to the disk, reflect this in the...

2914caa0 10/21/2011 06:34 pm Paolo Bonzini

block: take lock around bdrv_read implementations

This does the first part of the conversion to coroutines, by
wrapping bdrv_read implementations to take the mutex.

Drivers that implement bdrv_read rather than bdrv_co_readv can
then benefit from asynchronous operation (at least if the underlying...

e183ef75 10/21/2011 06:34 pm Paolo Bonzini

block: take lock around bdrv_write implementations

This does the first part of the conversion to coroutines, by
wrapping bdrv_write implementations to take the mutex.

Drivers that implement bdrv_write rather than bdrv_co_writev can
then benefit from asynchronous operation (at least if the underlying...

8b94ff85 10/21/2011 06:34 pm Paolo Bonzini

block: change flush to co_flush

Since coroutine operation is now mandatory, convert all bdrv_flush
implementations to coroutines. For qcow2, this means taking the lock.
Other implementations are simpler and just forward bdrv_flush to the
underlying protocol, so they can avoid the lock....

848c66e8 10/21/2011 06:34 pm Paolo Bonzini

block: add a CoMutex to synchronous read drivers

The big conversion of bdrv_read/write to coroutines caused the two
homonymous callbacks in BlockDriver to become reentrant. It goes
like this:

1) bdrv_read is now called in a coroutine, and calls bdrv_read or...

205ef796 11/04/2010 01:52 pm Kevin Wolf

block: Allow bdrv_flush to return errors

This changes bdrv_flush to return 0 on success and -errno in case of failure.
It's a requirement for implementing proper error handle in users of bdrv_flush.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

b0ad5a45 06/22/2010 03:38 pm Kevin Wolf

cow: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.
While at it, correct the wrong usage of errno.

Signed-off-by: Kevin Wolf <>

122bb9e3 06/15/2010 10:41 am Christoph Hellwig

cow: use pread/pwrite

Use pread/pwrite instead of lseek + read/write in preparation of using the
qemu block API.

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Kevin Wolf <>

893a9cb4 06/15/2010 10:41 am Christoph Hellwig

cow: stop using mmap

We don't have an equivalent to mmap in the qemu block API, so read and
write the bitmap directly. At least in the dumb implementation added
in this patch this is a lot less efficient, but it means cow can also
work on windows, and over nbd or curl. And it fixes qemu-iotests testcase...

2063392a 06/15/2010 10:41 am Christoph Hellwig

cow: use qemu block API

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <>...

66f82cee 05/03/2010 11:07 am Kevin Wolf

block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which...

48b66db9 03/09/2010 07:22 pm Juan Quintela

cow: return errno instead of -1

Remove not needed ret = 0 assignment.

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

31f38120 01/26/2010 10:59 pm Kirill A. Shutemov

block/cow.c: fix warnings with _FORTIFY_SOURCE

CC block/cow.o
cc1: warnings being treated as errors
block/cow.c: In function 'cow_create':
block/cow.c:251: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/cow.c:253: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result...

6f1953c4 09/11/2009 06:19 pm Christoph Hellwig

block: use fdatasync instead of fsync if possible

If we are flushing the caches for our image files we only care about the
data (including the metadata required for accessing it) but not things
like timestamp updates. So try to use fdatasync instead of fsync to...

db08adf5 06/06/2009 06:38 pm Kevin Wolf

qemu-img: Print available options with -o ?

This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?

Signed-off-by: Kevin Wolf <>

0e7e1989 05/22/2009 06:50 pm Kevin Wolf

Convert all block drivers to new bdrv_create

Now we can make use of the newly introduced option structures. Instead of
having bdrv_create carry more and more parameters (which are format specific in
most cases), just pass a option structure as defined by the driver itself....

019d6b8f 05/15/2009 12:13 am Anthony Liguori

Move block drivers into their own directory

Signed-off-by: Anthony Liguori <>