Whamcloud - gitweb
LU-506 kernel: FC15 - file_operations relate changes.
authoryangsheng <ys@whamcloud.com>
Wed, 4 Jan 2012 15:23:16 +0000 (23:23 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 Jan 2012 15:01:41 +0000 (10:01 -0500)
   -- file_operations.ioctl() has been removed.
   -- file_operations.fsync() changes need 2 arguments.

Change-Id: I7776593497dd988fbf860221e2dcea61c6c4870f
Signed-off-by: Yang Sheng <ys@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1862
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
libcfs/include/libcfs/linux/linux-fs.h
libcfs/libcfs/linux/linux-module.c
libcfs/libcfs/linux/linux-tcpip.c
lustre/autoconf/lustre-core.m4
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/lvfs/lvfs_linux.c

index 9d42a6c..41b0f67 100644 (file)
@@ -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)
index d290172..1824d88 100644 (file)
@@ -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 = {
index 9d673f0..95136c1 100644 (file)
@@ -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);
index 45b127e..8bd7f6b 100644 (file)
@@ -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 <linux/fs.h>
+],[
+        ((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
 
index dcd4331..392dce1 100644 (file)
@@ -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,
 };
index 42d0164..f797851 100644 (file)
@@ -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;
index 7cfba13..45990cb 100644 (file)
@@ -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);
index af03ac7..eac9f9c 100644 (file)
@@ -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);