f2fs: release inmemory pages when the file was closed
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 5 Dec 2014 22:37:37 +0000 (14:37 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 8 Dec 2014 18:35:15 +0000 (10:35 -0800)
If file is closed, let's drop inmemory pages.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index 146e58ab716ef10e7190fa611d1419d1ec6eba9d..b6f3fbf2a376bdb1925e5efe1868fe21309096ab 100644 (file)
@@ -901,6 +901,14 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
        return f2fs_convert_inline_inode(inode);
 }
 
+static int f2fs_release_file(struct inode *inode, struct file *filp)
+{
+       /* some remained atomic pages should discarded */
+       if (f2fs_is_atomic_file(inode) || f2fs_is_volatile_file(inode))
+               commit_inmem_pages(inode, true);
+       return 0;
+}
+
 static int f2fs_ioc_commit_atomic_write(struct file *filp)
 {
        struct inode *inode = file_inode(filp);
@@ -1010,6 +1018,7 @@ const struct file_operations f2fs_file_operations = {
        .read_iter      = generic_file_read_iter,
        .write_iter     = generic_file_write_iter,
        .open           = generic_file_open,
+       .release        = f2fs_release_file,
        .mmap           = f2fs_file_mmap,
        .fsync          = f2fs_sync_file,
        .fallocate      = f2fs_fallocate,