xfs: improve metadata I/O merging in the elevator
[safe/jmp/linux-2.6] / fs / xfs / xfs_rw.c
index 3f816ad..5aa07ca 100644 (file)
@@ -44,6 +44,7 @@
 #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)
@@ -171,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
@@ -205,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.
@@ -277,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);
@@ -336,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;
+}