aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-01-31 01:36:04 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-02-11 17:15:01 -0500
commitd4686d56ec912d55fd8a9d6d509de50de24e90ab (patch)
treef79a5df1353af58c671c58a4eaa7339d7ba80461 /fs/f2fs
parent369a708c2a6557fabd409cf17a03db271c54931a (diff)
f2fs: avoid balanc_fs during evict_inode
1. Background Previously, if f2fs tries to move data blocks of an *evicting* inode during the cleaning process, it stops the process incompletely and then restarts the whole process, since it needs a locked inode to grab victim data pages in its address space. In order to get a locked inode, iget_locked() by f2fs_iget() is normally used, but, it waits if the inode is on freeing. So, here is a deadlock scenario. 1. f2fs_evict_inode() <- inode "A" 2. f2fs_balance_fs() 3. f2fs_gc() 4. gc_data_segment() 5. f2fs_iget() <- inode "A" too! If step #1 and #5 treat a same inode "A", step #5 would fall into deadlock since the inode "A" is on freeing. In order to resolve this, f2fs_iget_nowait() which skips __wait_on_freeing_inode() was introduced in step #5, and stops f2fs_gc() to complete f2fs_evict_inode(). 1. f2fs_evict_inode() <- inode "A" 2. f2fs_balance_fs() 3. f2fs_gc() 4. gc_data_segment() 5. f2fs_iget_nowait() <- inode "A", then stop f2fs_gc() w/ -ENOENT 2. Problem and Solution In the above scenario, however, f2fs cannot finish f2fs_evict_inode() only if: o there are not enough free sections, and o f2fs_gc() tries to move data blocks of the *evicting* inode repeatedly. So, the final solution is to use f2fs_iget() and remove f2fs_balance_fs() in f2fs_evict_inode(). The f2fs_evict_inode() actually truncates all the data and node blocks, which means that it doesn't produce any dirty node pages accordingly. So, we don't need to do f2fs_balance_fs() in practical. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/file.c3
-rw-r--r--fs/f2fs/gc.c2
-rw-r--r--fs/f2fs/inode.c33
-rw-r--r--fs/f2fs/recovery.c2
5 files changed, 3 insertions, 38 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 975cb44851ab..5022a7d7f7ca 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -847,7 +847,6 @@ long f2fs_ioctl(struct file *, unsigned int, unsigned long);
847 * inode.c 847 * inode.c
848 */ 848 */
849void f2fs_set_inode_flags(struct inode *); 849void f2fs_set_inode_flags(struct inode *);
850struct inode *f2fs_iget_nowait(struct super_block *, unsigned long);
851struct inode *f2fs_iget(struct super_block *, unsigned long); 850struct inode *f2fs_iget(struct super_block *, unsigned long);
852void update_inode(struct inode *, struct page *); 851void update_inode(struct inode *, struct page *);
853int f2fs_write_inode(struct inode *, struct writeback_control *); 852int f2fs_write_inode(struct inode *, struct writeback_control *);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 6cdab2c64fc6..3efa4739b00c 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -298,8 +298,6 @@ void f2fs_truncate(struct inode *inode)
298 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 298 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
299 mark_inode_dirty(inode); 299 mark_inode_dirty(inode);
300 } 300 }
301
302 f2fs_balance_fs(F2FS_SB(inode->i_sb));
303} 301}
304 302
305static int f2fs_getattr(struct vfsmount *mnt, 303static int f2fs_getattr(struct vfsmount *mnt,
@@ -356,6 +354,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
356 attr->ia_size != i_size_read(inode)) { 354 attr->ia_size != i_size_read(inode)) {
357 truncate_setsize(inode, attr->ia_size); 355 truncate_setsize(inode, attr->ia_size);
358 f2fs_truncate(inode); 356 f2fs_truncate(inode);
357 f2fs_balance_fs(F2FS_SB(inode->i_sb));
359 } 358 }
360 359
361 __setattr_copy(inode, attr); 360 __setattr_copy(inode, attr);
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index fb03be68cb20..375e69e2c6f1 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -579,7 +579,7 @@ next_step:
579 ofs_in_node = le16_to_cpu(entry->ofs_in_node); 579 ofs_in_node = le16_to_cpu(entry->ofs_in_node);
580 580
581 if (phase == 2) { 581 if (phase == 2) {
582 inode = f2fs_iget_nowait(sb, dni.ino); 582 inode = f2fs_iget(sb, dni.ino);
583 if (IS_ERR(inode)) 583 if (IS_ERR(inode))
584 continue; 584 continue;
585 585
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 62433c63e2db..ddae412d30c8 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -16,11 +16,6 @@
16#include "f2fs.h" 16#include "f2fs.h"
17#include "node.h" 17#include "node.h"
18 18
19struct f2fs_iget_args {
20 u64 ino;
21 int on_free;
22};
23
24void f2fs_set_inode_flags(struct inode *inode) 19void f2fs_set_inode_flags(struct inode *inode)
25{ 20{
26 unsigned int flags = F2FS_I(inode)->i_flags; 21 unsigned int flags = F2FS_I(inode)->i_flags;
@@ -40,34 +35,6 @@ void f2fs_set_inode_flags(struct inode *inode)
40 inode->i_flags |= S_DIRSYNC; 35 inode->i_flags |= S_DIRSYNC;
41} 36}
42 37
43static int f2fs_iget_test(struct inode *inode, void *data)
44{
45 struct f2fs_iget_args *args = data;
46
47 if (inode->i_ino != args->ino)
48 return 0;
49 if (inode->i_state & (I_FREEING | I_WILL_FREE)) {
50 args->on_free = 1;
51 return 0;
52 }
53 return 1;
54}
55
56struct inode *f2fs_iget_nowait(struct super_block *sb, unsigned long ino)
57{
58 struct f2fs_iget_args args = {
59 .ino = ino,
60 .on_free = 0
61 };
62 struct inode *inode = ilookup5(sb, ino, f2fs_iget_test, &args);
63
64 if (inode)
65 return inode;
66 if (!args.on_free)
67 return f2fs_iget(sb, ino);
68 return ERR_PTR(-ENOENT);
69}
70
71static int do_read_inode(struct inode *inode) 38static int do_read_inode(struct inode *inode)
72{ 39{
73 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 40 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index f42e4060b399..e2a3e1a8eae9 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -226,7 +226,7 @@ static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
226 f2fs_put_page(node_page, 1); 226 f2fs_put_page(node_page, 1);
227 227
228 /* Deallocate previous index in the node page */ 228 /* Deallocate previous index in the node page */
229 inode = f2fs_iget_nowait(sbi->sb, ino); 229 inode = f2fs_iget(sbi->sb, ino);
230 if (IS_ERR(inode)) 230 if (IS_ERR(inode))
231 return; 231 return;
232 232