[PATCH] ntfs3: provide block_invalidate_folio to fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 30 May 2022, manualinux@xxxxxxxx wrote:

> 
> Hello again,
> 
> When you have time, try moving a large file from a SpadFS partition to
> an NTFS partition mounted with the NTFS3 driver and with a 5.18 kernel,
> and then, move the same file back again, to the SpadFS partition. At
> that very moment is when the size of the file remains permanently in
> the system memory (in my particular case). This does not happen if we
> do it to another Linux file system, nor does it happen if we do it from
> a NTFS partition to another XFS or Ext4 partition.
> 
> So no ccache or anything, I swap files quite often between the SpadFS
> partition and an external hard disk with an NTFS partition. Anyway,
> this problem is really unusual, and it must have some technical
> explanation, because with the ntfs-3g driver this doesn't happen.
> 
> If this information is of any use to you I will be satisfied.
> 
> Regards,
>      
> José Luis Lara Carrascal - Webmaster de Manualinux - GNU/Linux en
> Español (https://manualinux.es)

Hi

SpadFS is innocent here :)

The NTFS3 driver in the kernel 5.18 contains the same bug as SpadFS did - 
missing the invalidate_folio method. This patch adds this method and fixes 
the bug.

Mikulas



Author: Mikulas Patocka <mpatocka@xxxxxxxxxx>

The ntfs3 filesystem lacks the 'invalidate_folio' method and it causes
memory leak. If you write to the filesystem and then unmount it, the
cached written data are not freed and they are permanently leaked.

Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>
Reported-by: José Luis Lara Carrascal <manualinux@xxxxxxxx>
Fixes: 7ba13abbd31e ("fs: Turn block_invalidatepage into block_invalidate_folio")
Cc: stable@xxxxxxxxxxxxxxx	# v5.18

---
 fs/ntfs3/inode.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6/fs/ntfs3/inode.c
===================================================================
--- linux-2.6.orig/fs/ntfs3/inode.c	2022-05-16 16:57:24.000000000 +0200
+++ linux-2.6/fs/ntfs3/inode.c	2022-05-30 13:36:45.000000000 +0200
@@ -1951,6 +1951,7 @@ const struct address_space_operations nt
 	.direct_IO	= ntfs_direct_IO,
 	.bmap		= ntfs_bmap,
 	.dirty_folio	= block_dirty_folio,
+	.invalidate_folio = block_invalidate_folio,
 };
 
 const struct address_space_operations ntfs_aops_cmpr = {

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux