xfs: report iomap_bn in block base
authorChristoph Hellwig <hch@infradead.org>
Wed, 28 Apr 2010 12:28:55 +0000 (12:28 +0000)
committerAlex Elder <aelder@sgi.com>
Wed, 19 May 2010 14:58:17 +0000 (09:58 -0500)
Report the iomap_bn field of struct xfs_iomap in terms of filesystem
blocks instead of in terms of bytes.  Shift the byte conversions
into the caller, and replace the IOMAP_DELAY and IOMAP_HOLE flag
checks with checks for HOLESTARTBLOCK and DELAYSTARTBLOCK.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/xfs_iomap.c
fs/xfs/xfs_iomap.h

index 303a779..2b09cc3 100644 (file)
@@ -568,10 +568,12 @@ xfs_map_buffer(
        sector_t                bn;
        struct xfs_mount        *m = XFS_I(inode)->i_mount;
        xfs_off_t               iomap_offset = XFS_FSB_TO_B(m, mp->iomap_offset);
        sector_t                bn;
        struct xfs_mount        *m = XFS_I(inode)->i_mount;
        xfs_off_t               iomap_offset = XFS_FSB_TO_B(m, mp->iomap_offset);
+       xfs_daddr_t             iomap_bn = xfs_fsb_to_db(XFS_I(inode), mp->iomap_bn);
 
 
-       ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
+       ASSERT(mp->iomap_bn != HOLESTARTBLOCK);
+       ASSERT(mp->iomap_bn != DELAYSTARTBLOCK);
 
 
-       bn = (mp->iomap_bn >> (inode->i_blkbits - BBSHIFT)) +
+       bn = (iomap_bn >> (inode->i_blkbits - BBSHIFT)) +
              ((offset - iomap_offset) >> inode->i_blkbits);
 
        ASSERT(bn || XFS_IS_REALTIME_INODE(XFS_I(inode)));
              ((offset - iomap_offset) >> inode->i_blkbits);
 
        ASSERT(bn || XFS_IS_REALTIME_INODE(XFS_I(inode)));
@@ -587,8 +589,8 @@ xfs_map_at_offset(
        xfs_iomap_t             *iomapp,
        xfs_off_t               offset)
 {
        xfs_iomap_t             *iomapp,
        xfs_off_t               offset)
 {
-       ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
-       ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
+       ASSERT(iomapp->iomap_bn != HOLESTARTBLOCK);
+       ASSERT(iomapp->iomap_bn != DELAYSTARTBLOCK);
 
        lock_buffer(bh);
        xfs_map_buffer(inode, bh, iomapp, offset);
 
        lock_buffer(bh);
        xfs_map_buffer(inode, bh, iomapp, offset);
@@ -818,8 +820,8 @@ xfs_convert_page(
                                continue;
                        }
 
                                continue;
                        }
 
-                       ASSERT(!(mp->iomap_flags & IOMAP_HOLE));
-                       ASSERT(!(mp->iomap_flags & IOMAP_DELAY));
+                       ASSERT(mp->iomap_bn != HOLESTARTBLOCK);
+                       ASSERT(mp->iomap_bn != DELAYSTARTBLOCK);
 
                        xfs_map_at_offset(inode, bh, mp, offset);
                        if (startio) {
 
                        xfs_map_at_offset(inode, bh, mp, offset);
                        if (startio) {
@@ -1478,7 +1480,8 @@ __xfs_get_blocks(
        if (niomap == 0)
                return 0;
 
        if (niomap == 0)
                return 0;
 
-       if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
+       if (iomap.iomap_bn != HOLESTARTBLOCK &&
+           iomap.iomap_bn != DELAYSTARTBLOCK) {
                /*
                 * For unwritten extents do not report a disk address on
                 * the read case (treat as if we're reading into a hole).
                /*
                 * For unwritten extents do not report a disk address on
                 * the read case (treat as if we're reading into a hole).
@@ -1513,7 +1516,7 @@ __xfs_get_blocks(
             (iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN))))
                set_buffer_new(bh_result);
 
             (iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN))))
                set_buffer_new(bh_result);
 
-       if (iomap.iomap_flags & IOMAP_DELAY) {
+       if (iomap.iomap_bn == DELAYSTARTBLOCK) {
                BUG_ON(direct);
                if (create) {
                        set_buffer_uptodate(bh_result);
                BUG_ON(direct);
                if (create) {
                        set_buffer_uptodate(bh_result);
index 49b5ad2..fbe5d32 100644 (file)
@@ -64,24 +64,15 @@ xfs_imap_to_bmap(
        int             imaps,                  /* Number of imap entries */
        int             flags)
 {
        int             imaps,                  /* Number of imap entries */
        int             flags)
 {
-       xfs_fsblock_t   start_block;
-
        iomapp->iomap_offset = imap->br_startoff;
        iomapp->iomap_bsize = imap->br_blockcount;
        iomapp->iomap_flags = flags;
        iomapp->iomap_offset = imap->br_startoff;
        iomapp->iomap_bsize = imap->br_blockcount;
        iomapp->iomap_flags = flags;
+       iomapp->iomap_bn = imap->br_startblock;
 
 
-       start_block = imap->br_startblock;
-       if (start_block == HOLESTARTBLOCK) {
-               iomapp->iomap_bn = IOMAP_DADDR_NULL;
-               iomapp->iomap_flags |= IOMAP_HOLE;
-       } else if (start_block == DELAYSTARTBLOCK) {
-               iomapp->iomap_bn = IOMAP_DADDR_NULL;
-               iomapp->iomap_flags |= IOMAP_DELAY;
-       } else {
-               iomapp->iomap_bn = xfs_fsb_to_db(ip, start_block);
-               if (ISUNWRITTEN(imap))
-                       iomapp->iomap_flags |= IOMAP_UNWRITTEN;
-       }
+       if (imap->br_startblock != HOLESTARTBLOCK &&
+           imap->br_startblock != DELAYSTARTBLOCK &&
+           ISUNWRITTEN(imap))
+               iomapp->iomap_flags |= IOMAP_UNWRITTEN;
 }
 
 int
 }
 
 int
index db92996..d2f3b67 100644 (file)
 #ifndef __XFS_IOMAP_H__
 #define __XFS_IOMAP_H__
 
 #ifndef __XFS_IOMAP_H__
 #define __XFS_IOMAP_H__
 
-#define IOMAP_DADDR_NULL ((xfs_daddr_t) (-1LL))
-
-
 typedef enum {                         /* iomap_flags values */
        IOMAP_READ =            0,      /* mapping for a read */
 typedef enum {                         /* iomap_flags values */
        IOMAP_READ =            0,      /* mapping for a read */
-       IOMAP_HOLE =            0x02,   /* mapping covers a hole  */
        IOMAP_DELAY =           0x04,   /* mapping covers delalloc region  */
        IOMAP_UNWRITTEN =       0x20,   /* mapping covers allocated */
                                        /* but uninitialized file data  */
        IOMAP_DELAY =           0x04,   /* mapping covers delalloc region  */
        IOMAP_UNWRITTEN =       0x20,   /* mapping covers allocated */
                                        /* but uninitialized file data  */