Merge tag 'mm-nonmm-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/kernel/linux-starfive.git] / fs / isofs / compress.c
index b466172..c4da3f6 100644 (file)
@@ -67,8 +67,7 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
                for ( i = 0 ; i < pcount ; i++ ) {
                        if (!pages[i])
                                continue;
-                       memset(page_address(pages[i]), 0, PAGE_SIZE);
-                       flush_dcache_page(pages[i]);
+                       memzero_page(pages[i], 0, PAGE_SIZE);
                        SetPageUptodate(pages[i]);
                }
                return ((loff_t)pcount) << PAGE_SHIFT;
@@ -82,7 +81,7 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
                return 0;
        }
        haveblocks = isofs_get_blocks(inode, blocknum, bhs, needblocks);
-       ll_rw_block(REQ_OP_READ, haveblocks, bhs);
+       bh_read_batch(haveblocks, bhs);
 
        curbh = 0;
        curpage = 0;
@@ -120,7 +119,7 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
               zerr != Z_STREAM_END) {
                if (!stream.avail_out) {
                        if (pages[curpage]) {
-                               stream.next_out = page_address(pages[curpage])
+                               stream.next_out = kmap_local_page(pages[curpage])
                                                + poffset;
                                stream.avail_out = PAGE_SIZE - poffset;
                                poffset = 0;
@@ -176,6 +175,10 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
                                flush_dcache_page(pages[curpage]);
                                SetPageUptodate(pages[curpage]);
                        }
+                       if (stream.next_out != (unsigned char *)zisofs_sink_page) {
+                               kunmap_local(stream.next_out);
+                               stream.next_out = NULL;
+                       }
                        curpage++;
                }
                if (!stream.avail_in)
@@ -183,6 +186,8 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
        }
 inflate_out:
        zlib_inflateEnd(&stream);
+       if (stream.next_out && stream.next_out != (unsigned char *)zisofs_sink_page)
+               kunmap_local(stream.next_out);
 
 z_eio:
        mutex_unlock(&zisofs_zlib_lock);
@@ -283,9 +288,7 @@ static int zisofs_fill_pages(struct inode *inode, int full_page, int pcount,
        }
 
        if (poffset && *pages) {
-               memset(page_address(*pages) + poffset, 0,
-                      PAGE_SIZE - poffset);
-               flush_dcache_page(*pages);
+               memzero_page(*pages, poffset, PAGE_SIZE - poffset);
                SetPageUptodate(*pages);
        }
        return 0;
@@ -343,10 +346,8 @@ static int zisofs_read_folio(struct file *file, struct folio *folio)
        for (i = 0; i < pcount; i++, index++) {
                if (i != full_page)
                        pages[i] = grab_cache_page_nowait(mapping, index);
-               if (pages[i]) {
+               if (pages[i])
                        ClearPageError(pages[i]);
-                       kmap(pages[i]);
-               }
        }
 
        err = zisofs_fill_pages(inode, full_page, pcount, pages);
@@ -357,7 +358,6 @@ static int zisofs_read_folio(struct file *file, struct folio *folio)
                        flush_dcache_page(pages[i]);
                        if (i == full_page && err)
                                SetPageError(pages[i]);
-                       kunmap(pages[i]);
                        unlock_page(pages[i]);
                        if (i != full_page)
                                put_page(pages[i]);