Re: ramfs leak

Padraig Brady
2001-11-12T18:38:42Z

Tachino Nobuhiro wrote:

> Hello,
>
> At Fri, 9 Nov 2001 15:40:43 -0500 (EST),
> W Christopher Martin wrote:
>
>>Padraig Brady writes:
>>
>>>When I remove files from a ramfs the space is not reclaimed?
>>>What am I doing wrong? Details below.
>>>
>>Nothing. We've noticed the same thing. It's a bug and was
>>first reported back in July, but no one has provided a fix yet.
>>I've had a brief look at the source code, but nothing obvious
>>pops out at me.
>>
>
> I think you should use tmpfs instead of ramfs, but if you really want to use ramfs,
> the patch below may fix the problem.
>
> diff -Nur linux-2.4.13-ac7.org/fs/ramfs/inode.c linux-2.4.13-ac7/fs/ramfs/inode.c
> --- linux-2.4.13-ac7.org/fs/ramfs/inode.c Mon Nov 12 11:00:47 2001
> +++ linux-2.4.13-ac7/fs/ramfs/inode.c Mon Nov 12 11:26:40 2001
> @@ -182,12 +182,9 @@
> {
> struct ramfs_sb_info *rsb = RAMFS_SB(inode->i_sb);
>
> - if (! Page_Uptodate(page))
> - return;
> -
> lock_rsb(rsb);
> -
> - ClearPageDirty(page);
> + if (Page_Uptodate(page))
> + ClearPageDirty(page);
>
> rsb->free_pages++;
> inode->i_blocks -= IBLOCKS_PER_PAGE;
>

Cool, this fixes it,
and I was just getting to the bottom of it myself :-)
None of this accounting stuff is in 2.4.15-pre3, so Alan
can you apply this?

cheers,
Padraig.