diff options
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 394 |
1 files changed, 172 insertions, 222 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 8971fb09d387..6154ca030724 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -759,26 +759,10 @@ xfs_bmap_add_extent_delay_real( | |||
759 | xfs_filblks_t temp=0; /* value for dnew calculations */ | 759 | xfs_filblks_t temp=0; /* value for dnew calculations */ |
760 | xfs_filblks_t temp2=0;/* value for dnew calculations */ | 760 | xfs_filblks_t temp2=0;/* value for dnew calculations */ |
761 | int tmp_rval; /* partial logging flags */ | 761 | int tmp_rval; /* partial logging flags */ |
762 | enum { /* bit number definitions for state */ | ||
763 | LEFT_CONTIG, RIGHT_CONTIG, | ||
764 | LEFT_FILLING, RIGHT_FILLING, | ||
765 | LEFT_DELAY, RIGHT_DELAY, | ||
766 | LEFT_VALID, RIGHT_VALID | ||
767 | }; | ||
768 | 762 | ||
769 | #define LEFT r[0] | 763 | #define LEFT r[0] |
770 | #define RIGHT r[1] | 764 | #define RIGHT r[1] |
771 | #define PREV r[2] | 765 | #define PREV r[2] |
772 | #define MASK(b) (1 << (b)) | ||
773 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
774 | #define MASK3(a,b,c) (MASK2(a,b) | MASK(c)) | ||
775 | #define MASK4(a,b,c,d) (MASK3(a,b,c) | MASK(d)) | ||
776 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
777 | #define STATE_TEST(b) (state & MASK(b)) | ||
778 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
779 | ((state &= ~MASK(b)), 0)) | ||
780 | #define SWITCH_STATE \ | ||
781 | (state & MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG)) | ||
782 | 766 | ||
783 | /* | 767 | /* |
784 | * Set up a bunch of variables to make the tests simpler. | 768 | * Set up a bunch of variables to make the tests simpler. |
@@ -790,56 +774,69 @@ xfs_bmap_add_extent_delay_real( | |||
790 | new_endoff = new->br_startoff + new->br_blockcount; | 774 | new_endoff = new->br_startoff + new->br_blockcount; |
791 | ASSERT(PREV.br_startoff <= new->br_startoff); | 775 | ASSERT(PREV.br_startoff <= new->br_startoff); |
792 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); | 776 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); |
777 | |||
793 | /* | 778 | /* |
794 | * Set flags determining what part of the previous delayed allocation | 779 | * Set flags determining what part of the previous delayed allocation |
795 | * extent is being replaced by a real allocation. | 780 | * extent is being replaced by a real allocation. |
796 | */ | 781 | */ |
797 | STATE_SET(LEFT_FILLING, PREV.br_startoff == new->br_startoff); | 782 | if (PREV.br_startoff == new->br_startoff) |
798 | STATE_SET(RIGHT_FILLING, | 783 | state |= BMAP_LEFT_FILLING; |
799 | PREV.br_startoff + PREV.br_blockcount == new_endoff); | 784 | if (PREV.br_startoff + PREV.br_blockcount == new_endoff) |
785 | state |= BMAP_RIGHT_FILLING; | ||
786 | |||
800 | /* | 787 | /* |
801 | * Check and set flags if this segment has a left neighbor. | 788 | * Check and set flags if this segment has a left neighbor. |
802 | * Don't set contiguous if the combined extent would be too large. | 789 | * Don't set contiguous if the combined extent would be too large. |
803 | */ | 790 | */ |
804 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 791 | if (idx > 0) { |
792 | state |= BMAP_LEFT_VALID; | ||
805 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); | 793 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); |
806 | STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock)); | 794 | |
795 | if (isnullstartblock(LEFT.br_startblock)) | ||
796 | state |= BMAP_LEFT_DELAY; | ||
807 | } | 797 | } |
808 | STATE_SET(LEFT_CONTIG, | 798 | |
809 | STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && | 799 | if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) && |
810 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && | 800 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && |
811 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && | 801 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && |
812 | LEFT.br_state == new->br_state && | 802 | LEFT.br_state == new->br_state && |
813 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 803 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
804 | state |= BMAP_LEFT_CONTIG; | ||
805 | |||
814 | /* | 806 | /* |
815 | * Check and set flags if this segment has a right neighbor. | 807 | * Check and set flags if this segment has a right neighbor. |
816 | * Don't set contiguous if the combined extent would be too large. | 808 | * Don't set contiguous if the combined extent would be too large. |
817 | * Also check for all-three-contiguous being too large. | 809 | * Also check for all-three-contiguous being too large. |
818 | */ | 810 | */ |
819 | if (STATE_SET_TEST(RIGHT_VALID, | 811 | if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) { |
820 | idx < | 812 | state |= BMAP_RIGHT_VALID; |
821 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { | ||
822 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); | 813 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); |
823 | STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock)); | 814 | |
815 | if (isnullstartblock(RIGHT.br_startblock)) | ||
816 | state |= BMAP_RIGHT_DELAY; | ||
824 | } | 817 | } |
825 | STATE_SET(RIGHT_CONTIG, | 818 | |
826 | STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && | 819 | if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && |
827 | new_endoff == RIGHT.br_startoff && | 820 | new_endoff == RIGHT.br_startoff && |
828 | new->br_startblock + new->br_blockcount == | 821 | new->br_startblock + new->br_blockcount == RIGHT.br_startblock && |
829 | RIGHT.br_startblock && | 822 | new->br_state == RIGHT.br_state && |
830 | new->br_state == RIGHT.br_state && | 823 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && |
831 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && | 824 | ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
832 | ((state & MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING)) != | 825 | BMAP_RIGHT_FILLING)) != |
833 | MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING) || | 826 | (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
834 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount | 827 | BMAP_RIGHT_FILLING) || |
835 | <= MAXEXTLEN)); | 828 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount |
829 | <= MAXEXTLEN)) | ||
830 | state |= BMAP_RIGHT_CONTIG; | ||
831 | |||
836 | error = 0; | 832 | error = 0; |
837 | /* | 833 | /* |
838 | * Switch out based on the FILLING and CONTIG state bits. | 834 | * Switch out based on the FILLING and CONTIG state bits. |
839 | */ | 835 | */ |
840 | switch (SWITCH_STATE) { | 836 | switch (state & (BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
841 | 837 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG)) { | |
842 | case MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 838 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
839 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: | ||
843 | /* | 840 | /* |
844 | * Filling in all of a previously delayed allocation extent. | 841 | * Filling in all of a previously delayed allocation extent. |
845 | * The left and right neighbors are both contiguous with new. | 842 | * The left and right neighbors are both contiguous with new. |
@@ -885,7 +882,7 @@ xfs_bmap_add_extent_delay_real( | |||
885 | RIGHT.br_blockcount; | 882 | RIGHT.br_blockcount; |
886 | break; | 883 | break; |
887 | 884 | ||
888 | case MASK3(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG): | 885 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
889 | /* | 886 | /* |
890 | * Filling in all of a previously delayed allocation extent. | 887 | * Filling in all of a previously delayed allocation extent. |
891 | * The left neighbor is contiguous, the right is not. | 888 | * The left neighbor is contiguous, the right is not. |
@@ -921,7 +918,7 @@ xfs_bmap_add_extent_delay_real( | |||
921 | PREV.br_blockcount; | 918 | PREV.br_blockcount; |
922 | break; | 919 | break; |
923 | 920 | ||
924 | case MASK3(LEFT_FILLING, RIGHT_FILLING, RIGHT_CONTIG): | 921 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
925 | /* | 922 | /* |
926 | * Filling in all of a previously delayed allocation extent. | 923 | * Filling in all of a previously delayed allocation extent. |
927 | * The right neighbor is contiguous, the left is not. | 924 | * The right neighbor is contiguous, the left is not. |
@@ -956,7 +953,7 @@ xfs_bmap_add_extent_delay_real( | |||
956 | RIGHT.br_blockcount; | 953 | RIGHT.br_blockcount; |
957 | break; | 954 | break; |
958 | 955 | ||
959 | case MASK2(LEFT_FILLING, RIGHT_FILLING): | 956 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: |
960 | /* | 957 | /* |
961 | * Filling in all of a previously delayed allocation extent. | 958 | * Filling in all of a previously delayed allocation extent. |
962 | * Neither the left nor right neighbors are contiguous with | 959 | * Neither the left nor right neighbors are contiguous with |
@@ -987,7 +984,7 @@ xfs_bmap_add_extent_delay_real( | |||
987 | temp2 = new->br_blockcount; | 984 | temp2 = new->br_blockcount; |
988 | break; | 985 | break; |
989 | 986 | ||
990 | case MASK2(LEFT_FILLING, LEFT_CONTIG): | 987 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: |
991 | /* | 988 | /* |
992 | * Filling in the first part of a previous delayed allocation. | 989 | * Filling in the first part of a previous delayed allocation. |
993 | * The left neighbor is contiguous. | 990 | * The left neighbor is contiguous. |
@@ -1029,7 +1026,7 @@ xfs_bmap_add_extent_delay_real( | |||
1029 | PREV.br_blockcount; | 1026 | PREV.br_blockcount; |
1030 | break; | 1027 | break; |
1031 | 1028 | ||
1032 | case MASK(LEFT_FILLING): | 1029 | case BMAP_LEFT_FILLING: |
1033 | /* | 1030 | /* |
1034 | * Filling in the first part of a previous delayed allocation. | 1031 | * Filling in the first part of a previous delayed allocation. |
1035 | * The left neighbor is not contiguous. | 1032 | * The left neighbor is not contiguous. |
@@ -1078,7 +1075,7 @@ xfs_bmap_add_extent_delay_real( | |||
1078 | temp2 = PREV.br_blockcount; | 1075 | temp2 = PREV.br_blockcount; |
1079 | break; | 1076 | break; |
1080 | 1077 | ||
1081 | case MASK2(RIGHT_FILLING, RIGHT_CONTIG): | 1078 | case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
1082 | /* | 1079 | /* |
1083 | * Filling in the last part of a previous delayed allocation. | 1080 | * Filling in the last part of a previous delayed allocation. |
1084 | * The right neighbor is contiguous with the new allocation. | 1081 | * The right neighbor is contiguous with the new allocation. |
@@ -1120,7 +1117,7 @@ xfs_bmap_add_extent_delay_real( | |||
1120 | RIGHT.br_blockcount; | 1117 | RIGHT.br_blockcount; |
1121 | break; | 1118 | break; |
1122 | 1119 | ||
1123 | case MASK(RIGHT_FILLING): | 1120 | case BMAP_RIGHT_FILLING: |
1124 | /* | 1121 | /* |
1125 | * Filling in the last part of a previous delayed allocation. | 1122 | * Filling in the last part of a previous delayed allocation. |
1126 | * The right neighbor is not contiguous. | 1123 | * The right neighbor is not contiguous. |
@@ -1253,13 +1250,13 @@ xfs_bmap_add_extent_delay_real( | |||
1253 | temp2 = PREV.br_blockcount; | 1250 | temp2 = PREV.br_blockcount; |
1254 | break; | 1251 | break; |
1255 | 1252 | ||
1256 | case MASK3(LEFT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1253 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
1257 | case MASK3(RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1254 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
1258 | case MASK2(LEFT_FILLING, RIGHT_CONTIG): | 1255 | case BMAP_LEFT_FILLING | BMAP_RIGHT_CONTIG: |
1259 | case MASK2(RIGHT_FILLING, LEFT_CONTIG): | 1256 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
1260 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | 1257 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
1261 | case MASK(LEFT_CONTIG): | 1258 | case BMAP_LEFT_CONTIG: |
1262 | case MASK(RIGHT_CONTIG): | 1259 | case BMAP_RIGHT_CONTIG: |
1263 | /* | 1260 | /* |
1264 | * These cases are all impossible. | 1261 | * These cases are all impossible. |
1265 | */ | 1262 | */ |
@@ -1279,14 +1276,6 @@ done: | |||
1279 | #undef LEFT | 1276 | #undef LEFT |
1280 | #undef RIGHT | 1277 | #undef RIGHT |
1281 | #undef PREV | 1278 | #undef PREV |
1282 | #undef MASK | ||
1283 | #undef MASK2 | ||
1284 | #undef MASK3 | ||
1285 | #undef MASK4 | ||
1286 | #undef STATE_SET | ||
1287 | #undef STATE_TEST | ||
1288 | #undef STATE_SET_TEST | ||
1289 | #undef SWITCH_STATE | ||
1290 | } | 1279 | } |
1291 | 1280 | ||
1292 | /* | 1281 | /* |
@@ -1316,27 +1305,10 @@ xfs_bmap_add_extent_unwritten_real( | |||
1316 | int state = 0;/* state bits, accessed thru macros */ | 1305 | int state = 0;/* state bits, accessed thru macros */ |
1317 | xfs_filblks_t temp=0; | 1306 | xfs_filblks_t temp=0; |
1318 | xfs_filblks_t temp2=0; | 1307 | xfs_filblks_t temp2=0; |
1319 | enum { /* bit number definitions for state */ | ||
1320 | LEFT_CONTIG, RIGHT_CONTIG, | ||
1321 | LEFT_FILLING, RIGHT_FILLING, | ||
1322 | LEFT_DELAY, RIGHT_DELAY, | ||
1323 | LEFT_VALID, RIGHT_VALID | ||
1324 | }; | ||
1325 | 1308 | ||
1326 | #define LEFT r[0] | 1309 | #define LEFT r[0] |
1327 | #define RIGHT r[1] | 1310 | #define RIGHT r[1] |
1328 | #define PREV r[2] | 1311 | #define PREV r[2] |
1329 | #define MASK(b) (1 << (b)) | ||
1330 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
1331 | #define MASK3(a,b,c) (MASK2(a,b) | MASK(c)) | ||
1332 | #define MASK4(a,b,c,d) (MASK3(a,b,c) | MASK(d)) | ||
1333 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
1334 | #define STATE_TEST(b) (state & MASK(b)) | ||
1335 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
1336 | ((state &= ~MASK(b)), 0)) | ||
1337 | #define SWITCH_STATE \ | ||
1338 | (state & MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG)) | ||
1339 | |||
1340 | /* | 1312 | /* |
1341 | * Set up a bunch of variables to make the tests simpler. | 1313 | * Set up a bunch of variables to make the tests simpler. |
1342 | */ | 1314 | */ |
@@ -1352,55 +1324,67 @@ xfs_bmap_add_extent_unwritten_real( | |||
1352 | new_endoff = new->br_startoff + new->br_blockcount; | 1324 | new_endoff = new->br_startoff + new->br_blockcount; |
1353 | ASSERT(PREV.br_startoff <= new->br_startoff); | 1325 | ASSERT(PREV.br_startoff <= new->br_startoff); |
1354 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); | 1326 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); |
1327 | |||
1355 | /* | 1328 | /* |
1356 | * Set flags determining what part of the previous oldext allocation | 1329 | * Set flags determining what part of the previous oldext allocation |
1357 | * extent is being replaced by a newext allocation. | 1330 | * extent is being replaced by a newext allocation. |
1358 | */ | 1331 | */ |
1359 | STATE_SET(LEFT_FILLING, PREV.br_startoff == new->br_startoff); | 1332 | if (PREV.br_startoff == new->br_startoff) |
1360 | STATE_SET(RIGHT_FILLING, | 1333 | state |= BMAP_LEFT_FILLING; |
1361 | PREV.br_startoff + PREV.br_blockcount == new_endoff); | 1334 | if (PREV.br_startoff + PREV.br_blockcount == new_endoff) |
1335 | state |= BMAP_RIGHT_FILLING; | ||
1336 | |||
1362 | /* | 1337 | /* |
1363 | * Check and set flags if this segment has a left neighbor. | 1338 | * Check and set flags if this segment has a left neighbor. |
1364 | * Don't set contiguous if the combined extent would be too large. | 1339 | * Don't set contiguous if the combined extent would be too large. |
1365 | */ | 1340 | */ |
1366 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1341 | if (idx > 0) { |
1342 | state |= BMAP_LEFT_VALID; | ||
1367 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); | 1343 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); |
1368 | STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock)); | 1344 | |
1345 | if (isnullstartblock(LEFT.br_startblock)) | ||
1346 | state |= BMAP_LEFT_DELAY; | ||
1369 | } | 1347 | } |
1370 | STATE_SET(LEFT_CONTIG, | 1348 | |
1371 | STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && | 1349 | if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) && |
1372 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && | 1350 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && |
1373 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && | 1351 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && |
1374 | LEFT.br_state == newext && | 1352 | LEFT.br_state == newext && |
1375 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 1353 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
1354 | state |= BMAP_LEFT_CONTIG; | ||
1355 | |||
1376 | /* | 1356 | /* |
1377 | * Check and set flags if this segment has a right neighbor. | 1357 | * Check and set flags if this segment has a right neighbor. |
1378 | * Don't set contiguous if the combined extent would be too large. | 1358 | * Don't set contiguous if the combined extent would be too large. |
1379 | * Also check for all-three-contiguous being too large. | 1359 | * Also check for all-three-contiguous being too large. |
1380 | */ | 1360 | */ |
1381 | if (STATE_SET_TEST(RIGHT_VALID, | 1361 | if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) { |
1382 | idx < | 1362 | state |= BMAP_RIGHT_VALID; |
1383 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { | ||
1384 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); | 1363 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); |
1385 | STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock)); | 1364 | if (isnullstartblock(RIGHT.br_startblock)) |
1365 | state |= BMAP_RIGHT_DELAY; | ||
1386 | } | 1366 | } |
1387 | STATE_SET(RIGHT_CONTIG, | 1367 | |
1388 | STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && | 1368 | if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && |
1389 | new_endoff == RIGHT.br_startoff && | 1369 | new_endoff == RIGHT.br_startoff && |
1390 | new->br_startblock + new->br_blockcount == | 1370 | new->br_startblock + new->br_blockcount == RIGHT.br_startblock && |
1391 | RIGHT.br_startblock && | 1371 | newext == RIGHT.br_state && |
1392 | newext == RIGHT.br_state && | 1372 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && |
1393 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && | 1373 | ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
1394 | ((state & MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING)) != | 1374 | BMAP_RIGHT_FILLING)) != |
1395 | MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING) || | 1375 | (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
1396 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount | 1376 | BMAP_RIGHT_FILLING) || |
1397 | <= MAXEXTLEN)); | 1377 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount |
1378 | <= MAXEXTLEN)) | ||
1379 | state |= BMAP_RIGHT_CONTIG; | ||
1380 | |||
1398 | /* | 1381 | /* |
1399 | * Switch out based on the FILLING and CONTIG state bits. | 1382 | * Switch out based on the FILLING and CONTIG state bits. |
1400 | */ | 1383 | */ |
1401 | switch (SWITCH_STATE) { | 1384 | switch (state & (BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
1402 | 1385 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG)) { | |
1403 | case MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1386 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
1387 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: | ||
1404 | /* | 1388 | /* |
1405 | * Setting all of a previous oldext extent to newext. | 1389 | * Setting all of a previous oldext extent to newext. |
1406 | * The left and right neighbors are both contiguous with new. | 1390 | * The left and right neighbors are both contiguous with new. |
@@ -1450,7 +1434,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1450 | RIGHT.br_blockcount; | 1434 | RIGHT.br_blockcount; |
1451 | break; | 1435 | break; |
1452 | 1436 | ||
1453 | case MASK3(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG): | 1437 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
1454 | /* | 1438 | /* |
1455 | * Setting all of a previous oldext extent to newext. | 1439 | * Setting all of a previous oldext extent to newext. |
1456 | * The left neighbor is contiguous, the right is not. | 1440 | * The left neighbor is contiguous, the right is not. |
@@ -1492,7 +1476,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1492 | PREV.br_blockcount; | 1476 | PREV.br_blockcount; |
1493 | break; | 1477 | break; |
1494 | 1478 | ||
1495 | case MASK3(LEFT_FILLING, RIGHT_FILLING, RIGHT_CONTIG): | 1479 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
1496 | /* | 1480 | /* |
1497 | * Setting all of a previous oldext extent to newext. | 1481 | * Setting all of a previous oldext extent to newext. |
1498 | * The right neighbor is contiguous, the left is not. | 1482 | * The right neighbor is contiguous, the left is not. |
@@ -1535,7 +1519,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1535 | RIGHT.br_blockcount; | 1519 | RIGHT.br_blockcount; |
1536 | break; | 1520 | break; |
1537 | 1521 | ||
1538 | case MASK2(LEFT_FILLING, RIGHT_FILLING): | 1522 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: |
1539 | /* | 1523 | /* |
1540 | * Setting all of a previous oldext extent to newext. | 1524 | * Setting all of a previous oldext extent to newext. |
1541 | * Neither the left nor right neighbors are contiguous with | 1525 | * Neither the left nor right neighbors are contiguous with |
@@ -1566,7 +1550,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1566 | temp2 = new->br_blockcount; | 1550 | temp2 = new->br_blockcount; |
1567 | break; | 1551 | break; |
1568 | 1552 | ||
1569 | case MASK2(LEFT_FILLING, LEFT_CONTIG): | 1553 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: |
1570 | /* | 1554 | /* |
1571 | * Setting the first part of a previous oldext extent to newext. | 1555 | * Setting the first part of a previous oldext extent to newext. |
1572 | * The left neighbor is contiguous. | 1556 | * The left neighbor is contiguous. |
@@ -1617,7 +1601,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1617 | PREV.br_blockcount; | 1601 | PREV.br_blockcount; |
1618 | break; | 1602 | break; |
1619 | 1603 | ||
1620 | case MASK(LEFT_FILLING): | 1604 | case BMAP_LEFT_FILLING: |
1621 | /* | 1605 | /* |
1622 | * Setting the first part of a previous oldext extent to newext. | 1606 | * Setting the first part of a previous oldext extent to newext. |
1623 | * The left neighbor is not contiguous. | 1607 | * The left neighbor is not contiguous. |
@@ -1660,7 +1644,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1660 | temp2 = PREV.br_blockcount; | 1644 | temp2 = PREV.br_blockcount; |
1661 | break; | 1645 | break; |
1662 | 1646 | ||
1663 | case MASK2(RIGHT_FILLING, RIGHT_CONTIG): | 1647 | case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
1664 | /* | 1648 | /* |
1665 | * Setting the last part of a previous oldext extent to newext. | 1649 | * Setting the last part of a previous oldext extent to newext. |
1666 | * The right neighbor is contiguous with the new allocation. | 1650 | * The right neighbor is contiguous with the new allocation. |
@@ -1707,7 +1691,7 @@ xfs_bmap_add_extent_unwritten_real( | |||
1707 | RIGHT.br_blockcount; | 1691 | RIGHT.br_blockcount; |
1708 | break; | 1692 | break; |
1709 | 1693 | ||
1710 | case MASK(RIGHT_FILLING): | 1694 | case BMAP_RIGHT_FILLING: |
1711 | /* | 1695 | /* |
1712 | * Setting the last part of a previous oldext extent to newext. | 1696 | * Setting the last part of a previous oldext extent to newext. |
1713 | * The right neighbor is not contiguous. | 1697 | * The right neighbor is not contiguous. |
@@ -1813,13 +1797,13 @@ xfs_bmap_add_extent_unwritten_real( | |||
1813 | temp2 = PREV.br_blockcount; | 1797 | temp2 = PREV.br_blockcount; |
1814 | break; | 1798 | break; |
1815 | 1799 | ||
1816 | case MASK3(LEFT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1800 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
1817 | case MASK3(RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1801 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
1818 | case MASK2(LEFT_FILLING, RIGHT_CONTIG): | 1802 | case BMAP_LEFT_FILLING | BMAP_RIGHT_CONTIG: |
1819 | case MASK2(RIGHT_FILLING, LEFT_CONTIG): | 1803 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
1820 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | 1804 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
1821 | case MASK(LEFT_CONTIG): | 1805 | case BMAP_LEFT_CONTIG: |
1822 | case MASK(RIGHT_CONTIG): | 1806 | case BMAP_RIGHT_CONTIG: |
1823 | /* | 1807 | /* |
1824 | * These cases are all impossible. | 1808 | * These cases are all impossible. |
1825 | */ | 1809 | */ |
@@ -1839,14 +1823,6 @@ done: | |||
1839 | #undef LEFT | 1823 | #undef LEFT |
1840 | #undef RIGHT | 1824 | #undef RIGHT |
1841 | #undef PREV | 1825 | #undef PREV |
1842 | #undef MASK | ||
1843 | #undef MASK2 | ||
1844 | #undef MASK3 | ||
1845 | #undef MASK4 | ||
1846 | #undef STATE_SET | ||
1847 | #undef STATE_TEST | ||
1848 | #undef STATE_SET_TEST | ||
1849 | #undef SWITCH_STATE | ||
1850 | } | 1826 | } |
1851 | 1827 | ||
1852 | /* | 1828 | /* |
@@ -1872,62 +1848,57 @@ xfs_bmap_add_extent_hole_delay( | |||
1872 | int state; /* state bits, accessed thru macros */ | 1848 | int state; /* state bits, accessed thru macros */ |
1873 | xfs_filblks_t temp=0; /* temp for indirect calculations */ | 1849 | xfs_filblks_t temp=0; /* temp for indirect calculations */ |
1874 | xfs_filblks_t temp2=0; | 1850 | xfs_filblks_t temp2=0; |
1875 | enum { /* bit number definitions for state */ | ||
1876 | LEFT_CONTIG, RIGHT_CONTIG, | ||
1877 | LEFT_DELAY, RIGHT_DELAY, | ||
1878 | LEFT_VALID, RIGHT_VALID | ||
1879 | }; | ||
1880 | |||
1881 | #define MASK(b) (1 << (b)) | ||
1882 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
1883 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
1884 | #define STATE_TEST(b) (state & MASK(b)) | ||
1885 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
1886 | ((state &= ~MASK(b)), 0)) | ||
1887 | #define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG)) | ||
1888 | 1851 | ||
1889 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); | 1852 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); |
1890 | ep = xfs_iext_get_ext(ifp, idx); | 1853 | ep = xfs_iext_get_ext(ifp, idx); |
1891 | state = 0; | 1854 | state = 0; |
1892 | ASSERT(isnullstartblock(new->br_startblock)); | 1855 | ASSERT(isnullstartblock(new->br_startblock)); |
1856 | |||
1893 | /* | 1857 | /* |
1894 | * Check and set flags if this segment has a left neighbor | 1858 | * Check and set flags if this segment has a left neighbor |
1895 | */ | 1859 | */ |
1896 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1860 | if (idx > 0) { |
1861 | state |= BMAP_LEFT_VALID; | ||
1897 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); | 1862 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); |
1898 | STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock)); | 1863 | |
1864 | if (isnullstartblock(left.br_startblock)) | ||
1865 | state |= BMAP_LEFT_DELAY; | ||
1899 | } | 1866 | } |
1867 | |||
1900 | /* | 1868 | /* |
1901 | * Check and set flags if the current (right) segment exists. | 1869 | * Check and set flags if the current (right) segment exists. |
1902 | * If it doesn't exist, we're converting the hole at end-of-file. | 1870 | * If it doesn't exist, we're converting the hole at end-of-file. |
1903 | */ | 1871 | */ |
1904 | if (STATE_SET_TEST(RIGHT_VALID, | 1872 | if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { |
1905 | idx < | 1873 | state |= BMAP_RIGHT_VALID; |
1906 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { | ||
1907 | xfs_bmbt_get_all(ep, &right); | 1874 | xfs_bmbt_get_all(ep, &right); |
1908 | STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock)); | 1875 | |
1876 | if (isnullstartblock(right.br_startblock)) | ||
1877 | state |= BMAP_RIGHT_DELAY; | ||
1909 | } | 1878 | } |
1879 | |||
1910 | /* | 1880 | /* |
1911 | * Set contiguity flags on the left and right neighbors. | 1881 | * Set contiguity flags on the left and right neighbors. |
1912 | * Don't let extents get too large, even if the pieces are contiguous. | 1882 | * Don't let extents get too large, even if the pieces are contiguous. |
1913 | */ | 1883 | */ |
1914 | STATE_SET(LEFT_CONTIG, | 1884 | if ((state & BMAP_LEFT_VALID) && (state & BMAP_LEFT_DELAY) && |
1915 | STATE_TEST(LEFT_VALID) && STATE_TEST(LEFT_DELAY) && | 1885 | left.br_startoff + left.br_blockcount == new->br_startoff && |
1916 | left.br_startoff + left.br_blockcount == new->br_startoff && | 1886 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
1917 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 1887 | state |= BMAP_LEFT_CONTIG; |
1918 | STATE_SET(RIGHT_CONTIG, | 1888 | |
1919 | STATE_TEST(RIGHT_VALID) && STATE_TEST(RIGHT_DELAY) && | 1889 | if ((state & BMAP_RIGHT_VALID) && (state & BMAP_RIGHT_DELAY) && |
1920 | new->br_startoff + new->br_blockcount == right.br_startoff && | 1890 | new->br_startoff + new->br_blockcount == right.br_startoff && |
1921 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && | 1891 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && |
1922 | (!STATE_TEST(LEFT_CONTIG) || | 1892 | (!(state & BMAP_LEFT_CONTIG) || |
1923 | (left.br_blockcount + new->br_blockcount + | 1893 | (left.br_blockcount + new->br_blockcount + |
1924 | right.br_blockcount <= MAXEXTLEN))); | 1894 | right.br_blockcount <= MAXEXTLEN))) |
1895 | state |= BMAP_RIGHT_CONTIG; | ||
1896 | |||
1925 | /* | 1897 | /* |
1926 | * Switch out based on the contiguity flags. | 1898 | * Switch out based on the contiguity flags. |
1927 | */ | 1899 | */ |
1928 | switch (SWITCH_STATE) { | 1900 | switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) { |
1929 | 1901 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: | |
1930 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | ||
1931 | /* | 1902 | /* |
1932 | * New allocation is contiguous with delayed allocations | 1903 | * New allocation is contiguous with delayed allocations |
1933 | * on the left and on the right. | 1904 | * on the left and on the right. |
@@ -1954,7 +1925,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1954 | temp = left.br_startoff; | 1925 | temp = left.br_startoff; |
1955 | break; | 1926 | break; |
1956 | 1927 | ||
1957 | case MASK(LEFT_CONTIG): | 1928 | case BMAP_LEFT_CONTIG: |
1958 | /* | 1929 | /* |
1959 | * New allocation is contiguous with a delayed allocation | 1930 | * New allocation is contiguous with a delayed allocation |
1960 | * on the left. | 1931 | * on the left. |
@@ -1977,7 +1948,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1977 | temp = left.br_startoff; | 1948 | temp = left.br_startoff; |
1978 | break; | 1949 | break; |
1979 | 1950 | ||
1980 | case MASK(RIGHT_CONTIG): | 1951 | case BMAP_RIGHT_CONTIG: |
1981 | /* | 1952 | /* |
1982 | * New allocation is contiguous with a delayed allocation | 1953 | * New allocation is contiguous with a delayed allocation |
1983 | * on the right. | 1954 | * on the right. |
@@ -2030,12 +2001,6 @@ xfs_bmap_add_extent_hole_delay( | |||
2030 | } | 2001 | } |
2031 | *logflagsp = 0; | 2002 | *logflagsp = 0; |
2032 | return 0; | 2003 | return 0; |
2033 | #undef MASK | ||
2034 | #undef MASK2 | ||
2035 | #undef STATE_SET | ||
2036 | #undef STATE_TEST | ||
2037 | #undef STATE_SET_TEST | ||
2038 | #undef SWITCH_STATE | ||
2039 | } | 2004 | } |
2040 | 2005 | ||
2041 | /* | 2006 | /* |
@@ -2062,69 +2027,60 @@ xfs_bmap_add_extent_hole_real( | |||
2062 | int state; /* state bits, accessed thru macros */ | 2027 | int state; /* state bits, accessed thru macros */ |
2063 | xfs_filblks_t temp=0; | 2028 | xfs_filblks_t temp=0; |
2064 | xfs_filblks_t temp2=0; | 2029 | xfs_filblks_t temp2=0; |
2065 | enum { /* bit number definitions for state */ | ||
2066 | LEFT_CONTIG, RIGHT_CONTIG, | ||
2067 | LEFT_DELAY, RIGHT_DELAY, | ||
2068 | LEFT_VALID, RIGHT_VALID | ||
2069 | }; | ||
2070 | |||
2071 | #define MASK(b) (1 << (b)) | ||
2072 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
2073 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
2074 | #define STATE_TEST(b) (state & MASK(b)) | ||
2075 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
2076 | ((state &= ~MASK(b)), 0)) | ||
2077 | #define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG)) | ||
2078 | 2030 | ||
2079 | ifp = XFS_IFORK_PTR(ip, whichfork); | 2031 | ifp = XFS_IFORK_PTR(ip, whichfork); |
2080 | ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); | 2032 | ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); |
2081 | ep = xfs_iext_get_ext(ifp, idx); | 2033 | ep = xfs_iext_get_ext(ifp, idx); |
2082 | state = 0; | 2034 | state = 0; |
2035 | |||
2083 | /* | 2036 | /* |
2084 | * Check and set flags if this segment has a left neighbor. | 2037 | * Check and set flags if this segment has a left neighbor. |
2085 | */ | 2038 | */ |
2086 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 2039 | if (idx > 0) { |
2040 | state |= BMAP_LEFT_VALID; | ||
2087 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); | 2041 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); |
2088 | STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock)); | 2042 | if (isnullstartblock(left.br_startblock)) |
2043 | state |= BMAP_LEFT_DELAY; | ||
2089 | } | 2044 | } |
2045 | |||
2090 | /* | 2046 | /* |
2091 | * Check and set flags if this segment has a current value. | 2047 | * Check and set flags if this segment has a current value. |
2092 | * Not true if we're inserting into the "hole" at eof. | 2048 | * Not true if we're inserting into the "hole" at eof. |
2093 | */ | 2049 | */ |
2094 | if (STATE_SET_TEST(RIGHT_VALID, | 2050 | if (idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { |
2095 | idx < | 2051 | state |= BMAP_RIGHT_VALID; |
2096 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { | ||
2097 | xfs_bmbt_get_all(ep, &right); | 2052 | xfs_bmbt_get_all(ep, &right); |
2098 | STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock)); | 2053 | if (isnullstartblock(right.br_startblock)) |
2054 | state |= BMAP_RIGHT_DELAY; | ||
2099 | } | 2055 | } |
2056 | |||
2100 | /* | 2057 | /* |
2101 | * We're inserting a real allocation between "left" and "right". | 2058 | * We're inserting a real allocation between "left" and "right". |
2102 | * Set the contiguity flags. Don't let extents get too large. | 2059 | * Set the contiguity flags. Don't let extents get too large. |
2103 | */ | 2060 | */ |
2104 | STATE_SET(LEFT_CONTIG, | 2061 | if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) && |
2105 | STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && | 2062 | left.br_startoff + left.br_blockcount == new->br_startoff && |
2106 | left.br_startoff + left.br_blockcount == new->br_startoff && | 2063 | left.br_startblock + left.br_blockcount == new->br_startblock && |
2107 | left.br_startblock + left.br_blockcount == new->br_startblock && | 2064 | left.br_state == new->br_state && |
2108 | left.br_state == new->br_state && | 2065 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
2109 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 2066 | state |= BMAP_LEFT_CONTIG; |
2110 | STATE_SET(RIGHT_CONTIG, | 2067 | |
2111 | STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && | 2068 | if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && |
2112 | new->br_startoff + new->br_blockcount == right.br_startoff && | 2069 | new->br_startoff + new->br_blockcount == right.br_startoff && |
2113 | new->br_startblock + new->br_blockcount == | 2070 | new->br_startblock + new->br_blockcount == right.br_startblock && |
2114 | right.br_startblock && | 2071 | new->br_state == right.br_state && |
2115 | new->br_state == right.br_state && | 2072 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && |
2116 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && | 2073 | (!(state & BMAP_LEFT_CONTIG) || |
2117 | (!STATE_TEST(LEFT_CONTIG) || | 2074 | left.br_blockcount + new->br_blockcount + |
2118 | left.br_blockcount + new->br_blockcount + | 2075 | right.br_blockcount <= MAXEXTLEN)) |
2119 | right.br_blockcount <= MAXEXTLEN)); | 2076 | state |= BMAP_RIGHT_CONTIG; |
2120 | 2077 | ||
2121 | error = 0; | 2078 | error = 0; |
2122 | /* | 2079 | /* |
2123 | * Select which case we're in here, and implement it. | 2080 | * Select which case we're in here, and implement it. |
2124 | */ | 2081 | */ |
2125 | switch (SWITCH_STATE) { | 2082 | switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) { |
2126 | 2083 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: | |
2127 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | ||
2128 | /* | 2084 | /* |
2129 | * New allocation is contiguous with real allocations on the | 2085 | * New allocation is contiguous with real allocations on the |
2130 | * left and on the right. | 2086 | * left and on the right. |
@@ -2173,7 +2129,7 @@ xfs_bmap_add_extent_hole_real( | |||
2173 | right.br_blockcount; | 2129 | right.br_blockcount; |
2174 | break; | 2130 | break; |
2175 | 2131 | ||
2176 | case MASK(LEFT_CONTIG): | 2132 | case BMAP_LEFT_CONTIG: |
2177 | /* | 2133 | /* |
2178 | * New allocation is contiguous with a real allocation | 2134 | * New allocation is contiguous with a real allocation |
2179 | * on the left. | 2135 | * on the left. |
@@ -2207,7 +2163,7 @@ xfs_bmap_add_extent_hole_real( | |||
2207 | new->br_blockcount; | 2163 | new->br_blockcount; |
2208 | break; | 2164 | break; |
2209 | 2165 | ||
2210 | case MASK(RIGHT_CONTIG): | 2166 | case BMAP_RIGHT_CONTIG: |
2211 | /* | 2167 | /* |
2212 | * New allocation is contiguous with a real allocation | 2168 | * New allocation is contiguous with a real allocation |
2213 | * on the right. | 2169 | * on the right. |
@@ -2283,12 +2239,6 @@ xfs_bmap_add_extent_hole_real( | |||
2283 | done: | 2239 | done: |
2284 | *logflagsp = rval; | 2240 | *logflagsp = rval; |
2285 | return error; | 2241 | return error; |
2286 | #undef MASK | ||
2287 | #undef MASK2 | ||
2288 | #undef STATE_SET | ||
2289 | #undef STATE_TEST | ||
2290 | #undef STATE_SET_TEST | ||
2291 | #undef SWITCH_STATE | ||
2292 | } | 2242 | } |
2293 | 2243 | ||
2294 | /* | 2244 | /* |