[XFS] send dmapi events from nopage for mmapped files
authorDean Roehrich <roehrich@sgi.com>
Fri, 2 Sep 2005 05:43:05 +0000 (15:43 +1000)
committerNathan Scott <nathans@sgi.com>
Fri, 2 Sep 2005 05:43:05 +0000 (15:43 +1000)
SGI-PV: 935317
SGI-Modid: xfs-linux:xfs-kern:192007a

Signed-off-by: Dean Roehrich <roehrich@sgi.com>
Signed-off-by: Nathan Scott <nathans@sgi.com>
fs/xfs/linux-2.6/xfs_file.c

index f1ce4323f56e905c499e3889734d878d82c7b566..3881622bcf081abcf35d81dbe720f184a7720d3d 100644 (file)
@@ -311,6 +311,31 @@ linvfs_fsync(
 
 #define nextdp(dp)      ((struct xfs_dirent *)((char *)(dp) + (dp)->d_reclen))
 
+#ifdef CONFIG_XFS_DMAPI
+
+STATIC struct page *
+linvfs_filemap_nopage(
+       struct vm_area_struct   *area,
+       unsigned long           address,
+       int                     *type)
+{
+       struct inode    *inode = area->vm_file->f_dentry->d_inode;
+       vnode_t         *vp = LINVFS_GET_VP(inode);
+       xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
+       int             error;
+
+       ASSERT_ALWAYS(vp->v_vfsp->vfs_flag & VFS_DMI);
+
+       error = XFS_SEND_MMAP(mp, area, 0);
+       if (error)
+               return NULL;
+
+       return filemap_nopage(area, address, type);
+}
+
+#endif /* CONFIG_XFS_DMAPI */
+
+
 STATIC int
 linvfs_readdir(
        struct file     *filp,
@@ -390,14 +415,6 @@ done:
        return -error;
 }
 
-#ifdef CONFIG_XFS_DMAPI
-STATIC void
-linvfs_mmap_close(
-       struct vm_area_struct   *vma)
-{
-       xfs_dm_mm_put(vma);
-}
-#endif /* CONFIG_XFS_DMAPI */
 
 STATIC int
 linvfs_file_mmap(
@@ -411,16 +428,11 @@ linvfs_file_mmap(
 
        vma->vm_ops = &linvfs_file_vm_ops;
 
-       if (vp->v_vfsp->vfs_flag & VFS_DMI) {
-               xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
-
-               error = -XFS_SEND_MMAP(mp, vma, 0);
-               if (error)
-                       return error;
 #ifdef CONFIG_XFS_DMAPI
+       if (vp->v_vfsp->vfs_flag & VFS_DMI) {
                vma->vm_ops = &linvfs_dmapi_file_vm_ops;
-#endif
        }
+#endif /* CONFIG_XFS_DMAPI */
 
        VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
        if (!error)
@@ -474,6 +486,7 @@ linvfs_ioctl_invis(
        return error;
 }
 
+#ifdef CONFIG_XFS_DMAPI
 #ifdef HAVE_VMOP_MPROTECT
 STATIC int
 linvfs_mprotect(
@@ -494,6 +507,7 @@ linvfs_mprotect(
        return error;
 }
 #endif /* HAVE_VMOP_MPROTECT */
+#endif /* CONFIG_XFS_DMAPI */
 
 #ifdef HAVE_FOP_OPEN_EXEC
 /* If the user is attempting to execute a file that is offline then
@@ -528,49 +542,10 @@ open_exec_out:
 }
 #endif /* HAVE_FOP_OPEN_EXEC */
 
-/*
- * Temporary workaround to the AIO direct IO write problem.
- * This code can go and we can revert to do_sync_write once
- * the writepage(s) rework is merged.
- */
-STATIC ssize_t
-linvfs_write(
-       struct file     *filp,
-       const char      __user *buf,
-       size_t          len,
-       loff_t          *ppos)
-{
-       struct kiocb    kiocb;
-       ssize_t         ret;
-
-       init_sync_kiocb(&kiocb, filp);
-       kiocb.ki_pos = *ppos;
-       ret = __linvfs_write(&kiocb, buf, 0, len, kiocb.ki_pos);
-       *ppos = kiocb.ki_pos;
-       return ret;
-}
-STATIC ssize_t
-linvfs_write_invis(
-       struct file     *filp,
-       const char      __user *buf,
-       size_t          len,
-       loff_t          *ppos)
-{
-       struct kiocb    kiocb;
-       ssize_t         ret;
-
-       init_sync_kiocb(&kiocb, filp);
-       kiocb.ki_pos = *ppos;
-       ret = __linvfs_write(&kiocb, buf, IO_INVIS, len, kiocb.ki_pos);
-       *ppos = kiocb.ki_pos;
-       return ret;
-}
-
-
 struct file_operations linvfs_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
-       .write          = linvfs_write,
+       .write          = do_sync_write,
        .readv          = linvfs_readv,
        .writev         = linvfs_writev,
        .aio_read       = linvfs_aio_read,
@@ -592,7 +567,7 @@ struct file_operations linvfs_file_operations = {
 struct file_operations linvfs_invis_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
-       .write          = linvfs_write_invis,
+       .write          = do_sync_write,
        .readv          = linvfs_readv_invis,
        .writev         = linvfs_writev_invis,
        .aio_read       = linvfs_aio_read_invis,
@@ -626,8 +601,7 @@ static struct vm_operations_struct linvfs_file_vm_ops = {
 
 #ifdef CONFIG_XFS_DMAPI
 static struct vm_operations_struct linvfs_dmapi_file_vm_ops = {
-       .close          = linvfs_mmap_close,
-       .nopage         = filemap_nopage,
+       .nopage         = linvfs_filemap_nopage,
        .populate       = filemap_populate,
 #ifdef HAVE_VMOP_MPROTECT
        .mprotect       = linvfs_mprotect,