Block patches for 4.2-rc0
The following changes since commit 36609b4fa36f0ac934874371874416f7533a5408:
Merge remote-tracking branch 'remotes/palmer/tags/palmer-for-master-4.2-sf1' into staging (2019-11-02 17:59:03 +0000)
are available in the Git repository at:
https://github.com/XanClic/qemu.git tags/pull-block-2019-11-04
for you to fetch changes up to 292d06b925b2787ee6f2430996b95651cae42fce:
block/file-posix: Let post-EOF fallocate serialize (2019-11-04 09:33:51 +0100)
----------------------------------------------------------------
Block patches for 4.2-rc0:
- Work around XFS write-zeroes bug in file-posix block driver
- Fix backup job with compression
- Fix to the NVMe block driver header
----------------------------------------------------------------
Klaus Jensen (1):
nvme: fix NSSRS offset in CAP register
Max Reitz (3):
block: Make wait/mark serialising requests public
block: Add bdrv_co_get_self_request() block/file-posix: Let post-EOF fallocate serialize
Vladimir Sementsov-Ogievskiy (1):
block/block-copy: fix s->copy_size for compressed cluster
include/block/block_int.h | 4 ++++ include/block/nvme.h | 2 +- block/block-copy.c | 4 ++-- block/file-posix.c | 36 +++++++++++++++++++++++++++++++++ block/io.c | 42 ++++++++++++++++++++++++++++----------- 5 files changed, 73 insertions(+), 15 deletions(-)
Signature · 1 line
2.21.0
[PULL 2/5] block/block-copy: fix s->copy_size for compressed cluster
From: Vladimir Sementsov-Ogievskiy <[email protected]>
0e2402452f1f20429 allowed writes larger than cluster, but that's unsupported for compressed write. Fix it.
Message-id: [email protected]
--- block/block-copy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/block-copy.c +2 -2
@@ -109,9 +109,9 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, s->use_copy_range = false; s->copy_size = cluster_size; }else if (write_flags &BDRV_REQ_WRITE_COMPRESSED ) { -/* Compression is not supported for copy_range */ +/* Compression supports only cluster-size writes and no copy-range. */ s->use_copy_range = false; - s->copy_size =MAX (cluster_size,BLOCK_COPY_MAX_BUFFER ); + s->copy_size = cluster_size; }else {/* * copy_range does not respect max_transfer (it's a TODO), so we factor
Signature · 1 line
2.21.0
[PULL 3/5] block: Make wait/mark serialising requests public
In reply to Max ReitzMake both bdrv_mark_request_serialising() and bdrv_wait_serialising_requests() public so they can be used from block drivers.
Message-id: [email protected]
--- include/block/block_int.h | 3 +++ block/io.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-)
include/block/block_int.h +3 -0
@@ -999,6 +999,9 @@ extern unsigned int bdrv_drain_all_count;void bdrv_apply_subtree_drain (BdrvChild *child,BlockDriverState *new_parent);void bdrv_unapply_subtree_drain (BdrvChild *child,BlockDriverState *old_parent); +bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self); +void bdrv_mark_request_serialising (BdrvTrackedRequest *req,uint64_t align); +int get_tmp_filename (char *filename,int size);BlockDriver *bdrv_probe_all (const uint8_t *buf,int buf_size,const char *filename);
block/io.c +12 -12
@@ -715,7 +715,7 @@ static void tracked_request_begin(BdrvTrackedRequest *req,qemu_co_mutex_unlock (&bs->reqs_lock); } -static void mark_request_serialising (BdrvTrackedRequest *req,uint64_t align) +void bdrv_mark_request_serialising (BdrvTrackedRequest *req,uint64_t align) {int64_t overlap_offset = req->offset & ~(align -1 );uint64_t overlap_bytes =ROUND_UP (req->offset + req->bytes, align)
@@ -805,7 +805,7 @@ void bdrv_dec_in_flight(BlockDriverState *bs)bdrv_wakeup (bs); } -static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self) +bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self) {BlockDriverState *bs = self->bs;BdrvTrackedRequest *req;
@@ -1437,14 +1437,14 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,* with each other for the same cluster. For example, in copy-on-read * it ensures that the CoR read and write operations are atomic and * guest writes cannot interleave between them. */ -mark_request_serialising (req,bdrv_get_cluster_size (bs)); +bdrv_mark_request_serialising (req,bdrv_get_cluster_size (bs)); }/* BDRV_REQ_SERIALISING is only for write operation */ assert (!(flags &BDRV_REQ_SERIALISING ));if (!(flags &BDRV_REQ_NO_SERIALISING )) { -wait_serialising_requests (req); +bdrv_wait_serialising_requests (req); }if (flags &BDRV_REQ_COPY_ON_READ ) {
@@ -1841,10 +1841,10 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes,assert (!(flags & ~BDRV_REQ_MASK ));if (flags &BDRV_REQ_SERIALISING ) { -mark_request_serialising (req,bdrv_get_cluster_size (bs)); +bdrv_mark_request_serialising (req,bdrv_get_cluster_size (bs)); } - waited =wait_serialising_requests (req); + waited =bdrv_wait_serialising_requests (req);assert (!waited || !req->serialising ||is_request_serialising_and_aligned (req));
@@ -2008,8 +2008,8 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, padding =bdrv_init_padding (bs, offset, bytes, &pad);if (padding) { -mark_request_serialising (req, align); -wait_serialising_requests (req); +bdrv_mark_request_serialising (req, align); +bdrv_wait_serialising_requests (req);bdrv_padding_rmw_read (child, req, &pad, true);
@@ -2111,8 +2111,8 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, }if (bdrv_pad_request (bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { -mark_request_serialising (&req, align); -wait_serialising_requests (&req); +bdrv_mark_request_serialising (&req, align); +bdrv_wait_serialising_requests (&req);bdrv_padding_rmw_read (child, &req, &pad, false); }
@@ -3205,7 +3205,7 @@ static int coroutine_fn bdrv_co_copy_range_internal(/* BDRV_REQ_SERIALISING is only for write operation */ assert (!(read_flags &BDRV_REQ_SERIALISING ));if (!(read_flags &BDRV_REQ_NO_SERIALISING )) { -wait_serialising_requests (&req); +bdrv_wait_serialising_requests (&req); } ret = src->bs->drv->bdrv_co_copy_range_from(src->bs,
@@ -3336,7 +3336,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,* new area, we need to make sure that no write requests are made to it * concurrently or they might be overwritten by preallocation. */ if (new_bytes) { -mark_request_serialising (&req,1 ); +bdrv_mark_request_serialising (&req,1 ); }if (bs->read_only) {error_setg (errp,"Image is read-only" );
Signature · 1 line
2.21.0
[PULL 4/5] block: Add bdrv_co_get_self_request()
In reply to Max ReitzMessage-id: [email protected]
--- include/block/block_int.h | 1 + block/io.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
include/block/block_int.h +1 -0
@@ -1001,6 +1001,7 @@ void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent); bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self);void bdrv_mark_request_serialising (BdrvTrackedRequest *req,uint64_t align); +BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs);int get_tmp_filename (char *filename,int size); BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
block/io.c +18 -0
@@ -742,6 +742,24 @@ static bool is_request_serialising_and_aligned(BdrvTrackedRequest *req) (req->bytes == req->overlap_bytes); } +/** +* Return the tracked request on @bs for the current coroutine, or +* NULL if there is none. +*/ +BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs) +{ +BdrvTrackedRequest *req; +Coroutine *self =qemu_coroutine_self (); + + QLIST_FOREACH(req, &bs->tracked_requests, list) { +if (req->co == self) { +return req; + } + } + +return NULL ; +} +/** * Round a region to cluster boundaries */
Signature · 1 line
2.21.0
[PULL 5/5] block/file-posix: Let post-EOF fallocate serialize
In reply to Max ReitzThe XFS kernel driver has a bug that may cause data corruption for qcow2 images as of qemu commit c8bb23cbdbe32f. We can work around it by treating post-EOF fallocates as serializing up until infinity (INT64_MAX in practice).
Message-id: [email protected]
--- block/file-posix.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
block/file-posix.c +36 -0
@@ -2721,6 +2721,42 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes,RawPosixAIOData acb;ThreadPoolFunc *handler; +#ifdef CONFIG_FALLOCATE +if (offset + bytes > bs->total_sectors *BDRV_SECTOR_SIZE ) { +BdrvTrackedRequest *req; +uint64_t end; + +/* +* This is a workaround for a bug in the Linux XFS driver, +* where writes submitted through the AIO interface will be +* discarded if they happen beyond a concurrently running +* fallocate() that increases the file length (i.e., both the +* write and the fallocate() happen beyond the EOF). +* +* To work around it, we extend the tracked request for this +* zero write until INT64_MAX (effectively infinity), and mark +* it as serializing. +* +* We have to enable this workaround for all filesystems and +* AIO modes (not just XFS with aio=native), because for +* remote filesystems we do not know the host configuration. +*/ + + req =bdrv_co_get_self_request (bs); +assert (req); +assert (req->type ==BDRV_TRACKED_WRITE ); +assert (req->offset <= offset); +assert (req->offset + req->bytes >= offset + bytes); + + end =INT64_MAX & -(uint64_t )bs->bl.request_alignment; + req->bytes = end - req->offset; + req->overlap_bytes = req->bytes; + +bdrv_mark_request_serialising (req, bs->bl.request_alignment); +bdrv_wait_serialising_requests (req); + } +#endif + acb = (RawPosixAIOData ) { .bs = bs, .aio_fildes = s->fd,
Signature · 1 line
2.21.0
[PULL 1/5] nvme: fix NSSRS offset in CAP register
In reply to Max ReitzFrom: Klaus Jensen <[email protected]>
Fix the offset of the NSSRS field the CAP register.
From NVME 1.4, section 3 ("Controller Registers"), subsection 3.1.1 ("Offset 0h: CAP – Controller Capabilities") CAP_NSSRS_SHIFT is bit 36, not 33.
Message-id: [email protected]
[mreitz: Added John's note on the location in the specification where
this information can be found]
--- include/block/nvme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/block/nvme.h +1 -1
@@ -23,7 +23,7 @@ enum NvmeCapShift {CAP_AMS_SHIFT =17 ,CAP_TO_SHIFT =24 ,CAP_DSTRD_SHIFT =32 , -CAP_NSSRS_SHIFT =33 , +CAP_NSSRS_SHIFT =36 ,CAP_CSS_SHIFT =37 ,CAP_MPSMIN_SHIFT =48 , CAP_MPSMAX_SHIFT = 52,
Signature · 1 line
2.21.0
Peter Maydell
AppliedQuoted 11 lines · Max Reitz
The following changes since commit
36609b4fa36f0ac934874371874416f7533a5408:Merge remote-tracking branch 'remotes/palmer/tags/palmer-for-master-4.2-sf1' into staging (2019-11-02 17:59:03 +0000)
are available in the Git repository at:
https://github.com/XanClic/qemu.git tags/pull-block-2019-11-04
for you to fetch changes up to
292d06b925b2787ee6f2430996b95651cae42fce:
Quoted 8 lines
block/file-posix: Let post-EOF fallocate serialize (2019-11-04 09:33:51 +0100)----------------------------------------------------------------
Block patches for 4.2-rc0:
- Work around XFS write-zeroes bug in file-posix block driver
- Fix backup job with compression
- Fix to the NVMe block driver header
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.2
for any user-visible changes.
-- PMM