block.c (c3993cdca39c252d65bbbcc234d8d242dc9bd693) block.c (92196b2f5664d5defa778b1b24df56e2239b5e93)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 434 unchanged lines hidden (view full) ---

443 * Return 0 on success, -1 if the cache mode was invalid.
444 */
445int bdrv_parse_cache_flags(const char *mode, int *flags)
446{
447 *flags &= ~BDRV_O_CACHE_MASK;
448
449 if (!strcmp(mode, "off") || !strcmp(mode, "none")) {
450 *flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 434 unchanged lines hidden (view full) ---

443 * Return 0 on success, -1 if the cache mode was invalid.
444 */
445int bdrv_parse_cache_flags(const char *mode, int *flags)
446{
447 *flags &= ~BDRV_O_CACHE_MASK;
448
449 if (!strcmp(mode, "off") || !strcmp(mode, "none")) {
450 *flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
451 } else if (!strcmp(mode, "directsync")) {
452 *flags |= BDRV_O_NOCACHE;
451 } else if (!strcmp(mode, "writeback")) {
452 *flags |= BDRV_O_CACHE_WB;
453 } else if (!strcmp(mode, "unsafe")) {
454 *flags |= BDRV_O_CACHE_WB;
455 *flags |= BDRV_O_NO_FLUSH;
456 } else if (!strcmp(mode, "writethrough")) {
457 /* this is the default */
458 } else {

--- 724 unchanged lines hidden (view full) ---

1183{
1184 int ret;
1185
1186 ret = bdrv_pwrite(bs, offset, buf, count);
1187 if (ret < 0) {
1188 return ret;
1189 }
1190
453 } else if (!strcmp(mode, "writeback")) {
454 *flags |= BDRV_O_CACHE_WB;
455 } else if (!strcmp(mode, "unsafe")) {
456 *flags |= BDRV_O_CACHE_WB;
457 *flags |= BDRV_O_NO_FLUSH;
458 } else if (!strcmp(mode, "writethrough")) {
459 /* this is the default */
460 } else {

--- 724 unchanged lines hidden (view full) ---

1185{
1186 int ret;
1187
1188 ret = bdrv_pwrite(bs, offset, buf, count);
1189 if (ret < 0) {
1190 return ret;
1191 }
1192
1191 /* No flush needed for cache=writethrough, it uses O_DSYNC */
1192 if ((bs->open_flags & BDRV_O_CACHE_MASK) != 0) {
1193 /* No flush needed for cache modes that use O_DSYNC */
1194 if ((bs->open_flags & BDRV_O_CACHE_WB) != 0) {
1193 bdrv_flush(bs);
1194 }
1195
1196 return 0;
1197}
1198
1199int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
1200 int nb_sectors, QEMUIOVector *qiov)

--- 2102 unchanged lines hidden ---
1195 bdrv_flush(bs);
1196 }
1197
1198 return 0;
1199}
1200
1201int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
1202 int nb_sectors, QEMUIOVector *qiov)

--- 2102 unchanged lines hidden ---