xfs: improve metadata I/O merging in the elevator
[safe/jmp/linux-2.6] / fs / xfs / xfs_rw.c
index d33e4f5..5aa07ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
+ * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_bmap_btree.h"
 #include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_ialloc.h"
 #include "xfs_attr.h"
 #include "xfs_bmap.h"
-#include "xfs_acl.h"
-#include "xfs_mac.h"
 #include "xfs_error.h"
 #include "xfs_buf_item.h"
 #include "xfs_rw.h"
+#include "xfs_trace.h"
 
 /*
  * This is a subroutine for xfs_write() and other writers (xfs_ioctl)
@@ -86,7 +83,7 @@ xfs_write_clear_setuid(
        }
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        xfs_trans_set_sync(tp);
-       error = xfs_trans_commit(tp, 0, NULL);
+       error = xfs_trans_commit(tp, 0);
        xfs_iunlock(ip, XFS_ILOCK_EXCL);
        return 0;
 }
@@ -97,18 +94,15 @@ xfs_write_clear_setuid(
  * the shop, make sure that absolutely nothing persistent happens to
  * this filesystem after this point.
  */
-
 void
 xfs_do_force_shutdown(
-       bhv_desc_t      *bdp,
+       xfs_mount_t     *mp,
        int             flags,
        char            *fname,
        int             lnnum)
 {
        int             logerror;
-       xfs_mount_t     *mp;
 
-       mp = XFS_BHVTOM(bdp);
        logerror = flags & SHUTDOWN_LOG_IO_ERROR;
 
        if (!(flags & SHUTDOWN_FORCE_UMOUNT)) {
@@ -178,7 +172,6 @@ xfs_bioerror(
         * No need to wait until the buffer is unpinned.
         * We aren't flushing it.
         */
-       xfs_buftrace("XFS IOERROR", bp);
        XFS_BUF_ERROR(bp, EIO);
        /*
         * We're calling biodone, so delete B_DONE flag. Either way
@@ -212,7 +205,6 @@ xfs_bioerror_relse(
        ASSERT(XFS_BUF_IODONE_FUNC(bp) != xfs_buf_iodone_callbacks);
        ASSERT(XFS_BUF_IODONE_FUNC(bp) != xlog_iodone);
 
-       xfs_buftrace("XFS IOERRELSE", bp);
        fl = XFS_BUF_BFLAGS(bp);
        /*
         * No need to wait until the buffer is unpinned.
@@ -236,7 +228,7 @@ xfs_bioerror_relse(
                 * ASYNC buffers.
                 */
                XFS_BUF_ERROR(bp, EIO);
-               XFS_BUF_V_IODONESEMA(bp);
+               XFS_BUF_FINISH_IOWAIT(bp);
        } else {
                xfs_buf_relse(bp);
        }
@@ -284,10 +276,10 @@ xfs_read_buf(
        xfs_buf_t        *bp;
        int              error;
 
-       if (flags)
-               bp = xfs_buf_read_flags(target, blkno, len, flags);
-       else
-               bp = xfs_buf_read(target, blkno, len, flags);
+       if (!flags)
+               flags = XBF_LOCK | XBF_MAPPED;
+
+       bp = xfs_buf_read(target, blkno, len, flags);
        if (!bp)
                return XFS_ERROR(EIO);
        error = XFS_BUF_GETERROR(bp);
@@ -328,7 +320,7 @@ xfs_bwrite(
         * XXXsup how does this work for quotas.
         */
        XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
-       XFS_BUF_SET_FSPRIVATE3(bp, mp);
+       bp->b_mount = mp;
        XFS_BUF_WRITE(bp);
 
        if ((error = XFS_bwrite(bp))) {
@@ -343,3 +335,25 @@ xfs_bwrite(
        }
        return (error);
 }
+
+/*
+ * helper function to extract extent size hint from inode
+ */
+xfs_extlen_t
+xfs_get_extsz_hint(
+       struct xfs_inode        *ip)
+{
+       xfs_extlen_t            extsz;
+
+       if (unlikely(XFS_IS_REALTIME_INODE(ip))) {
+               extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
+                               ? ip->i_d.di_extsize
+                               : ip->i_mount->m_sb.sb_rextsize;
+               ASSERT(extsz);
+       } else {
+               extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
+                               ? ip->i_d.di_extsize : 0;
+       }
+
+       return extsz;
+}