From f40891396a460b6b73d2ff9ea55629e4065ef349 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Wed, 4 Jan 2012 23:23:16 +0800 Subject: [PATCH] LU-506 kernel: FC15 - file_operations relate changes. -- file_operations.ioctl() has been removed. -- file_operations.fsync() changes need 2 arguments. Change-Id: I7776593497dd988fbf860221e2dcea61c6c4870f Signed-off-by: Yang Sheng Reviewed-on: http://review.whamcloud.com/1862 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Niu Yawei --- libcfs/include/libcfs/linux/linux-fs.h | 7 ++++++- libcfs/libcfs/linux/linux-module.c | 21 +++++++++++++++------ libcfs/libcfs/linux/linux-tcpip.c | 12 +++++------- lustre/autoconf/lustre-core.m4 | 21 +++++++++++++++++++++ lustre/llite/dir.c | 15 ++++++++++++--- lustre/llite/file.c | 6 +++++- lustre/llite/llite_internal.h | 4 ++++ lustre/lvfs/lvfs_linux.c | 2 +- 8 files changed, 69 insertions(+), 19 deletions(-) diff --git a/libcfs/include/libcfs/linux/linux-fs.h b/libcfs/include/libcfs/linux/linux-fs.h index 9d42a6c..41b0f67 100644 --- a/libcfs/include/libcfs/linux/linux-fs.h +++ b/libcfs/include/libcfs/linux/linux-fs.h @@ -66,10 +66,15 @@ 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 +# define cfs_do_fsync(fp, flag) ((fp)->f_op->fsync(fp, 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) #define cfs_filp_write(fp, buf, size, pos) (fp)->f_op->write((fp), (buf), (size), pos) -#define cfs_filp_fsync(fp) (fp)->f_op->fsync((fp), (fp)->f_dentry, 1) +#define cfs_filp_fsync(fp) cfs_do_fsync(fp, 1) #define cfs_get_file(f) get_file(f) #define cfs_get_fd(x) fget(x) diff --git a/libcfs/libcfs/linux/linux-module.c b/libcfs/libcfs/linux/linux-module.c index d290172..1824d88 100644 --- a/libcfs/libcfs/linux/linux-module.c +++ b/libcfs/libcfs/linux/linux-module.c @@ -131,9 +131,14 @@ libcfs_psdev_release(struct inode * inode, struct file * file) return rc; } -static int -libcfs_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + +#ifdef HAVE_UNLOCKED_IOCTL +static long libcfs_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) +#else +static int libcfs_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +#endif { struct cfs_psdev_file pfile; int rc = 0; @@ -172,9 +177,13 @@ libcfs_ioctl(struct inode *inode, struct file *file, } static struct file_operations libcfs_fops = { - ioctl: libcfs_ioctl, - open: libcfs_psdev_open, - release: libcfs_psdev_release +#ifdef HAVE_UNLOCKED_IOCTL + unlocked_ioctl: libcfs_ioctl, +#else + ioctl: libcfs_ioctl, +#endif + open : libcfs_psdev_open, + release : libcfs_psdev_release }; cfs_psdev_t libcfs_dev = { diff --git a/libcfs/libcfs/linux/linux-tcpip.c b/libcfs/libcfs/linux/linux-tcpip.c index 9d673f0..95136c1 100644 --- a/libcfs/libcfs/linux/linux-tcpip.c +++ b/libcfs/libcfs/linux/linux-tcpip.c @@ -80,14 +80,12 @@ libcfs_sock_ioctl(int cmd, unsigned long arg) #ifdef HAVE_UNLOCKED_IOCTL if (sock_filp->f_op->unlocked_ioctl) rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg); - else +#else + lock_kernel(); + rc = sock_filp->f_op->ioctl(sock_filp->f_dentry->d_inode, + sock_filp, cmd, arg); + unlock_kernel(); #endif - { - lock_kernel(); - rc =sock_filp->f_op->ioctl(sock_filp->f_dentry->d_inode, - sock_filp, cmd, arg); - unlock_kernel(); - } set_fs(oldmm); fput(sock_filp); diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 45b127e..8bd7f6b 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2093,6 +2093,24 @@ LB_LINUX_TRY_COMPILE([ ]) # +# 2.6.35 file_operations.fsync taken 2 arguments. +# +AC_DEFUN([LC_FILE_FSYNC], +[AC_MSG_CHECKING([if file_operations.fsync taken 2 arguments]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + ((struct file_operations *)0)->fsync(NULL, 0); +],[ + AC_DEFINE(HAVE_FILE_FSYNC_2ARGS, 1, + [file_operations.fsync taken 2 arguments]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# # 2.6.38 export blkdev_get_by_dev # AC_DEFUN([LC_BLKDEV_GET_BY_DEV], @@ -2317,6 +2335,9 @@ AC_DEFUN([LC_PROG_LINUX], LC_BLK_QUEUE_MAX_SEGMENTS LC_SET_CPUS_ALLOWED + # 2.6.35 + LC_FILE_FSYNC + # 2.6.36 LC_SBOPS_EVICT_INODE diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index dcd4331..392dce1 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1028,9 +1028,14 @@ out: RETURN(rc); } -static int ll_dir_ioctl(struct inode *inode, struct file *file, +#ifdef HAVE_UNLOCKED_IOCTL +static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +#else +static int ll_dir_ioctl(struct inode *unuse, struct file *file, unsigned int cmd, unsigned long arg) +#endif { + struct inode *inode = file->f_dentry->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_ioctl_data *data; int rc = 0; @@ -1614,6 +1619,10 @@ struct file_operations ll_dir_operations = { .release = ll_dir_release, .read = generic_read_dir, .readdir = ll_readdir, - .ioctl = ll_dir_ioctl, - .fsync = ll_fsync +#ifdef HAVE_UNLOCKED_IOCTL + .unlocked_ioctl = ll_dir_ioctl, +#else + .ioctl = ll_dir_ioctl, +#endif + .fsync = ll_fsync, }; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 42d0164..f797851 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1938,9 +1938,13 @@ 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 +int ll_fsync(struct file *file, int data) +#endif { - struct inode *inode = dentry->d_inode; + struct inode *inode = file->f_dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); struct lov_stripe_md *lsm = lli->lli_smd; struct ptlrpc_request *req; diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 7cfba13..45990cb 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -745,7 +745,11 @@ 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 +int ll_fsync(struct file *file, int data); +#endif int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, int num_bytes); int ll_merge_lvb(struct inode *inode); diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index af03ac7..eac9f9c 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -375,7 +375,7 @@ int lustre_fsync(struct file *file) if (!file || !file->f_op || !file->f_op->fsync) RETURN(-ENOSYS); - RETURN(file->f_op->fsync(file, file->f_dentry, 0)); + RETURN(cfs_do_fsync(file, 0)); } EXPORT_SYMBOL(lustre_fsync); -- 1.8.3.1