mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 02:49:32 +03:00
Linux 2.6.39 compat, zlib_deflate_workspacesize()
The function zlib_deflate_workspacesize() now take 2 arguments. This was done to avoid always having to allocate the maximum size workspace (268K). The caller can now specific the windowBits and memLevel compression parameters to get a smaller workspace. For our purposes we introduce a spl_zlib_deflate_workspacesize() wrapper which accepts both arguments. When the two argument version of zlib_deflate_workspacesize() is available the arguments are passed through. When it's not we assume the worst case and a maximally sized workspace is used.
This commit is contained in:
parent
b1cbc4610c
commit
3dfc591ac4
@ -80,6 +80,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
|
|||||||
SPL_AC_SHRINK_DCACHE_MEMORY
|
SPL_AC_SHRINK_DCACHE_MEMORY
|
||||||
SPL_AC_SHRINK_ICACHE_MEMORY
|
SPL_AC_SHRINK_ICACHE_MEMORY
|
||||||
SPL_AC_KERN_PATH_PARENT
|
SPL_AC_KERN_PATH_PARENT
|
||||||
|
SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
|
AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
|
||||||
@ -1802,3 +1803,25 @@ AC_DEFUN([SPL_AC_KERN_PATH_PARENT], [
|
|||||||
[kern_path_parent() is available])],
|
[kern_path_parent() is available])],
|
||||||
[])
|
[])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 2.6.39 API compat,
|
||||||
|
dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
|
||||||
|
dnl # This was done to avoid always having to allocate the maximum size
|
||||||
|
dnl # workspace (268K). The caller can now specific the windowBits and
|
||||||
|
dnl # memLevel compression parameters to get a smaller workspace.
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
|
||||||
|
[AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
|
||||||
|
SPL_LINUX_TRY_COMPILE([
|
||||||
|
#include <linux/zlib.h>
|
||||||
|
],[
|
||||||
|
return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
|
||||||
|
[zlib_deflate_workspacesize() wants 2 args])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
128
configure
vendored
128
configure
vendored
@ -15654,6 +15654,70 @@ _ACEOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:$LINENO: checking whether zlib_deflate_workspacesize() wants 2 args" >&5
|
||||||
|
$as_echo_n "checking whether zlib_deflate_workspacesize() wants 2 args... " >&6; }
|
||||||
|
|
||||||
|
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.c
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
|
||||||
|
#include <linux/zlib.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
rm -Rf build && mkdir -p build
|
||||||
|
echo "obj-m := conftest.o" >build/Makefile
|
||||||
|
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:$LINENO: result: yes" >&5
|
||||||
|
$as_echo "yes" >&6; }
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
$as_echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:$LINENO: result: no" >&5
|
||||||
|
$as_echo "no" >&6; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -Rf build
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
user)
|
user)
|
||||||
|
|
||||||
@ -19668,6 +19732,70 @@ _ACEOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:$LINENO: checking whether zlib_deflate_workspacesize() wants 2 args" >&5
|
||||||
|
$as_echo_n "checking whether zlib_deflate_workspacesize() wants 2 args... " >&6; }
|
||||||
|
|
||||||
|
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.c
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
|
||||||
|
#include <linux/zlib.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
rm -Rf build && mkdir -p build
|
||||||
|
echo "obj-m := conftest.o" >build/Makefile
|
||||||
|
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||||
|
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||||
|
(eval $ac_try) 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:$LINENO: result: yes" >&5
|
||||||
|
$as_echo "yes" >&6; }
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
$as_echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:$LINENO: result: no" >&5
|
||||||
|
$as_echo "no" >&6; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -Rf build
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
37
include/linux/zlib_compat.h
Normal file
37
include/linux/zlib_compat.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*****************************************************************************\
|
||||||
|
* Copyright (C) 2011 Lawrence Livermore National Security, LLC.
|
||||||
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
||||||
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
||||||
|
* UCRL-CODE-235197
|
||||||
|
*
|
||||||
|
* This file is part of the SPL, Solaris Porting Layer.
|
||||||
|
* For details, see <http://github.com/behlendorf/spl/>.
|
||||||
|
*
|
||||||
|
* The SPL 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; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _SPL_ZLIB_COMPAT_H
|
||||||
|
#define _SPL_ZLIB_COMPAT_H
|
||||||
|
|
||||||
|
#include <linux/zlib.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
|
||||||
|
#define spl_zlib_deflate_workspacesize(wb, ml) \
|
||||||
|
zlib_deflate_workspacesize(wb, ml)
|
||||||
|
#else
|
||||||
|
#define spl_zlib_deflate_workspacesize(wb, ml) \
|
||||||
|
zlib_deflate_workspacesize()
|
||||||
|
#endif /* HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE */
|
||||||
|
|
||||||
|
#endif /* SPL_ZLIB_COMPAT_H */
|
@ -41,6 +41,7 @@
|
|||||||
#include <linux/sysctl_compat.h>
|
#include <linux/sysctl_compat.h>
|
||||||
#include <linux/proc_compat.h>
|
#include <linux/proc_compat.h>
|
||||||
#include <linux/math64_compat.h>
|
#include <linux/math64_compat.h>
|
||||||
|
#include <linux/zlib_compat.h>
|
||||||
|
|
||||||
#ifndef HAVE_UINTPTR_T
|
#ifndef HAVE_UINTPTR_T
|
||||||
typedef unsigned long uintptr_t;
|
typedef unsigned long uintptr_t;
|
||||||
|
@ -198,10 +198,14 @@ EXPORT_SYMBOL(z_uncompress);
|
|||||||
|
|
||||||
int zlib_init(void)
|
int zlib_init(void)
|
||||||
{
|
{
|
||||||
|
int size;
|
||||||
SENTRY;
|
SENTRY;
|
||||||
|
|
||||||
|
size = MAX(spl_zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
|
||||||
|
zlib_inflate_workspacesize());
|
||||||
|
|
||||||
zlib_workspace_cache = kmem_cache_create("spl_zlib_workspace_cache",
|
zlib_workspace_cache = kmem_cache_create("spl_zlib_workspace_cache",
|
||||||
max(zlib_deflate_workspacesize(), zlib_inflate_workspacesize()),
|
size, 0, NULL, NULL, NULL, NULL, NULL, KMC_VMEM);
|
||||||
0, NULL, NULL, NULL, NULL, NULL, KMC_VMEM);
|
|
||||||
if (!zlib_workspace_cache)
|
if (!zlib_workspace_cache)
|
||||||
SRETURN(1);
|
SRETURN(1);
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
/* vfs_unlink() wants 2 args */
|
/* vfs_unlink() wants 2 args */
|
||||||
#undef HAVE_2ARGS_VFS_UNLINK
|
#undef HAVE_2ARGS_VFS_UNLINK
|
||||||
|
|
||||||
|
/* zlib_deflate_workspacesize() wants 2 args */
|
||||||
|
#undef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
|
||||||
|
|
||||||
/* file_fsync() wants 3 args */
|
/* file_fsync() wants 3 args */
|
||||||
#undef HAVE_3ARGS_FILE_FSYNC
|
#undef HAVE_3ARGS_FILE_FSYNC
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user