From 574e5742ad3b11557f717e2bc18c042f00e338b3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 23 Apr 2010 18:14:53 +0000 Subject: [PATCH] Optionally use the IOCache instead of the IOScheduler (specified by USE_IO_CACHE macro in the header). Currently disabled, though. It works fine, if the machine has a good deal of RAM. I tested with the anyboot CD -- the boot and installation times drop dramatically. On machines with little RAM there are issues, though. Apparently the cache isn't drained fast enough, so that other allocations can fail. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36438 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp | 11 +++++++++++ .../kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp index 96630ecb29..a23fa1c0aa 100644 --- a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp +++ b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp @@ -884,7 +884,13 @@ cd_set_capacity(cd_driver_info* info, uint64 capacity, uint32 blockSize) if (status != B_OK) panic("initializing DMAResource failed: %s", strerror(status)); +#if USE_IO_CACHE + info->io_scheduler = new(std::nothrow) IOCache(info->dma_resource, + 1024 * 1024); +#else info->io_scheduler = new(std::nothrow) IOScheduler(info->dma_resource); +#endif + if (info->io_scheduler == NULL) panic("allocating IOScheduler failed."); @@ -896,6 +902,11 @@ cd_set_capacity(cd_driver_info* info, uint64 capacity, uint32 blockSize) info->io_scheduler->SetCallback(do_io, info); } +#if USE_IO_CACHE + if (info->io_scheduler != NULL) + info->io_scheduler->SetDeviceCapacity(capacity * blockSize); +#endif + info->block_size = blockSize; } diff --git a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h index 8671b46645..07ce167d82 100644 --- a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h +++ b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h @@ -12,6 +12,7 @@ #include #include "dma_resources.h" +#include "IOCache.h" #include "IORequest.h" #include "IOScheduler.h" @@ -19,13 +20,20 @@ #define SCSI_CD_DRIVER_MODULE_NAME "drivers/disk/scsi/scsi_cd/driver_v1" #define SCSI_CD_DEVICE_MODULE_NAME "drivers/disk/scsi/scsi_cd/device_v1" +// enables using the IOCache instead of the IOScheduler +#define USE_IO_CACHE 0 + struct cd_driver_info { device_node* node; ::scsi_periph_device scsi_periph_device; ::scsi_device scsi_device; scsi_device_interface* scsi; +#if USE_IO_CACHE + IOCache* io_scheduler; +#else IOScheduler* io_scheduler; +#endif DMAResource* dma_resource; uint64 capacity;