Commit 826bf0ad authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

xfs: limit xfs_imap_to_bmap to a single mapping

We only call xfs_iomap for single mappings anyway, so remove all
code dealing with multiple mappings from xfs_imap_to_bmap and add
asserts that we never get results that we do not expect.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent 4a5224d7
...@@ -55,22 +55,18 @@ ...@@ -55,22 +55,18 @@
#define XFS_STRAT_WRITE_IMAPS 2 #define XFS_STRAT_WRITE_IMAPS 2
#define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP
STATIC int STATIC void
xfs_imap_to_bmap( xfs_imap_to_bmap(
xfs_inode_t *ip, xfs_inode_t *ip,
xfs_off_t offset, xfs_off_t offset,
xfs_bmbt_irec_t *imap, xfs_bmbt_irec_t *imap,
xfs_iomap_t *iomapp, xfs_iomap_t *iomapp,
int imaps, /* Number of imap entries */ int imaps, /* Number of imap entries */
int iomaps, /* Number of iomap entries */
int flags) int flags)
{ {
xfs_mount_t *mp = ip->i_mount; xfs_mount_t *mp = ip->i_mount;
int pbm;
xfs_fsblock_t start_block; xfs_fsblock_t start_block;
for (pbm = 0; imaps && pbm < iomaps; imaps--, iomapp++, imap++, pbm++) {
iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff); iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
iomapp->iomap_delta = offset - iomapp->iomap_offset; iomapp->iomap_delta = offset - iomapp->iomap_offset;
iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
...@@ -94,10 +90,6 @@ xfs_imap_to_bmap( ...@@ -94,10 +90,6 @@ xfs_imap_to_bmap(
if (ISUNWRITTEN(imap)) if (ISUNWRITTEN(imap))
iomapp->iomap_flags |= IOMAP_UNWRITTEN; iomapp->iomap_flags |= IOMAP_UNWRITTEN;
} }
offset += iomapp->iomap_bsize - iomapp->iomap_delta;
}
return pbm; /* Return the number filled */
} }
int int
...@@ -119,6 +111,7 @@ xfs_iomap( ...@@ -119,6 +111,7 @@ xfs_iomap(
int iomap_flags = 0; int iomap_flags = 0;
ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
ASSERT(niomaps && *niomaps == 1);
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
...@@ -203,12 +196,11 @@ xfs_iomap( ...@@ -203,12 +196,11 @@ xfs_iomap(
break; break;
} }
if (nimaps) { ASSERT(nimaps <= 1);
*niomaps = xfs_imap_to_bmap(ip, offset, &imap,
iomapp, nimaps, *niomaps, iomap_flags); if (nimaps)
} else if (niomaps) { xfs_imap_to_bmap(ip, offset, &imap, iomapp, nimaps, iomap_flags);
*niomaps = 0; *niomaps = nimaps;
}
out: out:
if (lockmode) if (lockmode)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment