* Introduced IOScheduler::MediaChanged() - this is now called by scsi_cd instead
of having the logic be triggered by IOScheduler::SetDeviceCapacity(), as that one might actually be called more often (for each call to update_capacity(), ie. each B_GET_GEOMETRY/B_GET_DEVICE_SIZE will trigger it), and there is no reason to throw away the cache every time (will make a difference during partition/file system detection). * In cd_init_device() just call update_capacity() instead of duplicating its code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36986 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2009, Haiku, Inc. All rights reserved.
|
* Copyright 2004-2010, Haiku, Inc. All rights reserved.
|
||||||
* Copyright 2002-2003, Thomas Kurschel. All rights reserved.
|
* Copyright 2002-2003, Thomas Kurschel. All rights reserved.
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! Peripheral driver to handle CD-ROM drives. To be more
|
/*! Peripheral driver to handle CD-ROM drives. To be more
|
||||||
precisely, it supports CD-ROM and WORM drives (well -
|
precisely, it supports CD-ROM and WORM drives (well -
|
||||||
I've never _seen_ a WORM driver).
|
I've never _seen_ a WORM driver).
|
||||||
@@ -586,12 +587,9 @@ cd_init_device(void* _info, void** _cookie)
|
|||||||
cd_driver_info* info = (cd_driver_info*)_info;
|
cd_driver_info* info = (cd_driver_info*)_info;
|
||||||
|
|
||||||
// and get (initial) capacity
|
// and get (initial) capacity
|
||||||
scsi_ccb *request = info->scsi->alloc_ccb(info->scsi_device);
|
status_t status = update_capacity(info);
|
||||||
if (request == NULL)
|
if (status != B_OK)
|
||||||
return B_NO_MEMORY;
|
return status;
|
||||||
|
|
||||||
sSCSIPeripheral->check_capacity(info->scsi_periph_device, request);
|
|
||||||
info->scsi->free_ccb(request);
|
|
||||||
|
|
||||||
*_cookie = info;
|
*_cookie = info;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -929,6 +927,9 @@ cd_media_changed(cd_driver_info* info, scsi_ccb* request)
|
|||||||
// do a capacity check
|
// do a capacity check
|
||||||
// TBD: is this a good idea (e.g. if this is an empty CD)?
|
// TBD: is this a good idea (e.g. if this is an empty CD)?
|
||||||
sSCSIPeripheral->check_capacity(info->scsi_periph_device, request);
|
sSCSIPeripheral->check_capacity(info->scsi_periph_device, request);
|
||||||
|
|
||||||
|
if (info->io_scheduler != NULL)
|
||||||
|
info->io_scheduler->MediaChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,16 @@ IOCache::SetDeviceCapacity(off_t deviceCapacity)
|
|||||||
AutoLocker<VMCache> cacheLocker(fCache);
|
AutoLocker<VMCache> cacheLocker(fCache);
|
||||||
|
|
||||||
fDeviceCapacity = deviceCapacity;
|
fDeviceCapacity = deviceCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
IOCache::MediaChanged()
|
||||||
|
{
|
||||||
|
TRACE("%p->IOCache::MediaChanged()\n", this);
|
||||||
|
|
||||||
|
MutexLocker serializationLocker(fSerializationLock);
|
||||||
|
AutoLocker<VMCache> cacheLocker(fCache);
|
||||||
|
|
||||||
// new media -- burn all cached data
|
// new media -- burn all cached data
|
||||||
while (vm_page* page = fCache->pages.Root()) {
|
while (vm_page* page = fCache->pages.Root()) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
virtual status_t Init(const char* name);
|
virtual status_t Init(const char* name);
|
||||||
|
|
||||||
virtual void SetDeviceCapacity(off_t deviceCapacity);
|
virtual void SetDeviceCapacity(off_t deviceCapacity);
|
||||||
|
virtual void MediaChanged();
|
||||||
|
|
||||||
virtual status_t ScheduleRequest(IORequest* request);
|
virtual status_t ScheduleRequest(IORequest* request);
|
||||||
|
|
||||||
|
|||||||
@@ -66,3 +66,9 @@ void
|
|||||||
IOScheduler::SetDeviceCapacity(off_t deviceCapacity)
|
IOScheduler::SetDeviceCapacity(off_t deviceCapacity)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
IOScheduler::MediaChanged()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
virtual void SetCallback(io_callback callback, void* data);
|
virtual void SetCallback(io_callback callback, void* data);
|
||||||
|
|
||||||
virtual void SetDeviceCapacity(off_t deviceCapacity);
|
virtual void SetDeviceCapacity(off_t deviceCapacity);
|
||||||
|
virtual void MediaChanged();
|
||||||
|
|
||||||
virtual status_t ScheduleRequest(IORequest* request) = 0;
|
virtual status_t ScheduleRequest(IORequest* request) = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user