Skip to content

Commit e50ca17

Browse files
kevmwMichael Tokarev
authored andcommitted
file-posix: Fix aio=threads performance regression after enablign FUA
For aio=threads, we're currently not implementing REQ_FUA in any useful way, but just do a separate raw_co_flush_to_disk() call. This changes behaviour compared to the old state, which used bdrv_co_flush() with its optimisations. As a quick fix, call bdrv_co_flush() again like before. Eventually, we can use pwritev2() to make use of RWF_DSYNC if available, but we'll still have to keep this code path as a fallback, so this fix is required either way. While the fix itself is a one-liner, some new graph locking annotations are needed to convince TSA that the locking is correct. Cc: [email protected] Fixes: 984a32f ("file-posix: Support FUA writes") Buglink: https://issues.redhat.com/browse/RHEL-96854 Reported-by: Tingting Mao <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> Message-ID: <[email protected]> Reviewed-by: Eric Blake <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> (cherry picked from commit d402da1360c2240e81f0e5fc80ddbfc6238e0da8) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 787a817 commit e50ca17

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

block/file-posix.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,9 +2484,9 @@ static inline bool raw_check_linux_aio(BDRVRawState *s)
24842484
}
24852485
#endif
24862486

2487-
static int coroutine_fn raw_co_prw(BlockDriverState *bs, int64_t *offset_ptr,
2488-
uint64_t bytes, QEMUIOVector *qiov, int type,
2489-
int flags)
2487+
static int coroutine_fn GRAPH_RDLOCK
2488+
raw_co_prw(BlockDriverState *bs, int64_t *offset_ptr, uint64_t bytes,
2489+
QEMUIOVector *qiov, int type, int flags)
24902490
{
24912491
BDRVRawState *s = bs->opaque;
24922492
RawPosixAIOData acb;
@@ -2545,7 +2545,7 @@ static int coroutine_fn raw_co_prw(BlockDriverState *bs, int64_t *offset_ptr,
25452545
ret = raw_thread_pool_submit(handle_aiocb_rw, &acb);
25462546
if (ret == 0 && (flags & BDRV_REQ_FUA)) {
25472547
/* TODO Use pwritev2() instead if it's available */
2548-
ret = raw_co_flush_to_disk(bs);
2548+
ret = bdrv_co_flush(bs);
25492549
}
25502550
goto out; /* Avoid the compiler err of unused label */
25512551

@@ -2580,16 +2580,16 @@ static int coroutine_fn raw_co_prw(BlockDriverState *bs, int64_t *offset_ptr,
25802580
return ret;
25812581
}
25822582

2583-
static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset,
2584-
int64_t bytes, QEMUIOVector *qiov,
2585-
BdrvRequestFlags flags)
2583+
static int coroutine_fn GRAPH_RDLOCK
2584+
raw_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
2585+
QEMUIOVector *qiov, BdrvRequestFlags flags)
25862586
{
25872587
return raw_co_prw(bs, &offset, bytes, qiov, QEMU_AIO_READ, flags);
25882588
}
25892589

2590-
static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, int64_t offset,
2591-
int64_t bytes, QEMUIOVector *qiov,
2592-
BdrvRequestFlags flags)
2590+
static int coroutine_fn GRAPH_RDLOCK
2591+
raw_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
2592+
QEMUIOVector *qiov, BdrvRequestFlags flags)
25932593
{
25942594
return raw_co_prw(bs, &offset, bytes, qiov, QEMU_AIO_WRITE, flags);
25952595
}
@@ -3525,10 +3525,11 @@ static int coroutine_fn raw_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op,
35253525
#endif
35263526

35273527
#if defined(CONFIG_BLKZONED)
3528-
static int coroutine_fn raw_co_zone_append(BlockDriverState *bs,
3529-
int64_t *offset,
3530-
QEMUIOVector *qiov,
3531-
BdrvRequestFlags flags) {
3528+
static int coroutine_fn GRAPH_RDLOCK
3529+
raw_co_zone_append(BlockDriverState *bs,
3530+
int64_t *offset,
3531+
QEMUIOVector *qiov,
3532+
BdrvRequestFlags flags) {
35323533
assert(flags == 0);
35333534
int64_t zone_size_mask = bs->bl.zone_size - 1;
35343535
int64_t iov_len = 0;

0 commit comments

Comments
 (0)