ia64/xen-unstable

changeset 11230:9bb6c1c1890a

[qemu] hdparm tunable IDE write cache for HVM
qemu 0.8.2 has a flush callback to the storage backends, so now it is
possible to implement hdparm tunable IDE write cache enable/disable for
guest domains, allowing people to pick speed or data consistency on a
case by case basis.

As an added benefit, really large LBA48 IOs will now no longer be broken
up into smaller IOs on the host side.

From: Rik van Riel <riel@redhat.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Sun Aug 20 23:59:34 2006 +0100 (2006-08-20)
parents 78673ba510ed
children a61b92fc2966
files tools/ioemu/block-bochs.c tools/ioemu/block-cloop.c tools/ioemu/block-cow.c tools/ioemu/block-qcow.c tools/ioemu/block-vmdk.c tools/ioemu/block.c tools/ioemu/hw/ide.c
line diff
     1.1 --- a/tools/ioemu/block-bochs.c	Sun Aug 20 23:52:39 2006 +0100
     1.2 +++ b/tools/ioemu/block-bochs.c	Sun Aug 20 23:59:34 2006 +0100
     1.3 @@ -91,7 +91,7 @@ static int bochs_open(BlockDriverState *
     1.4      int fd, i;
     1.5      struct bochs_header bochs;
     1.6  
     1.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     1.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
     1.9      if (fd < 0) {
    1.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
    1.11          if (fd < 0)
     2.1 --- a/tools/ioemu/block-cloop.c	Sun Aug 20 23:52:39 2006 +0100
     2.2 +++ b/tools/ioemu/block-cloop.c	Sun Aug 20 23:59:34 2006 +0100
     2.3 @@ -55,7 +55,7 @@ static int cloop_open(BlockDriverState *
     2.4      BDRVCloopState *s = bs->opaque;
     2.5      uint32_t offsets_size,max_compressed_block_size=1,i;
     2.6  
     2.7 -    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE | O_SYNC);
     2.8 +    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
     2.9      if (s->fd < 0)
    2.10          return -1;
    2.11      bs->read_only = 1;
     3.1 --- a/tools/ioemu/block-cow.c	Sun Aug 20 23:52:39 2006 +0100
     3.2 +++ b/tools/ioemu/block-cow.c	Sun Aug 20 23:59:34 2006 +0100
     3.3 @@ -69,7 +69,7 @@ static int cow_open(BlockDriverState *bs
     3.4      struct cow_header_v2 cow_header;
     3.5      int64_t size;
     3.6  
     3.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     3.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
     3.9      if (fd < 0) {
    3.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
    3.11          if (fd < 0)
     4.1 --- a/tools/ioemu/block-qcow.c	Sun Aug 20 23:52:39 2006 +0100
     4.2 +++ b/tools/ioemu/block-qcow.c	Sun Aug 20 23:59:34 2006 +0100
     4.3 @@ -95,7 +95,7 @@ static int qcow_open(BlockDriverState *b
     4.4      int fd, len, i, shift;
     4.5      QCowHeader header;
     4.6      
     4.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     4.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
     4.9      if (fd < 0) {
    4.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
    4.11          if (fd < 0)
     5.1 --- a/tools/ioemu/block-vmdk.c	Sun Aug 20 23:52:39 2006 +0100
     5.2 +++ b/tools/ioemu/block-vmdk.c	Sun Aug 20 23:59:34 2006 +0100
     5.3 @@ -96,7 +96,7 @@ static int vmdk_open(BlockDriverState *b
     5.4      uint32_t magic;
     5.5      int l1_size;
     5.6  
     5.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     5.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
     5.9      if (fd < 0) {
    5.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
    5.11          if (fd < 0)
     6.1 --- a/tools/ioemu/block.c	Sun Aug 20 23:52:39 2006 +0100
     6.2 +++ b/tools/ioemu/block.c	Sun Aug 20 23:59:34 2006 +0100
     6.3 @@ -685,7 +685,7 @@ static int raw_open(BlockDriverState *bs
     6.4      int rv;
     6.5  #endif
     6.6  
     6.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
     6.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
     6.9      if (fd < 0) {
    6.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
    6.11          if (fd < 0)
     7.1 --- a/tools/ioemu/hw/ide.c	Sun Aug 20 23:52:39 2006 +0100
     7.2 +++ b/tools/ioemu/hw/ide.c	Sun Aug 20 23:59:34 2006 +0100
     7.3 @@ -305,6 +305,7 @@ typedef struct IDEState {
     7.4      PCIDevice *pci_dev;
     7.5      struct BMDMAState *bmdma;
     7.6      int drive_serial;
     7.7 +    int write_cache;
     7.8      /* ide regs */
     7.9      uint8_t feature;
    7.10      uint8_t error;
    7.11 @@ -789,6 +790,9 @@ static void ide_sector_write(IDEState *s
    7.12      }
    7.13      ide_set_sector(s, sector_num + n);
    7.14      
    7.15 +    if (!s->write_cache)
    7.16 +        bdrv_flush(s->bs);
    7.17 +    
    7.18  #ifdef TARGET_I386
    7.19      if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {
    7.20          /* It seems there is a bug in the Windows 2000 installer HDD
    7.21 @@ -863,6 +867,10 @@ static int ide_write_dma_cb(IDEState *s,
    7.22          transfer_size -= len;
    7.23          phys_addr += len;
    7.24      }
    7.25 +    /* Ensure the data hit disk before telling the guest OS so. */
    7.26 +    if (!s->write_cache)
    7.27 +        bdrv_flush(s->bs);
    7.28 +
    7.29      return transfer_size1 - transfer_size;
    7.30  }
    7.31  
    7.32 @@ -1672,7 +1680,15 @@ static void ide_ioport_write(void *opaqu
    7.33              /* XXX: valid for CDROM ? */
    7.34              switch(s->feature) {
    7.35              case 0x02: /* write cache enable */
    7.36 +                s->write_cache = 1;
    7.37 +                s->status = READY_STAT | SEEK_STAT;
    7.38 +                ide_set_irq(s);
    7.39 +                break;
    7.40              case 0x82: /* write cache disable */
    7.41 +                s->write_cache = 0;
    7.42 +                s->status = READY_STAT | SEEK_STAT;
    7.43 +                ide_set_irq(s);
    7.44 +                break;
    7.45              case 0xaa: /* read look-ahead enable */
    7.46              case 0x55: /* read look-ahead disable */
    7.47                  s->status = READY_STAT | SEEK_STAT;
    7.48 @@ -2090,6 +2106,7 @@ static void ide_init2(IDEState *ide_stat
    7.49          s->irq = irq;
    7.50          s->sector_write_timer = qemu_new_timer(vm_clock, 
    7.51                                                 ide_sector_write_timer_cb, s);
    7.52 +        s->write_cache = 0;
    7.53          ide_reset(s);
    7.54      }
    7.55  }