Messages in this thread |  | | Date | Mon, 2 Dec 1996 23:01:47 GMT | From | "Stephen C. Tweedie" <> | Subject | Re: [PATCH] Re: Corrupted inode list? |
| |
Hi,
On Sat, 30 Nov 1996 15:44:33 -0500 (EST), Benjamin C R LaHaise <blah@dot.superaje.com> 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 */ clear_inode(inode); inode->i_count++; if (ino) iput(ino); inode->i_count--;
before returning. That preserves the semantics that the VFS expects while eliminating the race concerning inode reuse.
Cheers, Stephen. -- Stephen Tweedie <sct@dcs.ed.ac.uk> Department of Computer Science, Edinburgh University, Scotland.
|  |