Skip to contentSkip to conversation

readahead not being thrown away by invalidate_inode_pages in 2.4

DISCUSSION Steve French 4 participants 5 messages Feb 5, 2004 – Feb 23, 2004 VFS

lore
Share & tools
lore
#0 lore raw

In the following snippet of the cifs vfs close file handle code (.release vfs operation), I see the code below being executed but I don't see it actually invalidating what I expect on 2.4 (in particular 2.4.24). The equivalent approach works on 2.6. The intent was that when the last instance of a file was closed on this client for the readahead data to be discarded by the call to invalidate_inode_pages (in 2.6 this is invalidate_remote_inode) so we will be forced to go to the server (ie invoke when the file is reopened for current copies of the data (cifs distributed caching token management works best when the file is open, and would be hard to monitor properly while the server file has no open
instances on the client). Is there a different call in 2.4 that can be
used to discard the readahead pages in the page cache for this inode, invalidate_inode_pages does not seem to work as expected?

if(list_empty(&(CIFS_I(inode)->openFileList))) {
cFYI(1,("closing last open instance for inode %p",inode)); /* if the file is not open we do not know if we can cache

    info on this inode, much less write behind and read ahead */
       CIFS_I(inode)->clientCanCacheRead = FALSE;
       CIFS_I(inode)->clientCanCacheAll  = FALSE;
       invalidate_inode_pages(inode);
}

The result of this code not working is that on 2.4 stale file data can continue to be given back to the application on the client, even long after the file has been opened and closed by the client and opened, updated, closed by multiple other clients or directly on the server itself.

#1 lore raw
Quoted 25 lines · Steve French

In the following snippet of the cifs vfs close file handle code (.release vfs operation), I see the code below being executed but I don't see it actually invalidating what I expect on 2.4 (in particular 2.4.24). The equivalent approach works on 2.6. The intent was that when the last instance of a file was closed on this client for the readahead data to be discarded by the call to invalidate_inode_pages (in 2.6 this is invalidate_remote_inode) so we will be forced to go to the server (ie invoke when the file is reopened for current copies of the data (cifs distributed caching token management works best when the file is open, and would be hard to monitor properly while the server file has no open
instances on the client). Is there a different call in 2.4 that can be
used to discard the readahead pages in the page cache for this inode, invalidate_inode_pages does not seem to work as expected?

if(list_empty(&(CIFS_I(inode)->openFileList))) {
cFYI(1,("closing last open instance for inode %p",inode)); /* if the file is not open we do not know if we can cache

    info on this inode, much less write behind and read ahead */
       CIFS_I(inode)->clientCanCacheRead = FALSE;
       CIFS_I(inode)->clientCanCacheAll  = FALSE;
       invalidate_inode_pages(inode);
}
Quoted 5 lines

The result of this code not working is that on 2.4 stale file data can continue to be given back to the application on the client, even long after the file has been opened and closed by the client and opened, updated, closed by multiple other clients or directly on the server itself.

(Delayed response)

invalidate_inode_pages() is just best-effort. If pages are currently under I/O then they will not be invalidated.

You will probably have some success with

	down(i_sem)
	filemap_fdatasync()
	filemap_fdatawait()
	invalidate_inode_pages()
	up(i_sem)
#2 lore raw
Quoted 26 lines · Andrew Morton
Quoted 14 lines · Steve French

Is there a different call in 2.4 that can be
used to discard the readahead pages in the page cache for this inode, invalidate_inode_pages does not seem to work as expected?

if(list_empty(&(CIFS_I(inode)->openFileList))) {
cFYI(1,("closing last open instance for inode %p",inode)); /* if the file is not open we do not know if we can cache

    info on this inode, much less write behind and read ahead */
       CIFS_I(inode)->clientCanCacheRead = FALSE;
       CIFS_I(inode)->clientCanCacheAll  = FALSE;
       invalidate_inode_pages(inode);
}
Quoted 5 lines

The result of this code not working is that on 2.4 stale file data can continue to be given back to the application on the client, even long after the file has been opened and closed by the client and opened, updated, closed by multiple other clients or directly on the server itself.

(Delayed response)

invalidate_inode_pages() is just best-effort. If pages are currently under I/O then they will not be invalidated.

Quoted 7 lines

You will probably have some success with

	down(i_sem)
	filemap_fdatasync()
	filemap_fdatawait()
	invalidate_inode_pages()
	up(i_sem)

What about truncate_inode_pages(inode, 0)? The comment above invalidate_inode_pages() says:

* invalidate_inode_pages - Invalidate all the unlocked pages of one inode *
* This function only removes the unlocked pages, if you want to
* remove all the pages of one inode, you must call truncate_inode_pages.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

#3 lore raw
Quoted 8 lines · Andreas Dilger
Quoted 8 lines

(Delayed response)

invalidate_inode_pages() is just best-effort. If pages are currently under I/O then they will not be invalidated.

You will probably have some success with

Quoted 7 lines
Quoted 5 lines
	down(i_sem)
	filemap_fdatasync()
	filemap_fdatawait()
	invalidate_inode_pages()
	up(i_sem)

What about truncate_inode_pages(inode, 0)?

If someone is mmapping those pages they'll end up with anonymous pages where they thought they had pagecache.

#4 lore raw

På må , 23/02/2004 klokka 11:41, skreiv Andrew Morton:

Quoted 5 lines
Quoted 2 lines

What about truncate_inode_pages(inode, 0)?

If someone is mmapping those pages they'll end up with anonymous pages where they thought they had pagecache.

invalidate_inode_pages2() should work, though...

Cheers,
Trond