aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_aops.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-04-28 08:28:56 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:17 -0400
commit207d041602cead1c1a16288f6225aea9da1f5bc4 (patch)
treead6149735c8bc0c5d112e301e6e17dac6280dcb6 /fs/xfs/linux-2.6/xfs_aops.c
parente513182d4d7ec8f1870ae368c549ef2838e2c105 (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/linux-2.6/xfs_aops.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c90
1 files changed, 46 insertions, 44 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
321STATIC int 322STATIC int
322xfs_iomap_valid( 323xfs_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
562xfs_map_buffer( 563xfs_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
586xfs_map_at_offset( 587xfs_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
875xfs_cluster_write( 876xfs_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,