From: Christoph Hellwig <hch@lst.de>

UDF discards file preallocations on every ->put_inode which is totally
bogus.  It already discards them in ->release which makes sense for normal
writes, so the only additional discard is in ->clear_inode so we make sure
we don't leak any reservations for shared writeable mappings.

This follows similar changes to ext2 and ext3.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/udf/inode.c   |   30 ++++++------------------------
 25-akpm/fs/udf/super.c   |    1 -
 25-akpm/fs/udf/udfdecl.h |    1 -
 3 files changed, 6 insertions(+), 26 deletions(-)

diff -puN fs/udf/inode.c~udf-fix-reservation-discarding fs/udf/inode.c
--- 25/fs/udf/inode.c~udf-fix-reservation-discarding	Mon Dec 13 14:25:59 2004
+++ 25-akpm/fs/udf/inode.c	Mon Dec 13 14:25:59 2004
@@ -70,30 +70,6 @@ static void udf_update_extents(struct in
 static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int);
 
 /*
- * udf_put_inode
- *
- * PURPOSE
- *
- * DESCRIPTION
- *	This routine is called whenever the kernel no longer needs the inode.
- *
- * HISTORY
- *	July 1, 1997 - Andrew E. Mileski
- *	Written, tested, and released.
- *
- *  Called at each iput()
- */
-void udf_put_inode(struct inode * inode)
-{
-	if (!(inode->i_sb->s_flags & MS_RDONLY))
-	{
-		lock_kernel();
-		udf_discard_prealloc(inode);
-		unlock_kernel();
-	}
-}
-
-/*
  * udf_delete_inode
  *
  * PURPOSE
@@ -129,6 +105,12 @@ no_delete:
 
 void udf_clear_inode(struct inode *inode)
 {
+	if (!(inode->i_sb->s_flags & MS_RDONLY)) {
+		lock_kernel();
+		udf_discard_prealloc(inode);
+		unlock_kernel();
+	}
+
 	kfree(UDF_I_DATA(inode));
 	UDF_I_DATA(inode) = NULL;
 }
diff -puN fs/udf/super.c~udf-fix-reservation-discarding fs/udf/super.c
--- 25/fs/udf/super.c~udf-fix-reservation-discarding	Mon Dec 13 14:25:59 2004
+++ 25-akpm/fs/udf/super.c	Mon Dec 13 14:25:59 2004
@@ -163,7 +163,6 @@ static struct super_operations udf_sb_op
 	.alloc_inode		= udf_alloc_inode,
 	.destroy_inode		= udf_destroy_inode,
 	.write_inode		= udf_write_inode,
-	.put_inode		= udf_put_inode,
 	.delete_inode		= udf_delete_inode,
 	.clear_inode		= udf_clear_inode,
 	.put_super		= udf_put_super,
diff -puN fs/udf/udfdecl.h~udf-fix-reservation-discarding fs/udf/udfdecl.h
--- 25/fs/udf/udfdecl.h~udf-fix-reservation-discarding	Mon Dec 13 14:25:59 2004
+++ 25-akpm/fs/udf/udfdecl.h	Mon Dec 13 14:25:59 2004
@@ -96,7 +96,6 @@ extern struct buffer_head * udf_expand_d
 extern struct buffer_head * udf_bread(struct inode *, int, int, int *);
 extern void udf_truncate(struct inode *);
 extern void udf_read_inode(struct inode *);
-extern void udf_put_inode(struct inode *);
 extern void udf_delete_inode(struct inode *);
 extern void udf_clear_inode(struct inode *);
 extern int udf_write_inode(struct inode *, int);
_