Revision 6f6dc656

b/block/blkdebug.c
397 397
    }
398 398
}
399 399

  
400
static int blkdebug_flush(BlockDriverState *bs)
401
{
402
    return bdrv_flush(bs->file);
403
}
404

  
405 400
static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
406 401
    BlockDriverCompletionFunc *cb, void *opaque)
407 402
{
......
454 449

  
455 450
    .bdrv_file_open     = blkdebug_open,
456 451
    .bdrv_close         = blkdebug_close,
457
    .bdrv_flush         = blkdebug_flush,
458 452

  
459 453
    .bdrv_aio_readv     = blkdebug_aio_readv,
460 454
    .bdrv_aio_writev    = blkdebug_aio_writev,
b/block/blkverify.c
116 116
    s->test_file = NULL;
117 117
}
118 118

  
119
static int blkverify_flush(BlockDriverState *bs)
120
{
121
    BDRVBlkverifyState *s = bs->opaque;
122

  
123
    /* Only flush test file, the raw file is not important */
124
    return bdrv_flush(s->test_file);
125
}
126

  
127 119
static int64_t blkverify_getlength(BlockDriverState *bs)
128 120
{
129 121
    BDRVBlkverifyState *s = bs->opaque;
......
368 360

  
369 361
    .bdrv_file_open     = blkverify_open,
370 362
    .bdrv_close         = blkverify_close,
371
    .bdrv_flush         = blkverify_flush,
372 363

  
373 364
    .bdrv_aio_readv     = blkverify_aio_readv,
374 365
    .bdrv_aio_writev    = blkverify_aio_writev,
b/block/qcow.c
781 781
    return 0;
782 782
}
783 783

  
784
static int qcow_flush(BlockDriverState *bs)
785
{
786
    return bdrv_flush(bs->file);
787
}
788

  
789 784
static BlockDriverAIOCB *qcow_aio_flush(BlockDriverState *bs,
790 785
        BlockDriverCompletionFunc *cb, void *opaque)
791 786
{
......
826 821
    .bdrv_open		= qcow_open,
827 822
    .bdrv_close		= qcow_close,
828 823
    .bdrv_create	= qcow_create,
829
    .bdrv_flush		= qcow_flush,
830 824
    .bdrv_is_allocated	= qcow_is_allocated,
831 825
    .bdrv_set_key	= qcow_set_key,
832 826
    .bdrv_make_empty	= qcow_make_empty,
b/block/qcow2.c
1092 1092
    return 0;
1093 1093
}
1094 1094

  
1095
static int qcow2_flush(BlockDriverState *bs)
1096
{
1097
    BDRVQcowState *s = bs->opaque;
1098
    int ret;
1099

  
1100
    ret = qcow2_cache_flush(bs, s->l2_table_cache);
1101
    if (ret < 0) {
1102
        return ret;
1103
    }
1104

  
1105
    ret = qcow2_cache_flush(bs, s->refcount_block_cache);
1106
    if (ret < 0) {
1107
        return ret;
1108
    }
1109

  
1110
    return bdrv_flush(bs->file);
1111
}
1112

  
1113 1095
static BlockDriverAIOCB *qcow2_aio_flush(BlockDriverState *bs,
1114 1096
                                         BlockDriverCompletionFunc *cb,
1115 1097
                                         void *opaque)
......
1242 1224
    .bdrv_open          = qcow2_open,
1243 1225
    .bdrv_close         = qcow2_close,
1244 1226
    .bdrv_create        = qcow2_create,
1245
    .bdrv_flush         = qcow2_flush,
1246 1227
    .bdrv_is_allocated  = qcow2_is_allocated,
1247 1228
    .bdrv_set_key       = qcow2_set_key,
1248 1229
    .bdrv_make_empty    = qcow2_make_empty,
b/block/qed.c
533 533
    qemu_vfree(s->l1_table);
534 534
}
535 535

  
536
static int bdrv_qed_flush(BlockDriverState *bs)
537
{
538
    return bdrv_flush(bs->file);
539
}
540

  
541 536
static int qed_create(const char *filename, uint32_t cluster_size,
542 537
                      uint64_t image_size, uint32_t table_size,
543 538
                      const char *backing_file, const char *backing_fmt)
......
1479 1474
    .bdrv_open                = bdrv_qed_open,
1480 1475
    .bdrv_close               = bdrv_qed_close,
1481 1476
    .bdrv_create              = bdrv_qed_create,
1482
    .bdrv_flush               = bdrv_qed_flush,
1483 1477
    .bdrv_is_allocated        = bdrv_qed_is_allocated,
1484 1478
    .bdrv_make_empty          = bdrv_qed_make_empty,
1485 1479
    .bdrv_aio_readv           = bdrv_qed_aio_readv,
b/block/raw-posix.c
583 583
    return result;
584 584
}
585 585

  
586
static int raw_flush(BlockDriverState *bs)
587
{
588
    BDRVRawState *s = bs->opaque;
589
    int ret;
590

  
591
    ret = qemu_fdatasync(s->fd);
592
    if (ret < 0) {
593
        return -errno;
594
    }
595

  
596
    return 0;
597
}
598

  
599 586
#ifdef CONFIG_XFS
600 587
static int xfs_discard(BDRVRawState *s, int64_t sector_num, int nb_sectors)
601 588
{
......
645 632
    .bdrv_file_open = raw_open,
646 633
    .bdrv_close = raw_close,
647 634
    .bdrv_create = raw_create,
648
    .bdrv_flush = raw_flush,
649 635
    .bdrv_discard = raw_discard,
650 636

  
651 637
    .bdrv_aio_readv = raw_aio_readv,
......
915 901
    .bdrv_create        = hdev_create,
916 902
    .create_options     = raw_create_options,
917 903
    .bdrv_has_zero_init = hdev_has_zero_init,
918
    .bdrv_flush         = raw_flush,
919 904

  
920 905
    .bdrv_aio_readv	= raw_aio_readv,
921 906
    .bdrv_aio_writev	= raw_aio_writev,
......
1035 1020
    .bdrv_create        = hdev_create,
1036 1021
    .create_options     = raw_create_options,
1037 1022
    .bdrv_has_zero_init = hdev_has_zero_init,
1038
    .bdrv_flush         = raw_flush,
1039 1023

  
1040 1024
    .bdrv_aio_readv     = raw_aio_readv,
1041 1025
    .bdrv_aio_writev    = raw_aio_writev,
......
1135 1119
    .bdrv_create        = hdev_create,
1136 1120
    .create_options     = raw_create_options,
1137 1121
    .bdrv_has_zero_init = hdev_has_zero_init,
1138
    .bdrv_flush         = raw_flush,
1139 1122

  
1140 1123
    .bdrv_aio_readv     = raw_aio_readv,
1141 1124
    .bdrv_aio_writev    = raw_aio_writev,
......
1255 1238
    .bdrv_create        = hdev_create,
1256 1239
    .create_options     = raw_create_options,
1257 1240
    .bdrv_has_zero_init = hdev_has_zero_init,
1258
    .bdrv_flush         = raw_flush,
1259 1241

  
1260 1242
    .bdrv_aio_readv     = raw_aio_readv,
1261 1243
    .bdrv_aio_writev    = raw_aio_writev,
b/block/raw.c
25 25
{
26 26
}
27 27

  
28
static int raw_flush(BlockDriverState *bs)
28
static int coroutine_fn raw_co_flush(BlockDriverState *bs)
29 29
{
30
    return bdrv_flush(bs->file);
31
}
32

  
33
static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs,
34
    BlockDriverCompletionFunc *cb, void *opaque)
35
{
36
    return bdrv_aio_flush(bs->file, cb, opaque);
30
    return bdrv_co_flush(bs->file);
37 31
}
38 32

  
39 33
static int64_t raw_getlength(BlockDriverState *bs)
......
117 111
    .bdrv_close         = raw_close,
118 112
    .bdrv_co_readv      = raw_co_readv,
119 113
    .bdrv_co_writev     = raw_co_writev,
120
    .bdrv_flush         = raw_flush,
114
    .bdrv_co_flush      = raw_co_flush,
121 115
    .bdrv_probe         = raw_probe,
122 116
    .bdrv_getlength     = raw_getlength,
123 117
    .bdrv_truncate      = raw_truncate,
124 118

  
125
    .bdrv_aio_flush     = raw_aio_flush,
126 119
    .bdrv_discard       = raw_discard,
127 120

  
128 121
    .bdrv_is_inserted   = raw_is_inserted,

Also available in: Unified diff