ceph: properly release page upon error
authorTaesoo Kim <tsgatesv@gmail.com>
Fri, 20 Mar 2015 21:36:56 +0000 (17:36 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 20 Apr 2015 15:55:34 +0000 (18:55 +0300)
When ceph_update_writeable_page fails (including -EAGAIN), it
unlocks (w/ unlock_page) the page but does not 'release'
(w/ page_cache_release) properly.

Upon error, properly set *pagep to NULL, indicating an error.

Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
Signed-off-by: Yan, Zheng <zyan@redhat.com>
fs/ceph/addr.c

index fd5599d323620a2c5617ea5355e2e1320d6a0954..e723482c5f3737ea2dad53c016ca308e0735dbe5 100644 (file)
@@ -1146,6 +1146,10 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
                     inode, page, (int)pos, (int)len);
 
                r = ceph_update_writeable_page(file, pos, len, page);
+               if (r < 0)
+                       page_cache_release(page);
+               else
+                       *pagep = page;
        } while (r == -EAGAIN);
 
        return r;