[PATCH 2.6.6-mm2] vfs iput in inode critical region

From: FabF
Date: Fri May 14 2004 - 14:28:09 EST


Hi,

AFAICS, block_dev.c : do_open calls bdput after an unlock_kernel.bdput
calls iput and iput plays with some parameters and locks in iput final
case only.Here's a patch to have a spinlock around the whole iput.

Regards,
FabF
diff -Naur orig/fs/inode.c edited/fs/inode.c
--- orig/fs/inode.c 2004-05-11 10:13:15.000000000 +0200
+++ edited/fs/inode.c 2004-05-13 21:10:48.000000000 +0200
@@ -1081,16 +1081,20 @@
void iput(struct inode *inode)
{
if (inode) {
+ spin_lock(&inode_lock);
struct super_operations *op = inode->i_sb->s_op;

if (inode->i_state == I_CLEAR)
BUG();

+ /*Calling fs relevant put_inode*/
if (op && op->put_inode)
op->put_inode(inode);

- if (atomic_dec_and_lock(&inode->i_count, &inode_lock))
+ /*finalize if inode is unused*/
+ if (atomic_dec_and_test(&inode->i_count))
iput_final(inode);
+ spin_unlock(&inode_lock);
}
}