Messages in this thread | | | From | (Thomas Niederreiter) | Subject | Partital Fix: Media-Change after generic-scsi-read | Date | Sat, 27 Apr 1996 18:00:34 +0200 (MET DST) |
| |
Hi,
I stated my problem with the undetected Media-Change on CD-Rom's after generic-scsi-reads a few days before, but nobody answered me. So (to be able to continue my work until the kernel fixed) I made a quick dirty hack, that solved all problems for me.
The exact problem is, that the kernel read-caches all block-devices and this cache is only cleared when a media is changed. So far so good... But I need to read from a CD-Rom with generic-scsi-calls to get the TOC of it or check sensekeys, and this generic-read seems to disable the kernel of being able to detect future Media-Changes on the CD-Rom.
I do now force the kernel upon closing the sg-device to invalidate the read-cache. I know this is brute-force attack, but it works me.
This patch is missing a very important thing...The right device have to be invalidated, so if you worked with /dev/sgd, the kernel must find out that this corresponds to /dev/sr0 and invalidate /dev/sr0. I hardcoded in the moment /dev/sr0....
Perhaps this patch helps the kernel-developers to track down the problem and fix in the right way!
But the best thing for me would be an ioctl to invalidate a device-buffer... Is there any? Any ideas how to do it another way?
Thomas Niederreiter
*** sg.c.orig Sat Apr 27 16:05:45 1996 --- sg.c Sat Apr 27 16:33:38 1996 *************** *** 150,161 **** --- 150,168 ---- static void sg_close(struct inode * inode, struct file * filp) { int dev=MINOR(inode->i_rdev); + /* 11,0 is /dev/sr0 */ + kdev_t devi = MKDEV(11,0); scsi_generics[dev].users--; if (scsi_generics[dev].device->host->hostt->usage_count) (*scsi_generics[dev].device->host->hostt->usage_count)--; if(sg_template.usage_count) (*sg_template.usage_count)--; scsi_generics[dev].exclude=0; wake_up(&scsi_generics[dev].generic_wait); + + /* T.N. Dirty hack to clear any buffers connected with the sg-device */ + /* Hardcoded /dev/sr0 at this time */ + invalidate_inodes(devi); + invalidate_buffers(devi); }
| |