From c57641df9ae8be55a0a94b879766f880b1e5a941 Mon Sep 17 00:00:00 2001 From: Wally Wang Date: Fri, 9 Mar 2012 10:39:49 -0800 Subject: [PATCH] LU-812 compat: file_operations.fsync needs 4 arguments Linux 3.0 file_operations.fsync needs 4 arguments. Change-Id: I1e376f35edb87e9eaa0feb82e69905f04ec8ee93 Signed-off-by: Wally Wang Reviewed-on: http://review.whamcloud.com/1950 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/linux/linux-fs.h | 8 +++++--- lustre/autoconf/lustre-core.m4 | 25 ++++++++++++++++++------- lustre/llite/file.c | 8 +++++--- lustre/llite/llite_internal.h | 8 +++++--- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/libcfs/include/libcfs/linux/linux-fs.h b/libcfs/include/libcfs/linux/linux-fs.h index bcc8850..774e958 100644 --- a/libcfs/include/libcfs/linux/linux-fs.h +++ b/libcfs/include/libcfs/linux/linux-fs.h @@ -68,10 +68,12 @@ typedef struct kstatfs cfs_kstatfs_t; * XXX Do we need to parse flags and mode in cfs_filp_open? */ cfs_file_t *cfs_filp_open (const char *name, int flags, int mode, int *err); -#ifndef HAVE_FILE_FSYNC_2ARGS -# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, (fp)->f_dentry, flag)) -#else +#ifdef HAVE_FILE_FSYNC_4ARGS +# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, 0, LLONG_MAX, flag)) +#elif defined(HAVE_FILE_FSYNC_2ARGS) # define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, flag)) +#else +# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, (fp)->f_dentry, flag)) #endif #define cfs_filp_close(f) filp_close(f, NULL) #define cfs_filp_read(fp, buf, size, pos) (fp)->f_op->read((fp), (buf), (size), pos) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 061d457..4818462 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1975,19 +1975,30 @@ LB_LINUX_TRY_COMPILE([ # # 2.6.35 file_operations.fsync taken 2 arguments. +# 3.0.0 file_operations.fsync takes 4 arguments. # AC_DEFUN([LC_FILE_FSYNC], -[AC_MSG_CHECKING([if file_operations.fsync taken 2 arguments]) +[AC_MSG_CHECKING([if file_operations.fsync takes 4 or 2 arguments]) LB_LINUX_TRY_COMPILE([ #include ],[ - ((struct file_operations *)0)->fsync(NULL, 0); + ((struct file_operations *)0)->fsync(NULL, 0, 0, 0); ],[ - AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1, - [file_operations.fsync taken 2 arguments]) - AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_FILE_FSYNC_4ARGS, 1, + [file_operations.fsync takes 4 arguments]) + AC_MSG_RESULT([yes, 4 args]) ],[ - AC_MSG_RESULT([no]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + ((struct file_operations *)0)->fsync(NULL, 0); + ],[ + AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1, + [file_operations.fsync takes 2 arguments]) + AC_MSG_RESULT([yes, 2 args]) + ],[ + AC_MSG_RESULT([no]) + ]) ]) ]) @@ -2244,7 +2255,7 @@ AC_DEFUN([LC_PROG_LINUX], LC_CACHE_UPCALL LC_EXPORT_GENERIC_ERROR_REMOVE_PAGE - # 2.6.35 + # 2.6.35, 3.0.0 LC_FILE_FSYNC LC_EXPORT_SIMPLE_SETATTR diff --git a/lustre/llite/file.c b/lustre/llite/file.c index b69a202..c458bb4 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1989,10 +1989,12 @@ int ll_flush(struct file *file) return rc ? -EIO : 0; } -#ifndef HAVE_FILE_FSYNC_2ARGS -int ll_fsync(struct file *file, struct dentry *dentry, int data) -#else +#ifdef HAVE_FILE_FSYNC_4ARGS +int ll_fsync(struct file *file, loff_t start, loff_t end, int data) +#elif defined(HAVE_FILE_FSYNC_2ARGS) int ll_fsync(struct file *file, int data) +#else +int ll_fsync(struct file *file, struct dentry *dentry, int data) #endif { struct inode *inode = file->f_dentry->d_inode; diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 693239c2..eb54145 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -744,10 +744,12 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, int set_default); int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm, int *lmm_size, struct ptlrpc_request **request); -#ifndef HAVE_FILE_FSYNC_2ARGS -int ll_fsync(struct file *file, struct dentry *dentry, int data); -#else +#ifdef HAVE_FILE_FSYNC_4ARGS +int ll_fsync(struct file *file, loff_t start, loff_t end, int data); +#elif defined(HAVE_FILE_FSYNC_2ARGS) int ll_fsync(struct file *file, int data); +#else +int ll_fsync(struct file *file, struct dentry *dentry, int data); #endif int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, int num_bytes); -- 1.8.3.1