Commit f0c596cb3d704a349a8ed27237363f124f001878

Authored by ths
1 parent 3ddf0b5c

Last AIO patch, by Vladimir N. Oleynik.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3147 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 37 additions and 17 deletions
hw/ide.c
... ... @@ -864,10 +864,44 @@ static void ide_sector_write_timer_cb(void *opaque)
864 864 ide_set_irq(s);
865 865 }
866 866  
  867 +static void ide_sector_write_aio_cb(void *opaque, int ret)
  868 +{
  869 + BMDMAState *bm = opaque;
  870 + IDEState *s = bm->ide_if;
  871 +
  872 +#ifdef TARGET_I386
  873 + if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {
  874 + /* It seems there is a bug in the Windows 2000 installer HDD
  875 + IDE driver which fills the disk with empty logs when the
  876 + IDE write IRQ comes too early. This hack tries to correct
  877 + that at the expense of slower write performances. Use this
  878 + option _only_ to install Windows 2000. You must disable it
  879 + for normal use. */
  880 + qemu_mod_timer(s->sector_write_timer,
  881 + qemu_get_clock(vm_clock) + (ticks_per_sec / 1000));
  882 + } else
  883 +#endif
  884 + {
  885 + ide_set_irq(s);
  886 + }
  887 + bm->aiocb = NULL;
  888 +}
  889 +
867 890 static void ide_sector_write(IDEState *s)
868 891 {
  892 + BMDMAState *bm;
869 893 int64_t sector_num;
870   - int ret, n, n1;
  894 + int n, n1;
  895 +
  896 + s->io_buffer_index = 0;
  897 + s->io_buffer_size = 0;
  898 + bm = s->bmdma;
  899 + if(bm == NULL) {
  900 + bm = qemu_mallocz(sizeof(BMDMAState));
  901 + s->bmdma = bm;
  902 + }
  903 + bm->ide_if = s;
  904 + bm->dma_cb = ide_sector_write_aio_cb;
871 905  
872 906 s->status = READY_STAT | SEEK_STAT;
873 907 sector_num = ide_get_sector(s);
... ... @@ -877,7 +911,6 @@ static void ide_sector_write(IDEState *s)
877 911 n = s->nsector;
878 912 if (n > s->req_nb_sectors)
879 913 n = s->req_nb_sectors;
880   - ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);
881 914 s->nsector -= n;
882 915 if (s->nsector == 0) {
883 916 /* no more sectors to write */
... ... @@ -890,21 +923,8 @@ static void ide_sector_write(IDEState *s)
890 923 }
891 924 ide_set_sector(s, sector_num + n);
892 925  
893   -#ifdef TARGET_I386
894   - if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {
895   - /* It seems there is a bug in the Windows 2000 installer HDD
896   - IDE driver which fills the disk with empty logs when the
897   - IDE write IRQ comes too early. This hack tries to correct
898   - that at the expense of slower write performances. Use this
899   - option _only_ to install Windows 2000. You must disable it
900   - for normal use. */
901   - qemu_mod_timer(s->sector_write_timer,
902   - qemu_get_clock(vm_clock) + (ticks_per_sec / 1000));
903   - } else
904   -#endif
905   - {
906   - ide_set_irq(s);
907   - }
  926 + bm->aiocb = bdrv_aio_write(s->bs, sector_num, s->io_buffer, n,
  927 + ide_sector_write_aio_cb, bm);
908 928 }
909 929  
910 930 /* XXX: handle errors */
... ...