Re: How can I force a read to hit the disk?

From: Richard B. Johnson
Date: Fri Sep 05 2003 - 13:41:31 EST


On Fri, 5 Sep 2003, Alan Stern wrote:

> My kernel module for Linux-2.6 needs to be able to verify that the media
> on which a file resides actually is readable. How can I do that?
>
> It would certainly suffice to use the normal VFS read routines, if there
> was some way to force the system to actually read from the device rather
> than just returning data already in the cache. So I guess it would be
> enough to perform an fdatasync for the file and then invalidate the file's
> cache entries. How does one invalidate a file's cache entries? Does
> filemap_flush() perform both these operations for you?
>
> TIA,
>
> Alan Stern

Force a read() before some write data was flushed to the disk??
Well, if you insist, just do a raw read of the device after
you find the inode, then offset, that your data is on. You
can walk the same fs structure(s) as the active file-system
to get all meta-data information.

...but... The most current data is probably in the kernel
buffers. I don't think you really want what you are asking
for. If you did a fdatasync(), you get the current data your
process wrote to go to the disk. However, there may be
other writers. This, too, may not be what you want. Also,
Just because the data was queued to go to a (SCSI) disk,
doesn't mean it actually got to the platters.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (794.73 BogoMips).
Note 96.31% of all statistics are fiction.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/