diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-05-13 17:35:14 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-06-01 19:20:54 -0400 |
commit | 06e1bc05cad8d06860b52c79d4669483c7e39a4f (patch) | |
tree | 0f2477b99923f231c45205d5d444baa122a1b8fb /fs/f2fs/super.c | |
parent | 912a83b5096eb4a5d8d95124d70585e0e861c564 (diff) |
f2fs: truncate data blocks for orphan inode
As Hu reported, F2FS has a space leak problem, when conducting:
1) format a 4GB f2fs partition
2) dd a 3G file,
3) unlink it.
So, when doing f2fs_drop_inode(), we need to truncate data blocks
before skipping it.
We can also drop unused caches assigned to each inode.
Reported-by: hujianyang <hujianyang@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r-- | fs/f2fs/super.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index d5dfd143c394..bfc900e87fcc 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -431,8 +431,30 @@ static int f2fs_drop_inode(struct inode *inode) | |||
431 | * - f2fs_gc -> iput -> evict | 431 | * - f2fs_gc -> iput -> evict |
432 | * - inode_wait_for_writeback(inode) | 432 | * - inode_wait_for_writeback(inode) |
433 | */ | 433 | */ |
434 | if (!inode_unhashed(inode) && inode->i_state & I_SYNC) | 434 | if (!inode_unhashed(inode) && inode->i_state & I_SYNC) { |
435 | if (!inode->i_nlink && !is_bad_inode(inode)) { | ||
436 | spin_unlock(&inode->i_lock); | ||
437 | |||
438 | /* some remained atomic pages should discarded */ | ||
439 | if (f2fs_is_atomic_file(inode)) | ||
440 | commit_inmem_pages(inode, true); | ||
441 | |||
442 | sb_start_intwrite(inode->i_sb); | ||
443 | i_size_write(inode, 0); | ||
444 | |||
445 | if (F2FS_HAS_BLOCKS(inode)) | ||
446 | f2fs_truncate(inode); | ||
447 | |||
448 | sb_end_intwrite(inode->i_sb); | ||
449 | |||
450 | #ifdef CONFIG_F2FS_FS_ENCRYPTION | ||
451 | if (F2FS_I(inode)->i_crypt_info) | ||
452 | f2fs_free_encryption_info(inode); | ||
453 | #endif | ||
454 | spin_lock(&inode->i_lock); | ||
455 | } | ||
435 | return 0; | 456 | return 0; |
457 | } | ||
436 | return generic_drop_inode(inode); | 458 | return generic_drop_inode(inode); |
437 | } | 459 | } |
438 | 460 | ||