Commit 1d7ea732 authored by Alexander Zarochentsev's avatar Alexander Zarochentsev Committed by Greg Kroah-Hartman
Browse files

[PATCH] fuse: fix error case in fuse_readpages



Don't let fuse_readpages leave the @pages list not empty when exiting
on error.

[akpm@osdl.org: kernel-doc fixes]
Signed-off-by: default avatarAlexander Zarochentsev <zam@namesys.com>
Signed-off-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9b41ea72
...@@ -395,14 +395,16 @@ static int fuse_readpages(struct file *file, struct address_space *mapping, ...@@ -395,14 +395,16 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
struct fuse_readpages_data data; struct fuse_readpages_data data;
int err; int err;
err = -EIO;
if (is_bad_inode(inode)) if (is_bad_inode(inode))
return -EIO; goto clean_pages_up;
data.file = file; data.file = file;
data.inode = inode; data.inode = inode;
data.req = fuse_get_req(fc); data.req = fuse_get_req(fc);
err = PTR_ERR(data.req);
if (IS_ERR(data.req)) if (IS_ERR(data.req))
return PTR_ERR(data.req); goto clean_pages_up;
err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data); err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data);
if (!err) { if (!err) {
...@@ -412,6 +414,10 @@ static int fuse_readpages(struct file *file, struct address_space *mapping, ...@@ -412,6 +414,10 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
fuse_put_request(fc, data.req); fuse_put_request(fc, data.req);
} }
return err; return err;
clean_pages_up:
put_pages_list(pages);
return err;
} }
static size_t fuse_send_write(struct fuse_req *req, struct file *file, static size_t fuse_send_write(struct fuse_req *req, struct file *file,
......
...@@ -336,6 +336,7 @@ static inline void init_page_count(struct page *page) ...@@ -336,6 +336,7 @@ static inline void init_page_count(struct page *page)
} }
void put_page(struct page *page); void put_page(struct page *page);
void put_pages_list(struct list_head *pages);
void split_page(struct page *page, unsigned int order); void split_page(struct page *page, unsigned int order);
......
...@@ -54,6 +54,26 @@ void put_page(struct page *page) ...@@ -54,6 +54,26 @@ void put_page(struct page *page)
} }
EXPORT_SYMBOL(put_page); EXPORT_SYMBOL(put_page);
/**
* put_pages_list(): release a list of pages
*
* Release a list of pages which are strung together on page.lru. Currently
* used by read_cache_pages() and related error recovery code.
*
* @pages: list of pages threaded on page->lru
*/
void put_pages_list(struct list_head *pages)
{
while (!list_empty(pages)) {
struct page *victim;
victim = list_entry(pages->prev, struct page, lru);
list_del(&victim->lru);
page_cache_release(victim);
}
}
EXPORT_SYMBOL(put_pages_list);
/* /*
* Writeback is about to end against a page which has been marked for immediate * Writeback is about to end against a page which has been marked for immediate
* reclaim. If it still appears to be reclaimable, move it to the tail of the * reclaim. If it still appears to be reclaimable, move it to the tail of the
......
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