f2fs: invalidate inode and data pages if inode is no longer used
Subsystems (2)
Jaegeuk Kim
maintainerPATCH 1/1 f2fs: invalidate inode and data pages if inode is no longer used
When a file is closed, let's deactivate inode page to mitigate further memory pressure. We can do data pages as well in the corner case of f2fs_drop_inode.
--- fs/f2fs/file.c | 4 ++++ fs/f2fs/super.c | 1 + 2 files changed, 5 insertions(+)
fs/f2fs/file.c +4 -0
@@ -1465,6 +1465,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)filemap_fdatawrite (inode->i_mapping);clear_inode_flag (inode,FI_DROP_CACHE ); } + +/* deactivate written inode page */ +invalidate_mapping_pages (NODE_MAPPING (F2FS_I_SB (inode)), + inode->i_ino, inode->i_ino);return 0 ; }
fs/f2fs/super.c +1 -0
@@ -618,6 +618,7 @@ static int f2fs_drop_inode(struct inode *inode)sb_end_intwrite (inode->i_sb);fscrypt_put_encryption_info (inode,NULL ); +invalidate_mapping_pages (inode->i_mapping,0 ,-1 );spin_lock (&inode->i_lock);atomic_dec (&inode->i_count); }
Signature · 4 lines
2.8.3 ------------------------------------------------------------------------------
Hi Jaegeuk,
Quoted 14 lines · Jaegeuk Kim
When a file is closed, let's deactivate inode page to mitigate further memory pressure. We can do data pages as well in the corner case of
f2fs_drop_inode.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 4 ++++ fs/f2fs/super.c | 1 + 2 files changed, 5 insertions(+)fs/f2fs/file.c +0
-0
fs/f2fs/file.c static int f2fs_release_file(struct inode *inode, struct file *filp) · line 1471
Quoted 7 lines
fs/f2fs/file.c +4
-0@@ -1465,6 +1465,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)filemap_fdatawrite (inode->i_mapping);clear_inode_flag (inode,FI_DROP_CACHE ); } + +/* deactivate written inode page */ +invalidate_mapping_pages (NODE_MAPPING (F2FS_I_SB (inode)), + inode->i_ino, inode->i_ino);
Seems if the file was opened by two processes, one process closes this file, another one will loss page cache of inode. I'm not sure whether this predication is friendly to user.
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 621
Quoted 12 lines
fs/f2fs/file.c +0
-0return 0 ; }fs/f2fs/super.c +1
-0@@ -618,6 +618,7 @@ static int f2fs_drop_inode(struct inode *inode)sb_end_intwrite (inode->i_sb);fscrypt_put_encryption_info (inode,NULL ); +invalidate_mapping_pages (inode->i_mapping,0 ,-1 );
Hmm, shouldn't we truncate page cache before f2fs_truncate() like we do in f2fs_evict?
Thanks,
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 624
Quoted 4 lines
fs/f2fs/super.c +0
-0spin_lock (&inode->i_lock);atomic_dec (&inode->i_count); }
------------------------------------------------------------------------------
Jaegeuk Kim
maintainerQuoted 12 lines · Chao Yu
Hi Jaegeuk,
Quoted 9 lines · Jaegeuk Kim
When a file is closed, let's deactivate inode page to mitigate further memory pressure. We can do data pages as well in the corner case of
f2fs_drop_inode.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 4 ++++ fs/f2fs/super.c | 1 + 2 files changed, 5 insertions(+)
Quoted 16 lines
fs/f2fs/file.c static int f2fs_release_file(struct inode *inode, struct file *filp) · line 1471
Quoted 12 lines
fs/f2fs/file.c +4
-0@@ -1465,6 +1465,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)filemap_fdatawrite (inode->i_mapping);clear_inode_flag (inode,FI_DROP_CACHE ); } + +/* deactivate written inode page */ +invalidate_mapping_pages (NODE_MAPPING (F2FS_I_SB (inode)), + inode->i_ino, inode->i_ino);Seems if the file was opened by two processes, one process closes this file, another one will loss page cache of inode. I'm not sure whether this predication is friendly to user.
No, this only calls when it's the last writer. BTW, I need to add reader case as well. :)
Quoted 11 lines
Quoted 11 lines
fs/f2fs/file.c +0
-0return 0 ; }fs/f2fs/super.c +0
-0@@ -618,6 +618,7 @@ static int f2fs_drop_inode(struct inode *inode)sb_end_intwrite (inode->i_sb);
Quoted 5 lines
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 621
Quoted 2 lines
fs/f2fs/super.c +1
-0fscrypt_put_encryption_info (inode,NULL ); +invalidate_mapping_pages (inode->i_mapping,0 ,-1 );Hmm, shouldn't we truncate page cache before
f2fs_truncate()like we do inf2fs_evict?
Then, it needs to be done under i_lock, and IMO, we don't need to wait for writeback here.
Thanks,
Quoted 9 lines
Thanks,
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 624
Quoted 4 lines
fs/f2fs/super.c +0
-0spin_lock (&inode->i_lock);atomic_dec (&inode->i_count); }
Quoted 5 lines
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
Jaegeuk Kim
maintainerQuoted 30 lines · Jaegeuk Kim
Quoted 12 lines · Chao Yu
Hi Jaegeuk,
Quoted 9 lines · Jaegeuk Kim
When a file is closed, let's deactivate inode page to mitigate further memory pressure. We can do data pages as well in the corner case of
f2fs_drop_inode.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 4 ++++ fs/f2fs/super.c | 1 + 2 files changed, 5 insertions(+)Quoted 16 lines
fs/f2fs/file.c static int f2fs_release_file(struct inode *inode, struct file *filp) · line 1471
Quoted 12 lines
fs/f2fs/file.c +4
-0@@ -1465,6 +1465,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)filemap_fdatawrite (inode->i_mapping);clear_inode_flag (inode,FI_DROP_CACHE ); } + +/* deactivate written inode page */ +invalidate_mapping_pages (NODE_MAPPING (F2FS_I_SB (inode)), + inode->i_ino, inode->i_ino);Seems if the file was opened by two processes, one process closes this file, another one will loss page cache of inode. I'm not sure whether this predication is friendly to user.
Quoted 2 lines
No, this only calls when it's the last writer. BTW, I need to add reader case as well. :)
if (!(filp->f_mode & FMODE_WRITE) || atomic_read(&inode->i_writecount) != 1) return 0;
So, it drops its inode page only when the last writer is closed.
Thanks,
Quoted 38 lines
Quoted 12 lines
Quoted 12 lines
fs/f2fs/file.c +0
-0return 0 ; }fs/f2fs/super.c +0
-0@@ -618,6 +618,7 @@ static int f2fs_drop_inode(struct inode *inode)sb_end_intwrite (inode->i_sb);Quoted 5 lines
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 621
Quoted 2 lines
fs/f2fs/super.c +1
-0fscrypt_put_encryption_info (inode,NULL ); +invalidate_mapping_pages (inode->i_mapping,0 ,-1 );Hmm, shouldn't we truncate page cache before
f2fs_truncate()like we do inf2fs_evict?Then, it needs to be done under
i_lock, and IMO, we don't need to wait for writeback here.Thanks,
Quoted 9 lines
Thanks,
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 624
Quoted 4 lines
fs/f2fs/super.c +0
-0spin_lock (&inode->i_lock);atomic_dec (&inode->i_count); }Quoted 5 lines
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 5 lines
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
Quoted 31 lines · Jaegeuk Kim
Quoted 30 lines · Jaegeuk Kim
Quoted 28 lines · Chao Yu
Hi Jaegeuk,
Quoted 14 lines · Jaegeuk Kim
When a file is closed, let's deactivate inode page to mitigate further memory pressure. We can do data pages as well in the corner case of
f2fs_drop_inode.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 4 ++++ fs/f2fs/super.c | 1 + 2 files changed, 5 insertions(+)fs/f2fs/file.c +0
-0fs/f2fs/file.c static int f2fs_release_file(struct inode *inode, struct file *filp) · line 1471
Quoted 7 lines
fs/f2fs/file.c +4
-0@@ -1465,6 +1465,10 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)filemap_fdatawrite (inode->i_mapping);clear_inode_flag (inode,FI_DROP_CACHE ); } + +/* deactivate written inode page */ +invalidate_mapping_pages (NODE_MAPPING (F2FS_I_SB (inode)), + inode->i_ino, inode->i_ino);Seems if the file was opened by two processes, one process closes this file, another one will loss page cache of inode. I'm not sure whether this predication is friendly to user.
Quoted 2 lines
Quoted 2 lines
No, this only calls when it's the last writer. BTW, I need to add reader case as well. :)
Oh, right.
Quoted 6 lines
if (!(filp->f_mode & FMODE_WRITE) || atomic_read(&inode->i_writecount) != 1) return 0;So, it drops its inode page only when the last writer is closed.
Reading data of inode will trigger atime updating, should we consider to keep inode page for read?
Thanks,
Quoted 41 lines
Thanks,
Quoted 38 lines
Quoted 12 lines
Quoted 12 lines
fs/f2fs/file.c +0
-0return 0 ; }fs/f2fs/super.c +0
-0@@ -618,6 +618,7 @@ static int f2fs_drop_inode(struct inode *inode)sb_end_intwrite (inode->i_sb);Quoted 5 lines
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 621
Quoted 2 lines
fs/f2fs/super.c +1
-0fscrypt_put_encryption_info (inode,NULL ); +invalidate_mapping_pages (inode->i_mapping,0 ,-1 );Hmm, shouldn't we truncate page cache before
f2fs_truncate()like we do inf2fs_evict?Then, it needs to be done under
i_lock, and IMO, we don't need to wait for writeback here.Thanks,
Quoted 14 lines
Thanks,
fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 624
Quoted 4 lines
fs/f2fs/super.c +0
-0spin_lock (&inode->i_lock);atomic_dec (&inode->i_count); }------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 8 lines
Quoted 5 lines
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
------------------------------------------------------------------------------