aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iomap.c
diff options
context:
space:
mode:
authorLachlan McIlroy <lachlan@sgi.com>2007-10-11 03:34:33 -0400
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-02-07 00:44:14 -0500
commit541d7d3c4b31e2b0ac846fe6d2eb5cdbe1353095 (patch)
treed8c9cf9cf75fd3d23ebc19e5f6b646a4d807b72c /fs/xfs/xfs_iomap.c
parent21a62542b6d7f726d6c1d2cfbfa084f721ba4a26 (diff)
[XFS] kill unnessecary ioops indirection
Currently there is an indirection called ioops in the XFS data I/O path. Various functions are called by functions pointers, but there is no coherence in what this is for, and of course for XFS itself it's entirely unused. This patch removes it instead and significantly reduces source and binary size of XFS while making maintaince easier. SGI-PV: 970841 SGI-Modid: xfs-linux-melb:xfs-kern:29737a Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r--fs/xfs/xfs_iomap.c94
1 files changed, 48 insertions, 46 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 21ca62880514..4821b8563c41 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -53,11 +53,11 @@
53void 53void
54xfs_iomap_enter_trace( 54xfs_iomap_enter_trace(
55 int tag, 55 int tag,
56 xfs_iocore_t *io, 56 xfs_inode_t *ip,
57 xfs_off_t offset, 57 xfs_off_t offset,
58 ssize_t count) 58 ssize_t count)
59{ 59{
60 xfs_inode_t *ip = XFS_IO_INODE(io); 60 xfs_iocore_t *io = &ip->i_iocore;
61 61
62 if (!ip->i_rwtrace) 62 if (!ip->i_rwtrace)
63 return; 63 return;
@@ -84,15 +84,13 @@ xfs_iomap_enter_trace(
84void 84void
85xfs_iomap_map_trace( 85xfs_iomap_map_trace(
86 int tag, 86 int tag,
87 xfs_iocore_t *io, 87 xfs_inode_t *ip,
88 xfs_off_t offset, 88 xfs_off_t offset,
89 ssize_t count, 89 ssize_t count,
90 xfs_iomap_t *iomapp, 90 xfs_iomap_t *iomapp,
91 xfs_bmbt_irec_t *imapp, 91 xfs_bmbt_irec_t *imapp,
92 int flags) 92 int flags)
93{ 93{
94 xfs_inode_t *ip = XFS_IO_INODE(io);
95
96 if (!ip->i_rwtrace) 94 if (!ip->i_rwtrace)
97 return; 95 return;
98 96
@@ -126,7 +124,7 @@ xfs_iomap_map_trace(
126 124
127STATIC int 125STATIC int
128xfs_imap_to_bmap( 126xfs_imap_to_bmap(
129 xfs_iocore_t *io, 127 xfs_inode_t *ip,
130 xfs_off_t offset, 128 xfs_off_t offset,
131 xfs_bmbt_irec_t *imap, 129 xfs_bmbt_irec_t *imap,
132 xfs_iomap_t *iomapp, 130 xfs_iomap_t *iomapp,
@@ -134,11 +132,10 @@ xfs_imap_to_bmap(
134 int iomaps, /* Number of iomap entries */ 132 int iomaps, /* Number of iomap entries */
135 int flags) 133 int flags)
136{ 134{
137 xfs_mount_t *mp; 135 xfs_mount_t *mp = ip->i_mount;
138 int pbm; 136 int pbm;
139 xfs_fsblock_t start_block; 137 xfs_fsblock_t start_block;
140 138
141 mp = io->io_mount;
142 139
143 for (pbm = 0; imaps && pbm < iomaps; imaps--, iomapp++, imap++, pbm++) { 140 for (pbm = 0; imaps && pbm < iomaps; imaps--, iomapp++, imap++, pbm++) {
144 iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff); 141 iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
@@ -146,7 +143,7 @@ xfs_imap_to_bmap(
146 iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); 143 iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
147 iomapp->iomap_flags = flags; 144 iomapp->iomap_flags = flags;
148 145
149 if (io->io_flags & XFS_IOCORE_RT) { 146 if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
150 iomapp->iomap_flags |= IOMAP_REALTIME; 147 iomapp->iomap_flags |= IOMAP_REALTIME;
151 iomapp->iomap_target = mp->m_rtdev_targp; 148 iomapp->iomap_target = mp->m_rtdev_targp;
152 } else { 149 } else {
@@ -160,7 +157,7 @@ xfs_imap_to_bmap(
160 iomapp->iomap_bn = IOMAP_DADDR_NULL; 157 iomapp->iomap_bn = IOMAP_DADDR_NULL;
161 iomapp->iomap_flags |= IOMAP_DELAY; 158 iomapp->iomap_flags |= IOMAP_DELAY;
162 } else { 159 } else {
163 iomapp->iomap_bn = XFS_FSB_TO_DB_IO(io, start_block); 160 iomapp->iomap_bn = XFS_FSB_TO_DB(ip, start_block);
164 if (ISUNWRITTEN(imap)) 161 if (ISUNWRITTEN(imap))
165 iomapp->iomap_flags |= IOMAP_UNWRITTEN; 162 iomapp->iomap_flags |= IOMAP_UNWRITTEN;
166 } 163 }
@@ -172,14 +169,14 @@ xfs_imap_to_bmap(
172 169
173int 170int
174xfs_iomap( 171xfs_iomap(
175 xfs_iocore_t *io, 172 xfs_inode_t *ip,
176 xfs_off_t offset, 173 xfs_off_t offset,
177 ssize_t count, 174 ssize_t count,
178 int flags, 175 int flags,
179 xfs_iomap_t *iomapp, 176 xfs_iomap_t *iomapp,
180 int *niomaps) 177 int *niomaps)
181{ 178{
182 xfs_mount_t *mp = io->io_mount; 179 xfs_mount_t *mp = ip->i_mount;
183 xfs_fileoff_t offset_fsb, end_fsb; 180 xfs_fileoff_t offset_fsb, end_fsb;
184 int error = 0; 181 int error = 0;
185 int lockmode = 0; 182 int lockmode = 0;
@@ -188,32 +185,37 @@ xfs_iomap(
188 int bmapi_flags = 0; 185 int bmapi_flags = 0;
189 int iomap_flags = 0; 186 int iomap_flags = 0;
190 187
188 ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
189 ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
190 ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
191
191 if (XFS_FORCED_SHUTDOWN(mp)) 192 if (XFS_FORCED_SHUTDOWN(mp))
192 return XFS_ERROR(EIO); 193 return XFS_ERROR(EIO);
193 194
194 switch (flags & (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE)) { 195 switch (flags & (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE)) {
195 case BMAPI_READ: 196 case BMAPI_READ:
196 xfs_iomap_enter_trace(XFS_IOMAP_READ_ENTER, io, offset, count); 197 xfs_iomap_enter_trace(XFS_IOMAP_READ_ENTER, ip, offset, count);
197 lockmode = XFS_LCK_MAP_SHARED(mp, io); 198 lockmode = xfs_ilock_map_shared(ip);
198 bmapi_flags = XFS_BMAPI_ENTIRE; 199 bmapi_flags = XFS_BMAPI_ENTIRE;
199 break; 200 break;
200 case BMAPI_WRITE: 201 case BMAPI_WRITE:
201 xfs_iomap_enter_trace(XFS_IOMAP_WRITE_ENTER, io, offset, count); 202 xfs_iomap_enter_trace(XFS_IOMAP_WRITE_ENTER, ip, offset, count);
202 lockmode = XFS_ILOCK_EXCL|XFS_EXTSIZE_WR; 203 lockmode = XFS_ILOCK_EXCL|XFS_EXTSIZE_WR;
203 if (flags & BMAPI_IGNSTATE) 204 if (flags & BMAPI_IGNSTATE)
204 bmapi_flags |= XFS_BMAPI_IGSTATE|XFS_BMAPI_ENTIRE; 205 bmapi_flags |= XFS_BMAPI_IGSTATE|XFS_BMAPI_ENTIRE;
205 XFS_ILOCK(mp, io, lockmode); 206 xfs_ilock(ip, lockmode);
206 break; 207 break;
207 case BMAPI_ALLOCATE: 208 case BMAPI_ALLOCATE:
208 xfs_iomap_enter_trace(XFS_IOMAP_ALLOC_ENTER, io, offset, count); 209 xfs_iomap_enter_trace(XFS_IOMAP_ALLOC_ENTER, ip, offset, count);
209 lockmode = XFS_ILOCK_SHARED|XFS_EXTSIZE_RD; 210 lockmode = XFS_ILOCK_SHARED|XFS_EXTSIZE_RD;
210 bmapi_flags = XFS_BMAPI_ENTIRE; 211 bmapi_flags = XFS_BMAPI_ENTIRE;
212
211 /* Attempt non-blocking lock */ 213 /* Attempt non-blocking lock */
212 if (flags & BMAPI_TRYLOCK) { 214 if (flags & BMAPI_TRYLOCK) {
213 if (!XFS_ILOCK_NOWAIT(mp, io, lockmode)) 215 if (!xfs_ilock_nowait(ip, lockmode))
214 return XFS_ERROR(EAGAIN); 216 return XFS_ERROR(EAGAIN);
215 } else { 217 } else {
216 XFS_ILOCK(mp, io, lockmode); 218 xfs_ilock(ip, lockmode);
217 } 219 }
218 break; 220 break;
219 default: 221 default:
@@ -226,7 +228,7 @@ xfs_iomap(
226 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); 228 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
227 offset_fsb = XFS_B_TO_FSBT(mp, offset); 229 offset_fsb = XFS_B_TO_FSBT(mp, offset);
228 230
229 error = XFS_BMAPI(mp, NULL, io, offset_fsb, 231 error = xfs_bmapi(NULL, ip, offset_fsb,
230 (xfs_filblks_t)(end_fsb - offset_fsb), 232 (xfs_filblks_t)(end_fsb - offset_fsb),
231 bmapi_flags, NULL, 0, &imap, 233 bmapi_flags, NULL, 0, &imap,
232 &nimaps, NULL, NULL); 234 &nimaps, NULL, NULL);
@@ -240,42 +242,42 @@ xfs_iomap(
240 if (nimaps && 242 if (nimaps &&
241 (imap.br_startblock != HOLESTARTBLOCK) && 243 (imap.br_startblock != HOLESTARTBLOCK) &&
242 (imap.br_startblock != DELAYSTARTBLOCK)) { 244 (imap.br_startblock != DELAYSTARTBLOCK)) {
243 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, io, 245 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip,
244 offset, count, iomapp, &imap, flags); 246 offset, count, iomapp, &imap, flags);
245 break; 247 break;
246 } 248 }
247 249
248 if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) { 250 if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) {
249 error = XFS_IOMAP_WRITE_DIRECT(mp, io, offset, 251 error = xfs_iomap_write_direct(ip, offset, count, flags,
250 count, flags, &imap, &nimaps, nimaps); 252 &imap, &nimaps, nimaps);
251 } else { 253 } else {
252 error = XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, 254 error = xfs_iomap_write_delay(ip, offset, count, flags,
253 flags, &imap, &nimaps); 255 &imap, &nimaps);
254 } 256 }
255 if (!error) { 257 if (!error) {
256 xfs_iomap_map_trace(XFS_IOMAP_ALLOC_MAP, io, 258 xfs_iomap_map_trace(XFS_IOMAP_ALLOC_MAP, ip,
257 offset, count, iomapp, &imap, flags); 259 offset, count, iomapp, &imap, flags);
258 } 260 }
259 iomap_flags = IOMAP_NEW; 261 iomap_flags = IOMAP_NEW;
260 break; 262 break;
261 case BMAPI_ALLOCATE: 263 case BMAPI_ALLOCATE:
262 /* If we found an extent, return it */ 264 /* If we found an extent, return it */
263 XFS_IUNLOCK(mp, io, lockmode); 265 xfs_iunlock(ip, lockmode);
264 lockmode = 0; 266 lockmode = 0;
265 267
266 if (nimaps && !ISNULLSTARTBLOCK(imap.br_startblock)) { 268 if (nimaps && !ISNULLSTARTBLOCK(imap.br_startblock)) {
267 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, io, 269 xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip,
268 offset, count, iomapp, &imap, flags); 270 offset, count, iomapp, &imap, flags);
269 break; 271 break;
270 } 272 }
271 273
272 error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, offset, count, 274 error = xfs_iomap_write_allocate(ip, offset, count,
273 &imap, &nimaps); 275 &imap, &nimaps);
274 break; 276 break;
275 } 277 }
276 278
277 if (nimaps) { 279 if (nimaps) {
278 *niomaps = xfs_imap_to_bmap(io, offset, &imap, 280 *niomaps = xfs_imap_to_bmap(ip, offset, &imap,
279 iomapp, nimaps, *niomaps, iomap_flags); 281 iomapp, nimaps, *niomaps, iomap_flags);
280 } else if (niomaps) { 282 } else if (niomaps) {
281 *niomaps = 0; 283 *niomaps = 0;
@@ -283,14 +285,15 @@ xfs_iomap(
283 285
284out: 286out:
285 if (lockmode) 287 if (lockmode)
286 XFS_IUNLOCK(mp, io, lockmode); 288 xfs_iunlock(ip, lockmode);
287 return XFS_ERROR(error); 289 return XFS_ERROR(error);
288} 290}
289 291
292
290STATIC int 293STATIC int
291xfs_iomap_eof_align_last_fsb( 294xfs_iomap_eof_align_last_fsb(
292 xfs_mount_t *mp, 295 xfs_mount_t *mp,
293 xfs_iocore_t *io, 296 xfs_inode_t *ip,
294 xfs_fsize_t isize, 297 xfs_fsize_t isize,
295 xfs_extlen_t extsize, 298 xfs_extlen_t extsize,
296 xfs_fileoff_t *last_fsb) 299 xfs_fileoff_t *last_fsb)
@@ -299,7 +302,7 @@ xfs_iomap_eof_align_last_fsb(
299 xfs_extlen_t align; 302 xfs_extlen_t align;
300 int eof, error; 303 int eof, error;
301 304
302 if (io->io_flags & XFS_IOCORE_RT) 305 if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
303 ; 306 ;
304 /* 307 /*
305 * If mounted with the "-o swalloc" option, roundup the allocation 308 * If mounted with the "-o swalloc" option, roundup the allocation
@@ -330,7 +333,7 @@ xfs_iomap_eof_align_last_fsb(
330 } 333 }
331 334
332 if (new_last_fsb) { 335 if (new_last_fsb) {
333 error = XFS_BMAP_EOF(mp, io, new_last_fsb, XFS_DATA_FORK, &eof); 336 error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof);
334 if (error) 337 if (error)
335 return error; 338 return error;
336 if (eof) 339 if (eof)
@@ -435,7 +438,7 @@ xfs_iomap_write_direct(
435 offset_fsb = XFS_B_TO_FSBT(mp, offset); 438 offset_fsb = XFS_B_TO_FSBT(mp, offset);
436 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); 439 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
437 if ((offset + count) > isize) { 440 if ((offset + count) > isize) {
438 error = xfs_iomap_eof_align_last_fsb(mp, io, isize, extsz, 441 error = xfs_iomap_eof_align_last_fsb(mp, ip, isize, extsz,
439 &last_fsb); 442 &last_fsb);
440 if (error) 443 if (error)
441 goto error_out; 444 goto error_out;
@@ -502,7 +505,7 @@ xfs_iomap_write_direct(
502 */ 505 */
503 XFS_BMAP_INIT(&free_list, &firstfsb); 506 XFS_BMAP_INIT(&free_list, &firstfsb);
504 nimaps = 1; 507 nimaps = 1;
505 error = XFS_BMAPI(mp, tp, io, offset_fsb, count_fsb, bmapi_flag, 508 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, bmapi_flag,
506 &firstfsb, 0, &imap, &nimaps, &free_list, NULL); 509 &firstfsb, 0, &imap, &nimaps, &free_list, NULL);
507 if (error) 510 if (error)
508 goto error0; 511 goto error0;
@@ -560,7 +563,7 @@ error_out:
560STATIC int 563STATIC int
561xfs_iomap_eof_want_preallocate( 564xfs_iomap_eof_want_preallocate(
562 xfs_mount_t *mp, 565 xfs_mount_t *mp,
563 xfs_iocore_t *io, 566 xfs_inode_t *ip,
564 xfs_fsize_t isize, 567 xfs_fsize_t isize,
565 xfs_off_t offset, 568 xfs_off_t offset,
566 size_t count, 569 size_t count,
@@ -587,7 +590,7 @@ xfs_iomap_eof_want_preallocate(
587 while (count_fsb > 0) { 590 while (count_fsb > 0) {
588 imaps = nimaps; 591 imaps = nimaps;
589 firstblock = NULLFSBLOCK; 592 firstblock = NULLFSBLOCK;
590 error = XFS_BMAPI(mp, NULL, io, start_fsb, count_fsb, 0, 593 error = xfs_bmapi(NULL, ip, start_fsb, count_fsb, 0,
591 &firstblock, 0, imap, &imaps, NULL, NULL); 594 &firstblock, 0, imap, &imaps, NULL, NULL);
592 if (error) 595 if (error)
593 return error; 596 return error;
@@ -644,7 +647,7 @@ retry:
644 if (io->io_new_size > isize) 647 if (io->io_new_size > isize)
645 isize = io->io_new_size; 648 isize = io->io_new_size;
646 649
647 error = xfs_iomap_eof_want_preallocate(mp, io, isize, offset, count, 650 error = xfs_iomap_eof_want_preallocate(mp, ip, isize, offset, count,
648 ioflag, imap, XFS_WRITE_IMAPS, &prealloc); 651 ioflag, imap, XFS_WRITE_IMAPS, &prealloc);
649 if (error) 652 if (error)
650 return error; 653 return error;
@@ -658,7 +661,7 @@ retry:
658 } 661 }
659 662
660 if (prealloc || extsz) { 663 if (prealloc || extsz) {
661 error = xfs_iomap_eof_align_last_fsb(mp, io, isize, extsz, 664 error = xfs_iomap_eof_align_last_fsb(mp, ip, isize, extsz,
662 &last_fsb); 665 &last_fsb);
663 if (error) 666 if (error)
664 return error; 667 return error;
@@ -666,7 +669,7 @@ retry:
666 669
667 nimaps = XFS_WRITE_IMAPS; 670 nimaps = XFS_WRITE_IMAPS;
668 firstblock = NULLFSBLOCK; 671 firstblock = NULLFSBLOCK;
669 error = XFS_BMAPI(mp, NULL, io, offset_fsb, 672 error = xfs_bmapi(NULL, ip, offset_fsb,
670 (xfs_filblks_t)(last_fsb - offset_fsb), 673 (xfs_filblks_t)(last_fsb - offset_fsb),
671 XFS_BMAPI_DELAY | XFS_BMAPI_WRITE | 674 XFS_BMAPI_DELAY | XFS_BMAPI_WRITE |
672 XFS_BMAPI_ENTIRE, &firstblock, 1, imap, 675 XFS_BMAPI_ENTIRE, &firstblock, 1, imap,
@@ -680,7 +683,7 @@ retry:
680 */ 683 */
681 if (nimaps == 0) { 684 if (nimaps == 0) {
682 xfs_iomap_enter_trace(XFS_IOMAP_WRITE_NOSPACE, 685 xfs_iomap_enter_trace(XFS_IOMAP_WRITE_NOSPACE,
683 io, offset, count); 686 ip, offset, count);
684 if (xfs_flush_space(ip, &fsynced, &ioflag)) 687 if (xfs_flush_space(ip, &fsynced, &ioflag))
685 return XFS_ERROR(ENOSPC); 688 return XFS_ERROR(ENOSPC);
686 689
@@ -788,7 +791,7 @@ xfs_iomap_write_allocate(
788 } 791 }
789 792
790 /* Go get the actual blocks */ 793 /* Go get the actual blocks */
791 error = XFS_BMAPI(mp, tp, io, map_start_fsb, count_fsb, 794 error = xfs_bmapi(tp, ip, map_start_fsb, count_fsb,
792 XFS_BMAPI_WRITE, &first_block, 1, 795 XFS_BMAPI_WRITE, &first_block, 1,
793 imap, &nimaps, &free_list, NULL); 796 imap, &nimaps, &free_list, NULL);
794 if (error) 797 if (error)
@@ -860,8 +863,7 @@ xfs_iomap_write_unwritten(
860 int committed; 863 int committed;
861 int error; 864 int error;
862 865
863 xfs_iomap_enter_trace(XFS_IOMAP_UNWRITTEN, 866 xfs_iomap_enter_trace(XFS_IOMAP_UNWRITTEN, ip, offset, count);
864 &ip->i_iocore, offset, count);
865 867
866 offset_fsb = XFS_B_TO_FSBT(mp, offset); 868 offset_fsb = XFS_B_TO_FSBT(mp, offset);
867 count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); 869 count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
@@ -895,7 +897,7 @@ xfs_iomap_write_unwritten(
895 */ 897 */
896 XFS_BMAP_INIT(&free_list, &firstfsb); 898 XFS_BMAP_INIT(&free_list, &firstfsb);
897 nimaps = 1; 899 nimaps = 1;
898 error = XFS_BMAPI(mp, tp, io, offset_fsb, count_fsb, 900 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb,
899 XFS_BMAPI_WRITE|XFS_BMAPI_CONVERT, &firstfsb, 901 XFS_BMAPI_WRITE|XFS_BMAPI_CONVERT, &firstfsb,
900 1, &imap, &nimaps, &free_list, NULL); 902 1, &imap, &nimaps, &free_list, NULL);
901 if (error) 903 if (error)