From: Jan Kara <jack@suse.cz>

Fix a subtle bug in error handling of ext2 xattrs.  When ext2_sync_inode()
fails because of ENOSPC (it could not write inode's dirty data) we want to
keep xattrs in a consistent state and release the old block properly.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/ext2/xattr.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)

diff -puN fs/ext2/xattr.c~ext2-quota-leak-fix fs/ext2/xattr.c
--- 25/fs/ext2/xattr.c~ext2-quota-leak-fix	Thu Jan 27 13:43:09 2005
+++ 25-akpm/fs/ext2/xattr.c	Thu Jan 27 13:43:09 2005
@@ -706,8 +706,14 @@ ext2_xattr_set2(struct inode *inode, str
 	inode->i_ctime = CURRENT_TIME_SEC;
 	if (IS_SYNC(inode)) {
 		error = ext2_sync_inode (inode);
-		if (error)
+		/* In case sync failed due to ENOSPC the inode was actually
+		 * written (only some dirty data were not) so we just proceed
+		 * as if nothing happened and cleanup the unused block */
+		if (error && error != ENOSPC) {
+			if (new_bh && new_bh != old_bh)
+				DQUOT_FREE_BLOCK(inode, 1);
 			goto cleanup;
+		}
 	} else
 		mark_inode_dirty(inode);
 
_