* 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:
Axel Dörfler 2010-06-01 12:05:24 +00:00
parent 266ee1f290
commit 03768a4052
5 changed files with 26 additions and 7 deletions

View File

@ -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.
*
* Distributed under the terms of the MIT License.
*/
/*! Peripheral driver to handle CD-ROM drives. To be more
precisely, it supports CD-ROM and WORM drives (well -
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;
// and get (initial) capacity
scsi_ccb *request = info->scsi->alloc_ccb(info->scsi_device);
if (request == NULL)
return B_NO_MEMORY;
sSCSIPeripheral->check_capacity(info->scsi_periph_device, request);
info->scsi->free_ccb(request);
status_t status = update_capacity(info);
if (status != B_OK)
return status;
*_cookie = info;
return B_OK;
@ -929,6 +927,9 @@ cd_media_changed(cd_driver_info* info, scsi_ccb* request)
// do a capacity check
// TBD: is this a good idea (e.g. if this is an empty CD)?
sSCSIPeripheral->check_capacity(info->scsi_periph_device, request);
if (info->io_scheduler != NULL)
info->io_scheduler->MediaChanged();
}

View File

@ -133,6 +133,16 @@ IOCache::SetDeviceCapacity(off_t deviceCapacity)
AutoLocker<VMCache> cacheLocker(fCache);
fDeviceCapacity = deviceCapacity;
}
void
IOCache::MediaChanged()
{
TRACE("%p->IOCache::MediaChanged()\n", this);
MutexLocker serializationLocker(fSerializationLock);
AutoLocker<VMCache> cacheLocker(fCache);
// new media -- burn all cached data
while (vm_page* page = fCache->pages.Root()) {

View File

@ -26,6 +26,7 @@ public:
virtual status_t Init(const char* name);
virtual void SetDeviceCapacity(off_t deviceCapacity);
virtual void MediaChanged();
virtual status_t ScheduleRequest(IORequest* request);

View File

@ -66,3 +66,9 @@ void
IOScheduler::SetDeviceCapacity(off_t deviceCapacity)
{
}
void
IOScheduler::MediaChanged()
{
}

View File

@ -46,6 +46,7 @@ public:
virtual void SetCallback(io_callback callback, void* data);
virtual void SetDeviceCapacity(off_t deviceCapacity);
virtual void MediaChanged();
virtual status_t ScheduleRequest(IORequest* request) = 0;