Skip to contentSkip to conversation

2.6.0-test10 O_DIRECT memory leak fix

PATCH In review Badari Pulavarty 3 participants 3 messages Nov 25, 2003 – Dec 1, 2003 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.0-test10 O_DIRECT memory leak fix

Hi Andrew,

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 sucess case).

The fix is to call dio_cleanup() even for sucess cases. Can you please review this ? I tested the patch with fsstress and there are no memory leak problems now.

Thanks,
Badari

fs/direct-io.c +6 -0
@@ -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.
#1 lore raw
Quoted 5 lines · Badari Pulavarty

Hi Andrew,

I found the problem with O_DIRECT memory leak.

Quoted 7 lines

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 sucess case).

The fix is to call dio_cleanup() even for sucess cases. Can you please review this ? I tested the patch with fsstress and there are no memory leak problems now.

Thanks, it looks OK. Those pages haven't even been put into BIOs so I see no problem releasing them here even if there is still async I/O in flight.

#2 lore raw
In reply to Badari Pulavarty

At Tue, 25 Nov 2003 14:49:50 -0800,

Quoted 10 lines · Badari Pulavarty

[1 <text/plain; us-ascii (quoted-printable)>]
Hi Andrew,

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 sucess case).

Quoted 7 lines

The fix is to call dio_cleanup() even for sucess cases. Can you please review this ? I tested the patch with fsstress and there are no memory leak problems now.

Thanks,
Badari
[2 dioleak.patch <text/x-diff; us-ascii (7bit)>]

I've tested this patch with linux-2.6.0-test11 (plus my memory hotplug patch) on the machine I observed the memory leak. The leak seems to be fixed. Thanks.

--
IWAMOTO Toshihiro