Commit 86531d6b authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: callers take care of the page from bio error

This patch changes for a caller to handle the page after its bio gets an error.
Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 727edac5
...@@ -69,8 +69,10 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) ...@@ -69,8 +69,10 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
fio.page = page; fio.page = page;
if (f2fs_submit_page_bio(&fio)) if (f2fs_submit_page_bio(&fio)) {
f2fs_put_page(page, 1);
goto repeat; goto repeat;
}
lock_page(page); lock_page(page);
if (unlikely(page->mapping != mapping)) { if (unlikely(page->mapping != mapping)) {
......
...@@ -156,7 +156,6 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) ...@@ -156,7 +156,6 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) { if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
bio_put(bio); bio_put(bio);
f2fs_put_page(page, 1);
return -EFAULT; return -EFAULT;
} }
...@@ -292,15 +291,13 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index, int rw) ...@@ -292,15 +291,13 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index, int rw)
set_new_dnode(&dn, inode, NULL, NULL, 0); set_new_dnode(&dn, inode, NULL, NULL, 0);
err = get_dnode_of_data(&dn, index, LOOKUP_NODE); err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
if (err) { if (err)
f2fs_put_page(page, 1); goto put_err;
return ERR_PTR(err);
}
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);
if (unlikely(dn.data_blkaddr == NULL_ADDR)) { if (unlikely(dn.data_blkaddr == NULL_ADDR)) {
f2fs_put_page(page, 1); err = -ENOENT;
return ERR_PTR(-ENOENT); goto put_err;
} }
got_it: got_it:
if (PageUptodate(page)) { if (PageUptodate(page)) {
...@@ -325,8 +322,12 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index, int rw) ...@@ -325,8 +322,12 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index, int rw)
fio.page = page; fio.page = page;
err = f2fs_submit_page_bio(&fio); err = f2fs_submit_page_bio(&fio);
if (err) if (err)
return ERR_PTR(err); goto put_err;
return page; return page;
put_err:
f2fs_put_page(page, 1);
return ERR_PTR(err);
} }
struct page *find_data_page(struct inode *inode, pgoff_t index) struct page *find_data_page(struct inode *inode, pgoff_t index)
...@@ -1322,7 +1323,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1322,7 +1323,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
{ {
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct page *page, *ipage; struct page *page = NULL;
struct page *ipage;
pgoff_t index = ((unsigned long long) pos) >> PAGE_CACHE_SHIFT; pgoff_t index = ((unsigned long long) pos) >> PAGE_CACHE_SHIFT;
struct dnode_of_data dn; struct dnode_of_data dn;
int err = 0; int err = 0;
...@@ -1412,7 +1414,6 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1412,7 +1414,6 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
lock_page(page); lock_page(page);
if (unlikely(!PageUptodate(page))) { if (unlikely(!PageUptodate(page))) {
f2fs_put_page(page, 1);
err = -EIO; err = -EIO;
goto fail; goto fail;
} }
...@@ -1424,12 +1425,10 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1424,12 +1425,10 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
/* avoid symlink page */ /* avoid symlink page */
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) { if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) {
err = f2fs_decrypt_one(inode, page); err = f2fs_decrypt_one(inode, page);
if (err) { if (err)
f2fs_put_page(page, 1);
goto fail; goto fail;
} }
} }
}
out_update: out_update:
SetPageUptodate(page); SetPageUptodate(page);
out_clear: out_clear:
...@@ -1440,8 +1439,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1440,8 +1439,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
f2fs_put_dnode(&dn); f2fs_put_dnode(&dn);
unlock_fail: unlock_fail:
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
f2fs_put_page(page, 1);
fail: fail:
f2fs_put_page(page, 1);
f2fs_write_failed(mapping, pos + len); f2fs_write_failed(mapping, pos + len);
return err; return err;
} }
......
...@@ -991,8 +991,7 @@ struct page *new_node_page(struct dnode_of_data *dn, ...@@ -991,8 +991,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
/* /*
* Caller should do after getting the following values. * Caller should do after getting the following values.
* 0: f2fs_put_page(page, 0) * 0: f2fs_put_page(page, 0)
* LOCKED_PAGE: f2fs_put_page(page, 1) * LOCKED_PAGE or error: f2fs_put_page(page, 1)
* error: nothing
*/ */
static int read_node_page(struct page *page, int rw) static int read_node_page(struct page *page, int rw)
{ {
...@@ -1010,7 +1009,6 @@ static int read_node_page(struct page *page, int rw) ...@@ -1010,7 +1009,6 @@ static int read_node_page(struct page *page, int rw)
if (unlikely(ni.blk_addr == NULL_ADDR)) { if (unlikely(ni.blk_addr == NULL_ADDR)) {
ClearPageUptodate(page); ClearPageUptodate(page);
f2fs_put_page(page, 1);
return -ENOENT; return -ENOENT;
} }
...@@ -1041,10 +1039,7 @@ void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid) ...@@ -1041,10 +1039,7 @@ void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
return; return;
err = read_node_page(apage, READA); err = read_node_page(apage, READA);
if (err == 0) f2fs_put_page(apage, err ? 1 : 0);
f2fs_put_page(apage, 0);
else if (err == LOCKED_PAGE)
f2fs_put_page(apage, 1);
} }
struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
...@@ -1057,10 +1052,12 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) ...@@ -1057,10 +1052,12 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = read_node_page(page, READ_SYNC); err = read_node_page(page, READ_SYNC);
if (err < 0) if (err < 0) {
f2fs_put_page(page, 1);
return ERR_PTR(err); return ERR_PTR(err);
else if (err != LOCKED_PAGE) } else if (err != LOCKED_PAGE) {
lock_page(page); lock_page(page);
}
if (unlikely(!PageUptodate(page) || nid != nid_of_node(page))) { if (unlikely(!PageUptodate(page) || nid != nid_of_node(page))) {
ClearPageUptodate(page); ClearPageUptodate(page);
...@@ -1096,10 +1093,12 @@ struct page *get_node_page_ra(struct page *parent, int start) ...@@ -1096,10 +1093,12 @@ struct page *get_node_page_ra(struct page *parent, int start)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = read_node_page(page, READ_SYNC); err = read_node_page(page, READ_SYNC);
if (err < 0) if (err < 0) {
f2fs_put_page(page, 1);
return ERR_PTR(err); return ERR_PTR(err);
else if (err == LOCKED_PAGE) } else if (err == LOCKED_PAGE) {
goto page_hit; goto page_hit;
}
blk_start_plug(&plug); blk_start_plug(&plug);
......
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