Skip to content

Commit 7851f1a

Browse files
committed
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - Copy offloading fixes for when the copy increases the image size - Temporary revert of the removal of deprecated -drive options - Fix request serialisation in the image fleecing scenario - Fix copy-on-read crash with unaligned image size - Fix another drain crash # gpg: Signature made Tue 10 Jul 2018 16:37:52 BST # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <[email protected]>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (24 commits) block: Use common write req handling in truncate block: Fix bdrv_co_truncate overlap check block: Use common req handling in copy offloading block: Use common req handling for discard block: Fix handling of image enlarging write block: Extract common write req handling block: Use uint64_t for BdrvTrackedRequest byte fields block: Use BdrvChild to discard block: Add copy offloading trace points block: Prefix file driver trace points with "file_" Revert "block: Remove deprecated -drive geometry options" Revert "block: Remove deprecated -drive option addr" Revert "block: Remove deprecated -drive option serial" Revert "block: Remove dead deprecation warning code" block/blklogwrites: Make sure the log sector size is not too small qapi/block-core.json: Add missing documentation for blklogwrites log-append option block/backup: fix fleecing scheme: use serialized writes block: add BDRV_REQ_SERIALISING flag block: split flags in copy_range block/io: fix copy_range ... Signed-off-by: Peter Maydell <[email protected]>
2 parents 0956ee3 + cd47d79 commit 7851f1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+647
-177
lines changed

block.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
20662066
}
20672067
assert(num >= 0);
20682068
for (i = 0; i < num; i++) {
2069-
child->role->drained_begin(child);
2069+
bdrv_parent_drained_begin_single(child, true);
20702070
}
20712071
}
20722072

block/backup.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ typedef struct BackupBlockJob {
4747
HBitmap *copy_bitmap;
4848
bool use_copy_range;
4949
int64_t copy_range_size;
50+
51+
bool serialize_target_writes;
5052
} BackupBlockJob;
5153

5254
static const BlockJobDriver backup_job_driver;
@@ -102,6 +104,8 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
102104
QEMUIOVector qiov;
103105
BlockBackend *blk = job->common.blk;
104106
int nbytes;
107+
int read_flags = is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0;
108+
int write_flags = job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0;
105109

106110
hbitmap_reset(job->copy_bitmap, start / job->cluster_size, 1);
107111
nbytes = MIN(job->cluster_size, job->len - start);
@@ -112,8 +116,7 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
112116
iov.iov_len = nbytes;
113117
qemu_iovec_init_external(&qiov, &iov, 1);
114118

115-
ret = blk_co_preadv(blk, start, qiov.size, &qiov,
116-
is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0);
119+
ret = blk_co_preadv(blk, start, qiov.size, &qiov, read_flags);
117120
if (ret < 0) {
118121
trace_backup_do_cow_read_fail(job, start, ret);
119122
if (error_is_read) {
@@ -124,11 +127,11 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
124127

125128
if (qemu_iovec_is_zero(&qiov)) {
126129
ret = blk_co_pwrite_zeroes(job->target, start,
127-
qiov.size, BDRV_REQ_MAY_UNMAP);
130+
qiov.size, write_flags | BDRV_REQ_MAY_UNMAP);
128131
} else {
129132
ret = blk_co_pwritev(job->target, start,
130-
qiov.size, &qiov,
131-
job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0);
133+
qiov.size, &qiov, write_flags |
134+
(job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0));
132135
}
133136
if (ret < 0) {
134137
trace_backup_do_cow_write_fail(job, start, ret);
@@ -156,14 +159,16 @@ static int coroutine_fn backup_cow_with_offload(BackupBlockJob *job,
156159
int nr_clusters;
157160
BlockBackend *blk = job->common.blk;
158161
int nbytes;
162+
int read_flags = is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0;
163+
int write_flags = job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0;
159164

160165
assert(QEMU_IS_ALIGNED(job->copy_range_size, job->cluster_size));
161166
nbytes = MIN(job->copy_range_size, end - start);
162167
nr_clusters = DIV_ROUND_UP(nbytes, job->cluster_size);
163168
hbitmap_reset(job->copy_bitmap, start / job->cluster_size,
164169
nr_clusters);
165170
ret = blk_co_copy_range(blk, start, job->target, start, nbytes,
166-
is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0);
171+
read_flags, write_flags);
167172
if (ret < 0) {
168173
trace_backup_do_cow_copy_range_fail(job, start, ret);
169174
hbitmap_set(job->copy_bitmap, start / job->cluster_size,
@@ -701,6 +706,9 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
701706
sync_bitmap : NULL;
702707
job->compress = compress;
703708

709+
/* Detect image-fleecing (and similar) schemes */
710+
job->serialize_target_writes = bdrv_chain_contains(target, bs);
711+
704712
/* If there is no backing file on the target, we cannot rely on COW if our
705713
* backup cluster size is smaller than the target cluster size. Even for
706714
* targets with a backing file, try to avoid COW if possible. */

block/blkdebug.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs,
625625
return err;
626626
}
627627

628-
return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
628+
return bdrv_co_pdiscard(bs->file, offset, bytes);
629629
}
630630

631631
static int coroutine_fn blkdebug_co_block_status(BlockDriverState *bs,

block/blklogwrites.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ static inline uint32_t blk_log_writes_log2(uint32_t value)
8989

9090
static inline bool blk_log_writes_sector_size_valid(uint32_t sector_size)
9191
{
92-
return sector_size < (1ull << 24) && is_power_of_2(sector_size);
92+
return is_power_of_2(sector_size) &&
93+
sector_size >= sizeof(struct log_write_super) &&
94+
sector_size >= sizeof(struct log_write_entry) &&
95+
sector_size < (1ull << 24);
9396
}
9497

9598
static uint64_t blk_log_writes_find_cur_log_sector(BdrvChild *log,
@@ -483,7 +486,7 @@ static int coroutine_fn blk_log_writes_co_do_file_flush(BlkLogWritesFileReq *fr)
483486
static int coroutine_fn
484487
blk_log_writes_co_do_file_pdiscard(BlkLogWritesFileReq *fr)
485488
{
486-
return bdrv_co_pdiscard(fr->bs->file->bs, fr->offset, fr->bytes);
489+
return bdrv_co_pdiscard(fr->bs->file, fr->offset, fr->bytes);
487490
}
488491

489492
static int coroutine_fn

block/blkreplay.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs,
113113
int64_t offset, int bytes)
114114
{
115115
uint64_t reqid = blkreplay_next_id();
116-
int ret = bdrv_co_pdiscard(bs->file->bs, offset, bytes);
116+
int ret = bdrv_co_pdiscard(bs->file, offset, bytes);
117117
block_request_create(reqid, bs, qemu_coroutine_self());
118118
qemu_coroutine_yield();
119119

block/block-backend.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ static void drive_info_del(DriveInfo *dinfo)
419419
return;
420420
}
421421
qemu_opts_del(dinfo->opts);
422+
g_free(dinfo->serial);
422423
g_free(dinfo);
423424
}
424425

@@ -1559,7 +1560,7 @@ int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes)
15591560
return ret;
15601561
}
15611562

1562-
return bdrv_co_pdiscard(blk_bs(blk), offset, bytes);
1563+
return bdrv_co_pdiscard(blk->root, offset, bytes);
15631564
}
15641565

15651566
int blk_co_flush(BlockBackend *blk)
@@ -2218,7 +2219,8 @@ void blk_unregister_buf(BlockBackend *blk, void *host)
22182219

22192220
int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
22202221
BlockBackend *blk_out, int64_t off_out,
2221-
int bytes, BdrvRequestFlags flags)
2222+
int bytes, BdrvRequestFlags read_flags,
2223+
BdrvRequestFlags write_flags)
22222224
{
22232225
int r;
22242226
r = blk_check_byte_request(blk_in, off_in, bytes);
@@ -2231,5 +2233,5 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
22312233
}
22322234
return bdrv_co_copy_range(blk_in->root, off_in,
22332235
blk_out->root, off_out,
2234-
bytes, flags);
2236+
bytes, read_flags, write_flags);
22352237
}

block/copy-on-read.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs,
116116
static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs,
117117
int64_t offset, int bytes)
118118
{
119-
return bdrv_co_pdiscard(bs->file->bs, offset, bytes);
119+
return bdrv_co_pdiscard(bs->file, offset, bytes);
120120
}
121121

122122

block/file-posix.c

+16-9
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,8 @@ static ssize_t handle_aiocb_copy_range(RawPosixAIOData *aiocb)
14881488
ssize_t ret = copy_file_range(aiocb->aio_fildes, &in_off,
14891489
aiocb->aio_fd2, &out_off,
14901490
bytes, 0);
1491+
trace_file_copy_file_range(aiocb->bs, aiocb->aio_fildes, in_off,
1492+
aiocb->aio_fd2, out_off, bytes, 0, ret);
14911493
if (ret == 0) {
14921494
/* No progress (e.g. when beyond EOF), let the caller fall back to
14931495
* buffer I/O. */
@@ -1743,7 +1745,7 @@ static int paio_submit_co_full(BlockDriverState *bs, int fd,
17431745
assert(qiov->size == bytes);
17441746
}
17451747

1746-
trace_paio_submit_co(offset, bytes, type);
1748+
trace_file_paio_submit_co(offset, bytes, type);
17471749
pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
17481750
return thread_pool_submit_co(pool, aio_worker, acb);
17491751
}
@@ -2589,18 +2591,23 @@ static void raw_abort_perm_update(BlockDriverState *bs)
25892591
raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL);
25902592
}
25912593

2592-
static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
2593-
BdrvChild *src, uint64_t src_offset,
2594-
BdrvChild *dst, uint64_t dst_offset,
2595-
uint64_t bytes, BdrvRequestFlags flags)
2594+
static int coroutine_fn raw_co_copy_range_from(
2595+
BlockDriverState *bs, BdrvChild *src, uint64_t src_offset,
2596+
BdrvChild *dst, uint64_t dst_offset, uint64_t bytes,
2597+
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags)
25962598
{
2597-
return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, flags);
2599+
return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
2600+
read_flags, write_flags);
25982601
}
25992602

26002603
static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
2601-
BdrvChild *src, uint64_t src_offset,
2602-
BdrvChild *dst, uint64_t dst_offset,
2603-
uint64_t bytes, BdrvRequestFlags flags)
2604+
BdrvChild *src,
2605+
uint64_t src_offset,
2606+
BdrvChild *dst,
2607+
uint64_t dst_offset,
2608+
uint64_t bytes,
2609+
BdrvRequestFlags read_flags,
2610+
BdrvRequestFlags write_flags)
26042611
{
26052612
BDRVRawState *s = bs->opaque;
26062613
BDRVRawState *src_s;

block/file-win32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static BlockAIOCB *paio_submit(BlockDriverState *bs, HANDLE hfile,
162162
acb->aio_nbytes = count;
163163
acb->aio_offset = offset;
164164

165-
trace_paio_submit(acb, opaque, offset, count, type);
165+
trace_file_paio_submit(acb, opaque, offset, count, type);
166166
pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
167167
return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque);
168168
}

0 commit comments

Comments
 (0)