diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-04-28 08:28:51 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-19 10:58:16 -0400 |
commit | 826bf0adce0cddd9c94c2706b63d181dfc5cdaaa (patch) | |
tree | 7176db312e0090040e9798f2c7e6371bb78eedd7 /fs/xfs/xfs_iomap.c | |
parent | 4a5224d7b167e5470ad34e5b1b6965a16f87854f (diff) |
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: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r-- | fs/xfs/xfs_iomap.c | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 0b65039951a0..2d9bce7fcf85 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -55,49 +55,41 @@ | |||
55 | #define XFS_STRAT_WRITE_IMAPS 2 | 55 | #define XFS_STRAT_WRITE_IMAPS 2 |
56 | #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP | 56 | #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP |
57 | 57 | ||
58 | STATIC int | 58 | STATIC void |
59 | xfs_imap_to_bmap( | 59 | xfs_imap_to_bmap( |
60 | xfs_inode_t *ip, | 60 | xfs_inode_t *ip, |
61 | xfs_off_t offset, | 61 | xfs_off_t offset, |
62 | xfs_bmbt_irec_t *imap, | 62 | xfs_bmbt_irec_t *imap, |
63 | xfs_iomap_t *iomapp, | 63 | xfs_iomap_t *iomapp, |
64 | int imaps, /* Number of imap entries */ | 64 | int imaps, /* Number of imap entries */ |
65 | int iomaps, /* Number of iomap entries */ | ||
66 | int flags) | 65 | int flags) |
67 | { | 66 | { |
68 | xfs_mount_t *mp = ip->i_mount; | 67 | xfs_mount_t *mp = ip->i_mount; |
69 | int pbm; | ||
70 | xfs_fsblock_t start_block; | 68 | xfs_fsblock_t start_block; |
71 | 69 | ||
70 | iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff); | ||
71 | iomapp->iomap_delta = offset - iomapp->iomap_offset; | ||
72 | iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); | ||
73 | iomapp->iomap_flags = flags; | ||
72 | 74 | ||
73 | for (pbm = 0; imaps && pbm < iomaps; imaps--, iomapp++, imap++, pbm++) { | 75 | if (XFS_IS_REALTIME_INODE(ip)) { |
74 | iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff); | 76 | iomapp->iomap_flags |= IOMAP_REALTIME; |
75 | iomapp->iomap_delta = offset - iomapp->iomap_offset; | 77 | iomapp->iomap_target = mp->m_rtdev_targp; |
76 | iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); | 78 | } else { |
77 | iomapp->iomap_flags = flags; | 79 | iomapp->iomap_target = mp->m_ddev_targp; |
78 | 80 | } | |
79 | if (XFS_IS_REALTIME_INODE(ip)) { | 81 | start_block = imap->br_startblock; |
80 | iomapp->iomap_flags |= IOMAP_REALTIME; | 82 | if (start_block == HOLESTARTBLOCK) { |
81 | iomapp->iomap_target = mp->m_rtdev_targp; | 83 | iomapp->iomap_bn = IOMAP_DADDR_NULL; |
82 | } else { | 84 | iomapp->iomap_flags |= IOMAP_HOLE; |
83 | iomapp->iomap_target = mp->m_ddev_targp; | 85 | } else if (start_block == DELAYSTARTBLOCK) { |
84 | } | 86 | iomapp->iomap_bn = IOMAP_DADDR_NULL; |
85 | start_block = imap->br_startblock; | 87 | iomapp->iomap_flags |= IOMAP_DELAY; |
86 | if (start_block == HOLESTARTBLOCK) { | 88 | } else { |
87 | iomapp->iomap_bn = IOMAP_DADDR_NULL; | 89 | iomapp->iomap_bn = xfs_fsb_to_db(ip, start_block); |
88 | iomapp->iomap_flags |= IOMAP_HOLE; | 90 | if (ISUNWRITTEN(imap)) |
89 | } else if (start_block == DELAYSTARTBLOCK) { | 91 | iomapp->iomap_flags |= IOMAP_UNWRITTEN; |
90 | iomapp->iomap_bn = IOMAP_DADDR_NULL; | ||
91 | iomapp->iomap_flags |= IOMAP_DELAY; | ||
92 | } else { | ||
93 | iomapp->iomap_bn = xfs_fsb_to_db(ip, start_block); | ||
94 | if (ISUNWRITTEN(imap)) | ||
95 | iomapp->iomap_flags |= IOMAP_UNWRITTEN; | ||
96 | } | ||
97 | |||
98 | offset += iomapp->iomap_bsize - iomapp->iomap_delta; | ||
99 | } | 92 | } |
100 | return pbm; /* Return the number filled */ | ||
101 | } | 93 | } |
102 | 94 | ||
103 | int | 95 | int |
@@ -119,6 +111,7 @@ xfs_iomap( | |||
119 | int iomap_flags = 0; | 111 | int iomap_flags = 0; |
120 | 112 | ||
121 | ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); | 113 | ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); |
114 | ASSERT(niomaps && *niomaps == 1); | ||
122 | 115 | ||
123 | if (XFS_FORCED_SHUTDOWN(mp)) | 116 | if (XFS_FORCED_SHUTDOWN(mp)) |
124 | return XFS_ERROR(EIO); | 117 | return XFS_ERROR(EIO); |
@@ -203,12 +196,11 @@ xfs_iomap( | |||
203 | break; | 196 | break; |
204 | } | 197 | } |
205 | 198 | ||
206 | if (nimaps) { | 199 | ASSERT(nimaps <= 1); |
207 | *niomaps = xfs_imap_to_bmap(ip, offset, &imap, | 200 | |
208 | iomapp, nimaps, *niomaps, iomap_flags); | 201 | if (nimaps) |
209 | } else if (niomaps) { | 202 | xfs_imap_to_bmap(ip, offset, &imap, iomapp, nimaps, iomap_flags); |
210 | *niomaps = 0; | 203 | *niomaps = nimaps; |
211 | } | ||
212 | 204 | ||
213 | out: | 205 | out: |
214 | if (lockmode) | 206 | if (lockmode) |