]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/squashfs/file_direct.c
x86/boot: Fix if_changed build flip/flop bug
[mirror_ubuntu-bionic-kernel.git] / fs / squashfs / file_direct.c
index cb485d8e0e91b1b2ff1cb9b0330339c51c15b8a4..80db1b86a27c66b1eb2105971685267171e52ce2 100644 (file)
 #include "page_actor.h"
 
 static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
-       int pages, struct page **page);
+       int pages, struct page **page, int bytes);
 
 /* Read separately compressed datablock directly into page cache */
-int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
+int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
+       int expected)
 
 {
        struct inode *inode = target_page->mapping->host;
@@ -83,7 +84,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
                 * using an intermediate buffer.
                 */
                res = squashfs_read_cache(target_page, block, bsize, pages,
-                                                               page);
+                                                       page, expected);
                if (res < 0)
                        goto mark_errored;
 
@@ -95,6 +96,11 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
        if (res < 0)
                goto mark_errored;
 
+       if (res != expected) {
+               res = -EIO;
+               goto mark_errored;
+       }
+
        /* Last page may have trailing bytes not filled */
        bytes = res % PAGE_SIZE;
        if (bytes) {
@@ -138,13 +144,12 @@ out:
 
 
 static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
-       int pages, struct page **page)
+       int pages, struct page **page, int bytes)
 {
        struct inode *i = target_page->mapping->host;
        struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
                                                 block, bsize);
-       int bytes = buffer->length, res = buffer->error, n, offset = 0;
-       void *pageaddr;
+       int res = buffer->error, n, offset = 0;
 
        if (res) {
                ERROR("Unable to read page, block %llx, size %x\n", block,
@@ -159,12 +164,7 @@ static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
                if (page[n] == NULL)
                        continue;
 
-               pageaddr = kmap_atomic(page[n]);
-               squashfs_copy_data(pageaddr, buffer, offset, avail);
-               memset(pageaddr + avail, 0, PAGE_SIZE - avail);
-               kunmap_atomic(pageaddr);
-               flush_dcache_page(page[n]);
-               SetPageUptodate(page[n]);
+               squashfs_fill_page(page[n], buffer, offset, avail);
                unlock_page(page[n]);
                if (page[n] != target_page)
                        put_page(page[n]);