diff options
author | Brian Behlendorf <[email protected]> | 2010-07-14 11:26:54 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2010-07-14 11:40:55 -0700 |
commit | f0ff89fc86873a96a3f60e86e1694775b664663e (patch) | |
tree | 21099dfd7e18a032ecb11d868be580eb61b1def3 | |
parent | 82b8c8fa64737edfb203156b245b48840139d2c1 (diff) |
Linux 2.6.35 compat: filp_fsync() dropped 'stuct dentry *'
The prototype for filp_fsync() drop the unused argument 'stuct dentry *'.
I've fixed this by adding the needed autoconf check and moving all of
those filp related functions to file_compat.h. This will simplify
handling any further API changes in the future.
-rw-r--r-- | config/spl-build.m4 | 20 | ||||
-rwxr-xr-x | configure | 130 | ||||
-rw-r--r-- | include/linux/file_compat.h | 27 | ||||
-rw-r--r-- | module/spl/spl-debug.c | 33 | ||||
-rw-r--r-- | module/spl/spl-vnode.c | 2 | ||||
-rw-r--r-- | spl_config.h.in | 3 |
6 files changed, 187 insertions, 28 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4 index ae4e1f162..b908a56d5 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -76,6 +76,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_PUT_TASK_STRUCT SPL_AC_5ARGS_PROC_HANDLER SPL_AC_KVASPRINTF + SPL_AC_3ARGS_FILE_FSYNC ]) AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ @@ -1438,3 +1439,22 @@ AC_DEFUN([SPL_AC_KVASPRINTF], [ [kvasprintf() is available])], []) ]) + +dnl # +dnl # 2.6.35 API change, +dnl # Unused 'struct dentry *' removed from prototype. +dnl # +AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [ + AC_MSG_CHECKING([whether file_fsync() wants 3 args]) + SPL_LINUX_TRY_COMPILE([ + #include <linux/buffer_head.h> + ],[ + file_fsync(NULL, NULL, 0); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1, + [file_fsync() wants 3 args]) + ],[ + AC_MSG_RESULT(no) + ]) +]) @@ -14905,6 +14905,71 @@ _ACEOF fi + + { $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 + + + ;; user) if test "x$AWK" != xgawk; then @@ -18350,6 +18415,71 @@ _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 + + + + if test "x$AWK" != xgawk; then diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h index d30e90356..b03373ebd 100644 --- a/include/linux/file_compat.h +++ b/include/linux/file_compat.h @@ -29,5 +29,32 @@ #include <linux/fdtable.h> #endif +static inline struct file * +spl_filp_open(const char *name, int flags, int mode, int *err) +{ + struct file *filp = NULL; + int rc; + + filp = filp_open(name, flags, mode); + if (IS_ERR(filp)) { + rc = PTR_ERR(filp); + if (err) + *err = rc; + filp = NULL; + } + return filp; +} + +#define spl_filp_close(f) filp_close(f, NULL) +#define spl_filp_poff(f) (&(f)->f_pos) +#define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p) + +#ifdef HAVE_3ARGS_FILE_FSYNC +#define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), \ + (fp)->f_dentry, sync) +#else +#define spl_filp_fsync(fp, sync) (fp)->f_op->fsync((fp), sync) +#endif + #endif /* SPL_FILE_COMPAT_H */ diff --git a/module/spl/spl-debug.c b/module/spl/spl-debug.c index 6a1086241..75778752b 100644 --- a/module/spl/spl-debug.c +++ b/module/spl/spl-debug.c @@ -35,6 +35,7 @@ #include <linux/interrupt.h> #include <linux/spinlock.h> #include <linux/proc_compat.h> +#include <linux/file_compat.h> #include <sys/sysmacros.h> #include <sys/debug.h> #include <spl-ctl.h> @@ -902,28 +903,6 @@ put_pages_back(struct page_collection *pc) put_pages_back_on_all_cpus(pc); } -static struct file * -trace_filp_open (const char *name, int flags, int mode, int *err) -{ - struct file *filp = NULL; - int rc; - - filp = filp_open(name, flags, mode); - if (IS_ERR(filp)) { - rc = PTR_ERR(filp); - printk(KERN_ERR "SPL: Can't open %s file: %d\n", name, rc); - if (err) - *err = rc; - filp = NULL; - } - return filp; -} - -#define trace_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p) -#define trace_filp_fsync(fp) (fp)->f_op->fsync((fp),(fp)->f_dentry,1) -#define trace_filp_close(f) filp_close(f, NULL) -#define trace_filp_poff(f) (&(f)->f_pos) - static int spl_debug_dump_all_pages(dumplog_priv_t *dp, char *filename) { @@ -936,7 +915,7 @@ spl_debug_dump_all_pages(dumplog_priv_t *dp, char *filename) down_write(&trace_sem); - filp = trace_filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, + filp = spl_filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600, &rc); if (filp == NULL) { if (rc != -EEXIST) @@ -958,8 +937,8 @@ spl_debug_dump_all_pages(dumplog_priv_t *dp, char *filename) list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) { __ASSERT_TAGE_INVARIANT(tage); - rc = trace_filp_write(filp, page_address(tage->page), - tage->used, trace_filp_poff(filp)); + rc = spl_filp_write(filp, page_address(tage->page), + tage->used, spl_filp_poff(filp)); if (rc != (int)tage->used) { printk(KERN_WARNING "SPL: Wanted to write %u " "but wrote %d\n", tage->used, rc); @@ -973,11 +952,11 @@ spl_debug_dump_all_pages(dumplog_priv_t *dp, char *filename) set_fs(oldfs); - rc = trace_filp_fsync(filp); + rc = spl_filp_fsync(filp, 1); if (rc) printk(KERN_ERR "SPL: Unable to sync: %d\n", rc); close: - trace_filp_close(filp); + spl_filp_close(filp); out: up_write(&trace_sem); diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index b5c34fbcd..c67fc4c7f 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -473,7 +473,7 @@ int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4) if (flags & FDSYNC) datasync = 1; - RETURN(-file_fsync(vp->v_file, vp->v_file->f_dentry, datasync)); + RETURN(-spl_filp_fsync(vp->v_file, datasync)); } /* vn_fsync() */ EXPORT_SYMBOL(vn_fsync); diff --git a/spl_config.h.in b/spl_config.h.in index 5ed1991f9..8d57a63ea 100644 --- a/spl_config.h.in +++ b/spl_config.h.in @@ -18,6 +18,9 @@ /* vfs_unlink() wants 2 args */ #undef HAVE_2ARGS_VFS_UNLINK +/* file_fsync() wants 3 args */ +#undef HAVE_3ARGS_FILE_FSYNC + /* INIT_WORK wants 3 args */ #undef HAVE_3ARGS_INIT_WORK |