diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-04-28 08:28:56 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-19 10:58:17 -0400 |
commit | 207d041602cead1c1a16288f6225aea9da1f5bc4 (patch) | |
tree | ad6149735c8bc0c5d112e301e6e17dac6280dcb6 /fs/xfs | |
parent | e513182d4d7ec8f1870ae368c549ef2838e2c105 (diff) |
xfs: kill struct xfs_iomap
Now that struct xfs_iomap contains exactly the same units as struct
xfs_bmbt_irec we can just use the latter directly in the aops code.
Replace the missing IOMAP_NEW flag with a new boolean output
parameter to xfs_iomap.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_aops.c | 90 | ||||
-rw-r--r-- | fs/xfs/xfs_iomap.c | 82 | ||||
-rw-r--r-- | fs/xfs/xfs_iomap.h | 26 |
3 files changed, 75 insertions, 123 deletions
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 2b09cc34dd07..70ce1da73d01 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -310,23 +310,24 @@ xfs_map_blocks( | |||
310 | struct inode *inode, | 310 | struct inode *inode, |
311 | loff_t offset, | 311 | loff_t offset, |
312 | ssize_t count, | 312 | ssize_t count, |
313 | xfs_iomap_t *mapp, | 313 | struct xfs_bmbt_irec *imap, |
314 | int flags) | 314 | int flags) |
315 | { | 315 | { |
316 | int nmaps = 1; | 316 | int nmaps = 1; |
317 | int new = 0; | ||
317 | 318 | ||
318 | return -xfs_iomap(XFS_I(inode), offset, count, flags, mapp, &nmaps); | 319 | return -xfs_iomap(XFS_I(inode), offset, count, flags, imap, &nmaps, &new); |
319 | } | 320 | } |
320 | 321 | ||
321 | STATIC int | 322 | STATIC int |
322 | xfs_iomap_valid( | 323 | xfs_iomap_valid( |
323 | struct inode *inode, | 324 | struct inode *inode, |
324 | xfs_iomap_t *iomapp, | 325 | struct xfs_bmbt_irec *imap, |
325 | loff_t offset) | 326 | loff_t offset) |
326 | { | 327 | { |
327 | struct xfs_mount *mp = XFS_I(inode)->i_mount; | 328 | struct xfs_mount *mp = XFS_I(inode)->i_mount; |
328 | xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, iomapp->iomap_offset); | 329 | xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff); |
329 | xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, iomapp->iomap_bsize); | 330 | xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); |
330 | 331 | ||
331 | return offset >= iomap_offset && | 332 | return offset >= iomap_offset && |
332 | offset < iomap_offset + iomap_bsize; | 333 | offset < iomap_offset + iomap_bsize; |
@@ -562,16 +563,16 @@ STATIC void | |||
562 | xfs_map_buffer( | 563 | xfs_map_buffer( |
563 | struct inode *inode, | 564 | struct inode *inode, |
564 | struct buffer_head *bh, | 565 | struct buffer_head *bh, |
565 | xfs_iomap_t *mp, | 566 | struct xfs_bmbt_irec *imap, |
566 | xfs_off_t offset) | 567 | xfs_off_t offset) |
567 | { | 568 | { |
568 | sector_t bn; | 569 | sector_t bn; |
569 | struct xfs_mount *m = XFS_I(inode)->i_mount; | 570 | struct xfs_mount *m = XFS_I(inode)->i_mount; |
570 | xfs_off_t iomap_offset = XFS_FSB_TO_B(m, mp->iomap_offset); | 571 | xfs_off_t iomap_offset = XFS_FSB_TO_B(m, imap->br_startoff); |
571 | xfs_daddr_t iomap_bn = xfs_fsb_to_db(XFS_I(inode), mp->iomap_bn); | 572 | xfs_daddr_t iomap_bn = xfs_fsb_to_db(XFS_I(inode), imap->br_startblock); |
572 | 573 | ||
573 | ASSERT(mp->iomap_bn != HOLESTARTBLOCK); | 574 | ASSERT(imap->br_startblock != HOLESTARTBLOCK); |
574 | ASSERT(mp->iomap_bn != DELAYSTARTBLOCK); | 575 | ASSERT(imap->br_startblock != DELAYSTARTBLOCK); |
575 | 576 | ||
576 | bn = (iomap_bn >> (inode->i_blkbits - BBSHIFT)) + | 577 | bn = (iomap_bn >> (inode->i_blkbits - BBSHIFT)) + |
577 | ((offset - iomap_offset) >> inode->i_blkbits); | 578 | ((offset - iomap_offset) >> inode->i_blkbits); |
@@ -586,14 +587,14 @@ STATIC void | |||
586 | xfs_map_at_offset( | 587 | xfs_map_at_offset( |
587 | struct inode *inode, | 588 | struct inode *inode, |
588 | struct buffer_head *bh, | 589 | struct buffer_head *bh, |
589 | xfs_iomap_t *iomapp, | 590 | struct xfs_bmbt_irec *imap, |
590 | xfs_off_t offset) | 591 | xfs_off_t offset) |
591 | { | 592 | { |
592 | ASSERT(iomapp->iomap_bn != HOLESTARTBLOCK); | 593 | ASSERT(imap->br_startblock != HOLESTARTBLOCK); |
593 | ASSERT(iomapp->iomap_bn != DELAYSTARTBLOCK); | 594 | ASSERT(imap->br_startblock != DELAYSTARTBLOCK); |
594 | 595 | ||
595 | lock_buffer(bh); | 596 | lock_buffer(bh); |
596 | xfs_map_buffer(inode, bh, iomapp, offset); | 597 | xfs_map_buffer(inode, bh, imap, offset); |
597 | bh->b_bdev = xfs_find_bdev_for_inode(inode); | 598 | bh->b_bdev = xfs_find_bdev_for_inode(inode); |
598 | set_buffer_mapped(bh); | 599 | set_buffer_mapped(bh); |
599 | clear_buffer_delay(bh); | 600 | clear_buffer_delay(bh); |
@@ -750,7 +751,7 @@ xfs_convert_page( | |||
750 | struct inode *inode, | 751 | struct inode *inode, |
751 | struct page *page, | 752 | struct page *page, |
752 | loff_t tindex, | 753 | loff_t tindex, |
753 | xfs_iomap_t *mp, | 754 | struct xfs_bmbt_irec *imap, |
754 | xfs_ioend_t **ioendp, | 755 | xfs_ioend_t **ioendp, |
755 | struct writeback_control *wbc, | 756 | struct writeback_control *wbc, |
756 | int startio, | 757 | int startio, |
@@ -815,15 +816,15 @@ xfs_convert_page( | |||
815 | else | 816 | else |
816 | type = IOMAP_DELAY; | 817 | type = IOMAP_DELAY; |
817 | 818 | ||
818 | if (!xfs_iomap_valid(inode, mp, offset)) { | 819 | if (!xfs_iomap_valid(inode, imap, offset)) { |
819 | done = 1; | 820 | done = 1; |
820 | continue; | 821 | continue; |
821 | } | 822 | } |
822 | 823 | ||
823 | ASSERT(mp->iomap_bn != HOLESTARTBLOCK); | 824 | ASSERT(imap->br_startblock != HOLESTARTBLOCK); |
824 | ASSERT(mp->iomap_bn != DELAYSTARTBLOCK); | 825 | ASSERT(imap->br_startblock != DELAYSTARTBLOCK); |
825 | 826 | ||
826 | xfs_map_at_offset(inode, bh, mp, offset); | 827 | xfs_map_at_offset(inode, bh, imap, offset); |
827 | if (startio) { | 828 | if (startio) { |
828 | xfs_add_to_ioend(inode, bh, offset, | 829 | xfs_add_to_ioend(inode, bh, offset, |
829 | type, ioendp, done); | 830 | type, ioendp, done); |
@@ -875,7 +876,7 @@ STATIC void | |||
875 | xfs_cluster_write( | 876 | xfs_cluster_write( |
876 | struct inode *inode, | 877 | struct inode *inode, |
877 | pgoff_t tindex, | 878 | pgoff_t tindex, |
878 | xfs_iomap_t *iomapp, | 879 | struct xfs_bmbt_irec *imap, |
879 | xfs_ioend_t **ioendp, | 880 | xfs_ioend_t **ioendp, |
880 | struct writeback_control *wbc, | 881 | struct writeback_control *wbc, |
881 | int startio, | 882 | int startio, |
@@ -894,7 +895,7 @@ xfs_cluster_write( | |||
894 | 895 | ||
895 | for (i = 0; i < pagevec_count(&pvec); i++) { | 896 | for (i = 0; i < pagevec_count(&pvec); i++) { |
896 | done = xfs_convert_page(inode, pvec.pages[i], tindex++, | 897 | done = xfs_convert_page(inode, pvec.pages[i], tindex++, |
897 | iomapp, ioendp, wbc, startio, all_bh); | 898 | imap, ioendp, wbc, startio, all_bh); |
898 | if (done) | 899 | if (done) |
899 | break; | 900 | break; |
900 | } | 901 | } |
@@ -1051,7 +1052,7 @@ xfs_page_state_convert( | |||
1051 | int unmapped) /* also implies page uptodate */ | 1052 | int unmapped) /* also implies page uptodate */ |
1052 | { | 1053 | { |
1053 | struct buffer_head *bh, *head; | 1054 | struct buffer_head *bh, *head; |
1054 | xfs_iomap_t iomap; | 1055 | struct xfs_bmbt_irec imap; |
1055 | xfs_ioend_t *ioend = NULL, *iohead = NULL; | 1056 | xfs_ioend_t *ioend = NULL, *iohead = NULL; |
1056 | loff_t offset; | 1057 | loff_t offset; |
1057 | unsigned long p_offset = 0; | 1058 | unsigned long p_offset = 0; |
@@ -1125,7 +1126,7 @@ xfs_page_state_convert( | |||
1125 | } | 1126 | } |
1126 | 1127 | ||
1127 | if (iomap_valid) | 1128 | if (iomap_valid) |
1128 | iomap_valid = xfs_iomap_valid(inode, &iomap, offset); | 1129 | iomap_valid = xfs_iomap_valid(inode, &imap, offset); |
1129 | 1130 | ||
1130 | /* | 1131 | /* |
1131 | * First case, map an unwritten extent and prepare for | 1132 | * First case, map an unwritten extent and prepare for |
@@ -1177,13 +1178,13 @@ xfs_page_state_convert( | |||
1177 | } | 1178 | } |
1178 | 1179 | ||
1179 | err = xfs_map_blocks(inode, offset, size, | 1180 | err = xfs_map_blocks(inode, offset, size, |
1180 | &iomap, flags); | 1181 | &imap, flags); |
1181 | if (err) | 1182 | if (err) |
1182 | goto error; | 1183 | goto error; |
1183 | iomap_valid = xfs_iomap_valid(inode, &iomap, offset); | 1184 | iomap_valid = xfs_iomap_valid(inode, &imap, offset); |
1184 | } | 1185 | } |
1185 | if (iomap_valid) { | 1186 | if (iomap_valid) { |
1186 | xfs_map_at_offset(inode, bh, &iomap, offset); | 1187 | xfs_map_at_offset(inode, bh, &imap, offset); |
1187 | if (startio) { | 1188 | if (startio) { |
1188 | xfs_add_to_ioend(inode, bh, offset, | 1189 | xfs_add_to_ioend(inode, bh, offset, |
1189 | type, &ioend, | 1190 | type, &ioend, |
@@ -1207,10 +1208,10 @@ xfs_page_state_convert( | |||
1207 | size = xfs_probe_cluster(inode, page, bh, | 1208 | size = xfs_probe_cluster(inode, page, bh, |
1208 | head, 1); | 1209 | head, 1); |
1209 | err = xfs_map_blocks(inode, offset, size, | 1210 | err = xfs_map_blocks(inode, offset, size, |
1210 | &iomap, flags); | 1211 | &imap, flags); |
1211 | if (err) | 1212 | if (err) |
1212 | goto error; | 1213 | goto error; |
1213 | iomap_valid = xfs_iomap_valid(inode, &iomap, offset); | 1214 | iomap_valid = xfs_iomap_valid(inode, &imap, offset); |
1214 | } | 1215 | } |
1215 | 1216 | ||
1216 | /* | 1217 | /* |
@@ -1251,13 +1252,13 @@ xfs_page_state_convert( | |||
1251 | 1252 | ||
1252 | if (ioend && iomap_valid) { | 1253 | if (ioend && iomap_valid) { |
1253 | struct xfs_mount *m = XFS_I(inode)->i_mount; | 1254 | struct xfs_mount *m = XFS_I(inode)->i_mount; |
1254 | xfs_off_t iomap_offset = XFS_FSB_TO_B(m, iomap.iomap_offset); | 1255 | xfs_off_t iomap_offset = XFS_FSB_TO_B(m, imap.br_startoff); |
1255 | xfs_off_t iomap_bsize = XFS_FSB_TO_B(m, iomap.iomap_bsize); | 1256 | xfs_off_t iomap_bsize = XFS_FSB_TO_B(m, imap.br_blockcount); |
1256 | 1257 | ||
1257 | offset = (iomap_offset + iomap_bsize - 1) >> | 1258 | offset = (iomap_offset + iomap_bsize - 1) >> |
1258 | PAGE_CACHE_SHIFT; | 1259 | PAGE_CACHE_SHIFT; |
1259 | tlast = min_t(pgoff_t, offset, last_index); | 1260 | tlast = min_t(pgoff_t, offset, last_index); |
1260 | xfs_cluster_write(inode, page->index + 1, &iomap, &ioend, | 1261 | xfs_cluster_write(inode, page->index + 1, &imap, &ioend, |
1261 | wbc, startio, all_bh, tlast); | 1262 | wbc, startio, all_bh, tlast); |
1262 | } | 1263 | } |
1263 | 1264 | ||
@@ -1460,10 +1461,11 @@ __xfs_get_blocks( | |||
1460 | int direct, | 1461 | int direct, |
1461 | bmapi_flags_t flags) | 1462 | bmapi_flags_t flags) |
1462 | { | 1463 | { |
1463 | xfs_iomap_t iomap; | 1464 | struct xfs_bmbt_irec imap; |
1464 | xfs_off_t offset; | 1465 | xfs_off_t offset; |
1465 | ssize_t size; | 1466 | ssize_t size; |
1466 | int niomap = 1; | 1467 | int nimap = 1; |
1468 | int new = 0; | ||
1467 | int error; | 1469 | int error; |
1468 | 1470 | ||
1469 | offset = (xfs_off_t)iblock << inode->i_blkbits; | 1471 | offset = (xfs_off_t)iblock << inode->i_blkbits; |
@@ -1474,21 +1476,21 @@ __xfs_get_blocks( | |||
1474 | return 0; | 1476 | return 0; |
1475 | 1477 | ||
1476 | error = xfs_iomap(XFS_I(inode), offset, size, | 1478 | error = xfs_iomap(XFS_I(inode), offset, size, |
1477 | create ? flags : BMAPI_READ, &iomap, &niomap); | 1479 | create ? flags : BMAPI_READ, &imap, &nimap, &new); |
1478 | if (error) | 1480 | if (error) |
1479 | return -error; | 1481 | return -error; |
1480 | if (niomap == 0) | 1482 | if (nimap == 0) |
1481 | return 0; | 1483 | return 0; |
1482 | 1484 | ||
1483 | if (iomap.iomap_bn != HOLESTARTBLOCK && | 1485 | if (imap.br_startblock != HOLESTARTBLOCK && |
1484 | iomap.iomap_bn != DELAYSTARTBLOCK) { | 1486 | imap.br_startblock != DELAYSTARTBLOCK) { |
1485 | /* | 1487 | /* |
1486 | * For unwritten extents do not report a disk address on | 1488 | * For unwritten extents do not report a disk address on |
1487 | * the read case (treat as if we're reading into a hole). | 1489 | * the read case (treat as if we're reading into a hole). |
1488 | */ | 1490 | */ |
1489 | if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) | 1491 | if (create || !ISUNWRITTEN(&imap)) |
1490 | xfs_map_buffer(inode, bh_result, &iomap, offset); | 1492 | xfs_map_buffer(inode, bh_result, &imap, offset); |
1491 | if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { | 1493 | if (create && ISUNWRITTEN(&imap)) { |
1492 | if (direct) | 1494 | if (direct) |
1493 | bh_result->b_private = inode; | 1495 | bh_result->b_private = inode; |
1494 | set_buffer_unwritten(bh_result); | 1496 | set_buffer_unwritten(bh_result); |
@@ -1513,10 +1515,10 @@ __xfs_get_blocks( | |||
1513 | if (create && | 1515 | if (create && |
1514 | ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || | 1516 | ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || |
1515 | (offset >= i_size_read(inode)) || | 1517 | (offset >= i_size_read(inode)) || |
1516 | (iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN)))) | 1518 | (new || ISUNWRITTEN(&imap)))) |
1517 | set_buffer_new(bh_result); | 1519 | set_buffer_new(bh_result); |
1518 | 1520 | ||
1519 | if (iomap.iomap_bn == DELAYSTARTBLOCK) { | 1521 | if (imap.br_startblock == DELAYSTARTBLOCK) { |
1520 | BUG_ON(direct); | 1522 | BUG_ON(direct); |
1521 | if (create) { | 1523 | if (create) { |
1522 | set_buffer_uptodate(bh_result); | 1524 | set_buffer_uptodate(bh_result); |
@@ -1527,9 +1529,9 @@ __xfs_get_blocks( | |||
1527 | 1529 | ||
1528 | if (direct || size > (1 << inode->i_blkbits)) { | 1530 | if (direct || size > (1 << inode->i_blkbits)) { |
1529 | struct xfs_mount *mp = XFS_I(inode)->i_mount; | 1531 | struct xfs_mount *mp = XFS_I(inode)->i_mount; |
1530 | xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, iomap.iomap_offset); | 1532 | xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, imap.br_startoff); |
1531 | xfs_off_t iomap_delta = offset - iomap_offset; | 1533 | xfs_off_t iomap_delta = offset - iomap_offset; |
1532 | xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, iomap.iomap_bsize); | 1534 | xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, imap.br_blockcount); |
1533 | 1535 | ||
1534 | ASSERT(iomap_bsize - iomap_delta > 0); | 1536 | ASSERT(iomap_bsize - iomap_delta > 0); |
1535 | offset = min_t(xfs_off_t, | 1537 | offset = min_t(xfs_off_t, |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index fbe5d32f9ef5..7545dcdaa8aa 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -55,46 +55,25 @@ | |||
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 void | ||
59 | xfs_imap_to_bmap( | ||
60 | xfs_inode_t *ip, | ||
61 | xfs_off_t offset, | ||
62 | xfs_bmbt_irec_t *imap, | ||
63 | xfs_iomap_t *iomapp, | ||
64 | int imaps, /* Number of imap entries */ | ||
65 | int flags) | ||
66 | { | ||
67 | iomapp->iomap_offset = imap->br_startoff; | ||
68 | iomapp->iomap_bsize = imap->br_blockcount; | ||
69 | iomapp->iomap_flags = flags; | ||
70 | iomapp->iomap_bn = imap->br_startblock; | ||
71 | |||
72 | if (imap->br_startblock != HOLESTARTBLOCK && | ||
73 | imap->br_startblock != DELAYSTARTBLOCK && | ||
74 | ISUNWRITTEN(imap)) | ||
75 | iomapp->iomap_flags |= IOMAP_UNWRITTEN; | ||
76 | } | ||
77 | |||
78 | int | 58 | int |
79 | xfs_iomap( | 59 | xfs_iomap( |
80 | xfs_inode_t *ip, | 60 | struct xfs_inode *ip, |
81 | xfs_off_t offset, | 61 | xfs_off_t offset, |
82 | ssize_t count, | 62 | ssize_t count, |
83 | int flags, | 63 | int flags, |
84 | xfs_iomap_t *iomapp, | 64 | struct xfs_bmbt_irec *imap, |
85 | int *niomaps) | 65 | int *nimaps, |
66 | int *new) | ||
86 | { | 67 | { |
87 | xfs_mount_t *mp = ip->i_mount; | 68 | struct xfs_mount *mp = ip->i_mount; |
88 | xfs_fileoff_t offset_fsb, end_fsb; | 69 | xfs_fileoff_t offset_fsb, end_fsb; |
89 | int error = 0; | 70 | int error = 0; |
90 | int lockmode = 0; | 71 | int lockmode = 0; |
91 | xfs_bmbt_irec_t imap; | 72 | int bmapi_flags = 0; |
92 | int nimaps = 1; | ||
93 | int bmapi_flags = 0; | ||
94 | int iomap_flags = 0; | ||
95 | 73 | ||
96 | ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); | 74 | ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); |
97 | ASSERT(niomaps && *niomaps == 1); | 75 | |
76 | *new = 0; | ||
98 | 77 | ||
99 | if (XFS_FORCED_SHUTDOWN(mp)) | 78 | if (XFS_FORCED_SHUTDOWN(mp)) |
100 | return XFS_ERROR(EIO); | 79 | return XFS_ERROR(EIO); |
@@ -136,8 +115,8 @@ xfs_iomap( | |||
136 | 115 | ||
137 | error = xfs_bmapi(NULL, ip, offset_fsb, | 116 | error = xfs_bmapi(NULL, ip, offset_fsb, |
138 | (xfs_filblks_t)(end_fsb - offset_fsb), | 117 | (xfs_filblks_t)(end_fsb - offset_fsb), |
139 | bmapi_flags, NULL, 0, &imap, | 118 | bmapi_flags, NULL, 0, imap, |
140 | &nimaps, NULL, NULL); | 119 | nimaps, NULL, NULL); |
141 | 120 | ||
142 | if (error) | 121 | if (error) |
143 | goto out; | 122 | goto out; |
@@ -145,45 +124,41 @@ xfs_iomap( | |||
145 | switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) { | 124 | switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) { |
146 | case BMAPI_WRITE: | 125 | case BMAPI_WRITE: |
147 | /* If we found an extent, return it */ | 126 | /* If we found an extent, return it */ |
148 | if (nimaps && | 127 | if (*nimaps && |
149 | (imap.br_startblock != HOLESTARTBLOCK) && | 128 | (imap->br_startblock != HOLESTARTBLOCK) && |
150 | (imap.br_startblock != DELAYSTARTBLOCK)) { | 129 | (imap->br_startblock != DELAYSTARTBLOCK)) { |
151 | trace_xfs_iomap_found(ip, offset, count, flags, &imap); | 130 | trace_xfs_iomap_found(ip, offset, count, flags, imap); |
152 | break; | 131 | break; |
153 | } | 132 | } |
154 | 133 | ||
155 | if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) { | 134 | if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) { |
156 | error = xfs_iomap_write_direct(ip, offset, count, flags, | 135 | error = xfs_iomap_write_direct(ip, offset, count, flags, |
157 | &imap, &nimaps, nimaps); | 136 | imap, nimaps, *nimaps); |
158 | } else { | 137 | } else { |
159 | error = xfs_iomap_write_delay(ip, offset, count, flags, | 138 | error = xfs_iomap_write_delay(ip, offset, count, flags, |
160 | &imap, &nimaps); | 139 | imap, nimaps); |
161 | } | 140 | } |
162 | if (!error) { | 141 | if (!error) { |
163 | trace_xfs_iomap_alloc(ip, offset, count, flags, &imap); | 142 | trace_xfs_iomap_alloc(ip, offset, count, flags, imap); |
164 | } | 143 | } |
165 | iomap_flags = IOMAP_NEW; | 144 | *new = 1; |
166 | break; | 145 | break; |
167 | case BMAPI_ALLOCATE: | 146 | case BMAPI_ALLOCATE: |
168 | /* If we found an extent, return it */ | 147 | /* If we found an extent, return it */ |
169 | xfs_iunlock(ip, lockmode); | 148 | xfs_iunlock(ip, lockmode); |
170 | lockmode = 0; | 149 | lockmode = 0; |
171 | 150 | ||
172 | if (nimaps && !isnullstartblock(imap.br_startblock)) { | 151 | if (*nimaps && !isnullstartblock(imap->br_startblock)) { |
173 | trace_xfs_iomap_found(ip, offset, count, flags, &imap); | 152 | trace_xfs_iomap_found(ip, offset, count, flags, imap); |
174 | break; | 153 | break; |
175 | } | 154 | } |
176 | 155 | ||
177 | error = xfs_iomap_write_allocate(ip, offset, count, | 156 | error = xfs_iomap_write_allocate(ip, offset, count, |
178 | &imap, &nimaps); | 157 | imap, nimaps); |
179 | break; | 158 | break; |
180 | } | 159 | } |
181 | 160 | ||
182 | ASSERT(nimaps <= 1); | 161 | ASSERT(*nimaps <= 1); |
183 | |||
184 | if (nimaps) | ||
185 | xfs_imap_to_bmap(ip, offset, &imap, iomapp, nimaps, iomap_flags); | ||
186 | *niomaps = nimaps; | ||
187 | 162 | ||
188 | out: | 163 | out: |
189 | if (lockmode) | 164 | if (lockmode) |
@@ -191,7 +166,6 @@ out: | |||
191 | return XFS_ERROR(error); | 166 | return XFS_ERROR(error); |
192 | } | 167 | } |
193 | 168 | ||
194 | |||
195 | STATIC int | 169 | STATIC int |
196 | xfs_iomap_eof_align_last_fsb( | 170 | xfs_iomap_eof_align_last_fsb( |
197 | xfs_mount_t *mp, | 171 | xfs_mount_t *mp, |
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index d2f3b67d39f9..ba49a4fd1b3f 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h | |||
@@ -47,35 +47,11 @@ typedef enum { | |||
47 | { BMAPI_MMAP, "MMAP" }, \ | 47 | { BMAPI_MMAP, "MMAP" }, \ |
48 | { BMAPI_TRYLOCK, "TRYLOCK" } | 48 | { BMAPI_TRYLOCK, "TRYLOCK" } |
49 | 49 | ||
50 | /* | ||
51 | * xfs_iomap_t: File system I/O map | ||
52 | * | ||
53 | * The iomap_bn field is expressed in 512-byte blocks, and is where the | ||
54 | * mapping starts on disk. | ||
55 | * | ||
56 | * The iomap_offset, iomap_bsize and iomap_delta fields are in bytes. | ||
57 | * iomap_offset is the offset of the mapping in the file itself. | ||
58 | * iomap_bsize is the size of the mapping, iomap_delta is the | ||
59 | * desired data's offset into the mapping, given the offset supplied | ||
60 | * to the file I/O map routine. | ||
61 | * | ||
62 | * When a request is made to read beyond the logical end of the object, | ||
63 | * iomap_size may be set to 0, but iomap_offset and iomap_length should be set | ||
64 | * to the actual amount of underlying storage that has been allocated, if any. | ||
65 | */ | ||
66 | |||
67 | typedef struct xfs_iomap { | ||
68 | xfs_daddr_t iomap_bn; /* first 512B blk of mapping */ | ||
69 | xfs_off_t iomap_offset; /* offset of mapping, bytes */ | ||
70 | xfs_off_t iomap_bsize; /* size of mapping, bytes */ | ||
71 | iomap_flags_t iomap_flags; | ||
72 | } xfs_iomap_t; | ||
73 | |||
74 | struct xfs_inode; | 50 | struct xfs_inode; |
75 | struct xfs_bmbt_irec; | 51 | struct xfs_bmbt_irec; |
76 | 52 | ||
77 | extern int xfs_iomap(struct xfs_inode *, xfs_off_t, ssize_t, int, | 53 | extern int xfs_iomap(struct xfs_inode *, xfs_off_t, ssize_t, int, |
78 | struct xfs_iomap *, int *); | 54 | struct xfs_bmbt_irec *, int *, int *); |
79 | extern int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, | 55 | extern int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, |
80 | int, struct xfs_bmbt_irec *, int *, int); | 56 | int, struct xfs_bmbt_irec *, int *, int); |
81 | extern int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int, | 57 | extern int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int, |