[PATCH] replace inode_update_time with file_update_time
[linux-2.6.git] / fs / xfs / linux-2.6 / xfs_lrw.c
index acab58c..885dfaf 100644 (file)
@@ -1,44 +1,25 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003,2005 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
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation.
  *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
-/*
- *  fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
- *
- */
-
 #include "xfs.h"
-
 #include "xfs_fs.h"
-#include "xfs_inum.h"
+#include "xfs_bit.h"
 #include "xfs_log.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
 #include "xfs_dmapi.h"
 #include "xfs_quota.h"
 #include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
 #include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
+#include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_bmap.h"
-#include "xfs_bit.h"
+#include "xfs_btree.h"
+#include "xfs_ialloc.h"
 #include "xfs_rtalloc.h"
 #include "xfs_error.h"
 #include "xfs_itable.h"
@@ -274,7 +254,7 @@ xfs_read(
        }
 
        if (unlikely(ioflags & IO_ISDIRECT))
-               down(&inode->i_sem);
+               mutex_lock(&inode->i_mutex);
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
 
        if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
@@ -302,11 +282,11 @@ xfs_read(
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 
        if (likely(!(ioflags & IO_INVIS)))
-               xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
+               xfs_ichgtime_fast(ip, inode, XFS_ICHGTIME_ACC);
 
 unlock_isem:
        if (unlikely(ioflags & IO_ISDIRECT))
-               up(&inode->i_sem);
+               mutex_unlock(&inode->i_mutex);
        return ret;
 }
 
@@ -367,7 +347,7 @@ xfs_sendfile(
                XFS_STATS_ADD(xs_read_bytes, ret);
 
        if (likely(!(ioflags & IO_INVIS)))
-               xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
+               xfs_ichgtime_fast(ip, LINVFS_GET_IP(vp), XFS_ICHGTIME_ACC);
 
        return ret;
 }
@@ -660,9 +640,6 @@ xfs_write(
                        (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
                                mp->m_rtdev_targp : mp->m_ddev_targp;
 
-               if (ioflags & IO_ISAIO)
-                       return XFS_ERROR(-ENOSYS);
-
                if ((pos & target->pbr_smask) || (count & target->pbr_smask))
                        return XFS_ERROR(-EINVAL);
 
@@ -678,7 +655,7 @@ relock:
                iolock = XFS_IOLOCK_EXCL;
                locktype = VRWLOCK_WRITE;
 
-               down(&inode->i_sem);
+               mutex_lock(&inode->i_mutex);
        } else {
                iolock = XFS_IOLOCK_SHARED;
                locktype = VRWLOCK_WRITE_DIRECT;
@@ -709,7 +686,7 @@ start:
                int             dmflags = FILP_DELAY_FLAG(file);
 
                if (need_isem)
-                       dmflags |= DM_FLAGS_ISEM;
+                       dmflags |= DM_FLAGS_IMUX;
 
                xfs_iunlock(xip, XFS_ILOCK_EXCL);
                error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
@@ -735,15 +712,10 @@ start:
                }
        }
 
-       /*
-        * On Linux, generic_file_write updates the times even if
-        * no data is copied in so long as the write had a size.
-        *
-        * We must update xfs' times since revalidate will overcopy xfs.
-        */
-       if (!(ioflags & IO_INVIS)) {
-               xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-               inode_update_time(inode, 1);
+       if (likely(!(ioflags & IO_INVIS))) {
+               file_update_time(file);
+               xfs_ichgtime_fast(xip, inode,
+                                 XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
        }
 
        /*
@@ -800,7 +772,7 @@ retry:
                if (need_isem) {
                        /* demote the lock now the cached pages are gone */
                        XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
-                       up(&inode->i_sem);
+                       mutex_unlock(&inode->i_mutex);
 
                        iolock = XFS_IOLOCK_SHARED;
                        locktype = VRWLOCK_WRITE_DIRECT;
@@ -845,14 +817,14 @@ retry:
 
                xfs_rwunlock(bdp, locktype);
                if (need_isem)
-                       up(&inode->i_sem);
+                       mutex_unlock(&inode->i_mutex);
                error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
                                DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
                                0, 0, 0); /* Delay flag intentionally  unused */
                if (error)
                        goto out_nounlocks;
                if (need_isem)
-                       down(&inode->i_sem);
+                       mutex_lock(&inode->i_mutex);
                xfs_rwlock(bdp, locktype);
                pos = xip->i_d.di_size;
                ret = 0;
@@ -954,7 +926,7 @@ retry:
        
                xfs_rwunlock(bdp, locktype);
                if (need_isem)
-                       up(&inode->i_sem);
+                       mutex_unlock(&inode->i_mutex);
 
                error = sync_page_range(inode, mapping, pos, ret);
                if (!error)
@@ -966,7 +938,7 @@ retry:
        xfs_rwunlock(bdp, locktype);
  out_unlock_isem:
        if (need_isem)
-               up(&inode->i_sem);
+               mutex_unlock(&inode->i_mutex);
  out_nounlocks:
        return -error;
 }