From: Badari Pulavarty <pbadari@us.ibm.com>

I found the problem with O_DIRECT memory leak.

The problem is, when we are doing DIO read and crossed the end of file - we
don't release referencess on all the pages we got from get_user_pages(= ). 
(since it is a success case).

The fix is to call dio_cleanup() even for sucess cases.



 25-akpm/fs/direct-io.c |    6 ++++++
 1 files changed, 6 insertions(+)

diff -puN fs/direct-io.c~direct-io-memleak-fix fs/direct-io.c
--- 25/fs/direct-io.c~direct-io-memleak-fix	Tue Nov 25 17:01:27 2003
+++ 25-akpm/fs/direct-io.c	Tue Nov 25 17:01:27 2003
@@ -946,6 +946,12 @@ direct_io_worker(int rw, struct kiocb *i
 	if (dio->bio)
 		dio_bio_submit(dio);
 
+	/*
+	 * It is possible that, we return short IO due to end of file.
+	 * In that case, we need to release all the pages we got hold on.
+	 */
+	dio_cleanup(dio);
+
 	/*
 	 * OK, all BIOs are submitted, so we can decrement bio_count to truly
 	 * reflect the number of to-be-processed BIOs.

_