[PATCH] f2fs: don't worry about inode leak in evict_inode

From: Jaegeuk Kim
Date: Wed May 04 2016 - 22:48:53 EST


Even if an inode failed to release its blocks, it should be kept in an orphan
inode list, so it will be released later.

Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
---
fs/f2fs/inode.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index baf3a2a..689d691 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -377,20 +377,8 @@ no_delete:
alloc_nid_failed(sbi, inode->i_ino);
clear_inode_flag(fi, FI_FREE_NID);
}
-
- if (err && err != -ENOENT) {
- if (!exist_written_data(sbi, inode->i_ino, ORPHAN_INO)) {
- /*
- * get here because we failed to release resource
- * of inode previously, reminder our user to run fsck
- * for fixing.
- */
- set_sbi_flag(sbi, SBI_NEED_FSCK);
- f2fs_msg(sbi->sb, KERN_WARNING,
- "inode (ino:%lu) resource leak, run fsck "
- "to fix this issue!", inode->i_ino);
- }
- }
+ f2fs_bug_on(sbi, err &&
+ !exist_written_data(sbi, inode->i_ino, ORPHAN_INO));
out_clear:
fscrypt_put_encryption_info(inode, NULL);
clear_inode(inode);
--
2.6.3

>
> How about this patch?
>
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -345,6 +345,7 @@ void f2fs_evict_inode(struct inode *inode)
> set_inode_flag(fi, FI_NO_ALLOC);
> i_size_write(inode, 0);
>
> +retry:
> if (F2FS_HAS_BLOCKS(inode))
> err = f2fs_truncate(inode, true);
>
> @@ -354,6 +355,11 @@ void f2fs_evict_inode(struct inode *inode)
> f2fs_unlock_op(sbi);
> }
>
> + if (err == -ENOMEM) {
> + err = 0;
> + goto retry;
> + }
> +
> sb_end_intwrite(inode->i_sb);
> no_delete:
> stat_dec_inline_xattr(inode);
> >Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
> >---
> > fs/f2fs/inode.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> >diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> >index f4ac851..5cccd7a 100644
> >--- a/fs/f2fs/inode.c
> >+++ b/fs/f2fs/inode.c
> >@@ -344,7 +344,7 @@ void f2fs_evict_inode(struct inode *inode)
> > sb_start_intwrite(inode->i_sb);
> > set_inode_flag(fi, FI_NO_ALLOC);
> > i_size_write(inode, 0);
> >-
> >+retry:
> > if (F2FS_HAS_BLOCKS(inode))
> > err = f2fs_truncate(inode, true);
> >
> >@@ -374,6 +374,11 @@ no_delete:
> >
> > if (err && err != -ENOENT) {
> > if (!exist_written_data(sbi, inode->i_ino, ORPHAN_INO)) {
> >+ /* give more chances, if ENOMEM case */
> >+ if (err == -ENOMEM) {
> >+ err = 0;
> >+ goto retry;
> >+ }
> > /*
> > * get here because we failed to release resource
> > * of inode previously, reminder our user to run fsck
> >
>