
From: Mingming Cao <cmm@us.ibm.com>

This should fix a reservation window race between multiple processes when
one process closed the file while another one is in the middle of block
allocation using the inode's reservation window.  reservation window should
be discard on the last writer on the inode, not the last writer on the
filp.  


---

 25-akpm/fs/ext3/file.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

diff -puN fs/ext3/file.c~ext3_reservation_discard_race_fix fs/ext3/file.c
--- 25/fs/ext3/file.c~ext3_reservation_discard_race_fix	2004-05-06 17:48:52.494893376 -0700
+++ 25-akpm/fs/ext3/file.c	2004-05-06 17:49:27.058638888 -0700
@@ -33,7 +33,9 @@
  */
 static int ext3_release_file (struct inode * inode, struct file * filp)
 {
-	if (filp->f_mode & FMODE_WRITE)
+	/* if we are the last writer on the inode, drop the block reservation */
+	if ((filp->f_mode & FMODE_WRITE) &&
+			(atomic_read(&inode->i_writecount) == 1))
 		ext3_discard_reservation(inode);
 	if (is_dx(inode) && filp->private_data)
 		ext3_htree_free_dir_info(filp->private_data);

_
