f2fs: handle error cases in commit_inmem_pages
This patch adds to handle error cases in commit_inmem_pages. If an error occurs, it stops to write the pages and return the error right away. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
a6d494b6d8
commit
edb27deea7
|
@ -1697,7 +1697,7 @@ void destroy_node_manager_caches(void);
|
||||||
* segment.c
|
* segment.c
|
||||||
*/
|
*/
|
||||||
void register_inmem_page(struct inode *, struct page *);
|
void register_inmem_page(struct inode *, struct page *);
|
||||||
void commit_inmem_pages(struct inode *, bool);
|
int commit_inmem_pages(struct inode *, bool);
|
||||||
void f2fs_balance_fs(struct f2fs_sb_info *);
|
void f2fs_balance_fs(struct f2fs_sb_info *);
|
||||||
void f2fs_balance_fs_bg(struct f2fs_sb_info *);
|
void f2fs_balance_fs_bg(struct f2fs_sb_info *);
|
||||||
int f2fs_issue_flush(struct f2fs_sb_info *);
|
int f2fs_issue_flush(struct f2fs_sb_info *);
|
||||||
|
|
|
@ -1358,10 +1358,13 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
|
||||||
|
|
||||||
if (f2fs_is_atomic_file(inode)) {
|
if (f2fs_is_atomic_file(inode)) {
|
||||||
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
|
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
|
||||||
commit_inmem_pages(inode, false);
|
ret = commit_inmem_pages(inode, false);
|
||||||
|
if (ret)
|
||||||
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = f2fs_sync_file(filp, 0, LLONG_MAX, 0);
|
ret = f2fs_sync_file(filp, 0, LLONG_MAX, 0);
|
||||||
|
err_out:
|
||||||
mnt_drop_write_file(filp);
|
mnt_drop_write_file(filp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1418,7 +1421,7 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp)
|
||||||
|
|
||||||
if (f2fs_is_atomic_file(inode)) {
|
if (f2fs_is_atomic_file(inode)) {
|
||||||
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
|
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
|
||||||
commit_inmem_pages(inode, false);
|
commit_inmem_pages(inode, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f2fs_is_volatile_file(inode))
|
if (f2fs_is_volatile_file(inode))
|
||||||
|
|
|
@ -227,7 +227,7 @@ retry:
|
||||||
trace_f2fs_register_inmem_page(page, INMEM);
|
trace_f2fs_register_inmem_page(page, INMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void commit_inmem_pages(struct inode *inode, bool abort)
|
int commit_inmem_pages(struct inode *inode, bool abort)
|
||||||
{
|
{
|
||||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
||||||
struct f2fs_inode_info *fi = F2FS_I(inode);
|
struct f2fs_inode_info *fi = F2FS_I(inode);
|
||||||
|
@ -239,6 +239,7 @@ void commit_inmem_pages(struct inode *inode, bool abort)
|
||||||
.rw = WRITE_SYNC | REQ_PRIO,
|
.rw = WRITE_SYNC | REQ_PRIO,
|
||||||
.encrypted_page = NULL,
|
.encrypted_page = NULL,
|
||||||
};
|
};
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The abort is true only when f2fs_evict_inode is called.
|
* The abort is true only when f2fs_evict_inode is called.
|
||||||
|
@ -263,8 +264,12 @@ void commit_inmem_pages(struct inode *inode, bool abort)
|
||||||
inode_dec_dirty_pages(inode);
|
inode_dec_dirty_pages(inode);
|
||||||
trace_f2fs_commit_inmem_page(cur->page, INMEM);
|
trace_f2fs_commit_inmem_page(cur->page, INMEM);
|
||||||
fio.page = cur->page;
|
fio.page = cur->page;
|
||||||
do_write_data_page(&fio);
|
err = do_write_data_page(&fio);
|
||||||
submit_bio = true;
|
submit_bio = true;
|
||||||
|
if (err) {
|
||||||
|
unlock_page(cur->page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
f2fs_put_page(cur->page, 1);
|
f2fs_put_page(cur->page, 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -283,6 +288,7 @@ void commit_inmem_pages(struct inode *inode, bool abort)
|
||||||
if (submit_bio)
|
if (submit_bio)
|
||||||
f2fs_submit_merged_bio(sbi, DATA, WRITE);
|
f2fs_submit_merged_bio(sbi, DATA, WRITE);
|
||||||
}
|
}
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue