Enabled the IOCache depending on the amount of free pages. Currently the
limit is 180 MB. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5060d7980f
commit
e76856a4a5
@ -19,6 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <io_requests.h>
|
#include <io_requests.h>
|
||||||
|
#include <vm/vm_page.h>
|
||||||
|
|
||||||
#include "IOCache.h"
|
#include "IOCache.h"
|
||||||
#include "IOSchedulerSimple.h"
|
#include "IOSchedulerSimple.h"
|
||||||
@ -887,13 +888,22 @@ cd_set_capacity(cd_driver_info* info, uint64 capacity, uint32 blockSize)
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
panic("initializing DMAResource failed: %s", strerror(status));
|
panic("initializing DMAResource failed: %s", strerror(status));
|
||||||
|
|
||||||
#if USE_IO_CACHE
|
// Allocate the I/O scheduler. If there seems to be sufficient memory
|
||||||
info->io_scheduler = new(std::nothrow) IOCache(info->dma_resource,
|
// we use an IOCache, since that adds caching at the lowest I/O layer
|
||||||
1024 * 1024);
|
// and thus dramatically reduces I/O operations and seeks. The
|
||||||
#else
|
// disadvantage is that it increases free memory (physical pages)
|
||||||
info->io_scheduler = new(std::nothrow) IOSchedulerSimple(
|
// fragmentation, which makes large contiguous allocations more likely
|
||||||
info->dma_resource);
|
// to fail.
|
||||||
#endif
|
size_t freeMemory = vm_page_num_free_pages();
|
||||||
|
if (freeMemory > 180 * 1024 * 1024 / B_PAGE_SIZE) {
|
||||||
|
info->io_scheduler = new(std::nothrow) IOCache(info->dma_resource,
|
||||||
|
1024 * 1024);
|
||||||
|
} else {
|
||||||
|
dprintf("scsi_cd: Using IOSchedulerSimple instead of IOCache to "
|
||||||
|
"avoid memory allocation issues.\n");
|
||||||
|
info->io_scheduler = new(std::nothrow) IOSchedulerSimple(
|
||||||
|
info->dma_resource);
|
||||||
|
}
|
||||||
|
|
||||||
if (info->io_scheduler == NULL)
|
if (info->io_scheduler == NULL)
|
||||||
panic("allocating IOScheduler failed.");
|
panic("allocating IOScheduler failed.");
|
||||||
@ -906,10 +916,8 @@ cd_set_capacity(cd_driver_info* info, uint64 capacity, uint32 blockSize)
|
|||||||
info->io_scheduler->SetCallback(do_io, info);
|
info->io_scheduler->SetCallback(do_io, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_IO_CACHE
|
|
||||||
if (info->io_scheduler != NULL)
|
if (info->io_scheduler != NULL)
|
||||||
info->io_scheduler->SetDeviceCapacity(capacity * blockSize);
|
info->io_scheduler->SetDeviceCapacity(capacity * blockSize);
|
||||||
#endif
|
|
||||||
|
|
||||||
info->block_size = blockSize;
|
info->block_size = blockSize;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "dma_resources.h"
|
#include "dma_resources.h"
|
||||||
#include "IORequest.h"
|
#include "IORequest.h"
|
||||||
|
|
||||||
|
|
||||||
struct IOCache;
|
struct IOCache;
|
||||||
struct IOScheduler;
|
struct IOScheduler;
|
||||||
|
|
||||||
@ -21,20 +22,13 @@ struct IOScheduler;
|
|||||||
#define SCSI_CD_DRIVER_MODULE_NAME "drivers/disk/scsi/scsi_cd/driver_v1"
|
#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"
|
#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 {
|
struct cd_driver_info {
|
||||||
device_node* node;
|
device_node* node;
|
||||||
::scsi_periph_device scsi_periph_device;
|
::scsi_periph_device scsi_periph_device;
|
||||||
::scsi_device scsi_device;
|
::scsi_device scsi_device;
|
||||||
scsi_device_interface* scsi;
|
scsi_device_interface* scsi;
|
||||||
#if USE_IO_CACHE
|
|
||||||
IOCache* io_scheduler;
|
|
||||||
#else
|
|
||||||
IOScheduler* io_scheduler;
|
IOScheduler* io_scheduler;
|
||||||
#endif
|
|
||||||
DMAResource* dma_resource;
|
DMAResource* dma_resource;
|
||||||
|
|
||||||
uint64 capacity;
|
uint64 capacity;
|
||||||
|
Loading…
Reference in New Issue
Block a user