fedora core 2.6.10-1.12-FC2
[linux-2.6.git] / fs / xfs / linux-2.6 / xfs_file.c
index aaa74d2..66462e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -53,6 +53,7 @@
 #include "xfs_rw.h"
 
 #include <linux/dcache.h>
+#include <linux/smp_lock.h>
 
 static struct vm_operations_struct linvfs_file_vm_ops;
 
@@ -60,7 +61,7 @@ static struct vm_operations_struct linvfs_file_vm_ops;
 STATIC inline ssize_t
 __linvfs_read(
        struct kiocb            *iocb,
-       char __user             *buf,
+       char                    __user *buf,
        int                     ioflags,
        size_t                  count,
        loff_t                  pos)
@@ -82,7 +83,7 @@ __linvfs_read(
 STATIC ssize_t
 linvfs_read(
        struct kiocb            *iocb,
-       char __user             *buf,
+       char                    __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
@@ -92,7 +93,7 @@ linvfs_read(
 STATIC ssize_t
 linvfs_read_invis(
        struct kiocb            *iocb,
-       char __user             *buf,
+       char                    __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
@@ -103,29 +104,22 @@ linvfs_read_invis(
 STATIC inline ssize_t
 __linvfs_write(
        struct kiocb    *iocb,
-       const char      *buf,
+       const char      __user *buf,
        int             ioflags,
        size_t          count,
        loff_t          pos)
 {
-       struct iovec    iov = {(void *)buf, count};
+       struct iovec    iov = {(void __user *)buf, count};
        struct file     *file = iocb->ki_filp;
        struct inode    *inode = file->f_mapping->host;
        vnode_t         *vp = LINVFS_GET_VP(inode);
        ssize_t         rval;
 
        BUG_ON(iocb->ki_pos != pos);
-       if (unlikely(file->f_flags & O_DIRECT)) {
+       if (unlikely(file->f_flags & O_DIRECT))
                ioflags |= IO_ISDIRECT;
-               VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos,
-                               ioflags, NULL, rval);
-       } else {
-               down(&inode->i_sem);
-               VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos,
-                               ioflags, NULL, rval);
-               up(&inode->i_sem);
-       }
 
+       VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL, rval);
        return rval;
 }
 
@@ -133,7 +127,7 @@ __linvfs_write(
 STATIC ssize_t
 linvfs_write(
        struct kiocb            *iocb,
-       const char __user       *buf,
+       const char              __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
@@ -143,7 +137,7 @@ linvfs_write(
 STATIC ssize_t
 linvfs_write_invis(
        struct kiocb            *iocb,
-       const char __user       *buf,
+       const char              __user *buf,
        size_t                  count,
        loff_t                  pos)
 {
@@ -170,8 +164,6 @@ __linvfs_readv(
        if (unlikely(file->f_flags & O_DIRECT))
                ioflags |= IO_ISDIRECT;
        VOP_READ(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval);
-       if (rval == -EIOCBQUEUED)
-               rval = wait_on_sync_kiocb(&kiocb);
 
        *ppos = kiocb.ki_pos;
        return rval;
@@ -213,19 +205,10 @@ __linvfs_writev(
 
        init_sync_kiocb(&kiocb, file);
        kiocb.ki_pos = *ppos;
-       if (unlikely(file->f_flags & O_DIRECT)) {
+       if (unlikely(file->f_flags & O_DIRECT))
                ioflags |= IO_ISDIRECT;
-               VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos,
-                               ioflags, NULL, rval);
-       } else {
-               down(&inode->i_sem);
-               VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos,
-                               ioflags, NULL, rval);
-               up(&inode->i_sem);
-       }
 
-       if (rval == -EIOCBQUEUED)
-               rval = wait_on_sync_kiocb(&kiocb);
+       VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval);
 
        *ppos = kiocb.ki_pos;
        return rval;
@@ -415,7 +398,7 @@ linvfs_file_mmap(
        vattr_t         va = { .va_mask = XFS_AT_UPDATIME };
        int             error;
 
-       if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
+       if (vp->v_vfsp->vfs_flag & VFS_DMI) {
                xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);
 
                error = -XFS_SEND_MMAP(mp, vma, 0);
@@ -426,6 +409,8 @@ linvfs_file_mmap(
        vma->vm_ops = &linvfs_file_vm_ops;
 
        VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
+       if (!error)
+               vn_revalidate(vp);      /* update Linux inode flags */
        return 0;
 }
 
@@ -440,9 +425,10 @@ linvfs_ioctl(
        int             error;
        vnode_t         *vp = LINVFS_GET_VP(inode);
 
-       ASSERT(vp);
-       VOP_IOCTL(vp, inode, filp, 0, cmd, arg, error);
+       unlock_kernel();
+       VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error);
        VMODIFY(vp);
+       lock_kernel();
 
        /* NOTE:  some of the ioctl's return positive #'s as a
         *        byte count indicating success, such as
@@ -463,9 +449,11 @@ linvfs_ioctl_invis(
        int             error;
        vnode_t         *vp = LINVFS_GET_VP(inode);
 
+       unlock_kernel();
        ASSERT(vp);
-       VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, arg, error);
+       VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error);
        VMODIFY(vp);
+       lock_kernel();
 
        /* NOTE:  some of the ioctl's return positive #'s as a
         *        byte count indicating success, such as
@@ -485,7 +473,7 @@ linvfs_mprotect(
        vnode_t         *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode);
        int             error = 0;
 
-       if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
+       if (vp->v_vfsp->vfs_flag & VFS_DMI) {
                if ((vma->vm_flags & VM_MAYSHARE) &&
                    (newflags & VM_WRITE) && !(vma->vm_flags & VM_WRITE)) {
                        xfs_mount_t     *mp = XFS_VFSTOM(vp->v_vfsp);