aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Patlasov <MPatlasov@parallels.com>2013-10-02 07:01:07 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2013-11-05 04:11:26 -0500
commitf6011081f5e290756bd90fe96f1e86d3eac76f77 (patch)
tree12c724c1dcb89f2618ff39457941593f10749a96
parentcb2ffb26e67ef89c44f46e971440cda2f83ae236 (diff)
fuse: writepages: roll back changes if request not found
fuse_writepage_in_flight() returns false if it fails to find request with given index in fi->writepages. Then the caller proceeds with populating data->orig_pages[] and incrementing req->num_pages. Hence, fuse_writepage_in_flight() must revert changes it made in request before returning false. Signed-off-by: Maxim Patlasov <MPatlasov@parallels.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
-rw-r--r--fs/fuse/file.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 135360e2b9e5..077b03844998 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1649,7 +1649,6 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req,
1649 1649
1650 spin_lock(&fc->lock); 1650 spin_lock(&fc->lock);
1651 list_del(&new_req->writepages_entry); 1651 list_del(&new_req->writepages_entry);
1652 new_req->num_pages = 1;
1653 list_for_each_entry(old_req, &fi->writepages, writepages_entry) { 1652 list_for_each_entry(old_req, &fi->writepages, writepages_entry) {
1654 BUG_ON(old_req->inode != new_req->inode); 1653 BUG_ON(old_req->inode != new_req->inode);
1655 curr_index = old_req->misc.write.in.offset >> PAGE_CACHE_SHIFT; 1654 curr_index = old_req->misc.write.in.offset >> PAGE_CACHE_SHIFT;
@@ -1659,9 +1658,12 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req,
1659 break; 1658 break;
1660 } 1659 }
1661 } 1660 }
1662 if (!found) 1661 if (!found) {
1662 list_add(&new_req->writepages_entry, &fi->writepages);
1663 goto out_unlock; 1663 goto out_unlock;
1664 }
1664 1665
1666 new_req->num_pages = 1;
1665 for (tmp = old_req; tmp != NULL; tmp = tmp->misc.write.next) { 1667 for (tmp = old_req; tmp != NULL; tmp = tmp->misc.write.next) {
1666 BUG_ON(tmp->inode != new_req->inode); 1668 BUG_ON(tmp->inode != new_req->inode);
1667 curr_index = tmp->misc.write.in.offset >> PAGE_CACHE_SHIFT; 1669 curr_index = tmp->misc.write.in.offset >> PAGE_CACHE_SHIFT;