vserver 2.0 rc7
[linux-2.6.git] / fs / xfs / xfs_iomap.c
index 3826e8f..469e1a7 100644 (file)
@@ -278,7 +278,9 @@ phase2:
        switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE|BMAPI_UNWRITTEN)) {
        case BMAPI_WRITE:
                /* If we found an extent, return it */
-               if (nimaps && (imap.br_startblock != HOLESTARTBLOCK)) {
+               if (nimaps &&
+                   (imap.br_startblock != HOLESTARTBLOCK) && 
+                   (imap.br_startblock != DELAYSTARTBLOCK)) {
                        xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, io,
                                        offset, count, iomapp, &imap, flags);
                        break;
@@ -308,7 +310,8 @@ phase2:
                        break;
                }
 
-               error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, &imap, &nimaps);
+               error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, offset, count,
+                                                &imap, &nimaps);
                break;
        case BMAPI_UNWRITTEN:
                lockmode = 0;
@@ -365,7 +368,7 @@ xfs_flush_space(
 int
 xfs_iomap_write_direct(
        xfs_inode_t     *ip,
-       loff_t          offset,
+       xfs_off_t       offset,
        size_t          count,
        int             flags,
        xfs_bmbt_irec_t *ret_imap,
@@ -541,7 +544,7 @@ error_out:
 int
 xfs_iomap_write_delay(
        xfs_inode_t     *ip,
-       loff_t          offset,
+       xfs_off_t       offset,
        size_t          count,
        int             ioflag,
        xfs_bmbt_irec_t *ret_imap,
@@ -746,6 +749,8 @@ write_map:
 int
 xfs_iomap_write_allocate(
        xfs_inode_t     *ip,
+       xfs_off_t       offset,
+       size_t          count,
        xfs_bmbt_irec_t *map,
        int             *retmap)
 {
@@ -770,9 +775,9 @@ xfs_iomap_write_allocate(
        if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
                return XFS_ERROR(error);
 
-       offset_fsb = map->br_startoff;
+       offset_fsb = XFS_B_TO_FSBT(mp, offset);
        count_fsb = map->br_blockcount;
-       map_start_fsb = offset_fsb;
+       map_start_fsb = map->br_startoff;
 
        XFS_STATS_ADD(xs_xstrat_bytes, XFS_FSB_TO_B(mp, count_fsb));
 
@@ -868,9 +873,9 @@ xfs_iomap_write_allocate(
                                        imap[i].br_startoff,
                                        imap[i].br_blockcount,imap[i].br_state);
                         }
-                       if ((map->br_startoff >= imap[i].br_startoff) &&
-                           (map->br_startoff < (imap[i].br_startoff +
-                                                imap[i].br_blockcount))) {
+                       if ((offset_fsb >= imap[i].br_startoff) &&
+                           (offset_fsb < (imap[i].br_startoff +
+                                          imap[i].br_blockcount))) {
                                *map = imap[i];
                                *retmap = 1;
                                XFS_STATS_INC(xs_xstrat_quick);
@@ -883,9 +888,8 @@ xfs_iomap_write_allocate(
                 * file, just surrounding data, try again.
                 */
                nimaps--;
-               offset_fsb = imap[nimaps].br_startoff +
-                            imap[nimaps].br_blockcount;
-               map_start_fsb = offset_fsb;
+               map_start_fsb = imap[nimaps].br_startoff +
+                               imap[nimaps].br_blockcount;
        }
 
 trans_cancel:
@@ -899,7 +903,7 @@ error0:
 int
 xfs_iomap_write_unwritten(
        xfs_inode_t     *ip,
-       loff_t          offset,
+       xfs_off_t       offset,
        size_t          count)
 {
        xfs_mount_t     *mp = ip->i_mount;