aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r--fs/xfs/xfs_bmap.c217
1 files changed, 18 insertions, 199 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 598a30ba3141..d74fbec80622 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -101,7 +101,6 @@ xfs_bmap_add_extent(
101 xfs_fsblock_t *first, /* pointer to firstblock variable */ 101 xfs_fsblock_t *first, /* pointer to firstblock variable */
102 xfs_bmap_free_t *flist, /* list of extents to be freed */ 102 xfs_bmap_free_t *flist, /* list of extents to be freed */
103 int *logflagsp, /* inode logging flags */ 103 int *logflagsp, /* inode logging flags */
104 xfs_extdelta_t *delta, /* Change made to incore extents */
105 int whichfork, /* data or attr fork */ 104 int whichfork, /* data or attr fork */
106 int rsvd); /* OK to allocate reserved blocks */ 105 int rsvd); /* OK to allocate reserved blocks */
107 106
@@ -119,7 +118,6 @@ xfs_bmap_add_extent_delay_real(
119 xfs_fsblock_t *first, /* pointer to firstblock variable */ 118 xfs_fsblock_t *first, /* pointer to firstblock variable */
120 xfs_bmap_free_t *flist, /* list of extents to be freed */ 119 xfs_bmap_free_t *flist, /* list of extents to be freed */
121 int *logflagsp, /* inode logging flags */ 120 int *logflagsp, /* inode logging flags */
122 xfs_extdelta_t *delta, /* Change made to incore extents */
123 int rsvd); /* OK to allocate reserved blocks */ 121 int rsvd); /* OK to allocate reserved blocks */
124 122
125/* 123/*
@@ -132,7 +130,6 @@ xfs_bmap_add_extent_hole_delay(
132 xfs_extnum_t idx, /* extent number to update/insert */ 130 xfs_extnum_t idx, /* extent number to update/insert */
133 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 131 xfs_bmbt_irec_t *new, /* new data to add to file extents */
134 int *logflagsp,/* inode logging flags */ 132 int *logflagsp,/* inode logging flags */
135 xfs_extdelta_t *delta, /* Change made to incore extents */
136 int rsvd); /* OK to allocate reserved blocks */ 133 int rsvd); /* OK to allocate reserved blocks */
137 134
138/* 135/*
@@ -146,7 +143,6 @@ xfs_bmap_add_extent_hole_real(
146 xfs_btree_cur_t *cur, /* if null, not a btree */ 143 xfs_btree_cur_t *cur, /* if null, not a btree */
147 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 144 xfs_bmbt_irec_t *new, /* new data to add to file extents */
148 int *logflagsp, /* inode logging flags */ 145 int *logflagsp, /* inode logging flags */
149 xfs_extdelta_t *delta, /* Change made to incore extents */
150 int whichfork); /* data or attr fork */ 146 int whichfork); /* data or attr fork */
151 147
152/* 148/*
@@ -159,8 +155,7 @@ xfs_bmap_add_extent_unwritten_real(
159 xfs_extnum_t idx, /* extent number to update/insert */ 155 xfs_extnum_t idx, /* extent number to update/insert */
160 xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ 156 xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
161 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 157 xfs_bmbt_irec_t *new, /* new data to add to file extents */
162 int *logflagsp, /* inode logging flags */ 158 int *logflagsp); /* inode logging flags */
163 xfs_extdelta_t *delta); /* Change made to incore extents */
164 159
165/* 160/*
166 * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file. 161 * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file.
@@ -197,7 +192,6 @@ xfs_bmap_del_extent(
197 xfs_btree_cur_t *cur, /* if null, not a btree */ 192 xfs_btree_cur_t *cur, /* if null, not a btree */
198 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 193 xfs_bmbt_irec_t *new, /* new data to add to file extents */
199 int *logflagsp,/* inode logging flags */ 194 int *logflagsp,/* inode logging flags */
200 xfs_extdelta_t *delta, /* Change made to incore extents */
201 int whichfork, /* data or attr fork */ 195 int whichfork, /* data or attr fork */
202 int rsvd); /* OK to allocate reserved blocks */ 196 int rsvd); /* OK to allocate reserved blocks */
203 197
@@ -486,7 +480,6 @@ xfs_bmap_add_extent(
486 xfs_fsblock_t *first, /* pointer to firstblock variable */ 480 xfs_fsblock_t *first, /* pointer to firstblock variable */
487 xfs_bmap_free_t *flist, /* list of extents to be freed */ 481 xfs_bmap_free_t *flist, /* list of extents to be freed */
488 int *logflagsp, /* inode logging flags */ 482 int *logflagsp, /* inode logging flags */
489 xfs_extdelta_t *delta, /* Change made to incore extents */
490 int whichfork, /* data or attr fork */ 483 int whichfork, /* data or attr fork */
491 int rsvd) /* OK to use reserved data blocks */ 484 int rsvd) /* OK to use reserved data blocks */
492{ 485{
@@ -521,15 +514,6 @@ xfs_bmap_add_extent(
521 logflags = XFS_ILOG_CORE | xfs_ilog_fext(whichfork); 514 logflags = XFS_ILOG_CORE | xfs_ilog_fext(whichfork);
522 } else 515 } else
523 logflags = 0; 516 logflags = 0;
524 /* DELTA: single new extent */
525 if (delta) {
526 if (delta->xed_startoff > new->br_startoff)
527 delta->xed_startoff = new->br_startoff;
528 if (delta->xed_blockcount <
529 new->br_startoff + new->br_blockcount)
530 delta->xed_blockcount = new->br_startoff +
531 new->br_blockcount;
532 }
533 } 517 }
534 /* 518 /*
535 * Any kind of new delayed allocation goes here. 519 * Any kind of new delayed allocation goes here.
@@ -539,7 +523,7 @@ xfs_bmap_add_extent(
539 ASSERT((cur->bc_private.b.flags & 523 ASSERT((cur->bc_private.b.flags &
540 XFS_BTCUR_BPRV_WASDEL) == 0); 524 XFS_BTCUR_BPRV_WASDEL) == 0);
541 if ((error = xfs_bmap_add_extent_hole_delay(ip, idx, new, 525 if ((error = xfs_bmap_add_extent_hole_delay(ip, idx, new,
542 &logflags, delta, rsvd))) 526 &logflags, rsvd)))
543 goto done; 527 goto done;
544 } 528 }
545 /* 529 /*
@@ -550,7 +534,7 @@ xfs_bmap_add_extent(
550 ASSERT((cur->bc_private.b.flags & 534 ASSERT((cur->bc_private.b.flags &
551 XFS_BTCUR_BPRV_WASDEL) == 0); 535 XFS_BTCUR_BPRV_WASDEL) == 0);
552 if ((error = xfs_bmap_add_extent_hole_real(ip, idx, cur, new, 536 if ((error = xfs_bmap_add_extent_hole_real(ip, idx, cur, new,
553 &logflags, delta, whichfork))) 537 &logflags, whichfork)))
554 goto done; 538 goto done;
555 } else { 539 } else {
556 xfs_bmbt_irec_t prev; /* old extent at offset idx */ 540 xfs_bmbt_irec_t prev; /* old extent at offset idx */
@@ -575,17 +559,17 @@ xfs_bmap_add_extent(
575 XFS_BTCUR_BPRV_WASDEL); 559 XFS_BTCUR_BPRV_WASDEL);
576 if ((error = xfs_bmap_add_extent_delay_real(ip, 560 if ((error = xfs_bmap_add_extent_delay_real(ip,
577 idx, &cur, new, &da_new, first, flist, 561 idx, &cur, new, &da_new, first, flist,
578 &logflags, delta, rsvd))) 562 &logflags, rsvd)))
579 goto done; 563 goto done;
580 } else if (new->br_state == XFS_EXT_NORM) { 564 } else if (new->br_state == XFS_EXT_NORM) {
581 ASSERT(new->br_state == XFS_EXT_NORM); 565 ASSERT(new->br_state == XFS_EXT_NORM);
582 if ((error = xfs_bmap_add_extent_unwritten_real( 566 if ((error = xfs_bmap_add_extent_unwritten_real(
583 ip, idx, &cur, new, &logflags, delta))) 567 ip, idx, &cur, new, &logflags)))
584 goto done; 568 goto done;
585 } else { 569 } else {
586 ASSERT(new->br_state == XFS_EXT_UNWRITTEN); 570 ASSERT(new->br_state == XFS_EXT_UNWRITTEN);
587 if ((error = xfs_bmap_add_extent_unwritten_real( 571 if ((error = xfs_bmap_add_extent_unwritten_real(
588 ip, idx, &cur, new, &logflags, delta))) 572 ip, idx, &cur, new, &logflags)))
589 goto done; 573 goto done;
590 } 574 }
591 ASSERT(*curp == cur || *curp == NULL); 575 ASSERT(*curp == cur || *curp == NULL);
@@ -598,7 +582,7 @@ xfs_bmap_add_extent(
598 ASSERT((cur->bc_private.b.flags & 582 ASSERT((cur->bc_private.b.flags &
599 XFS_BTCUR_BPRV_WASDEL) == 0); 583 XFS_BTCUR_BPRV_WASDEL) == 0);
600 if ((error = xfs_bmap_add_extent_hole_real(ip, idx, cur, 584 if ((error = xfs_bmap_add_extent_hole_real(ip, idx, cur,
601 new, &logflags, delta, whichfork))) 585 new, &logflags, whichfork)))
602 goto done; 586 goto done;
603 } 587 }
604 } 588 }
@@ -663,7 +647,6 @@ xfs_bmap_add_extent_delay_real(
663 xfs_fsblock_t *first, /* pointer to firstblock variable */ 647 xfs_fsblock_t *first, /* pointer to firstblock variable */
664 xfs_bmap_free_t *flist, /* list of extents to be freed */ 648 xfs_bmap_free_t *flist, /* list of extents to be freed */
665 int *logflagsp, /* inode logging flags */ 649 int *logflagsp, /* inode logging flags */
666 xfs_extdelta_t *delta, /* Change made to incore extents */
667 int rsvd) /* OK to use reserved data block allocation */ 650 int rsvd) /* OK to use reserved data block allocation */
668{ 651{
669 xfs_btree_cur_t *cur; /* btree cursor */ 652 xfs_btree_cur_t *cur; /* btree cursor */
@@ -794,11 +777,6 @@ xfs_bmap_add_extent_delay_real(
794 goto done; 777 goto done;
795 } 778 }
796 *dnew = 0; 779 *dnew = 0;
797 /* DELTA: Three in-core extents are replaced by one. */
798 temp = LEFT.br_startoff;
799 temp2 = LEFT.br_blockcount +
800 PREV.br_blockcount +
801 RIGHT.br_blockcount;
802 break; 780 break;
803 781
804 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: 782 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG:
@@ -829,10 +807,6 @@ xfs_bmap_add_extent_delay_real(
829 goto done; 807 goto done;
830 } 808 }
831 *dnew = 0; 809 *dnew = 0;
832 /* DELTA: Two in-core extents are replaced by one. */
833 temp = LEFT.br_startoff;
834 temp2 = LEFT.br_blockcount +
835 PREV.br_blockcount;
836 break; 810 break;
837 811
838 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: 812 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
@@ -864,10 +838,6 @@ xfs_bmap_add_extent_delay_real(
864 goto done; 838 goto done;
865 } 839 }
866 *dnew = 0; 840 *dnew = 0;
867 /* DELTA: Two in-core extents are replaced by one. */
868 temp = PREV.br_startoff;
869 temp2 = PREV.br_blockcount +
870 RIGHT.br_blockcount;
871 break; 841 break;
872 842
873 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: 843 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING:
@@ -897,9 +867,6 @@ xfs_bmap_add_extent_delay_real(
897 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 867 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
898 } 868 }
899 *dnew = 0; 869 *dnew = 0;
900 /* DELTA: The in-core extent described by new changed type. */
901 temp = new->br_startoff;
902 temp2 = new->br_blockcount;
903 break; 870 break;
904 871
905 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: 872 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG:
@@ -939,10 +906,6 @@ xfs_bmap_add_extent_delay_real(
939 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); 906 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
940 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); 907 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
941 *dnew = temp; 908 *dnew = temp;
942 /* DELTA: The boundary between two in-core extents moved. */
943 temp = LEFT.br_startoff;
944 temp2 = LEFT.br_blockcount +
945 PREV.br_blockcount;
946 break; 909 break;
947 910
948 case BMAP_LEFT_FILLING: 911 case BMAP_LEFT_FILLING:
@@ -987,9 +950,6 @@ xfs_bmap_add_extent_delay_real(
987 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); 950 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
988 trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_); 951 trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_);
989 *dnew = temp; 952 *dnew = temp;
990 /* DELTA: One in-core extent is split in two. */
991 temp = PREV.br_startoff;
992 temp2 = PREV.br_blockcount;
993 break; 953 break;
994 954
995 case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: 955 case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
@@ -1028,10 +988,6 @@ xfs_bmap_add_extent_delay_real(
1028 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); 988 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1029 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); 989 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
1030 *dnew = temp; 990 *dnew = temp;
1031 /* DELTA: The boundary between two in-core extents moved. */
1032 temp = PREV.br_startoff;
1033 temp2 = PREV.br_blockcount +
1034 RIGHT.br_blockcount;
1035 break; 991 break;
1036 992
1037 case BMAP_RIGHT_FILLING: 993 case BMAP_RIGHT_FILLING:
@@ -1075,9 +1031,6 @@ xfs_bmap_add_extent_delay_real(
1075 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); 1031 xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
1076 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); 1032 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
1077 *dnew = temp; 1033 *dnew = temp;
1078 /* DELTA: One in-core extent is split in two. */
1079 temp = PREV.br_startoff;
1080 temp2 = PREV.br_blockcount;
1081 break; 1034 break;
1082 1035
1083 case 0: 1036 case 0:
@@ -1158,9 +1111,6 @@ xfs_bmap_add_extent_delay_real(
1158 nullstartblock((int)temp2)); 1111 nullstartblock((int)temp2));
1159 trace_xfs_bmap_post_update(ip, idx + 2, state, _THIS_IP_); 1112 trace_xfs_bmap_post_update(ip, idx + 2, state, _THIS_IP_);
1160 *dnew = temp + temp2; 1113 *dnew = temp + temp2;
1161 /* DELTA: One in-core extent is split in three. */
1162 temp = PREV.br_startoff;
1163 temp2 = PREV.br_blockcount;
1164 break; 1114 break;
1165 1115
1166 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: 1116 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
@@ -1176,13 +1126,6 @@ xfs_bmap_add_extent_delay_real(
1176 ASSERT(0); 1126 ASSERT(0);
1177 } 1127 }
1178 *curp = cur; 1128 *curp = cur;
1179 if (delta) {
1180 temp2 += temp;
1181 if (delta->xed_startoff > temp)
1182 delta->xed_startoff = temp;
1183 if (delta->xed_blockcount < temp2)
1184 delta->xed_blockcount = temp2;
1185 }
1186done: 1129done:
1187 *logflagsp = rval; 1130 *logflagsp = rval;
1188 return error; 1131 return error;
@@ -1201,8 +1144,7 @@ xfs_bmap_add_extent_unwritten_real(
1201 xfs_extnum_t idx, /* extent number to update/insert */ 1144 xfs_extnum_t idx, /* extent number to update/insert */
1202 xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ 1145 xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
1203 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 1146 xfs_bmbt_irec_t *new, /* new data to add to file extents */
1204 int *logflagsp, /* inode logging flags */ 1147 int *logflagsp) /* inode logging flags */
1205 xfs_extdelta_t *delta) /* Change made to incore extents */
1206{ 1148{
1207 xfs_btree_cur_t *cur; /* btree cursor */ 1149 xfs_btree_cur_t *cur; /* btree cursor */
1208 xfs_bmbt_rec_host_t *ep; /* extent entry for idx */ 1150 xfs_bmbt_rec_host_t *ep; /* extent entry for idx */
@@ -1216,8 +1158,6 @@ xfs_bmap_add_extent_unwritten_real(
1216 /* left is 0, right is 1, prev is 2 */ 1158 /* left is 0, right is 1, prev is 2 */
1217 int rval=0; /* return value (logging flags) */ 1159 int rval=0; /* return value (logging flags) */
1218 int state = 0;/* state bits, accessed thru macros */ 1160 int state = 0;/* state bits, accessed thru macros */
1219 xfs_filblks_t temp=0;
1220 xfs_filblks_t temp2=0;
1221 1161
1222#define LEFT r[0] 1162#define LEFT r[0]
1223#define RIGHT r[1] 1163#define RIGHT r[1]
@@ -1338,11 +1278,6 @@ xfs_bmap_add_extent_unwritten_real(
1338 RIGHT.br_blockcount, LEFT.br_state))) 1278 RIGHT.br_blockcount, LEFT.br_state)))
1339 goto done; 1279 goto done;
1340 } 1280 }
1341 /* DELTA: Three in-core extents are replaced by one. */
1342 temp = LEFT.br_startoff;
1343 temp2 = LEFT.br_blockcount +
1344 PREV.br_blockcount +
1345 RIGHT.br_blockcount;
1346 break; 1281 break;
1347 1282
1348 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: 1283 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG:
@@ -1379,10 +1314,6 @@ xfs_bmap_add_extent_unwritten_real(
1379 LEFT.br_state))) 1314 LEFT.br_state)))
1380 goto done; 1315 goto done;
1381 } 1316 }
1382 /* DELTA: Two in-core extents are replaced by one. */
1383 temp = LEFT.br_startoff;
1384 temp2 = LEFT.br_blockcount +
1385 PREV.br_blockcount;
1386 break; 1317 break;
1387 1318
1388 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: 1319 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
@@ -1419,10 +1350,6 @@ xfs_bmap_add_extent_unwritten_real(
1419 newext))) 1350 newext)))
1420 goto done; 1351 goto done;
1421 } 1352 }
1422 /* DELTA: Two in-core extents are replaced by one. */
1423 temp = PREV.br_startoff;
1424 temp2 = PREV.br_blockcount +
1425 RIGHT.br_blockcount;
1426 break; 1353 break;
1427 1354
1428 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: 1355 case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING:
@@ -1450,9 +1377,6 @@ xfs_bmap_add_extent_unwritten_real(
1450 newext))) 1377 newext)))
1451 goto done; 1378 goto done;
1452 } 1379 }
1453 /* DELTA: The in-core extent described by new changed type. */
1454 temp = new->br_startoff;
1455 temp2 = new->br_blockcount;
1456 break; 1380 break;
1457 1381
1458 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: 1382 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG:
@@ -1498,10 +1422,6 @@ xfs_bmap_add_extent_unwritten_real(
1498 LEFT.br_state)) 1422 LEFT.br_state))
1499 goto done; 1423 goto done;
1500 } 1424 }
1501 /* DELTA: The boundary between two in-core extents moved. */
1502 temp = LEFT.br_startoff;
1503 temp2 = LEFT.br_blockcount +
1504 PREV.br_blockcount;
1505 break; 1425 break;
1506 1426
1507 case BMAP_LEFT_FILLING: 1427 case BMAP_LEFT_FILLING:
@@ -1541,9 +1461,6 @@ xfs_bmap_add_extent_unwritten_real(
1541 goto done; 1461 goto done;
1542 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1462 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
1543 } 1463 }
1544 /* DELTA: One in-core extent is split in two. */
1545 temp = PREV.br_startoff;
1546 temp2 = PREV.br_blockcount;
1547 break; 1464 break;
1548 1465
1549 case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: 1466 case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
@@ -1584,10 +1501,6 @@ xfs_bmap_add_extent_unwritten_real(
1584 newext))) 1501 newext)))
1585 goto done; 1502 goto done;
1586 } 1503 }
1587 /* DELTA: The boundary between two in-core extents moved. */
1588 temp = PREV.br_startoff;
1589 temp2 = PREV.br_blockcount +
1590 RIGHT.br_blockcount;
1591 break; 1504 break;
1592 1505
1593 case BMAP_RIGHT_FILLING: 1506 case BMAP_RIGHT_FILLING:
@@ -1627,9 +1540,6 @@ xfs_bmap_add_extent_unwritten_real(
1627 goto done; 1540 goto done;
1628 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1541 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
1629 } 1542 }
1630 /* DELTA: One in-core extent is split in two. */
1631 temp = PREV.br_startoff;
1632 temp2 = PREV.br_blockcount;
1633 break; 1543 break;
1634 1544
1635 case 0: 1545 case 0:
@@ -1689,9 +1599,6 @@ xfs_bmap_add_extent_unwritten_real(
1689 goto done; 1599 goto done;
1690 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1600 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
1691 } 1601 }
1692 /* DELTA: One in-core extent is split in three. */
1693 temp = PREV.br_startoff;
1694 temp2 = PREV.br_blockcount;
1695 break; 1602 break;
1696 1603
1697 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: 1604 case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
@@ -1707,13 +1614,6 @@ xfs_bmap_add_extent_unwritten_real(
1707 ASSERT(0); 1614 ASSERT(0);
1708 } 1615 }
1709 *curp = cur; 1616 *curp = cur;
1710 if (delta) {
1711 temp2 += temp;
1712 if (delta->xed_startoff > temp)
1713 delta->xed_startoff = temp;
1714 if (delta->xed_blockcount < temp2)
1715 delta->xed_blockcount = temp2;
1716 }
1717done: 1617done:
1718 *logflagsp = rval; 1618 *logflagsp = rval;
1719 return error; 1619 return error;
@@ -1733,7 +1633,6 @@ xfs_bmap_add_extent_hole_delay(
1733 xfs_extnum_t idx, /* extent number to update/insert */ 1633 xfs_extnum_t idx, /* extent number to update/insert */
1734 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 1634 xfs_bmbt_irec_t *new, /* new data to add to file extents */
1735 int *logflagsp, /* inode logging flags */ 1635 int *logflagsp, /* inode logging flags */
1736 xfs_extdelta_t *delta, /* Change made to incore extents */
1737 int rsvd) /* OK to allocate reserved blocks */ 1636 int rsvd) /* OK to allocate reserved blocks */
1738{ 1637{
1739 xfs_bmbt_rec_host_t *ep; /* extent record for idx */ 1638 xfs_bmbt_rec_host_t *ep; /* extent record for idx */
@@ -1744,7 +1643,6 @@ xfs_bmap_add_extent_hole_delay(
1744 xfs_bmbt_irec_t right; /* right neighbor extent entry */ 1643 xfs_bmbt_irec_t right; /* right neighbor extent entry */
1745 int state; /* state bits, accessed thru macros */ 1644 int state; /* state bits, accessed thru macros */
1746 xfs_filblks_t temp=0; /* temp for indirect calculations */ 1645 xfs_filblks_t temp=0; /* temp for indirect calculations */
1747 xfs_filblks_t temp2=0;
1748 1646
1749 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 1647 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1750 ep = xfs_iext_get_ext(ifp, idx); 1648 ep = xfs_iext_get_ext(ifp, idx);
@@ -1816,9 +1714,6 @@ xfs_bmap_add_extent_hole_delay(
1816 1714
1817 xfs_iext_remove(ip, idx, 1, state); 1715 xfs_iext_remove(ip, idx, 1, state);
1818 ip->i_df.if_lastex = idx - 1; 1716 ip->i_df.if_lastex = idx - 1;
1819 /* DELTA: Two in-core extents were replaced by one. */
1820 temp2 = temp;
1821 temp = left.br_startoff;
1822 break; 1717 break;
1823 1718
1824 case BMAP_LEFT_CONTIG: 1719 case BMAP_LEFT_CONTIG:
@@ -1838,9 +1733,6 @@ xfs_bmap_add_extent_hole_delay(
1838 trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); 1733 trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
1839 1734
1840 ip->i_df.if_lastex = idx - 1; 1735 ip->i_df.if_lastex = idx - 1;
1841 /* DELTA: One in-core extent grew into a hole. */
1842 temp2 = temp;
1843 temp = left.br_startoff;
1844 break; 1736 break;
1845 1737
1846 case BMAP_RIGHT_CONTIG: 1738 case BMAP_RIGHT_CONTIG:
@@ -1859,9 +1751,6 @@ xfs_bmap_add_extent_hole_delay(
1859 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); 1751 trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
1860 1752
1861 ip->i_df.if_lastex = idx; 1753 ip->i_df.if_lastex = idx;
1862 /* DELTA: One in-core extent grew into a hole. */
1863 temp2 = temp;
1864 temp = new->br_startoff;
1865 break; 1754 break;
1866 1755
1867 case 0: 1756 case 0:
@@ -1873,9 +1762,6 @@ xfs_bmap_add_extent_hole_delay(
1873 oldlen = newlen = 0; 1762 oldlen = newlen = 0;
1874 xfs_iext_insert(ip, idx, 1, new, state); 1763 xfs_iext_insert(ip, idx, 1, new, state);
1875 ip->i_df.if_lastex = idx; 1764 ip->i_df.if_lastex = idx;
1876 /* DELTA: A new in-core extent was added in a hole. */
1877 temp2 = new->br_blockcount;
1878 temp = new->br_startoff;
1879 break; 1765 break;
1880 } 1766 }
1881 if (oldlen != newlen) { 1767 if (oldlen != newlen) {
@@ -1886,13 +1772,6 @@ xfs_bmap_add_extent_hole_delay(
1886 * Nothing to do for disk quota accounting here. 1772 * Nothing to do for disk quota accounting here.
1887 */ 1773 */
1888 } 1774 }
1889 if (delta) {
1890 temp2 += temp;
1891 if (delta->xed_startoff > temp)
1892 delta->xed_startoff = temp;
1893 if (delta->xed_blockcount < temp2)
1894 delta->xed_blockcount = temp2;
1895 }
1896 *logflagsp = 0; 1775 *logflagsp = 0;
1897 return 0; 1776 return 0;
1898} 1777}
@@ -1908,7 +1787,6 @@ xfs_bmap_add_extent_hole_real(
1908 xfs_btree_cur_t *cur, /* if null, not a btree */ 1787 xfs_btree_cur_t *cur, /* if null, not a btree */
1909 xfs_bmbt_irec_t *new, /* new data to add to file extents */ 1788 xfs_bmbt_irec_t *new, /* new data to add to file extents */
1910 int *logflagsp, /* inode logging flags */ 1789 int *logflagsp, /* inode logging flags */
1911 xfs_extdelta_t *delta, /* Change made to incore extents */
1912 int whichfork) /* data or attr fork */ 1790 int whichfork) /* data or attr fork */
1913{ 1791{
1914 xfs_bmbt_rec_host_t *ep; /* pointer to extent entry ins. point */ 1792 xfs_bmbt_rec_host_t *ep; /* pointer to extent entry ins. point */
@@ -1919,8 +1797,6 @@ xfs_bmap_add_extent_hole_real(
1919 xfs_bmbt_irec_t right; /* right neighbor extent entry */ 1797 xfs_bmbt_irec_t right; /* right neighbor extent entry */
1920 int rval=0; /* return value (logging flags) */ 1798 int rval=0; /* return value (logging flags) */
1921 int state; /* state bits, accessed thru macros */ 1799 int state; /* state bits, accessed thru macros */
1922 xfs_filblks_t temp=0;
1923 xfs_filblks_t temp2=0;
1924 1800
1925 ifp = XFS_IFORK_PTR(ip, whichfork); 1801 ifp = XFS_IFORK_PTR(ip, whichfork);
1926 ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); 1802 ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t));
@@ -2017,11 +1893,6 @@ xfs_bmap_add_extent_hole_real(
2017 left.br_state))) 1893 left.br_state)))
2018 goto done; 1894 goto done;
2019 } 1895 }
2020 /* DELTA: Two in-core extents were replaced by one. */
2021 temp = left.br_startoff;
2022 temp2 = left.br_blockcount +
2023 new->br_blockcount +
2024 right.br_blockcount;
2025 break; 1896 break;
2026 1897
2027 case BMAP_LEFT_CONTIG: 1898 case BMAP_LEFT_CONTIG:
@@ -2053,10 +1924,6 @@ xfs_bmap_add_extent_hole_real(
2053 left.br_state))) 1924 left.br_state)))
2054 goto done; 1925 goto done;
2055 } 1926 }
2056 /* DELTA: One in-core extent grew. */
2057 temp = left.br_startoff;
2058 temp2 = left.br_blockcount +
2059 new->br_blockcount;
2060 break; 1927 break;
2061 1928
2062 case BMAP_RIGHT_CONTIG: 1929 case BMAP_RIGHT_CONTIG:
@@ -2089,10 +1956,6 @@ xfs_bmap_add_extent_hole_real(
2089 right.br_state))) 1956 right.br_state)))
2090 goto done; 1957 goto done;
2091 } 1958 }
2092 /* DELTA: One in-core extent grew. */
2093 temp = new->br_startoff;
2094 temp2 = new->br_blockcount +
2095 right.br_blockcount;
2096 break; 1959 break;
2097 1960
2098 case 0: 1961 case 0:
@@ -2120,18 +1983,8 @@ xfs_bmap_add_extent_hole_real(
2120 goto done; 1983 goto done;
2121 XFS_WANT_CORRUPTED_GOTO(i == 1, done); 1984 XFS_WANT_CORRUPTED_GOTO(i == 1, done);
2122 } 1985 }
2123 /* DELTA: A new extent was added in a hole. */
2124 temp = new->br_startoff;
2125 temp2 = new->br_blockcount;
2126 break; 1986 break;
2127 } 1987 }
2128 if (delta) {
2129 temp2 += temp;
2130 if (delta->xed_startoff > temp)
2131 delta->xed_startoff = temp;
2132 if (delta->xed_blockcount < temp2)
2133 delta->xed_blockcount = temp2;
2134 }
2135done: 1988done:
2136 *logflagsp = rval; 1989 *logflagsp = rval;
2137 return error; 1990 return error;
@@ -2956,7 +2809,6 @@ xfs_bmap_del_extent(
2956 xfs_btree_cur_t *cur, /* if null, not a btree */ 2809 xfs_btree_cur_t *cur, /* if null, not a btree */
2957 xfs_bmbt_irec_t *del, /* data to remove from extents */ 2810 xfs_bmbt_irec_t *del, /* data to remove from extents */
2958 int *logflagsp, /* inode logging flags */ 2811 int *logflagsp, /* inode logging flags */
2959 xfs_extdelta_t *delta, /* Change made to incore extents */
2960 int whichfork, /* data or attr fork */ 2812 int whichfork, /* data or attr fork */
2961 int rsvd) /* OK to allocate reserved blocks */ 2813 int rsvd) /* OK to allocate reserved blocks */
2962{ 2814{
@@ -3262,14 +3114,6 @@ xfs_bmap_del_extent(
3262 if (da_old > da_new) 3114 if (da_old > da_new)
3263 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int64_t)(da_old - da_new), 3115 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int64_t)(da_old - da_new),
3264 rsvd); 3116 rsvd);
3265 if (delta) {
3266 /* DELTA: report the original extent. */
3267 if (delta->xed_startoff > got.br_startoff)
3268 delta->xed_startoff = got.br_startoff;
3269 if (delta->xed_blockcount < got.br_startoff+got.br_blockcount)
3270 delta->xed_blockcount = got.br_startoff +
3271 got.br_blockcount;
3272 }
3273done: 3117done:
3274 *logflagsp = flags; 3118 *logflagsp = flags;
3275 return error; 3119 return error;
@@ -4481,8 +4325,7 @@ xfs_bmapi(
4481 xfs_extlen_t total, /* total blocks needed */ 4325 xfs_extlen_t total, /* total blocks needed */
4482 xfs_bmbt_irec_t *mval, /* output: map values */ 4326 xfs_bmbt_irec_t *mval, /* output: map values */
4483 int *nmap, /* i/o: mval size/count */ 4327 int *nmap, /* i/o: mval size/count */
4484 xfs_bmap_free_t *flist, /* i/o: list extents to free */ 4328 xfs_bmap_free_t *flist) /* i/o: list extents to free */
4485 xfs_extdelta_t *delta) /* o: change made to incore extents */
4486{ 4329{
4487 xfs_fsblock_t abno; /* allocated block number */ 4330 xfs_fsblock_t abno; /* allocated block number */
4488 xfs_extlen_t alen; /* allocated extent length */ 4331 xfs_extlen_t alen; /* allocated extent length */
@@ -4594,10 +4437,7 @@ xfs_bmapi(
4594 end = bno + len; 4437 end = bno + len;
4595 obno = bno; 4438 obno = bno;
4596 bma.ip = NULL; 4439 bma.ip = NULL;
4597 if (delta) { 4440
4598 delta->xed_startoff = NULLFILEOFF;
4599 delta->xed_blockcount = 0;
4600 }
4601 while (bno < end && n < *nmap) { 4441 while (bno < end && n < *nmap) {
4602 /* 4442 /*
4603 * Reading past eof, act as though there's a hole 4443 * Reading past eof, act as though there's a hole
@@ -4823,7 +4663,7 @@ xfs_bmapi(
4823 got.br_state = XFS_EXT_UNWRITTEN; 4663 got.br_state = XFS_EXT_UNWRITTEN;
4824 } 4664 }
4825 error = xfs_bmap_add_extent(ip, lastx, &cur, &got, 4665 error = xfs_bmap_add_extent(ip, lastx, &cur, &got,
4826 firstblock, flist, &tmp_logflags, delta, 4666 firstblock, flist, &tmp_logflags,
4827 whichfork, (flags & XFS_BMAPI_RSVBLOCKS)); 4667 whichfork, (flags & XFS_BMAPI_RSVBLOCKS));
4828 logflags |= tmp_logflags; 4668 logflags |= tmp_logflags;
4829 if (error) 4669 if (error)
@@ -4919,7 +4759,7 @@ xfs_bmapi(
4919 } 4759 }
4920 mval->br_state = XFS_EXT_NORM; 4760 mval->br_state = XFS_EXT_NORM;
4921 error = xfs_bmap_add_extent(ip, lastx, &cur, mval, 4761 error = xfs_bmap_add_extent(ip, lastx, &cur, mval,
4922 firstblock, flist, &tmp_logflags, delta, 4762 firstblock, flist, &tmp_logflags,
4923 whichfork, (flags & XFS_BMAPI_RSVBLOCKS)); 4763 whichfork, (flags & XFS_BMAPI_RSVBLOCKS));
4924 logflags |= tmp_logflags; 4764 logflags |= tmp_logflags;
4925 if (error) 4765 if (error)
@@ -5009,14 +4849,6 @@ xfs_bmapi(
5009 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE || 4849 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE ||
5010 XFS_IFORK_NEXTENTS(ip, whichfork) > ifp->if_ext_max); 4850 XFS_IFORK_NEXTENTS(ip, whichfork) > ifp->if_ext_max);
5011 error = 0; 4851 error = 0;
5012 if (delta && delta->xed_startoff != NULLFILEOFF) {
5013 /* A change was actually made.
5014 * Note that delta->xed_blockount is an offset at this
5015 * point and needs to be converted to a block count.
5016 */
5017 ASSERT(delta->xed_blockcount > delta->xed_startoff);
5018 delta->xed_blockcount -= delta->xed_startoff;
5019 }
5020error0: 4852error0:
5021 /* 4853 /*
5022 * Log everything. Do this after conversion, there's no point in 4854 * Log everything. Do this after conversion, there's no point in
@@ -5128,8 +4960,6 @@ xfs_bunmapi(
5128 xfs_fsblock_t *firstblock, /* first allocated block 4960 xfs_fsblock_t *firstblock, /* first allocated block
5129 controls a.g. for allocs */ 4961 controls a.g. for allocs */
5130 xfs_bmap_free_t *flist, /* i/o: list extents to free */ 4962 xfs_bmap_free_t *flist, /* i/o: list extents to free */
5131 xfs_extdelta_t *delta, /* o: change made to incore
5132 extents */
5133 int *done) /* set if not done yet */ 4963 int *done) /* set if not done yet */
5134{ 4964{
5135 xfs_btree_cur_t *cur; /* bmap btree cursor */ 4965 xfs_btree_cur_t *cur; /* bmap btree cursor */
@@ -5188,10 +5018,7 @@ xfs_bunmapi(
5188 bno = start + len - 1; 5018 bno = start + len - 1;
5189 ep = xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got, 5019 ep = xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got,
5190 &prev); 5020 &prev);
5191 if (delta) { 5021
5192 delta->xed_startoff = NULLFILEOFF;
5193 delta->xed_blockcount = 0;
5194 }
5195 /* 5022 /*
5196 * Check to see if the given block number is past the end of the 5023 * Check to see if the given block number is past the end of the
5197 * file, back up to the last block if so... 5024 * file, back up to the last block if so...
@@ -5289,7 +5116,7 @@ xfs_bunmapi(
5289 } 5116 }
5290 del.br_state = XFS_EXT_UNWRITTEN; 5117 del.br_state = XFS_EXT_UNWRITTEN;
5291 error = xfs_bmap_add_extent(ip, lastx, &cur, &del, 5118 error = xfs_bmap_add_extent(ip, lastx, &cur, &del,
5292 firstblock, flist, &logflags, delta, 5119 firstblock, flist, &logflags,
5293 XFS_DATA_FORK, 0); 5120 XFS_DATA_FORK, 0);
5294 if (error) 5121 if (error)
5295 goto error0; 5122 goto error0;
@@ -5344,7 +5171,7 @@ xfs_bunmapi(
5344 prev.br_state = XFS_EXT_UNWRITTEN; 5171 prev.br_state = XFS_EXT_UNWRITTEN;
5345 error = xfs_bmap_add_extent(ip, lastx - 1, &cur, 5172 error = xfs_bmap_add_extent(ip, lastx - 1, &cur,
5346 &prev, firstblock, flist, &logflags, 5173 &prev, firstblock, flist, &logflags,
5347 delta, XFS_DATA_FORK, 0); 5174 XFS_DATA_FORK, 0);
5348 if (error) 5175 if (error)
5349 goto error0; 5176 goto error0;
5350 goto nodelete; 5177 goto nodelete;
@@ -5353,7 +5180,7 @@ xfs_bunmapi(
5353 del.br_state = XFS_EXT_UNWRITTEN; 5180 del.br_state = XFS_EXT_UNWRITTEN;
5354 error = xfs_bmap_add_extent(ip, lastx, &cur, 5181 error = xfs_bmap_add_extent(ip, lastx, &cur,
5355 &del, firstblock, flist, &logflags, 5182 &del, firstblock, flist, &logflags,
5356 delta, XFS_DATA_FORK, 0); 5183 XFS_DATA_FORK, 0);
5357 if (error) 5184 if (error)
5358 goto error0; 5185 goto error0;
5359 goto nodelete; 5186 goto nodelete;
@@ -5406,7 +5233,7 @@ xfs_bunmapi(
5406 goto error0; 5233 goto error0;
5407 } 5234 }
5408 error = xfs_bmap_del_extent(ip, tp, lastx, flist, cur, &del, 5235 error = xfs_bmap_del_extent(ip, tp, lastx, flist, cur, &del,
5409 &tmp_logflags, delta, whichfork, rsvd); 5236 &tmp_logflags, whichfork, rsvd);
5410 logflags |= tmp_logflags; 5237 logflags |= tmp_logflags;
5411 if (error) 5238 if (error)
5412 goto error0; 5239 goto error0;
@@ -5463,14 +5290,6 @@ nodelete:
5463 ASSERT(ifp->if_ext_max == 5290 ASSERT(ifp->if_ext_max ==
5464 XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t)); 5291 XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
5465 error = 0; 5292 error = 0;
5466 if (delta && delta->xed_startoff != NULLFILEOFF) {
5467 /* A change was actually made.
5468 * Note that delta->xed_blockount is an offset at this
5469 * point and needs to be converted to a block count.
5470 */
5471 ASSERT(delta->xed_blockcount > delta->xed_startoff);
5472 delta->xed_blockcount -= delta->xed_startoff;
5473 }
5474error0: 5293error0:
5475 /* 5294 /*
5476 * Log everything. Do this after conversion, there's no point in 5295 * Log everything. Do this after conversion, there's no point in
@@ -5683,7 +5502,7 @@ xfs_getbmap(
5683 error = xfs_bmapi(NULL, ip, XFS_BB_TO_FSBT(mp, bmv->bmv_offset), 5502 error = xfs_bmapi(NULL, ip, XFS_BB_TO_FSBT(mp, bmv->bmv_offset),
5684 XFS_BB_TO_FSB(mp, bmv->bmv_length), 5503 XFS_BB_TO_FSB(mp, bmv->bmv_length),
5685 bmapi_flags, NULL, 0, map, &nmap, 5504 bmapi_flags, NULL, 0, map, &nmap,
5686 NULL, NULL); 5505 NULL);
5687 if (error) 5506 if (error)
5688 goto out_free_map; 5507 goto out_free_map;
5689 ASSERT(nmap <= subnex); 5508 ASSERT(nmap <= subnex);