Linux 3.1 compat, vfs_fsync()

Preferentially use the vfs_fsync() function.  This function was
initially introduced in 2.6.29 and took three arguments.  As
of 2.6.35 the dentry argument was dropped from the function.
For older kernels fall back to using file_fsync() which also
took three arguments including the dentry.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #52
This commit is contained in:
Brian Behlendorf 2011-11-09 12:45:35 -08:00
parent 12ff95ff57
commit 0d0b523728
4 changed files with 248 additions and 147 deletions

View File

@ -68,13 +68,14 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_2ARGS_SET_FS_PWD SPL_AC_2ARGS_SET_FS_PWD
SPL_AC_2ARGS_VFS_UNLINK SPL_AC_2ARGS_VFS_UNLINK
SPL_AC_4ARGS_VFS_RENAME SPL_AC_4ARGS_VFS_RENAME
SPL_AC_VFS_FSYNC
SPL_AC_2ARGS_VFS_FSYNC
SPL_AC_FS_STRUCT_SPINLOCK SPL_AC_FS_STRUCT_SPINLOCK
SPL_AC_CRED_STRUCT SPL_AC_CRED_STRUCT
SPL_AC_GROUPS_SEARCH SPL_AC_GROUPS_SEARCH
SPL_AC_PUT_TASK_STRUCT SPL_AC_PUT_TASK_STRUCT
SPL_AC_5ARGS_PROC_HANDLER SPL_AC_5ARGS_PROC_HANDLER
SPL_AC_KVASPRINTF SPL_AC_KVASPRINTF
SPL_AC_3ARGS_FILE_FSYNC
SPL_AC_EXPORTED_RWSEM_IS_LOCKED SPL_AC_EXPORTED_RWSEM_IS_LOCKED
SPL_AC_KERNEL_INVALIDATE_INODES SPL_AC_KERNEL_INVALIDATE_INODES
SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
@ -1718,19 +1719,30 @@ AC_DEFUN([SPL_AC_KVASPRINTF], [
]) ])
dnl # dnl #
dnl # 2.6.35 API change, dnl # 2.6.29 API change,
dnl # Unused 'struct dentry *' removed from prototype. dnl # vfs_fsync() funcation added, prior to this use file_fsync().
dnl # dnl #
AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [ AC_DEFUN([SPL_AC_VFS_FSYNC], [
AC_MSG_CHECKING([whether file_fsync() wants 3 args]) SPL_CHECK_SYMBOL_EXPORT(
[vfs_fsync],
[fs/sync.c],
[AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
[])
])
dnl #
dnl # 2.6.35 API change,
dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
dnl #
AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
SPL_LINUX_TRY_COMPILE([ SPL_LINUX_TRY_COMPILE([
#include <linux/buffer_head.h> #include <linux/fs.h>
],[ ],[
file_fsync(NULL, NULL, 0); vfs_fsync(NULL, 0);
],[ ],[
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1, AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
[file_fsync() wants 3 args])
],[ ],[
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
]) ])

342
configure vendored
View File

@ -15067,6 +15067,112 @@ fi
{ $as_echo "$as_me:$LINENO: checking whether symbol vfs_fsync is exported" >&5
$as_echo_n "checking whether symbol vfs_fsync is exported... " >&6; }
grep -q -E '[[:space:]]vfs_fsync[[:space:]]' \
$LINUX_OBJ/Module*.symvers 2>/dev/null
rc=$?
if test $rc -ne 0; then
export=0
for file in fs/sync.c; do
grep -q -E "EXPORT_SYMBOL.*(vfs_fsync)" \
"$LINUX_OBJ/$file" 2>/dev/null
rc=$?
if test $rc -eq 0; then
export=1
break;
fi
done
if test $export -eq 0; then
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_VFS_FSYNC 1
_ACEOF
fi
else
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_VFS_FSYNC 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking whether vfs_fsync() wants 2 args" >&5
$as_echo_n "checking whether vfs_fsync() 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/fs.h>
int
main (void)
{
vfs_fsync(NULL, 0);
;
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_VFS_FSYNC 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
{ $as_echo "$as_me:$LINENO: checking whether struct fs_struct uses spinlock_t" >&5 { $as_echo "$as_me:$LINENO: checking whether struct fs_struct uses spinlock_t" >&5
$as_echo_n "checking whether struct fs_struct uses spinlock_t... " >&6; } $as_echo_n "checking whether struct fs_struct uses spinlock_t... " >&6; }
tmp_flags="$EXTRA_KCFLAGS" tmp_flags="$EXTRA_KCFLAGS"
@ -15391,71 +15497,6 @@ _ACEOF
{ $as_echo "$as_me:$LINENO: checking whether file_fsync() wants 3 args" >&5
$as_echo_n "checking whether file_fsync() wants 3 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/buffer_head.h>
int
main (void)
{
file_fsync(NULL, NULL, 0);
;
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_3ARGS_FILE_FSYNC 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
{ $as_echo "$as_me:$LINENO: checking whether symbol rwsem_is_locked is exported" >&5 { $as_echo "$as_me:$LINENO: checking whether symbol rwsem_is_locked is exported" >&5
$as_echo_n "checking whether symbol rwsem_is_locked is exported... " >&6; } $as_echo_n "checking whether symbol rwsem_is_locked is exported... " >&6; }
grep -q -E '[[:space:]]rwsem_is_locked[[:space:]]' \ grep -q -E '[[:space:]]rwsem_is_locked[[:space:]]' \
@ -19296,6 +19337,112 @@ fi
{ $as_echo "$as_me:$LINENO: checking whether symbol vfs_fsync is exported" >&5
$as_echo_n "checking whether symbol vfs_fsync is exported... " >&6; }
grep -q -E '[[:space:]]vfs_fsync[[:space:]]' \
$LINUX_OBJ/Module*.symvers 2>/dev/null
rc=$?
if test $rc -ne 0; then
export=0
for file in fs/sync.c; do
grep -q -E "EXPORT_SYMBOL.*(vfs_fsync)" \
"$LINUX_OBJ/$file" 2>/dev/null
rc=$?
if test $rc -eq 0; then
export=1
break;
fi
done
if test $export -eq 0; then
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_VFS_FSYNC 1
_ACEOF
fi
else
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_VFS_FSYNC 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking whether vfs_fsync() wants 2 args" >&5
$as_echo_n "checking whether vfs_fsync() 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/fs.h>
int
main (void)
{
vfs_fsync(NULL, 0);
;
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_VFS_FSYNC 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
{ $as_echo "$as_me:$LINENO: checking whether struct fs_struct uses spinlock_t" >&5 { $as_echo "$as_me:$LINENO: checking whether struct fs_struct uses spinlock_t" >&5
$as_echo_n "checking whether struct fs_struct uses spinlock_t... " >&6; } $as_echo_n "checking whether struct fs_struct uses spinlock_t... " >&6; }
tmp_flags="$EXTRA_KCFLAGS" tmp_flags="$EXTRA_KCFLAGS"
@ -19620,71 +19767,6 @@ _ACEOF
{ $as_echo "$as_me:$LINENO: checking whether file_fsync() wants 3 args" >&5
$as_echo_n "checking whether file_fsync() wants 3 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/buffer_head.h>
int
main (void)
{
file_fsync(NULL, NULL, 0);
;
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_3ARGS_FILE_FSYNC 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
{ $as_echo "$as_me:$LINENO: checking whether symbol rwsem_is_locked is exported" >&5 { $as_echo "$as_me:$LINENO: checking whether symbol rwsem_is_locked is exported" >&5
$as_echo_n "checking whether symbol rwsem_is_locked is exported... " >&6; } $as_echo_n "checking whether symbol rwsem_is_locked is exported... " >&6; }
grep -q -E '[[:space:]]rwsem_is_locked[[:space:]]' \ grep -q -E '[[:space:]]rwsem_is_locked[[:space:]]' \

View File

@ -50,12 +50,16 @@ spl_filp_open(const char *name, int flags, int mode, int *err)
#define spl_filp_poff(f) (&(f)->f_pos) #define spl_filp_poff(f) (&(f)->f_pos)
#define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p) #define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p)
#ifdef HAVE_3ARGS_FILE_FSYNC #ifdef HAVE_VFS_FSYNC
#define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), \ # ifdef HAVE_2ARGS_VFS_FSYNC
(fp)->f_dentry, sync) # define spl_filp_fsync(fp, sync) vfs_fsync(fp, sync)
# else
# define spl_filp_fsync(fp, sync) vfs_fsync(fp, (fp)->f_dentry, sync)
# endif /* HAVE_2ARGS_VFS_FSYNC */
#else #else
#define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), sync) # include <linux/buffer_head.h>
#endif # define spl_filp_fsync(fp, sync) file_fsync(fp, (fp)->f_dentry, sync)
#endif /* HAVE_VFS_FSYNC */
#ifdef HAVE_INODE_I_MUTEX #ifdef HAVE_INODE_I_MUTEX
#define spl_inode_lock(ip) (mutex_lock(&(ip)->i_mutex)) #define spl_inode_lock(ip) (mutex_lock(&(ip)->i_mutex))

View File

@ -18,15 +18,15 @@
/* set_fs_pwd() wants 2 args */ /* set_fs_pwd() wants 2 args */
#undef HAVE_2ARGS_SET_FS_PWD #undef HAVE_2ARGS_SET_FS_PWD
/* vfs_fsync() wants 2 args */
#undef HAVE_2ARGS_VFS_FSYNC
/* 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 */ /* zlib_deflate_workspacesize() wants 2 args */
#undef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE #undef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
/* file_fsync() wants 3 args */
#undef HAVE_3ARGS_FILE_FSYNC
/* INIT_WORK wants 3 args */ /* INIT_WORK wants 3 args */
#undef HAVE_3ARGS_INIT_WORK #undef HAVE_3ARGS_INIT_WORK
@ -216,6 +216,9 @@
/* user_path_dir() is available */ /* user_path_dir() is available */
#undef HAVE_USER_PATH_DIR #undef HAVE_USER_PATH_DIR
/* vfs_fsync() is available */
#undef HAVE_VFS_FSYNC
/* Page state NR_ACTIVE is available */ /* Page state NR_ACTIVE is available */
#undef HAVE_ZONE_STAT_ITEM_NR_ACTIVE #undef HAVE_ZONE_STAT_ITEM_NR_ACTIVE