Re: [PATCH] Re: Corrupted inode list?

Stephen C. Tweedie (
Mon, 2 Dec 1996 23:01:47 GMT


On Sat, 30 Nov 1996 15:44:33 -0500 (EST), Benjamin C R LaHaise
<> said:

> On Fri, 29 Nov 1996, Stephen C. Tweedie wrote:
>> On investigation this appears to be the case --- FAT is ignoring a
>> totally undocumented requirement of the VFS. :) The reuse of inodes
>> can't happen as long as the put_inode() operation keeps the inode
>> in-use flag set right up until the end.

>> Does this much smaller patch fix your problem?

> The smaller (admittedly more beautiful) patch doesn't quite fix the
> problem. For example, in lofs I have the following sort of code in
> put_inode:

> static int lofs_put_inode(struct inode *inode)
> {
> struct inode *ino = inode->u.lofs_i.inode;
> lofs_check_inode(inode); /* debugging */
> clear_inode(inode);
> if (ino)
> iput(ino);
> return 1;
> }

> My problem is that clear_inode *must* be called before iput,
> otherwise another task might come along and reuse the
> inode.... splat! If it could have been done the other way, I would
> have.

That's an issue for the filesystem itself to address, not a deficiency
of the VFS. It is still essential that the filesystem does block
after dropping inode->i_count to zero. Fortunately, there is an easy
way around this: in your code above, just rewrite it as

lofs_check_inode(inode); /* debugging */
if (ino)

before returning. That preserves the semantics that the VFS expects
while eliminating the race concerning inode reuse.


Stephen Tweedie <>
Department of Computer Science, Edinburgh University, Scotland.