diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-05-21 19:02:02 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-05-28 02:03:04 -0400 |
commit | b292dcab068e141d8a820b77cbcc88d98c610eb4 (patch) | |
tree | e71ecb2992458d1b29d7e628c46cc8f9788b9966 /fs/f2fs | |
parent | b638f0c4b8fca9d2f82805a2d6601b09283e0d32 (diff) |
f2fs: reuse the locked dnode page and its inode
This patch fixes the following deadlock bug during the recovery.
INFO: task mount:1322 blocked for more than 120 seconds.
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
mount D ffffffff81125870 0 1322 1266 0x00000000
ffff8801207e39d8 0000000000000046 ffff88012ab1dee0 0000000000000046
ffff8801207e3a08 ffff880115903f40 ffff8801207e3fd8 ffff8801207e3fd8
ffff8801207e3fd8 ffff880115903f40 ffff8801207e39d8 ffff88012fc94520
Call Trace:
[<ffffffff81125870>] ? __lock_page+0x70/0x70
[<ffffffff816a92d9>] schedule+0x29/0x70
[<ffffffff816a93af>] io_schedule+0x8f/0xd0
[<ffffffff8112587e>] sleep_on_page+0xe/0x20
[<ffffffff816a649a>] __wait_on_bit_lock+0x5a/0xc0
[<ffffffff81125867>] __lock_page+0x67/0x70
[<ffffffff8106c7b0>] ? autoremove_wake_function+0x40/0x40
[<ffffffff81126857>] find_lock_page+0x67/0x80
[<ffffffff8112698f>] find_or_create_page+0x3f/0xb0
[<ffffffffa03901a8>] ? sync_inode_page+0xa8/0xd0 [f2fs]
[<ffffffffa038fdf7>] get_node_page+0x67/0x180 [f2fs]
[<ffffffffa039818b>] recover_fsync_data+0xacb/0xff0 [f2fs]
[<ffffffff816aaa1e>] ? _raw_spin_unlock+0x3e/0x40
[<ffffffffa0389634>] f2fs_fill_super+0x7d4/0x850 [f2fs]
[<ffffffff81184cf9>] mount_bdev+0x1c9/0x210
[<ffffffffa0388e60>] ? validate_superblock+0x180/0x180 [f2fs]
[<ffffffffa0387635>] f2fs_mount+0x15/0x20 [f2fs]
[<ffffffff81185a13>] mount_fs+0x43/0x1b0
[<ffffffff81145ba0>] ? __alloc_percpu+0x10/0x20
[<ffffffff811a0796>] vfs_kern_mount+0x76/0x120
[<ffffffff811a2cb7>] do_mount+0x237/0xa10
[<ffffffff81140b9b>] ? strndup_user+0x5b/0x80
[<ffffffff811a3520>] SyS_mount+0x90/0xe0
[<ffffffff816b3502>] system_call_fastpath+0x16/0x1b
The bug is triggered when check_index_in_prev_nodes tries to get the direct
node page by calling get_node_page.
At this point, if the direct node page is already locked by get_dnode_of_data,
its caller, we got a deadlock condition.
This patch adds additional condition check for the reuse of locked direct node
pages prior to the get_node_page call.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/f2fs.h | 1 | ||||
-rw-r--r-- | fs/f2fs/file.c | 2 | ||||
-rw-r--r-- | fs/f2fs/recovery.c | 26 |
3 files changed, 23 insertions, 6 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 6594ce15a7bb..7b050298d6c9 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -900,6 +900,7 @@ void truncate_data_blocks(struct dnode_of_data *); | |||
900 | void f2fs_truncate(struct inode *); | 900 | void f2fs_truncate(struct inode *); |
901 | int f2fs_setattr(struct dentry *, struct iattr *); | 901 | int f2fs_setattr(struct dentry *, struct iattr *); |
902 | int truncate_hole(struct inode *, pgoff_t, pgoff_t); | 902 | int truncate_hole(struct inode *, pgoff_t, pgoff_t); |
903 | int truncate_data_blocks_range(struct dnode_of_data *, int); | ||
903 | long f2fs_ioctl(struct file *, unsigned int, unsigned long); | 904 | long f2fs_ioctl(struct file *, unsigned int, unsigned long); |
904 | long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); | 905 | long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); |
905 | 906 | ||
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 316bcfe80448..deefd258b847 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -168,7 +168,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int truncate_data_blocks_range(struct dnode_of_data *dn, int count) | 171 | int truncate_data_blocks_range(struct dnode_of_data *dn, int count) |
172 | { | 172 | { |
173 | int nr_free = 0, ofs = dn->ofs_in_node; | 173 | int nr_free = 0, ofs = dn->ofs_in_node; |
174 | struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); | 174 | struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); |
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 5148d90049b0..eceb6652532d 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c | |||
@@ -189,14 +189,14 @@ static void destroy_fsync_dnodes(struct f2fs_sb_info *sbi, | |||
189 | } | 189 | } |
190 | 190 | ||
191 | static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi, | 191 | static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi, |
192 | block_t blkaddr) | 192 | block_t blkaddr, struct dnode_of_data *dn) |
193 | { | 193 | { |
194 | struct seg_entry *sentry; | 194 | struct seg_entry *sentry; |
195 | unsigned int segno = GET_SEGNO(sbi, blkaddr); | 195 | unsigned int segno = GET_SEGNO(sbi, blkaddr); |
196 | unsigned short blkoff = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) & | 196 | unsigned short blkoff = GET_SEGOFF_FROM_SEG0(sbi, blkaddr) & |
197 | (sbi->blocks_per_seg - 1); | 197 | (sbi->blocks_per_seg - 1); |
198 | struct f2fs_summary sum; | 198 | struct f2fs_summary sum; |
199 | nid_t ino; | 199 | nid_t ino, nid; |
200 | void *kaddr; | 200 | void *kaddr; |
201 | struct inode *inode; | 201 | struct inode *inode; |
202 | struct page *node_page; | 202 | struct page *node_page; |
@@ -224,10 +224,26 @@ static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi, | |||
224 | f2fs_put_page(sum_page, 1); | 224 | f2fs_put_page(sum_page, 1); |
225 | } | 225 | } |
226 | 226 | ||
227 | /* Use the locked dnode page and inode */ | ||
228 | nid = le32_to_cpu(sum.nid); | ||
229 | if (dn->inode->i_ino == nid) { | ||
230 | struct dnode_of_data tdn = *dn; | ||
231 | tdn.nid = nid; | ||
232 | tdn.node_page = dn->inode_page; | ||
233 | tdn.ofs_in_node = sum.ofs_in_node; | ||
234 | truncate_data_blocks_range(&tdn, 1); | ||
235 | return; | ||
236 | } else if (dn->nid == nid) { | ||
237 | struct dnode_of_data tdn = *dn; | ||
238 | tdn.ofs_in_node = sum.ofs_in_node; | ||
239 | truncate_data_blocks_range(&tdn, 1); | ||
240 | return; | ||
241 | } | ||
242 | |||
227 | /* Get the node page */ | 243 | /* Get the node page */ |
228 | node_page = get_node_page(sbi, le32_to_cpu(sum.nid)); | 244 | node_page = get_node_page(sbi, nid); |
229 | bidx = start_bidx_of_node(ofs_of_node(node_page)) + | 245 | bidx = start_bidx_of_node(ofs_of_node(node_page)) + |
230 | le16_to_cpu(sum.ofs_in_node); | 246 | le16_to_cpu(sum.ofs_in_node); |
231 | ino = ino_of_node(node_page); | 247 | ino = ino_of_node(node_page); |
232 | f2fs_put_page(node_page, 1); | 248 | f2fs_put_page(node_page, 1); |
233 | 249 | ||
@@ -285,7 +301,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, | |||
285 | } | 301 | } |
286 | 302 | ||
287 | /* Check the previous node page having this index */ | 303 | /* Check the previous node page having this index */ |
288 | check_index_in_prev_nodes(sbi, dest); | 304 | check_index_in_prev_nodes(sbi, dest, &dn); |
289 | 305 | ||
290 | set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version); | 306 | set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version); |
291 | 307 | ||