* [PATCH] btrfs-progs: Replace hardcoded PAGE_CACHE_SIZE with getpagesize().
@ 2016-03-09 12:22 Feifei Xu
2016-03-09 12:45 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Feifei Xu @ 2016-03-09 12:22 UTC (permalink / raw)
To: linux-btrfs; +Cc: chandan, Feifei Xu
PAGE_CACHE_SIZE is hardcoded to 4K in cmds-restore.c. It makes lzo
decompress fail on ppc64. Fix this through replacing hardcoded 4K
with getpagesize().
Signed-off-by: Feifei Xu <xufeifei@linux.vnet.ibm.com>
---
cmds-restore.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/cmds-restore.c b/cmds-restore.c
index 161fd91..17a5475 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -56,7 +56,6 @@ static int get_xattrs = 0;
static int dry_run = 0;
#define LZO_LEN 4
-#define PAGE_CACHE_SIZE 4096
#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
static int decompress_zlib(char *inbuf, char *outbuf, u64 compress_len,
@@ -127,7 +126,7 @@ static int decompress_lzo(unsigned char *inbuf, char *outbuf, u64 compress_len,
inbuf += LZO_LEN;
tot_in += LZO_LEN;
- new_len = lzo1x_worst_compress(PAGE_CACHE_SIZE);
+ new_len = lzo1x_worst_compress(getpagesize());
ret = lzo1x_decompress_safe((const unsigned char *)inbuf, in_len,
(unsigned char *)outbuf,
(void *)&new_len, NULL);
@@ -144,8 +143,8 @@ static int decompress_lzo(unsigned char *inbuf, char *outbuf, u64 compress_len,
* If the 4 byte header does not fit to the rest of the page we
* have to move to the next one, unless we read some garbage
*/
- mod_page = tot_in % PAGE_CACHE_SIZE;
- rem_page = PAGE_CACHE_SIZE - mod_page;
+ mod_page = tot_in % getpagesize();
+ rem_page = getpagesize() - mod_page;
if (rem_page < LZO_LEN) {
inbuf += rem_page;
tot_in += rem_page;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: Replace hardcoded PAGE_CACHE_SIZE with getpagesize().
2016-03-09 12:22 [PATCH] btrfs-progs: Replace hardcoded PAGE_CACHE_SIZE with getpagesize() Feifei Xu
@ 2016-03-09 12:45 ` David Sterba
2016-03-10 6:06 ` Fiona
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2016-03-09 12:45 UTC (permalink / raw)
To: Feifei Xu; +Cc: linux-btrfs, chandan
On Wed, Mar 09, 2016 at 08:22:13PM +0800, Feifei Xu wrote:
> PAGE_CACHE_SIZE is hardcoded to 4K in cmds-restore.c. It makes lzo
> decompress fail on ppc64. Fix this through replacing hardcoded 4K
> with getpagesize().
You're right that the hardcoded value is a bug, but the correct value is
the sector size. Ie. when the system is 4k page size and filesystem is
eg. from ppc64.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: Replace hardcoded PAGE_CACHE_SIZE with getpagesize().
2016-03-09 12:45 ` David Sterba
@ 2016-03-10 6:06 ` Fiona
0 siblings, 0 replies; 3+ messages in thread
From: Fiona @ 2016-03-10 6:06 UTC (permalink / raw)
To: dsterba, linux-btrfs, chandan
On 2016/3/9 20:45, David Sterba wrote:
> On Wed, Mar 09, 2016 at 08:22:13PM +0800, Feifei Xu wrote:
>> PAGE_CACHE_SIZE is hardcoded to 4K in cmds-restore.c. It makes lzo
>> decompress fail on ppc64. Fix this through replacing hardcoded 4K
>> with getpagesize().
> You're right that the hardcoded value is a bug, but the correct value is
> the sector size. Ie. when the system is 4k page size and filesystem is
> eg. from ppc64.
Hi David,
You're right, I am working to fix it.
Thanks
Fiona
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-10 6:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09 12:22 [PATCH] btrfs-progs: Replace hardcoded PAGE_CACHE_SIZE with getpagesize() Feifei Xu
2016-03-09 12:45 ` David Sterba
2016-03-10 6:06 ` Fiona
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).