Commit 38f91ca8 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: flush pending bios right away when error occurs

Given errors, this patch flushes pending bios as soon as possible.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 975756c4
...@@ -26,6 +26,14 @@ ...@@ -26,6 +26,14 @@
static struct kmem_cache *ino_entry_slab; static struct kmem_cache *ino_entry_slab;
struct kmem_cache *inode_entry_slab; struct kmem_cache *inode_entry_slab;
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
{
set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
sbi->sb->s_flags |= MS_RDONLY;
if (!end_io)
f2fs_flush_merged_bios(sbi);
}
/* /*
* We guarantee no failure on the returned page. * We guarantee no failure on the returned page.
*/ */
...@@ -91,7 +99,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index, ...@@ -91,7 +99,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
* meta page. * meta page.
*/ */
if (unlikely(!PageUptodate(page))) if (unlikely(!PageUptodate(page)))
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, false);
out: out:
return page; return page;
} }
......
...@@ -68,7 +68,7 @@ static void f2fs_write_end_io(struct bio *bio) ...@@ -68,7 +68,7 @@ static void f2fs_write_end_io(struct bio *bio)
if (unlikely(bio->bi_error)) { if (unlikely(bio->bi_error)) {
set_bit(AS_EIO, &page->mapping->flags); set_bit(AS_EIO, &page->mapping->flags);
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, true);
} }
end_page_writeback(page); end_page_writeback(page);
} }
......
...@@ -1698,12 +1698,6 @@ static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi) ...@@ -1698,12 +1698,6 @@ static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi)
return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG); return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
} }
static inline void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi)
{
set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
sbi->sb->s_flags |= MS_RDONLY;
}
static inline bool is_dot_dotdot(const struct qstr *str) static inline bool is_dot_dotdot(const struct qstr *str)
{ {
if (str->len == 1 && str->name[0] == '.') if (str->len == 1 && str->name[0] == '.')
...@@ -1937,6 +1931,7 @@ void destroy_segment_manager_caches(void); ...@@ -1937,6 +1931,7 @@ void destroy_segment_manager_caches(void);
/* /*
* checkpoint.c * checkpoint.c
*/ */
void f2fs_stop_checkpoint(struct f2fs_sb_info *, bool);
struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t); struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
struct page *get_tmp_page(struct f2fs_sb_info *, pgoff_t); struct page *get_tmp_page(struct f2fs_sb_info *, pgoff_t);
......
...@@ -1571,21 +1571,21 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) ...@@ -1571,21 +1571,21 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
case F2FS_GOING_DOWN_FULLSYNC: case F2FS_GOING_DOWN_FULLSYNC:
sb = freeze_bdev(sb->s_bdev); sb = freeze_bdev(sb->s_bdev);
if (sb && !IS_ERR(sb)) { if (sb && !IS_ERR(sb)) {
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, false);
thaw_bdev(sb->s_bdev, sb); thaw_bdev(sb->s_bdev, sb);
} }
break; break;
case F2FS_GOING_DOWN_METASYNC: case F2FS_GOING_DOWN_METASYNC:
/* do checkpoint only */ /* do checkpoint only */
f2fs_sync_fs(sb, 1); f2fs_sync_fs(sb, 1);
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, false);
break; break;
case F2FS_GOING_DOWN_NOSYNC: case F2FS_GOING_DOWN_NOSYNC:
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, false);
break; break;
case F2FS_GOING_DOWN_METAFLUSH: case F2FS_GOING_DOWN_METAFLUSH:
sync_meta_pages(sbi, META, LONG_MAX); sync_meta_pages(sbi, META, LONG_MAX);
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, false);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
......
...@@ -283,7 +283,7 @@ int update_inode_page(struct inode *inode) ...@@ -283,7 +283,7 @@ int update_inode_page(struct inode *inode)
cond_resched(); cond_resched();
goto retry; goto retry;
} else if (err != -ENOENT) { } else if (err != -ENOENT) {
f2fs_stop_checkpoint(sbi); f2fs_stop_checkpoint(sbi, false);
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment