2005-04-17 00:20:36 +02:00
|
|
|
/* -*- linux-c -*- ------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Copyright 2001 H. Peter Anvin - All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
|
|
|
|
* USA; either version 2 of the License, or (at your option) any later
|
|
|
|
* version; incorporated herein by reference.
|
|
|
|
*
|
|
|
|
* ----------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* linux/fs/isofs/compress.c
|
|
|
|
*
|
|
|
|
* Transparent decompression of files on an iso9660 filesystem
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
2016-11-01 14:40:13 +01:00
|
|
|
#include <linux/bio.h>
|
2005-04-26 03:32:12 +02:00
|
|
|
|
2018-04-11 02:02:29 +02:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/zlib.h>
|
|
|
|
|
2005-04-26 03:32:12 +02:00
|
|
|
#include "isofs.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
#include "zisofs.h"
|
|
|
|
|
|
|
|
/* This should probably be global. */
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
static char zisofs_sink_page[PAGE_SIZE];
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This contains the zlib memory allocation and the mutex for the
|
|
|
|
* allocation; this avoids failures at block-decompression time.
|
|
|
|
*/
|
|
|
|
static void *zisofs_zlib_workspace;
|
2007-10-17 08:26:10 +02:00
|
|
|
static DEFINE_MUTEX(zisofs_zlib_lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
2009-09-23 14:44:56 +02:00
|
|
|
* Read data of @inode from @block_start to @block_end and uncompress
|
|
|
|
* to one zisofs block. Store the data in the @pages array with @pcount
|
|
|
|
* entries. Start storing at offset @poffset of the first page.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
2009-09-23 14:44:56 +02:00
|
|
|
static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
|
|
|
|
loff_t block_end, int pcount,
|
|
|
|
struct page **pages, unsigned poffset,
|
|
|
|
int *errp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];
|
2009-09-23 14:44:56 +02:00
|
|
|
unsigned int bufsize = ISOFS_BUFFER_SIZE(inode);
|
|
|
|
unsigned int bufshift = ISOFS_BUFFER_BITS(inode);
|
|
|
|
unsigned int bufmask = bufsize - 1;
|
|
|
|
int i, block_size = block_end - block_start;
|
|
|
|
z_stream stream = { .total_out = 0,
|
|
|
|
.avail_in = 0,
|
|
|
|
.avail_out = 0, };
|
|
|
|
int zerr;
|
|
|
|
int needblocks = (block_size + (block_start & bufmask) + bufmask)
|
|
|
|
>> bufshift;
|
|
|
|
int haveblocks;
|
|
|
|
blkcnt_t blocknum;
|
2018-04-11 02:02:29 +02:00
|
|
|
struct buffer_head **bhs;
|
2009-09-23 14:44:56 +02:00
|
|
|
int curbh, curpage;
|
|
|
|
|
|
|
|
if (block_size > deflateBound(1UL << zisofs_block_shift)) {
|
|
|
|
*errp = -EIO;
|
2008-03-20 01:01:01 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
/* Empty block? */
|
|
|
|
if (block_size == 0) {
|
|
|
|
for ( i = 0 ; i < pcount ; i++ ) {
|
|
|
|
if (!pages[i])
|
|
|
|
continue;
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
memset(page_address(pages[i]), 0, PAGE_SIZE);
|
2009-09-23 14:44:56 +02:00
|
|
|
flush_dcache_page(pages[i]);
|
|
|
|
SetPageUptodate(pages[i]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
return ((loff_t)pcount) << PAGE_SHIFT;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
/* Because zlib is not thread-safe, do all the I/O at the top. */
|
|
|
|
blocknum = block_start >> bufshift;
|
2018-04-11 02:02:29 +02:00
|
|
|
bhs = kcalloc(needblocks + 1, sizeof(*bhs), GFP_KERNEL);
|
|
|
|
if (!bhs) {
|
|
|
|
*errp = -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
haveblocks = isofs_get_blocks(inode, blocknum, bhs, needblocks);
|
2016-06-05 21:31:44 +02:00
|
|
|
ll_rw_block(REQ_OP_READ, 0, haveblocks, bhs);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
curbh = 0;
|
|
|
|
curpage = 0;
|
|
|
|
/*
|
|
|
|
* First block is special since it may be fractional. We also wait for
|
|
|
|
* it before grabbing the zlib mutex; odds are that the subsequent
|
|
|
|
* blocks are going to come in in short order so we don't hold the zlib
|
|
|
|
* mutex longer than necessary.
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
if (!bhs[0])
|
|
|
|
goto b_eio;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
wait_on_buffer(bhs[0]);
|
|
|
|
if (!buffer_uptodate(bhs[0])) {
|
|
|
|
*errp = -EIO;
|
|
|
|
goto b_eio;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
stream.workspace = zisofs_zlib_workspace;
|
|
|
|
mutex_lock(&zisofs_zlib_lock);
|
2005-08-06 18:42:06 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
zerr = zlib_inflateInit(&stream);
|
|
|
|
if (zerr != Z_OK) {
|
|
|
|
if (zerr == Z_MEM_ERROR)
|
|
|
|
*errp = -ENOMEM;
|
|
|
|
else
|
|
|
|
*errp = -EIO;
|
|
|
|
printk(KERN_DEBUG "zisofs: zisofs_inflateInit returned %d\n",
|
|
|
|
zerr);
|
|
|
|
goto z_eio;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (curpage < pcount && curbh < haveblocks &&
|
|
|
|
zerr != Z_STREAM_END) {
|
|
|
|
if (!stream.avail_out) {
|
|
|
|
if (pages[curpage]) {
|
|
|
|
stream.next_out = page_address(pages[curpage])
|
|
|
|
+ poffset;
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
stream.avail_out = PAGE_SIZE - poffset;
|
2009-09-23 14:44:56 +02:00
|
|
|
poffset = 0;
|
|
|
|
} else {
|
|
|
|
stream.next_out = (void *)&zisofs_sink_page;
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
stream.avail_out = PAGE_SIZE;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
if (!stream.avail_in) {
|
|
|
|
wait_on_buffer(bhs[curbh]);
|
|
|
|
if (!buffer_uptodate(bhs[curbh])) {
|
|
|
|
*errp = -EIO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
stream.next_in = bhs[curbh]->b_data +
|
|
|
|
(block_start & bufmask);
|
|
|
|
stream.avail_in = min_t(unsigned, bufsize -
|
|
|
|
(block_start & bufmask),
|
|
|
|
block_size);
|
|
|
|
block_size -= stream.avail_in;
|
|
|
|
block_start = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
while (stream.avail_out && stream.avail_in) {
|
|
|
|
zerr = zlib_inflate(&stream, Z_SYNC_FLUSH);
|
|
|
|
if (zerr == Z_BUF_ERROR && stream.avail_in == 0)
|
|
|
|
break;
|
|
|
|
if (zerr == Z_STREAM_END)
|
|
|
|
break;
|
|
|
|
if (zerr != Z_OK) {
|
|
|
|
/* EOF, error, or trying to read beyond end of input */
|
|
|
|
if (zerr == Z_MEM_ERROR)
|
|
|
|
*errp = -ENOMEM;
|
|
|
|
else {
|
|
|
|
printk(KERN_DEBUG
|
|
|
|
"zisofs: zisofs_inflate returned"
|
|
|
|
" %d, inode = %lu,"
|
|
|
|
" page idx = %d, bh idx = %d,"
|
initramfs: support initramfs that is bigger than 2GiB
Now with 64bit bzImage and kexec tools, we support ramdisk that size is
bigger than 2g, as we could put it above 4G.
Found compressed initramfs image could not be decompressed properly. It
turns out that image length is int during decompress detection, and it
will become < 0 when length is more than 2G. Furthermore, during
decompressing len as int is used for inbuf count, that has problem too.
Change len to long, that should be ok as on 32 bit platform long is
32bits.
Tested with following compressed initramfs image as root with kexec.
gzip, bzip2, xz, lzma, lzop, lz4.
run time for populate_rootfs():
size name Nehalem-EX Westmere-EX Ivybridge-EX
9034400256 root_img : 26s 24s 30s
3561095057 root_img.lz4 : 28s 27s 27s
3459554629 root_img.lzo : 29s 29s 28s
3219399480 root_img.gz : 64s 62s 49s
2251594592 root_img.xz : 262s 260s 183s
2226366598 root_img.lzma: 386s 376s 277s
2901482513 root_img.bz2 : 635s 599s
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Rashika Kheria <rashika.kheria@gmail.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: P J P <ppandit@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: "Daniel M. Weeks" <dan@danweeks.net>
Cc: Alexandre Courbot <acourbot@nvidia.com>
Cc: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-08 23:23:14 +02:00
|
|
|
" avail_in = %ld,"
|
|
|
|
" avail_out = %ld\n",
|
2009-09-23 14:44:56 +02:00
|
|
|
zerr, inode->i_ino, curpage,
|
|
|
|
curbh, stream.avail_in,
|
|
|
|
stream.avail_out);
|
|
|
|
*errp = -EIO;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
goto inflate_out;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
if (!stream.avail_out) {
|
|
|
|
/* This page completed */
|
|
|
|
if (pages[curpage]) {
|
|
|
|
flush_dcache_page(pages[curpage]);
|
|
|
|
SetPageUptodate(pages[curpage]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
curpage++;
|
|
|
|
}
|
|
|
|
if (!stream.avail_in)
|
|
|
|
curbh++;
|
|
|
|
}
|
|
|
|
inflate_out:
|
|
|
|
zlib_inflateEnd(&stream);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
z_eio:
|
|
|
|
mutex_unlock(&zisofs_zlib_lock);
|
|
|
|
|
|
|
|
b_eio:
|
|
|
|
for (i = 0; i < haveblocks; i++)
|
|
|
|
brelse(bhs[i]);
|
2018-04-11 02:02:29 +02:00
|
|
|
kfree(bhs);
|
2009-09-23 14:44:56 +02:00
|
|
|
return stream.total_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Uncompress data so that pages[full_page] is fully uptodate and possibly
|
|
|
|
* fills in other pages if we have data for them.
|
|
|
|
*/
|
|
|
|
static int zisofs_fill_pages(struct inode *inode, int full_page, int pcount,
|
|
|
|
struct page **pages)
|
|
|
|
{
|
|
|
|
loff_t start_off, end_off;
|
|
|
|
loff_t block_start, block_end;
|
|
|
|
unsigned int header_size = ISOFS_I(inode)->i_format_parm[0];
|
|
|
|
unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];
|
|
|
|
unsigned int blockptr;
|
|
|
|
loff_t poffset = 0;
|
|
|
|
blkcnt_t cstart_block, cend_block;
|
|
|
|
struct buffer_head *bh;
|
|
|
|
unsigned int blkbits = ISOFS_BUFFER_BITS(inode);
|
|
|
|
unsigned int blksize = 1 << blkbits;
|
|
|
|
int err;
|
|
|
|
loff_t ret;
|
|
|
|
|
|
|
|
BUG_ON(!pages[full_page]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to read at least 'full_page' page. Because we have to
|
|
|
|
* uncompress the whole compression block anyway, fill the surrounding
|
|
|
|
* pages with the data we have anyway...
|
|
|
|
*/
|
|
|
|
start_off = page_offset(pages[full_page]);
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
end_off = min_t(loff_t, start_off + PAGE_SIZE, inode->i_size);
|
2009-09-23 14:44:56 +02:00
|
|
|
|
|
|
|
cstart_block = start_off >> zisofs_block_shift;
|
|
|
|
cend_block = (end_off + (1 << zisofs_block_shift) - 1)
|
|
|
|
>> zisofs_block_shift;
|
|
|
|
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
WARN_ON(start_off - (full_page << PAGE_SHIFT) !=
|
|
|
|
((cstart_block << zisofs_block_shift) & PAGE_MASK));
|
2009-09-23 14:44:56 +02:00
|
|
|
|
|
|
|
/* Find the pointer to this specific chunk */
|
|
|
|
/* Note: we're not using isonum_731() here because the data is known aligned */
|
|
|
|
/* Note: header_size is in 32-bit words (4 bytes) */
|
|
|
|
blockptr = (header_size + cstart_block) << 2;
|
|
|
|
bh = isofs_bread(inode, blockptr >> blkbits);
|
|
|
|
if (!bh)
|
|
|
|
return -EIO;
|
|
|
|
block_start = le32_to_cpu(*(__le32 *)
|
|
|
|
(bh->b_data + (blockptr & (blksize - 1))));
|
|
|
|
|
|
|
|
while (cstart_block < cend_block && pcount > 0) {
|
|
|
|
/* Load end of the compressed block in the file */
|
|
|
|
blockptr += 4;
|
|
|
|
/* Traversed to next block? */
|
|
|
|
if (!(blockptr & (blksize - 1))) {
|
|
|
|
brelse(bh);
|
|
|
|
|
|
|
|
bh = isofs_bread(inode, blockptr >> blkbits);
|
|
|
|
if (!bh)
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
block_end = le32_to_cpu(*(__le32 *)
|
|
|
|
(bh->b_data + (blockptr & (blksize - 1))));
|
|
|
|
if (block_start > block_end) {
|
|
|
|
brelse(bh);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
err = 0;
|
|
|
|
ret = zisofs_uncompress_block(inode, block_start, block_end,
|
|
|
|
pcount, pages, poffset, &err);
|
|
|
|
poffset += ret;
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
pages += poffset >> PAGE_SHIFT;
|
|
|
|
pcount -= poffset >> PAGE_SHIFT;
|
|
|
|
full_page -= poffset >> PAGE_SHIFT;
|
|
|
|
poffset &= ~PAGE_MASK;
|
2009-09-23 14:44:56 +02:00
|
|
|
|
|
|
|
if (err) {
|
|
|
|
brelse(bh);
|
|
|
|
/*
|
|
|
|
* Did we finish reading the page we really wanted
|
|
|
|
* to read?
|
|
|
|
*/
|
|
|
|
if (full_page < 0)
|
|
|
|
return 0;
|
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
block_start = block_end;
|
|
|
|
cstart_block++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (poffset && *pages) {
|
|
|
|
memset(page_address(*pages) + poffset, 0,
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
PAGE_SIZE - poffset);
|
2009-09-23 14:44:56 +02:00
|
|
|
flush_dcache_page(*pages);
|
|
|
|
SetPageUptodate(*pages);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
/*
|
|
|
|
* When decompressing, we typically obtain more than one page
|
|
|
|
* per reference. We inject the additional pages into the page
|
|
|
|
* cache as a form of readahead.
|
|
|
|
*/
|
|
|
|
static int zisofs_readpage(struct file *file, struct page *page)
|
|
|
|
{
|
2013-01-23 23:07:38 +01:00
|
|
|
struct inode *inode = file_inode(file);
|
2009-09-23 14:44:56 +02:00
|
|
|
struct address_space *mapping = inode->i_mapping;
|
|
|
|
int err;
|
|
|
|
int i, pcount, full_page;
|
|
|
|
unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];
|
|
|
|
unsigned int zisofs_pages_per_cblock =
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
PAGE_SHIFT <= zisofs_block_shift ?
|
|
|
|
(1 << (zisofs_block_shift - PAGE_SHIFT)) : 0;
|
2018-04-11 02:02:29 +02:00
|
|
|
struct page **pages;
|
2009-09-23 14:44:56 +02:00
|
|
|
pgoff_t index = page->index, end_index;
|
|
|
|
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
end_index = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
2009-09-23 14:44:56 +02:00
|
|
|
/*
|
|
|
|
* If this page is wholly outside i_size we just return zero;
|
|
|
|
* do_generic_file_read() will handle this for us
|
|
|
|
*/
|
|
|
|
if (index >= end_index) {
|
|
|
|
SetPageUptodate(page);
|
|
|
|
unlock_page(page);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
if (PAGE_SHIFT <= zisofs_block_shift) {
|
2009-09-23 14:44:56 +02:00
|
|
|
/* We have already been given one page, this is the one
|
|
|
|
we must do. */
|
|
|
|
full_page = index & (zisofs_pages_per_cblock - 1);
|
|
|
|
pcount = min_t(int, zisofs_pages_per_cblock,
|
|
|
|
end_index - (index & ~(zisofs_pages_per_cblock - 1)));
|
|
|
|
index -= full_page;
|
|
|
|
} else {
|
|
|
|
full_page = 0;
|
|
|
|
pcount = 1;
|
|
|
|
}
|
2018-04-11 02:02:29 +02:00
|
|
|
pages = kcalloc(max_t(unsigned int, zisofs_pages_per_cblock, 1),
|
|
|
|
sizeof(*pages), GFP_KERNEL);
|
|
|
|
if (!pages) {
|
|
|
|
unlock_page(page);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2009-09-23 14:44:56 +02:00
|
|
|
pages[full_page] = page;
|
|
|
|
|
|
|
|
for (i = 0; i < pcount; i++, index++) {
|
|
|
|
if (i != full_page)
|
|
|
|
pages[i] = grab_cache_page_nowait(mapping, index);
|
|
|
|
if (pages[i]) {
|
|
|
|
ClearPageError(pages[i]);
|
|
|
|
kmap(pages[i]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-23 14:44:56 +02:00
|
|
|
err = zisofs_fill_pages(inode, full_page, pcount, pages);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Release any residual pages, do not SetPageUptodate */
|
2009-09-23 14:44:56 +02:00
|
|
|
for (i = 0; i < pcount; i++) {
|
|
|
|
if (pages[i]) {
|
|
|
|
flush_dcache_page(pages[i]);
|
|
|
|
if (i == full_page && err)
|
|
|
|
SetPageError(pages[i]);
|
|
|
|
kunmap(pages[i]);
|
|
|
|
unlock_page(pages[i]);
|
|
|
|
if (i != full_page)
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 14:29:47 +02:00
|
|
|
put_page(pages[i]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* At this point, err contains 0 or -EIO depending on the "critical" page */
|
2018-04-11 02:02:29 +02:00
|
|
|
kfree(pages);
|
2005-04-17 00:20:36 +02:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2006-06-28 13:26:44 +02:00
|
|
|
const struct address_space_operations zisofs_aops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.readpage = zisofs_readpage,
|
|
|
|
/* No bmap operation supported */
|
|
|
|
};
|
|
|
|
|
|
|
|
int __init zisofs_init(void)
|
|
|
|
{
|
|
|
|
zisofs_zlib_workspace = vmalloc(zlib_inflate_workspacesize());
|
|
|
|
if ( !zisofs_zlib_workspace )
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void zisofs_cleanup(void)
|
|
|
|
{
|
|
|
|
vfree(zisofs_zlib_workspace);
|
|
|
|
}
|