diff options
author | Steve French <sfrench@us.ibm.com> | 2007-07-18 20:38:57 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-07-18 20:38:57 -0400 |
commit | 1ff8392c32a2645d2665ca779ecb91bb29361c13 (patch) | |
tree | 860b95e9a499ade4060848740fc6ce1fbb4e4e8d /fs/xfs/xfs_bmap.c | |
parent | 70b315b0dd3879cb3ab8aadffb14f10b2d19b9c3 (diff) | |
parent | 5bae7ac9feba925fd0099057f6b23d7be80b7b41 (diff) |
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
fs/cifs/export.c
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 369 |
1 files changed, 188 insertions, 181 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index b1ea26e40aaf..94b5c5fe2681 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include "xfs_quota.h" | 52 | #include "xfs_quota.h" |
53 | #include "xfs_trans_space.h" | 53 | #include "xfs_trans_space.h" |
54 | #include "xfs_buf_item.h" | 54 | #include "xfs_buf_item.h" |
55 | #include "xfs_filestream.h" | ||
55 | 56 | ||
56 | 57 | ||
57 | #ifdef DEBUG | 58 | #ifdef DEBUG |
@@ -277,7 +278,7 @@ xfs_bmap_isaeof( | |||
277 | STATIC void | 278 | STATIC void |
278 | xfs_bmap_trace_addentry( | 279 | xfs_bmap_trace_addentry( |
279 | int opcode, /* operation */ | 280 | int opcode, /* operation */ |
280 | char *fname, /* function name */ | 281 | const char *fname, /* function name */ |
281 | char *desc, /* operation description */ | 282 | char *desc, /* operation description */ |
282 | xfs_inode_t *ip, /* incore inode pointer */ | 283 | xfs_inode_t *ip, /* incore inode pointer */ |
283 | xfs_extnum_t idx, /* index of entry(ies) */ | 284 | xfs_extnum_t idx, /* index of entry(ies) */ |
@@ -291,7 +292,7 @@ xfs_bmap_trace_addentry( | |||
291 | */ | 292 | */ |
292 | STATIC void | 293 | STATIC void |
293 | xfs_bmap_trace_delete( | 294 | xfs_bmap_trace_delete( |
294 | char *fname, /* function name */ | 295 | const char *fname, /* function name */ |
295 | char *desc, /* operation description */ | 296 | char *desc, /* operation description */ |
296 | xfs_inode_t *ip, /* incore inode pointer */ | 297 | xfs_inode_t *ip, /* incore inode pointer */ |
297 | xfs_extnum_t idx, /* index of entry(entries) deleted */ | 298 | xfs_extnum_t idx, /* index of entry(entries) deleted */ |
@@ -304,7 +305,7 @@ xfs_bmap_trace_delete( | |||
304 | */ | 305 | */ |
305 | STATIC void | 306 | STATIC void |
306 | xfs_bmap_trace_insert( | 307 | xfs_bmap_trace_insert( |
307 | char *fname, /* function name */ | 308 | const char *fname, /* function name */ |
308 | char *desc, /* operation description */ | 309 | char *desc, /* operation description */ |
309 | xfs_inode_t *ip, /* incore inode pointer */ | 310 | xfs_inode_t *ip, /* incore inode pointer */ |
310 | xfs_extnum_t idx, /* index of entry(entries) inserted */ | 311 | xfs_extnum_t idx, /* index of entry(entries) inserted */ |
@@ -318,7 +319,7 @@ xfs_bmap_trace_insert( | |||
318 | */ | 319 | */ |
319 | STATIC void | 320 | STATIC void |
320 | xfs_bmap_trace_post_update( | 321 | xfs_bmap_trace_post_update( |
321 | char *fname, /* function name */ | 322 | const char *fname, /* function name */ |
322 | char *desc, /* operation description */ | 323 | char *desc, /* operation description */ |
323 | xfs_inode_t *ip, /* incore inode pointer */ | 324 | xfs_inode_t *ip, /* incore inode pointer */ |
324 | xfs_extnum_t idx, /* index of entry updated */ | 325 | xfs_extnum_t idx, /* index of entry updated */ |
@@ -329,17 +330,25 @@ xfs_bmap_trace_post_update( | |||
329 | */ | 330 | */ |
330 | STATIC void | 331 | STATIC void |
331 | xfs_bmap_trace_pre_update( | 332 | xfs_bmap_trace_pre_update( |
332 | char *fname, /* function name */ | 333 | const char *fname, /* function name */ |
333 | char *desc, /* operation description */ | 334 | char *desc, /* operation description */ |
334 | xfs_inode_t *ip, /* incore inode pointer */ | 335 | xfs_inode_t *ip, /* incore inode pointer */ |
335 | xfs_extnum_t idx, /* index of entry to be updated */ | 336 | xfs_extnum_t idx, /* index of entry to be updated */ |
336 | int whichfork); /* data or attr fork */ | 337 | int whichfork); /* data or attr fork */ |
337 | 338 | ||
339 | #define XFS_BMAP_TRACE_DELETE(d,ip,i,c,w) \ | ||
340 | xfs_bmap_trace_delete(__FUNCTION__,d,ip,i,c,w) | ||
341 | #define XFS_BMAP_TRACE_INSERT(d,ip,i,c,r1,r2,w) \ | ||
342 | xfs_bmap_trace_insert(__FUNCTION__,d,ip,i,c,r1,r2,w) | ||
343 | #define XFS_BMAP_TRACE_POST_UPDATE(d,ip,i,w) \ | ||
344 | xfs_bmap_trace_post_update(__FUNCTION__,d,ip,i,w) | ||
345 | #define XFS_BMAP_TRACE_PRE_UPDATE(d,ip,i,w) \ | ||
346 | xfs_bmap_trace_pre_update(__FUNCTION__,d,ip,i,w) | ||
338 | #else | 347 | #else |
339 | #define xfs_bmap_trace_delete(f,d,ip,i,c,w) | 348 | #define XFS_BMAP_TRACE_DELETE(d,ip,i,c,w) |
340 | #define xfs_bmap_trace_insert(f,d,ip,i,c,r1,r2,w) | 349 | #define XFS_BMAP_TRACE_INSERT(d,ip,i,c,r1,r2,w) |
341 | #define xfs_bmap_trace_post_update(f,d,ip,i,w) | 350 | #define XFS_BMAP_TRACE_POST_UPDATE(d,ip,i,w) |
342 | #define xfs_bmap_trace_pre_update(f,d,ip,i,w) | 351 | #define XFS_BMAP_TRACE_PRE_UPDATE(d,ip,i,w) |
343 | #endif /* XFS_BMAP_TRACE */ | 352 | #endif /* XFS_BMAP_TRACE */ |
344 | 353 | ||
345 | /* | 354 | /* |
@@ -531,9 +540,6 @@ xfs_bmap_add_extent( | |||
531 | xfs_filblks_t da_new; /* new count del alloc blocks used */ | 540 | xfs_filblks_t da_new; /* new count del alloc blocks used */ |
532 | xfs_filblks_t da_old; /* old count del alloc blocks used */ | 541 | xfs_filblks_t da_old; /* old count del alloc blocks used */ |
533 | int error; /* error return value */ | 542 | int error; /* error return value */ |
534 | #ifdef XFS_BMAP_TRACE | ||
535 | static char fname[] = "xfs_bmap_add_extent"; | ||
536 | #endif | ||
537 | xfs_ifork_t *ifp; /* inode fork ptr */ | 543 | xfs_ifork_t *ifp; /* inode fork ptr */ |
538 | int logflags; /* returned value */ | 544 | int logflags; /* returned value */ |
539 | xfs_extnum_t nextents; /* number of extents in file now */ | 545 | xfs_extnum_t nextents; /* number of extents in file now */ |
@@ -551,8 +557,8 @@ xfs_bmap_add_extent( | |||
551 | * already extents in the list. | 557 | * already extents in the list. |
552 | */ | 558 | */ |
553 | if (nextents == 0) { | 559 | if (nextents == 0) { |
554 | xfs_bmap_trace_insert(fname, "insert empty", ip, 0, 1, new, | 560 | XFS_BMAP_TRACE_INSERT("insert empty", ip, 0, 1, new, NULL, |
555 | NULL, whichfork); | 561 | whichfork); |
556 | xfs_iext_insert(ifp, 0, 1, new); | 562 | xfs_iext_insert(ifp, 0, 1, new); |
557 | ASSERT(cur == NULL); | 563 | ASSERT(cur == NULL); |
558 | ifp->if_lastex = 0; | 564 | ifp->if_lastex = 0; |
@@ -710,9 +716,6 @@ xfs_bmap_add_extent_delay_real( | |||
710 | int diff; /* temp value */ | 716 | int diff; /* temp value */ |
711 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ | 717 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ |
712 | int error; /* error return value */ | 718 | int error; /* error return value */ |
713 | #ifdef XFS_BMAP_TRACE | ||
714 | static char fname[] = "xfs_bmap_add_extent_delay_real"; | ||
715 | #endif | ||
716 | int i; /* temp state */ | 719 | int i; /* temp state */ |
717 | xfs_ifork_t *ifp; /* inode fork pointer */ | 720 | xfs_ifork_t *ifp; /* inode fork pointer */ |
718 | xfs_fileoff_t new_endoff; /* end offset of new entry */ | 721 | xfs_fileoff_t new_endoff; /* end offset of new entry */ |
@@ -808,15 +811,14 @@ xfs_bmap_add_extent_delay_real( | |||
808 | * Filling in all of a previously delayed allocation extent. | 811 | * Filling in all of a previously delayed allocation extent. |
809 | * The left and right neighbors are both contiguous with new. | 812 | * The left and right neighbors are both contiguous with new. |
810 | */ | 813 | */ |
811 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 814 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC|RC", ip, idx - 1, |
812 | XFS_DATA_FORK); | 815 | XFS_DATA_FORK); |
813 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 816 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
814 | LEFT.br_blockcount + PREV.br_blockcount + | 817 | LEFT.br_blockcount + PREV.br_blockcount + |
815 | RIGHT.br_blockcount); | 818 | RIGHT.br_blockcount); |
816 | xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 819 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1, |
817 | XFS_DATA_FORK); | ||
818 | xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2, | ||
819 | XFS_DATA_FORK); | 820 | XFS_DATA_FORK); |
821 | XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK); | ||
820 | xfs_iext_remove(ifp, idx, 2); | 822 | xfs_iext_remove(ifp, idx, 2); |
821 | ip->i_df.if_lastex = idx - 1; | 823 | ip->i_df.if_lastex = idx - 1; |
822 | ip->i_d.di_nextents--; | 824 | ip->i_d.di_nextents--; |
@@ -855,15 +857,14 @@ xfs_bmap_add_extent_delay_real( | |||
855 | * Filling in all of a previously delayed allocation extent. | 857 | * Filling in all of a previously delayed allocation extent. |
856 | * The left neighbor is contiguous, the right is not. | 858 | * The left neighbor is contiguous, the right is not. |
857 | */ | 859 | */ |
858 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1, | 860 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC", ip, idx - 1, |
859 | XFS_DATA_FORK); | 861 | XFS_DATA_FORK); |
860 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 862 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
861 | LEFT.br_blockcount + PREV.br_blockcount); | 863 | LEFT.br_blockcount + PREV.br_blockcount); |
862 | xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1, | 864 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC", ip, idx - 1, |
863 | XFS_DATA_FORK); | 865 | XFS_DATA_FORK); |
864 | ip->i_df.if_lastex = idx - 1; | 866 | ip->i_df.if_lastex = idx - 1; |
865 | xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1, | 867 | XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK); |
866 | XFS_DATA_FORK); | ||
867 | xfs_iext_remove(ifp, idx, 1); | 868 | xfs_iext_remove(ifp, idx, 1); |
868 | if (cur == NULL) | 869 | if (cur == NULL) |
869 | rval = XFS_ILOG_DEXT; | 870 | rval = XFS_ILOG_DEXT; |
@@ -892,16 +893,13 @@ xfs_bmap_add_extent_delay_real( | |||
892 | * Filling in all of a previously delayed allocation extent. | 893 | * Filling in all of a previously delayed allocation extent. |
893 | * The right neighbor is contiguous, the left is not. | 894 | * The right neighbor is contiguous, the left is not. |
894 | */ | 895 | */ |
895 | xfs_bmap_trace_pre_update(fname, "LF|RF|RC", ip, idx, | 896 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK); |
896 | XFS_DATA_FORK); | ||
897 | xfs_bmbt_set_startblock(ep, new->br_startblock); | 897 | xfs_bmbt_set_startblock(ep, new->br_startblock); |
898 | xfs_bmbt_set_blockcount(ep, | 898 | xfs_bmbt_set_blockcount(ep, |
899 | PREV.br_blockcount + RIGHT.br_blockcount); | 899 | PREV.br_blockcount + RIGHT.br_blockcount); |
900 | xfs_bmap_trace_post_update(fname, "LF|RF|RC", ip, idx, | 900 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK); |
901 | XFS_DATA_FORK); | ||
902 | ip->i_df.if_lastex = idx; | 901 | ip->i_df.if_lastex = idx; |
903 | xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1, | 902 | XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK); |
904 | XFS_DATA_FORK); | ||
905 | xfs_iext_remove(ifp, idx + 1, 1); | 903 | xfs_iext_remove(ifp, idx + 1, 1); |
906 | if (cur == NULL) | 904 | if (cur == NULL) |
907 | rval = XFS_ILOG_DEXT; | 905 | rval = XFS_ILOG_DEXT; |
@@ -931,11 +929,9 @@ xfs_bmap_add_extent_delay_real( | |||
931 | * Neither the left nor right neighbors are contiguous with | 929 | * Neither the left nor right neighbors are contiguous with |
932 | * the new one. | 930 | * the new one. |
933 | */ | 931 | */ |
934 | xfs_bmap_trace_pre_update(fname, "LF|RF", ip, idx, | 932 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF", ip, idx, XFS_DATA_FORK); |
935 | XFS_DATA_FORK); | ||
936 | xfs_bmbt_set_startblock(ep, new->br_startblock); | 933 | xfs_bmbt_set_startblock(ep, new->br_startblock); |
937 | xfs_bmap_trace_post_update(fname, "LF|RF", ip, idx, | 934 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF", ip, idx, XFS_DATA_FORK); |
938 | XFS_DATA_FORK); | ||
939 | ip->i_df.if_lastex = idx; | 935 | ip->i_df.if_lastex = idx; |
940 | ip->i_d.di_nextents++; | 936 | ip->i_d.di_nextents++; |
941 | if (cur == NULL) | 937 | if (cur == NULL) |
@@ -963,17 +959,14 @@ xfs_bmap_add_extent_delay_real( | |||
963 | * Filling in the first part of a previous delayed allocation. | 959 | * Filling in the first part of a previous delayed allocation. |
964 | * The left neighbor is contiguous. | 960 | * The left neighbor is contiguous. |
965 | */ | 961 | */ |
966 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1, | 962 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx - 1, XFS_DATA_FORK); |
967 | XFS_DATA_FORK); | ||
968 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 963 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
969 | LEFT.br_blockcount + new->br_blockcount); | 964 | LEFT.br_blockcount + new->br_blockcount); |
970 | xfs_bmbt_set_startoff(ep, | 965 | xfs_bmbt_set_startoff(ep, |
971 | PREV.br_startoff + new->br_blockcount); | 966 | PREV.br_startoff + new->br_blockcount); |
972 | xfs_bmap_trace_post_update(fname, "LF|LC", ip, idx - 1, | 967 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx - 1, XFS_DATA_FORK); |
973 | XFS_DATA_FORK); | ||
974 | temp = PREV.br_blockcount - new->br_blockcount; | 968 | temp = PREV.br_blockcount - new->br_blockcount; |
975 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx, | 969 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK); |
976 | XFS_DATA_FORK); | ||
977 | xfs_bmbt_set_blockcount(ep, temp); | 970 | xfs_bmbt_set_blockcount(ep, temp); |
978 | ip->i_df.if_lastex = idx - 1; | 971 | ip->i_df.if_lastex = idx - 1; |
979 | if (cur == NULL) | 972 | if (cur == NULL) |
@@ -995,8 +988,7 @@ xfs_bmap_add_extent_delay_real( | |||
995 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 988 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
996 | STARTBLOCKVAL(PREV.br_startblock)); | 989 | STARTBLOCKVAL(PREV.br_startblock)); |
997 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 990 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
998 | xfs_bmap_trace_post_update(fname, "LF|LC", ip, idx, | 991 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK); |
999 | XFS_DATA_FORK); | ||
1000 | *dnew = temp; | 992 | *dnew = temp; |
1001 | /* DELTA: The boundary between two in-core extents moved. */ | 993 | /* DELTA: The boundary between two in-core extents moved. */ |
1002 | temp = LEFT.br_startoff; | 994 | temp = LEFT.br_startoff; |
@@ -1009,11 +1001,11 @@ xfs_bmap_add_extent_delay_real( | |||
1009 | * Filling in the first part of a previous delayed allocation. | 1001 | * Filling in the first part of a previous delayed allocation. |
1010 | * The left neighbor is not contiguous. | 1002 | * The left neighbor is not contiguous. |
1011 | */ | 1003 | */ |
1012 | xfs_bmap_trace_pre_update(fname, "LF", ip, idx, XFS_DATA_FORK); | 1004 | XFS_BMAP_TRACE_PRE_UPDATE("LF", ip, idx, XFS_DATA_FORK); |
1013 | xfs_bmbt_set_startoff(ep, new_endoff); | 1005 | xfs_bmbt_set_startoff(ep, new_endoff); |
1014 | temp = PREV.br_blockcount - new->br_blockcount; | 1006 | temp = PREV.br_blockcount - new->br_blockcount; |
1015 | xfs_bmbt_set_blockcount(ep, temp); | 1007 | xfs_bmbt_set_blockcount(ep, temp); |
1016 | xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL, | 1008 | XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL, |
1017 | XFS_DATA_FORK); | 1009 | XFS_DATA_FORK); |
1018 | xfs_iext_insert(ifp, idx, 1, new); | 1010 | xfs_iext_insert(ifp, idx, 1, new); |
1019 | ip->i_df.if_lastex = idx; | 1011 | ip->i_df.if_lastex = idx; |
@@ -1046,8 +1038,7 @@ xfs_bmap_add_extent_delay_real( | |||
1046 | (cur ? cur->bc_private.b.allocated : 0)); | 1038 | (cur ? cur->bc_private.b.allocated : 0)); |
1047 | ep = xfs_iext_get_ext(ifp, idx + 1); | 1039 | ep = xfs_iext_get_ext(ifp, idx + 1); |
1048 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1040 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1049 | xfs_bmap_trace_post_update(fname, "LF", ip, idx + 1, | 1041 | XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx + 1, XFS_DATA_FORK); |
1050 | XFS_DATA_FORK); | ||
1051 | *dnew = temp; | 1042 | *dnew = temp; |
1052 | /* DELTA: One in-core extent is split in two. */ | 1043 | /* DELTA: One in-core extent is split in two. */ |
1053 | temp = PREV.br_startoff; | 1044 | temp = PREV.br_startoff; |
@@ -1060,17 +1051,14 @@ xfs_bmap_add_extent_delay_real( | |||
1060 | * The right neighbor is contiguous with the new allocation. | 1051 | * The right neighbor is contiguous with the new allocation. |
1061 | */ | 1052 | */ |
1062 | temp = PREV.br_blockcount - new->br_blockcount; | 1053 | temp = PREV.br_blockcount - new->br_blockcount; |
1063 | xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx, | 1054 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK); |
1064 | XFS_DATA_FORK); | 1055 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx + 1, XFS_DATA_FORK); |
1065 | xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx + 1, | ||
1066 | XFS_DATA_FORK); | ||
1067 | xfs_bmbt_set_blockcount(ep, temp); | 1056 | xfs_bmbt_set_blockcount(ep, temp); |
1068 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), | 1057 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), |
1069 | new->br_startoff, new->br_startblock, | 1058 | new->br_startoff, new->br_startblock, |
1070 | new->br_blockcount + RIGHT.br_blockcount, | 1059 | new->br_blockcount + RIGHT.br_blockcount, |
1071 | RIGHT.br_state); | 1060 | RIGHT.br_state); |
1072 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1, | 1061 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx + 1, XFS_DATA_FORK); |
1073 | XFS_DATA_FORK); | ||
1074 | ip->i_df.if_lastex = idx + 1; | 1062 | ip->i_df.if_lastex = idx + 1; |
1075 | if (cur == NULL) | 1063 | if (cur == NULL) |
1076 | rval = XFS_ILOG_DEXT; | 1064 | rval = XFS_ILOG_DEXT; |
@@ -1091,8 +1079,7 @@ xfs_bmap_add_extent_delay_real( | |||
1091 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 1079 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
1092 | STARTBLOCKVAL(PREV.br_startblock)); | 1080 | STARTBLOCKVAL(PREV.br_startblock)); |
1093 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1081 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1094 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx, | 1082 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK); |
1095 | XFS_DATA_FORK); | ||
1096 | *dnew = temp; | 1083 | *dnew = temp; |
1097 | /* DELTA: The boundary between two in-core extents moved. */ | 1084 | /* DELTA: The boundary between two in-core extents moved. */ |
1098 | temp = PREV.br_startoff; | 1085 | temp = PREV.br_startoff; |
@@ -1106,10 +1093,10 @@ xfs_bmap_add_extent_delay_real( | |||
1106 | * The right neighbor is not contiguous. | 1093 | * The right neighbor is not contiguous. |
1107 | */ | 1094 | */ |
1108 | temp = PREV.br_blockcount - new->br_blockcount; | 1095 | temp = PREV.br_blockcount - new->br_blockcount; |
1109 | xfs_bmap_trace_pre_update(fname, "RF", ip, idx, XFS_DATA_FORK); | 1096 | XFS_BMAP_TRACE_PRE_UPDATE("RF", ip, idx, XFS_DATA_FORK); |
1110 | xfs_bmbt_set_blockcount(ep, temp); | 1097 | xfs_bmbt_set_blockcount(ep, temp); |
1111 | xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1, | 1098 | XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL, |
1112 | new, NULL, XFS_DATA_FORK); | 1099 | XFS_DATA_FORK); |
1113 | xfs_iext_insert(ifp, idx + 1, 1, new); | 1100 | xfs_iext_insert(ifp, idx + 1, 1, new); |
1114 | ip->i_df.if_lastex = idx + 1; | 1101 | ip->i_df.if_lastex = idx + 1; |
1115 | ip->i_d.di_nextents++; | 1102 | ip->i_d.di_nextents++; |
@@ -1141,7 +1128,7 @@ xfs_bmap_add_extent_delay_real( | |||
1141 | (cur ? cur->bc_private.b.allocated : 0)); | 1128 | (cur ? cur->bc_private.b.allocated : 0)); |
1142 | ep = xfs_iext_get_ext(ifp, idx); | 1129 | ep = xfs_iext_get_ext(ifp, idx); |
1143 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1130 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1144 | xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK); | 1131 | XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK); |
1145 | *dnew = temp; | 1132 | *dnew = temp; |
1146 | /* DELTA: One in-core extent is split in two. */ | 1133 | /* DELTA: One in-core extent is split in two. */ |
1147 | temp = PREV.br_startoff; | 1134 | temp = PREV.br_startoff; |
@@ -1155,7 +1142,7 @@ xfs_bmap_add_extent_delay_real( | |||
1155 | * This case is avoided almost all the time. | 1142 | * This case is avoided almost all the time. |
1156 | */ | 1143 | */ |
1157 | temp = new->br_startoff - PREV.br_startoff; | 1144 | temp = new->br_startoff - PREV.br_startoff; |
1158 | xfs_bmap_trace_pre_update(fname, "0", ip, idx, XFS_DATA_FORK); | 1145 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, XFS_DATA_FORK); |
1159 | xfs_bmbt_set_blockcount(ep, temp); | 1146 | xfs_bmbt_set_blockcount(ep, temp); |
1160 | r[0] = *new; | 1147 | r[0] = *new; |
1161 | r[1].br_state = PREV.br_state; | 1148 | r[1].br_state = PREV.br_state; |
@@ -1163,7 +1150,7 @@ xfs_bmap_add_extent_delay_real( | |||
1163 | r[1].br_startoff = new_endoff; | 1150 | r[1].br_startoff = new_endoff; |
1164 | temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; | 1151 | temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; |
1165 | r[1].br_blockcount = temp2; | 1152 | r[1].br_blockcount = temp2; |
1166 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1], | 1153 | XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1], |
1167 | XFS_DATA_FORK); | 1154 | XFS_DATA_FORK); |
1168 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); | 1155 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); |
1169 | ip->i_df.if_lastex = idx + 1; | 1156 | ip->i_df.if_lastex = idx + 1; |
@@ -1222,13 +1209,11 @@ xfs_bmap_add_extent_delay_real( | |||
1222 | } | 1209 | } |
1223 | ep = xfs_iext_get_ext(ifp, idx); | 1210 | ep = xfs_iext_get_ext(ifp, idx); |
1224 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 1211 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
1225 | xfs_bmap_trace_post_update(fname, "0", ip, idx, XFS_DATA_FORK); | 1212 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK); |
1226 | xfs_bmap_trace_pre_update(fname, "0", ip, idx + 2, | 1213 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx + 2, XFS_DATA_FORK); |
1227 | XFS_DATA_FORK); | ||
1228 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2), | 1214 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2), |
1229 | NULLSTARTBLOCK((int)temp2)); | 1215 | NULLSTARTBLOCK((int)temp2)); |
1230 | xfs_bmap_trace_post_update(fname, "0", ip, idx + 2, | 1216 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx + 2, XFS_DATA_FORK); |
1231 | XFS_DATA_FORK); | ||
1232 | *dnew = temp + temp2; | 1217 | *dnew = temp + temp2; |
1233 | /* DELTA: One in-core extent is split in three. */ | 1218 | /* DELTA: One in-core extent is split in three. */ |
1234 | temp = PREV.br_startoff; | 1219 | temp = PREV.br_startoff; |
@@ -1287,9 +1272,6 @@ xfs_bmap_add_extent_unwritten_real( | |||
1287 | xfs_btree_cur_t *cur; /* btree cursor */ | 1272 | xfs_btree_cur_t *cur; /* btree cursor */ |
1288 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ | 1273 | xfs_bmbt_rec_t *ep; /* extent entry for idx */ |
1289 | int error; /* error return value */ | 1274 | int error; /* error return value */ |
1290 | #ifdef XFS_BMAP_TRACE | ||
1291 | static char fname[] = "xfs_bmap_add_extent_unwritten_real"; | ||
1292 | #endif | ||
1293 | int i; /* temp state */ | 1275 | int i; /* temp state */ |
1294 | xfs_ifork_t *ifp; /* inode fork pointer */ | 1276 | xfs_ifork_t *ifp; /* inode fork pointer */ |
1295 | xfs_fileoff_t new_endoff; /* end offset of new entry */ | 1277 | xfs_fileoff_t new_endoff; /* end offset of new entry */ |
@@ -1390,15 +1372,14 @@ xfs_bmap_add_extent_unwritten_real( | |||
1390 | * Setting all of a previous oldext extent to newext. | 1372 | * Setting all of a previous oldext extent to newext. |
1391 | * The left and right neighbors are both contiguous with new. | 1373 | * The left and right neighbors are both contiguous with new. |
1392 | */ | 1374 | */ |
1393 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 1375 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC|RC", ip, idx - 1, |
1394 | XFS_DATA_FORK); | 1376 | XFS_DATA_FORK); |
1395 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1377 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
1396 | LEFT.br_blockcount + PREV.br_blockcount + | 1378 | LEFT.br_blockcount + PREV.br_blockcount + |
1397 | RIGHT.br_blockcount); | 1379 | RIGHT.br_blockcount); |
1398 | xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1, | 1380 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1, |
1399 | XFS_DATA_FORK); | ||
1400 | xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2, | ||
1401 | XFS_DATA_FORK); | 1381 | XFS_DATA_FORK); |
1382 | XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK); | ||
1402 | xfs_iext_remove(ifp, idx, 2); | 1383 | xfs_iext_remove(ifp, idx, 2); |
1403 | ip->i_df.if_lastex = idx - 1; | 1384 | ip->i_df.if_lastex = idx - 1; |
1404 | ip->i_d.di_nextents -= 2; | 1385 | ip->i_d.di_nextents -= 2; |
@@ -1441,15 +1422,14 @@ xfs_bmap_add_extent_unwritten_real( | |||
1441 | * Setting all of a previous oldext extent to newext. | 1422 | * Setting all of a previous oldext extent to newext. |
1442 | * The left neighbor is contiguous, the right is not. | 1423 | * The left neighbor is contiguous, the right is not. |
1443 | */ | 1424 | */ |
1444 | xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1, | 1425 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC", ip, idx - 1, |
1445 | XFS_DATA_FORK); | 1426 | XFS_DATA_FORK); |
1446 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1427 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
1447 | LEFT.br_blockcount + PREV.br_blockcount); | 1428 | LEFT.br_blockcount + PREV.br_blockcount); |
1448 | xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1, | 1429 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC", ip, idx - 1, |
1449 | XFS_DATA_FORK); | 1430 | XFS_DATA_FORK); |
1450 | ip->i_df.if_lastex = idx - 1; | 1431 | ip->i_df.if_lastex = idx - 1; |
1451 | xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1, | 1432 | XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK); |
1452 | XFS_DATA_FORK); | ||
1453 | xfs_iext_remove(ifp, idx, 1); | 1433 | xfs_iext_remove(ifp, idx, 1); |
1454 | ip->i_d.di_nextents--; | 1434 | ip->i_d.di_nextents--; |
1455 | if (cur == NULL) | 1435 | if (cur == NULL) |
@@ -1484,16 +1464,15 @@ xfs_bmap_add_extent_unwritten_real( | |||
1484 | * Setting all of a previous oldext extent to newext. | 1464 | * Setting all of a previous oldext extent to newext. |
1485 | * The right neighbor is contiguous, the left is not. | 1465 | * The right neighbor is contiguous, the left is not. |
1486 | */ | 1466 | */ |
1487 | xfs_bmap_trace_pre_update(fname, "LF|RF|RC", ip, idx, | 1467 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|RC", ip, idx, |
1488 | XFS_DATA_FORK); | 1468 | XFS_DATA_FORK); |
1489 | xfs_bmbt_set_blockcount(ep, | 1469 | xfs_bmbt_set_blockcount(ep, |
1490 | PREV.br_blockcount + RIGHT.br_blockcount); | 1470 | PREV.br_blockcount + RIGHT.br_blockcount); |
1491 | xfs_bmbt_set_state(ep, newext); | 1471 | xfs_bmbt_set_state(ep, newext); |
1492 | xfs_bmap_trace_post_update(fname, "LF|RF|RC", ip, idx, | 1472 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, |
1493 | XFS_DATA_FORK); | 1473 | XFS_DATA_FORK); |
1494 | ip->i_df.if_lastex = idx; | 1474 | ip->i_df.if_lastex = idx; |
1495 | xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1, | 1475 | XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK); |
1496 | XFS_DATA_FORK); | ||
1497 | xfs_iext_remove(ifp, idx + 1, 1); | 1476 | xfs_iext_remove(ifp, idx + 1, 1); |
1498 | ip->i_d.di_nextents--; | 1477 | ip->i_d.di_nextents--; |
1499 | if (cur == NULL) | 1478 | if (cur == NULL) |
@@ -1529,10 +1508,10 @@ xfs_bmap_add_extent_unwritten_real( | |||
1529 | * Neither the left nor right neighbors are contiguous with | 1508 | * Neither the left nor right neighbors are contiguous with |
1530 | * the new one. | 1509 | * the new one. |
1531 | */ | 1510 | */ |
1532 | xfs_bmap_trace_pre_update(fname, "LF|RF", ip, idx, | 1511 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF", ip, idx, |
1533 | XFS_DATA_FORK); | 1512 | XFS_DATA_FORK); |
1534 | xfs_bmbt_set_state(ep, newext); | 1513 | xfs_bmbt_set_state(ep, newext); |
1535 | xfs_bmap_trace_post_update(fname, "LF|RF", ip, idx, | 1514 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF", ip, idx, |
1536 | XFS_DATA_FORK); | 1515 | XFS_DATA_FORK); |
1537 | ip->i_df.if_lastex = idx; | 1516 | ip->i_df.if_lastex = idx; |
1538 | if (cur == NULL) | 1517 | if (cur == NULL) |
@@ -1559,21 +1538,21 @@ xfs_bmap_add_extent_unwritten_real( | |||
1559 | * Setting the first part of a previous oldext extent to newext. | 1538 | * Setting the first part of a previous oldext extent to newext. |
1560 | * The left neighbor is contiguous. | 1539 | * The left neighbor is contiguous. |
1561 | */ | 1540 | */ |
1562 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1, | 1541 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx - 1, |
1563 | XFS_DATA_FORK); | 1542 | XFS_DATA_FORK); |
1564 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1543 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
1565 | LEFT.br_blockcount + new->br_blockcount); | 1544 | LEFT.br_blockcount + new->br_blockcount); |
1566 | xfs_bmbt_set_startoff(ep, | 1545 | xfs_bmbt_set_startoff(ep, |
1567 | PREV.br_startoff + new->br_blockcount); | 1546 | PREV.br_startoff + new->br_blockcount); |
1568 | xfs_bmap_trace_post_update(fname, "LF|LC", ip, idx - 1, | 1547 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx - 1, |
1569 | XFS_DATA_FORK); | 1548 | XFS_DATA_FORK); |
1570 | xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx, | 1549 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx, |
1571 | XFS_DATA_FORK); | 1550 | XFS_DATA_FORK); |
1572 | xfs_bmbt_set_startblock(ep, | 1551 | xfs_bmbt_set_startblock(ep, |
1573 | new->br_startblock + new->br_blockcount); | 1552 | new->br_startblock + new->br_blockcount); |
1574 | xfs_bmbt_set_blockcount(ep, | 1553 | xfs_bmbt_set_blockcount(ep, |
1575 | PREV.br_blockcount - new->br_blockcount); | 1554 | PREV.br_blockcount - new->br_blockcount); |
1576 | xfs_bmap_trace_post_update(fname, "LF|LC", ip, idx, | 1555 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, |
1577 | XFS_DATA_FORK); | 1556 | XFS_DATA_FORK); |
1578 | ip->i_df.if_lastex = idx - 1; | 1557 | ip->i_df.if_lastex = idx - 1; |
1579 | if (cur == NULL) | 1558 | if (cur == NULL) |
@@ -1610,15 +1589,15 @@ xfs_bmap_add_extent_unwritten_real( | |||
1610 | * Setting the first part of a previous oldext extent to newext. | 1589 | * Setting the first part of a previous oldext extent to newext. |
1611 | * The left neighbor is not contiguous. | 1590 | * The left neighbor is not contiguous. |
1612 | */ | 1591 | */ |
1613 | xfs_bmap_trace_pre_update(fname, "LF", ip, idx, XFS_DATA_FORK); | 1592 | XFS_BMAP_TRACE_PRE_UPDATE("LF", ip, idx, XFS_DATA_FORK); |
1614 | ASSERT(ep && xfs_bmbt_get_state(ep) == oldext); | 1593 | ASSERT(ep && xfs_bmbt_get_state(ep) == oldext); |
1615 | xfs_bmbt_set_startoff(ep, new_endoff); | 1594 | xfs_bmbt_set_startoff(ep, new_endoff); |
1616 | xfs_bmbt_set_blockcount(ep, | 1595 | xfs_bmbt_set_blockcount(ep, |
1617 | PREV.br_blockcount - new->br_blockcount); | 1596 | PREV.br_blockcount - new->br_blockcount); |
1618 | xfs_bmbt_set_startblock(ep, | 1597 | xfs_bmbt_set_startblock(ep, |
1619 | new->br_startblock + new->br_blockcount); | 1598 | new->br_startblock + new->br_blockcount); |
1620 | xfs_bmap_trace_post_update(fname, "LF", ip, idx, XFS_DATA_FORK); | 1599 | XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx, XFS_DATA_FORK); |
1621 | xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL, | 1600 | XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL, |
1622 | XFS_DATA_FORK); | 1601 | XFS_DATA_FORK); |
1623 | xfs_iext_insert(ifp, idx, 1, new); | 1602 | xfs_iext_insert(ifp, idx, 1, new); |
1624 | ip->i_df.if_lastex = idx; | 1603 | ip->i_df.if_lastex = idx; |
@@ -1653,18 +1632,18 @@ xfs_bmap_add_extent_unwritten_real( | |||
1653 | * Setting the last part of a previous oldext extent to newext. | 1632 | * Setting the last part of a previous oldext extent to newext. |
1654 | * The right neighbor is contiguous with the new allocation. | 1633 | * The right neighbor is contiguous with the new allocation. |
1655 | */ | 1634 | */ |
1656 | xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx, | 1635 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx, |
1657 | XFS_DATA_FORK); | 1636 | XFS_DATA_FORK); |
1658 | xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx + 1, | 1637 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx + 1, |
1659 | XFS_DATA_FORK); | 1638 | XFS_DATA_FORK); |
1660 | xfs_bmbt_set_blockcount(ep, | 1639 | xfs_bmbt_set_blockcount(ep, |
1661 | PREV.br_blockcount - new->br_blockcount); | 1640 | PREV.br_blockcount - new->br_blockcount); |
1662 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx, | 1641 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, |
1663 | XFS_DATA_FORK); | 1642 | XFS_DATA_FORK); |
1664 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), | 1643 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), |
1665 | new->br_startoff, new->br_startblock, | 1644 | new->br_startoff, new->br_startblock, |
1666 | new->br_blockcount + RIGHT.br_blockcount, newext); | 1645 | new->br_blockcount + RIGHT.br_blockcount, newext); |
1667 | xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1, | 1646 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx + 1, |
1668 | XFS_DATA_FORK); | 1647 | XFS_DATA_FORK); |
1669 | ip->i_df.if_lastex = idx + 1; | 1648 | ip->i_df.if_lastex = idx + 1; |
1670 | if (cur == NULL) | 1649 | if (cur == NULL) |
@@ -1700,12 +1679,12 @@ xfs_bmap_add_extent_unwritten_real( | |||
1700 | * Setting the last part of a previous oldext extent to newext. | 1679 | * Setting the last part of a previous oldext extent to newext. |
1701 | * The right neighbor is not contiguous. | 1680 | * The right neighbor is not contiguous. |
1702 | */ | 1681 | */ |
1703 | xfs_bmap_trace_pre_update(fname, "RF", ip, idx, XFS_DATA_FORK); | 1682 | XFS_BMAP_TRACE_PRE_UPDATE("RF", ip, idx, XFS_DATA_FORK); |
1704 | xfs_bmbt_set_blockcount(ep, | 1683 | xfs_bmbt_set_blockcount(ep, |
1705 | PREV.br_blockcount - new->br_blockcount); | 1684 | PREV.br_blockcount - new->br_blockcount); |
1706 | xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK); | 1685 | XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK); |
1707 | xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1, | 1686 | XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL, |
1708 | new, NULL, XFS_DATA_FORK); | 1687 | XFS_DATA_FORK); |
1709 | xfs_iext_insert(ifp, idx + 1, 1, new); | 1688 | xfs_iext_insert(ifp, idx + 1, 1, new); |
1710 | ip->i_df.if_lastex = idx + 1; | 1689 | ip->i_df.if_lastex = idx + 1; |
1711 | ip->i_d.di_nextents++; | 1690 | ip->i_d.di_nextents++; |
@@ -1744,17 +1723,17 @@ xfs_bmap_add_extent_unwritten_real( | |||
1744 | * newext. Contiguity is impossible here. | 1723 | * newext. Contiguity is impossible here. |
1745 | * One extent becomes three extents. | 1724 | * One extent becomes three extents. |
1746 | */ | 1725 | */ |
1747 | xfs_bmap_trace_pre_update(fname, "0", ip, idx, XFS_DATA_FORK); | 1726 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, XFS_DATA_FORK); |
1748 | xfs_bmbt_set_blockcount(ep, | 1727 | xfs_bmbt_set_blockcount(ep, |
1749 | new->br_startoff - PREV.br_startoff); | 1728 | new->br_startoff - PREV.br_startoff); |
1750 | xfs_bmap_trace_post_update(fname, "0", ip, idx, XFS_DATA_FORK); | 1729 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK); |
1751 | r[0] = *new; | 1730 | r[0] = *new; |
1752 | r[1].br_startoff = new_endoff; | 1731 | r[1].br_startoff = new_endoff; |
1753 | r[1].br_blockcount = | 1732 | r[1].br_blockcount = |
1754 | PREV.br_startoff + PREV.br_blockcount - new_endoff; | 1733 | PREV.br_startoff + PREV.br_blockcount - new_endoff; |
1755 | r[1].br_startblock = new->br_startblock + new->br_blockcount; | 1734 | r[1].br_startblock = new->br_startblock + new->br_blockcount; |
1756 | r[1].br_state = oldext; | 1735 | r[1].br_state = oldext; |
1757 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1], | 1736 | XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1], |
1758 | XFS_DATA_FORK); | 1737 | XFS_DATA_FORK); |
1759 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); | 1738 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); |
1760 | ip->i_df.if_lastex = idx + 1; | 1739 | ip->i_df.if_lastex = idx + 1; |
@@ -1845,9 +1824,6 @@ xfs_bmap_add_extent_hole_delay( | |||
1845 | int rsvd) /* OK to allocate reserved blocks */ | 1824 | int rsvd) /* OK to allocate reserved blocks */ |
1846 | { | 1825 | { |
1847 | xfs_bmbt_rec_t *ep; /* extent record for idx */ | 1826 | xfs_bmbt_rec_t *ep; /* extent record for idx */ |
1848 | #ifdef XFS_BMAP_TRACE | ||
1849 | static char fname[] = "xfs_bmap_add_extent_hole_delay"; | ||
1850 | #endif | ||
1851 | xfs_ifork_t *ifp; /* inode fork pointer */ | 1827 | xfs_ifork_t *ifp; /* inode fork pointer */ |
1852 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ | 1828 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ |
1853 | xfs_filblks_t newlen=0; /* new indirect size */ | 1829 | xfs_filblks_t newlen=0; /* new indirect size */ |
@@ -1919,7 +1895,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1919 | */ | 1895 | */ |
1920 | temp = left.br_blockcount + new->br_blockcount + | 1896 | temp = left.br_blockcount + new->br_blockcount + |
1921 | right.br_blockcount; | 1897 | right.br_blockcount; |
1922 | xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1, | 1898 | XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1, |
1923 | XFS_DATA_FORK); | 1899 | XFS_DATA_FORK); |
1924 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); | 1900 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); |
1925 | oldlen = STARTBLOCKVAL(left.br_startblock) + | 1901 | oldlen = STARTBLOCKVAL(left.br_startblock) + |
@@ -1928,10 +1904,9 @@ xfs_bmap_add_extent_hole_delay( | |||
1928 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1904 | newlen = xfs_bmap_worst_indlen(ip, temp); |
1929 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), | 1905 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), |
1930 | NULLSTARTBLOCK((int)newlen)); | 1906 | NULLSTARTBLOCK((int)newlen)); |
1931 | xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1, | 1907 | XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, |
1932 | XFS_DATA_FORK); | ||
1933 | xfs_bmap_trace_delete(fname, "LC|RC", ip, idx, 1, | ||
1934 | XFS_DATA_FORK); | 1908 | XFS_DATA_FORK); |
1909 | XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK); | ||
1935 | xfs_iext_remove(ifp, idx, 1); | 1910 | xfs_iext_remove(ifp, idx, 1); |
1936 | ip->i_df.if_lastex = idx - 1; | 1911 | ip->i_df.if_lastex = idx - 1; |
1937 | /* DELTA: Two in-core extents were replaced by one. */ | 1912 | /* DELTA: Two in-core extents were replaced by one. */ |
@@ -1946,7 +1921,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1946 | * Merge the new allocation with the left neighbor. | 1921 | * Merge the new allocation with the left neighbor. |
1947 | */ | 1922 | */ |
1948 | temp = left.br_blockcount + new->br_blockcount; | 1923 | temp = left.br_blockcount + new->br_blockcount; |
1949 | xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, | 1924 | XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1, |
1950 | XFS_DATA_FORK); | 1925 | XFS_DATA_FORK); |
1951 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); | 1926 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); |
1952 | oldlen = STARTBLOCKVAL(left.br_startblock) + | 1927 | oldlen = STARTBLOCKVAL(left.br_startblock) + |
@@ -1954,7 +1929,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1954 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1929 | newlen = xfs_bmap_worst_indlen(ip, temp); |
1955 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), | 1930 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), |
1956 | NULLSTARTBLOCK((int)newlen)); | 1931 | NULLSTARTBLOCK((int)newlen)); |
1957 | xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, | 1932 | XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, |
1958 | XFS_DATA_FORK); | 1933 | XFS_DATA_FORK); |
1959 | ip->i_df.if_lastex = idx - 1; | 1934 | ip->i_df.if_lastex = idx - 1; |
1960 | /* DELTA: One in-core extent grew into a hole. */ | 1935 | /* DELTA: One in-core extent grew into a hole. */ |
@@ -1968,14 +1943,14 @@ xfs_bmap_add_extent_hole_delay( | |||
1968 | * on the right. | 1943 | * on the right. |
1969 | * Merge the new allocation with the right neighbor. | 1944 | * Merge the new allocation with the right neighbor. |
1970 | */ | 1945 | */ |
1971 | xfs_bmap_trace_pre_update(fname, "RC", ip, idx, XFS_DATA_FORK); | 1946 | XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, XFS_DATA_FORK); |
1972 | temp = new->br_blockcount + right.br_blockcount; | 1947 | temp = new->br_blockcount + right.br_blockcount; |
1973 | oldlen = STARTBLOCKVAL(new->br_startblock) + | 1948 | oldlen = STARTBLOCKVAL(new->br_startblock) + |
1974 | STARTBLOCKVAL(right.br_startblock); | 1949 | STARTBLOCKVAL(right.br_startblock); |
1975 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1950 | newlen = xfs_bmap_worst_indlen(ip, temp); |
1976 | xfs_bmbt_set_allf(ep, new->br_startoff, | 1951 | xfs_bmbt_set_allf(ep, new->br_startoff, |
1977 | NULLSTARTBLOCK((int)newlen), temp, right.br_state); | 1952 | NULLSTARTBLOCK((int)newlen), temp, right.br_state); |
1978 | xfs_bmap_trace_post_update(fname, "RC", ip, idx, XFS_DATA_FORK); | 1953 | XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, XFS_DATA_FORK); |
1979 | ip->i_df.if_lastex = idx; | 1954 | ip->i_df.if_lastex = idx; |
1980 | /* DELTA: One in-core extent grew into a hole. */ | 1955 | /* DELTA: One in-core extent grew into a hole. */ |
1981 | temp2 = temp; | 1956 | temp2 = temp; |
@@ -1989,7 +1964,7 @@ xfs_bmap_add_extent_hole_delay( | |||
1989 | * Insert a new entry. | 1964 | * Insert a new entry. |
1990 | */ | 1965 | */ |
1991 | oldlen = newlen = 0; | 1966 | oldlen = newlen = 0; |
1992 | xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL, | 1967 | XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, |
1993 | XFS_DATA_FORK); | 1968 | XFS_DATA_FORK); |
1994 | xfs_iext_insert(ifp, idx, 1, new); | 1969 | xfs_iext_insert(ifp, idx, 1, new); |
1995 | ip->i_df.if_lastex = idx; | 1970 | ip->i_df.if_lastex = idx; |
@@ -2039,9 +2014,6 @@ xfs_bmap_add_extent_hole_real( | |||
2039 | { | 2014 | { |
2040 | xfs_bmbt_rec_t *ep; /* pointer to extent entry ins. point */ | 2015 | xfs_bmbt_rec_t *ep; /* pointer to extent entry ins. point */ |
2041 | int error; /* error return value */ | 2016 | int error; /* error return value */ |
2042 | #ifdef XFS_BMAP_TRACE | ||
2043 | static char fname[] = "xfs_bmap_add_extent_hole_real"; | ||
2044 | #endif | ||
2045 | int i; /* temp state */ | 2017 | int i; /* temp state */ |
2046 | xfs_ifork_t *ifp; /* inode fork pointer */ | 2018 | xfs_ifork_t *ifp; /* inode fork pointer */ |
2047 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ | 2019 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ |
@@ -2118,15 +2090,14 @@ xfs_bmap_add_extent_hole_real( | |||
2118 | * left and on the right. | 2090 | * left and on the right. |
2119 | * Merge all three into a single extent record. | 2091 | * Merge all three into a single extent record. |
2120 | */ | 2092 | */ |
2121 | xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1, | 2093 | XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1, |
2122 | whichfork); | 2094 | whichfork); |
2123 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 2095 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
2124 | left.br_blockcount + new->br_blockcount + | 2096 | left.br_blockcount + new->br_blockcount + |
2125 | right.br_blockcount); | 2097 | right.br_blockcount); |
2126 | xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1, | 2098 | XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, |
2127 | whichfork); | 2099 | whichfork); |
2128 | xfs_bmap_trace_delete(fname, "LC|RC", ip, | 2100 | XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, whichfork); |
2129 | idx, 1, whichfork); | ||
2130 | xfs_iext_remove(ifp, idx, 1); | 2101 | xfs_iext_remove(ifp, idx, 1); |
2131 | ifp->if_lastex = idx - 1; | 2102 | ifp->if_lastex = idx - 1; |
2132 | XFS_IFORK_NEXT_SET(ip, whichfork, | 2103 | XFS_IFORK_NEXT_SET(ip, whichfork, |
@@ -2168,10 +2139,10 @@ xfs_bmap_add_extent_hole_real( | |||
2168 | * on the left. | 2139 | * on the left. |
2169 | * Merge the new allocation with the left neighbor. | 2140 | * Merge the new allocation with the left neighbor. |
2170 | */ | 2141 | */ |
2171 | xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, whichfork); | 2142 | XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1, whichfork); |
2172 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 2143 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
2173 | left.br_blockcount + new->br_blockcount); | 2144 | left.br_blockcount + new->br_blockcount); |
2174 | xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, whichfork); | 2145 | XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, whichfork); |
2175 | ifp->if_lastex = idx - 1; | 2146 | ifp->if_lastex = idx - 1; |
2176 | if (cur == NULL) { | 2147 | if (cur == NULL) { |
2177 | rval = XFS_ILOG_FEXT(whichfork); | 2148 | rval = XFS_ILOG_FEXT(whichfork); |
@@ -2202,11 +2173,11 @@ xfs_bmap_add_extent_hole_real( | |||
2202 | * on the right. | 2173 | * on the right. |
2203 | * Merge the new allocation with the right neighbor. | 2174 | * Merge the new allocation with the right neighbor. |
2204 | */ | 2175 | */ |
2205 | xfs_bmap_trace_pre_update(fname, "RC", ip, idx, whichfork); | 2176 | XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, whichfork); |
2206 | xfs_bmbt_set_allf(ep, new->br_startoff, new->br_startblock, | 2177 | xfs_bmbt_set_allf(ep, new->br_startoff, new->br_startblock, |
2207 | new->br_blockcount + right.br_blockcount, | 2178 | new->br_blockcount + right.br_blockcount, |
2208 | right.br_state); | 2179 | right.br_state); |
2209 | xfs_bmap_trace_post_update(fname, "RC", ip, idx, whichfork); | 2180 | XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, whichfork); |
2210 | ifp->if_lastex = idx; | 2181 | ifp->if_lastex = idx; |
2211 | if (cur == NULL) { | 2182 | if (cur == NULL) { |
2212 | rval = XFS_ILOG_FEXT(whichfork); | 2183 | rval = XFS_ILOG_FEXT(whichfork); |
@@ -2237,8 +2208,7 @@ xfs_bmap_add_extent_hole_real( | |||
2237 | * real allocation. | 2208 | * real allocation. |
2238 | * Insert a new entry. | 2209 | * Insert a new entry. |
2239 | */ | 2210 | */ |
2240 | xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL, | 2211 | XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, whichfork); |
2241 | whichfork); | ||
2242 | xfs_iext_insert(ifp, idx, 1, new); | 2212 | xfs_iext_insert(ifp, idx, 1, new); |
2243 | ifp->if_lastex = idx; | 2213 | ifp->if_lastex = idx; |
2244 | XFS_IFORK_NEXT_SET(ip, whichfork, | 2214 | XFS_IFORK_NEXT_SET(ip, whichfork, |
@@ -2605,12 +2575,10 @@ xfs_bmap_rtalloc( | |||
2605 | xfs_extlen_t prod = 0; /* product factor for allocators */ | 2575 | xfs_extlen_t prod = 0; /* product factor for allocators */ |
2606 | xfs_extlen_t ralen = 0; /* realtime allocation length */ | 2576 | xfs_extlen_t ralen = 0; /* realtime allocation length */ |
2607 | xfs_extlen_t align; /* minimum allocation alignment */ | 2577 | xfs_extlen_t align; /* minimum allocation alignment */ |
2608 | xfs_rtblock_t rtx; /* realtime extent number */ | ||
2609 | xfs_rtblock_t rtb; | 2578 | xfs_rtblock_t rtb; |
2610 | 2579 | ||
2611 | mp = ap->ip->i_mount; | 2580 | mp = ap->ip->i_mount; |
2612 | align = ap->ip->i_d.di_extsize ? | 2581 | align = xfs_get_extsz_hint(ap->ip); |
2613 | ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize; | ||
2614 | prod = align / mp->m_sb.sb_rextsize; | 2582 | prod = align / mp->m_sb.sb_rextsize; |
2615 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | 2583 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, |
2616 | align, 1, ap->eof, 0, | 2584 | align, 1, ap->eof, 0, |
@@ -2644,6 +2612,8 @@ xfs_bmap_rtalloc( | |||
2644 | * pick an extent that will space things out in the rt area. | 2612 | * pick an extent that will space things out in the rt area. |
2645 | */ | 2613 | */ |
2646 | if (ap->eof && ap->off == 0) { | 2614 | if (ap->eof && ap->off == 0) { |
2615 | xfs_rtblock_t uninitialized_var(rtx); /* realtime extent no */ | ||
2616 | |||
2647 | error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); | 2617 | error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); |
2648 | if (error) | 2618 | if (error) |
2649 | return error; | 2619 | return error; |
@@ -2715,9 +2685,7 @@ xfs_bmap_btalloc( | |||
2715 | int error; | 2685 | int error; |
2716 | 2686 | ||
2717 | mp = ap->ip->i_mount; | 2687 | mp = ap->ip->i_mount; |
2718 | align = (ap->userdata && ap->ip->i_d.di_extsize && | 2688 | align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0; |
2719 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ? | ||
2720 | ap->ip->i_d.di_extsize : 0; | ||
2721 | if (unlikely(align)) { | 2689 | if (unlikely(align)) { |
2722 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | 2690 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, |
2723 | align, 0, ap->eof, 0, ap->conv, | 2691 | align, 0, ap->eof, 0, ap->conv, |
@@ -2727,9 +2695,15 @@ xfs_bmap_btalloc( | |||
2727 | } | 2695 | } |
2728 | nullfb = ap->firstblock == NULLFSBLOCK; | 2696 | nullfb = ap->firstblock == NULLFSBLOCK; |
2729 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock); | 2697 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock); |
2730 | if (nullfb) | 2698 | if (nullfb) { |
2731 | ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino); | 2699 | if (ap->userdata && xfs_inode_is_filestream(ap->ip)) { |
2732 | else | 2700 | ag = xfs_filestream_lookup_ag(ap->ip); |
2701 | ag = (ag != NULLAGNUMBER) ? ag : 0; | ||
2702 | ap->rval = XFS_AGB_TO_FSB(mp, ag, 0); | ||
2703 | } else { | ||
2704 | ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino); | ||
2705 | } | ||
2706 | } else | ||
2733 | ap->rval = ap->firstblock; | 2707 | ap->rval = ap->firstblock; |
2734 | 2708 | ||
2735 | xfs_bmap_adjacent(ap); | 2709 | xfs_bmap_adjacent(ap); |
@@ -2753,13 +2727,22 @@ xfs_bmap_btalloc( | |||
2753 | args.firstblock = ap->firstblock; | 2727 | args.firstblock = ap->firstblock; |
2754 | blen = 0; | 2728 | blen = 0; |
2755 | if (nullfb) { | 2729 | if (nullfb) { |
2756 | args.type = XFS_ALLOCTYPE_START_BNO; | 2730 | if (ap->userdata && xfs_inode_is_filestream(ap->ip)) |
2731 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | ||
2732 | else | ||
2733 | args.type = XFS_ALLOCTYPE_START_BNO; | ||
2757 | args.total = ap->total; | 2734 | args.total = ap->total; |
2735 | |||
2758 | /* | 2736 | /* |
2759 | * Find the longest available space. | 2737 | * Search for an allocation group with a single extent |
2760 | * We're going to try for the whole allocation at once. | 2738 | * large enough for the request. |
2739 | * | ||
2740 | * If one isn't found, then adjust the minimum allocation | ||
2741 | * size to the largest space found. | ||
2761 | */ | 2742 | */ |
2762 | startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno); | 2743 | startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno); |
2744 | if (startag == NULLAGNUMBER) | ||
2745 | startag = ag = 0; | ||
2763 | notinit = 0; | 2746 | notinit = 0; |
2764 | down_read(&mp->m_peraglock); | 2747 | down_read(&mp->m_peraglock); |
2765 | while (blen < ap->alen) { | 2748 | while (blen < ap->alen) { |
@@ -2785,6 +2768,35 @@ xfs_bmap_btalloc( | |||
2785 | blen = longest; | 2768 | blen = longest; |
2786 | } else | 2769 | } else |
2787 | notinit = 1; | 2770 | notinit = 1; |
2771 | |||
2772 | if (xfs_inode_is_filestream(ap->ip)) { | ||
2773 | if (blen >= ap->alen) | ||
2774 | break; | ||
2775 | |||
2776 | if (ap->userdata) { | ||
2777 | /* | ||
2778 | * If startag is an invalid AG, we've | ||
2779 | * come here once before and | ||
2780 | * xfs_filestream_new_ag picked the | ||
2781 | * best currently available. | ||
2782 | * | ||
2783 | * Don't continue looping, since we | ||
2784 | * could loop forever. | ||
2785 | */ | ||
2786 | if (startag == NULLAGNUMBER) | ||
2787 | break; | ||
2788 | |||
2789 | error = xfs_filestream_new_ag(ap, &ag); | ||
2790 | if (error) { | ||
2791 | up_read(&mp->m_peraglock); | ||
2792 | return error; | ||
2793 | } | ||
2794 | |||
2795 | /* loop again to set 'blen'*/ | ||
2796 | startag = NULLAGNUMBER; | ||
2797 | continue; | ||
2798 | } | ||
2799 | } | ||
2788 | if (++ag == mp->m_sb.sb_agcount) | 2800 | if (++ag == mp->m_sb.sb_agcount) |
2789 | ag = 0; | 2801 | ag = 0; |
2790 | if (ag == startag) | 2802 | if (ag == startag) |
@@ -2809,17 +2821,27 @@ xfs_bmap_btalloc( | |||
2809 | */ | 2821 | */ |
2810 | else | 2822 | else |
2811 | args.minlen = ap->alen; | 2823 | args.minlen = ap->alen; |
2824 | |||
2825 | /* | ||
2826 | * set the failure fallback case to look in the selected | ||
2827 | * AG as the stream may have moved. | ||
2828 | */ | ||
2829 | if (xfs_inode_is_filestream(ap->ip)) | ||
2830 | ap->rval = args.fsbno = XFS_AGB_TO_FSB(mp, ag, 0); | ||
2812 | } else if (ap->low) { | 2831 | } else if (ap->low) { |
2813 | args.type = XFS_ALLOCTYPE_START_BNO; | 2832 | if (xfs_inode_is_filestream(ap->ip)) |
2833 | args.type = XFS_ALLOCTYPE_FIRST_AG; | ||
2834 | else | ||
2835 | args.type = XFS_ALLOCTYPE_START_BNO; | ||
2814 | args.total = args.minlen = ap->minlen; | 2836 | args.total = args.minlen = ap->minlen; |
2815 | } else { | 2837 | } else { |
2816 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 2838 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
2817 | args.total = ap->total; | 2839 | args.total = ap->total; |
2818 | args.minlen = ap->minlen; | 2840 | args.minlen = ap->minlen; |
2819 | } | 2841 | } |
2820 | if (unlikely(ap->userdata && ap->ip->i_d.di_extsize && | 2842 | /* apply extent size hints if obtained earlier */ |
2821 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) { | 2843 | if (unlikely(align)) { |
2822 | args.prod = ap->ip->i_d.di_extsize; | 2844 | args.prod = align; |
2823 | if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) | 2845 | if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) |
2824 | args.mod = (xfs_extlen_t)(args.prod - args.mod); | 2846 | args.mod = (xfs_extlen_t)(args.prod - args.mod); |
2825 | } else if (mp->m_sb.sb_blocksize >= NBPP) { | 2847 | } else if (mp->m_sb.sb_blocksize >= NBPP) { |
@@ -3051,9 +3073,6 @@ xfs_bmap_del_extent( | |||
3051 | xfs_bmbt_rec_t *ep; /* current extent entry pointer */ | 3073 | xfs_bmbt_rec_t *ep; /* current extent entry pointer */ |
3052 | int error; /* error return value */ | 3074 | int error; /* error return value */ |
3053 | int flags; /* inode logging flags */ | 3075 | int flags; /* inode logging flags */ |
3054 | #ifdef XFS_BMAP_TRACE | ||
3055 | static char fname[] = "xfs_bmap_del_extent"; | ||
3056 | #endif | ||
3057 | xfs_bmbt_irec_t got; /* current extent entry */ | 3076 | xfs_bmbt_irec_t got; /* current extent entry */ |
3058 | xfs_fileoff_t got_endoff; /* first offset past got */ | 3077 | xfs_fileoff_t got_endoff; /* first offset past got */ |
3059 | int i; /* temp state */ | 3078 | int i; /* temp state */ |
@@ -3147,7 +3166,7 @@ xfs_bmap_del_extent( | |||
3147 | /* | 3166 | /* |
3148 | * Matches the whole extent. Delete the entry. | 3167 | * Matches the whole extent. Delete the entry. |
3149 | */ | 3168 | */ |
3150 | xfs_bmap_trace_delete(fname, "3", ip, idx, 1, whichfork); | 3169 | XFS_BMAP_TRACE_DELETE("3", ip, idx, 1, whichfork); |
3151 | xfs_iext_remove(ifp, idx, 1); | 3170 | xfs_iext_remove(ifp, idx, 1); |
3152 | ifp->if_lastex = idx; | 3171 | ifp->if_lastex = idx; |
3153 | if (delay) | 3172 | if (delay) |
@@ -3168,7 +3187,7 @@ xfs_bmap_del_extent( | |||
3168 | /* | 3187 | /* |
3169 | * Deleting the first part of the extent. | 3188 | * Deleting the first part of the extent. |
3170 | */ | 3189 | */ |
3171 | xfs_bmap_trace_pre_update(fname, "2", ip, idx, whichfork); | 3190 | XFS_BMAP_TRACE_PRE_UPDATE("2", ip, idx, whichfork); |
3172 | xfs_bmbt_set_startoff(ep, del_endoff); | 3191 | xfs_bmbt_set_startoff(ep, del_endoff); |
3173 | temp = got.br_blockcount - del->br_blockcount; | 3192 | temp = got.br_blockcount - del->br_blockcount; |
3174 | xfs_bmbt_set_blockcount(ep, temp); | 3193 | xfs_bmbt_set_blockcount(ep, temp); |
@@ -3177,13 +3196,13 @@ xfs_bmap_del_extent( | |||
3177 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 3196 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
3178 | da_old); | 3197 | da_old); |
3179 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 3198 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
3180 | xfs_bmap_trace_post_update(fname, "2", ip, idx, | 3199 | XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, |
3181 | whichfork); | 3200 | whichfork); |
3182 | da_new = temp; | 3201 | da_new = temp; |
3183 | break; | 3202 | break; |
3184 | } | 3203 | } |
3185 | xfs_bmbt_set_startblock(ep, del_endblock); | 3204 | xfs_bmbt_set_startblock(ep, del_endblock); |
3186 | xfs_bmap_trace_post_update(fname, "2", ip, idx, whichfork); | 3205 | XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, whichfork); |
3187 | if (!cur) { | 3206 | if (!cur) { |
3188 | flags |= XFS_ILOG_FEXT(whichfork); | 3207 | flags |= XFS_ILOG_FEXT(whichfork); |
3189 | break; | 3208 | break; |
@@ -3199,19 +3218,19 @@ xfs_bmap_del_extent( | |||
3199 | * Deleting the last part of the extent. | 3218 | * Deleting the last part of the extent. |
3200 | */ | 3219 | */ |
3201 | temp = got.br_blockcount - del->br_blockcount; | 3220 | temp = got.br_blockcount - del->br_blockcount; |
3202 | xfs_bmap_trace_pre_update(fname, "1", ip, idx, whichfork); | 3221 | XFS_BMAP_TRACE_PRE_UPDATE("1", ip, idx, whichfork); |
3203 | xfs_bmbt_set_blockcount(ep, temp); | 3222 | xfs_bmbt_set_blockcount(ep, temp); |
3204 | ifp->if_lastex = idx; | 3223 | ifp->if_lastex = idx; |
3205 | if (delay) { | 3224 | if (delay) { |
3206 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 3225 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
3207 | da_old); | 3226 | da_old); |
3208 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); | 3227 | xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp)); |
3209 | xfs_bmap_trace_post_update(fname, "1", ip, idx, | 3228 | XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, |
3210 | whichfork); | 3229 | whichfork); |
3211 | da_new = temp; | 3230 | da_new = temp; |
3212 | break; | 3231 | break; |
3213 | } | 3232 | } |
3214 | xfs_bmap_trace_post_update(fname, "1", ip, idx, whichfork); | 3233 | XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, whichfork); |
3215 | if (!cur) { | 3234 | if (!cur) { |
3216 | flags |= XFS_ILOG_FEXT(whichfork); | 3235 | flags |= XFS_ILOG_FEXT(whichfork); |
3217 | break; | 3236 | break; |
@@ -3228,7 +3247,7 @@ xfs_bmap_del_extent( | |||
3228 | * Deleting the middle of the extent. | 3247 | * Deleting the middle of the extent. |
3229 | */ | 3248 | */ |
3230 | temp = del->br_startoff - got.br_startoff; | 3249 | temp = del->br_startoff - got.br_startoff; |
3231 | xfs_bmap_trace_pre_update(fname, "0", ip, idx, whichfork); | 3250 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, whichfork); |
3232 | xfs_bmbt_set_blockcount(ep, temp); | 3251 | xfs_bmbt_set_blockcount(ep, temp); |
3233 | new.br_startoff = del_endoff; | 3252 | new.br_startoff = del_endoff; |
3234 | temp2 = got_endoff - del_endoff; | 3253 | temp2 = got_endoff - del_endoff; |
@@ -3315,8 +3334,8 @@ xfs_bmap_del_extent( | |||
3315 | } | 3334 | } |
3316 | } | 3335 | } |
3317 | } | 3336 | } |
3318 | xfs_bmap_trace_post_update(fname, "0", ip, idx, whichfork); | 3337 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, whichfork); |
3319 | xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 1, &new, NULL, | 3338 | XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 1, &new, NULL, |
3320 | whichfork); | 3339 | whichfork); |
3321 | xfs_iext_insert(ifp, idx + 1, 1, &new); | 3340 | xfs_iext_insert(ifp, idx + 1, 1, &new); |
3322 | ifp->if_lastex = idx + 1; | 3341 | ifp->if_lastex = idx + 1; |
@@ -3556,9 +3575,6 @@ xfs_bmap_local_to_extents( | |||
3556 | { | 3575 | { |
3557 | int error; /* error return value */ | 3576 | int error; /* error return value */ |
3558 | int flags; /* logging flags returned */ | 3577 | int flags; /* logging flags returned */ |
3559 | #ifdef XFS_BMAP_TRACE | ||
3560 | static char fname[] = "xfs_bmap_local_to_extents"; | ||
3561 | #endif | ||
3562 | xfs_ifork_t *ifp; /* inode fork pointer */ | 3578 | xfs_ifork_t *ifp; /* inode fork pointer */ |
3563 | 3579 | ||
3564 | /* | 3580 | /* |
@@ -3613,7 +3629,7 @@ xfs_bmap_local_to_extents( | |||
3613 | xfs_iext_add(ifp, 0, 1); | 3629 | xfs_iext_add(ifp, 0, 1); |
3614 | ep = xfs_iext_get_ext(ifp, 0); | 3630 | ep = xfs_iext_get_ext(ifp, 0); |
3615 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); | 3631 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); |
3616 | xfs_bmap_trace_post_update(fname, "new", ip, 0, whichfork); | 3632 | XFS_BMAP_TRACE_POST_UPDATE("new", ip, 0, whichfork); |
3617 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); | 3633 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); |
3618 | ip->i_d.di_nblocks = 1; | 3634 | ip->i_d.di_nblocks = 1; |
3619 | XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, | 3635 | XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, |
@@ -3736,7 +3752,7 @@ ktrace_t *xfs_bmap_trace_buf; | |||
3736 | STATIC void | 3752 | STATIC void |
3737 | xfs_bmap_trace_addentry( | 3753 | xfs_bmap_trace_addentry( |
3738 | int opcode, /* operation */ | 3754 | int opcode, /* operation */ |
3739 | char *fname, /* function name */ | 3755 | const char *fname, /* function name */ |
3740 | char *desc, /* operation description */ | 3756 | char *desc, /* operation description */ |
3741 | xfs_inode_t *ip, /* incore inode pointer */ | 3757 | xfs_inode_t *ip, /* incore inode pointer */ |
3742 | xfs_extnum_t idx, /* index of entry(ies) */ | 3758 | xfs_extnum_t idx, /* index of entry(ies) */ |
@@ -3795,7 +3811,7 @@ xfs_bmap_trace_addentry( | |||
3795 | */ | 3811 | */ |
3796 | STATIC void | 3812 | STATIC void |
3797 | xfs_bmap_trace_delete( | 3813 | xfs_bmap_trace_delete( |
3798 | char *fname, /* function name */ | 3814 | const char *fname, /* function name */ |
3799 | char *desc, /* operation description */ | 3815 | char *desc, /* operation description */ |
3800 | xfs_inode_t *ip, /* incore inode pointer */ | 3816 | xfs_inode_t *ip, /* incore inode pointer */ |
3801 | xfs_extnum_t idx, /* index of entry(entries) deleted */ | 3817 | xfs_extnum_t idx, /* index of entry(entries) deleted */ |
@@ -3817,7 +3833,7 @@ xfs_bmap_trace_delete( | |||
3817 | */ | 3833 | */ |
3818 | STATIC void | 3834 | STATIC void |
3819 | xfs_bmap_trace_insert( | 3835 | xfs_bmap_trace_insert( |
3820 | char *fname, /* function name */ | 3836 | const char *fname, /* function name */ |
3821 | char *desc, /* operation description */ | 3837 | char *desc, /* operation description */ |
3822 | xfs_inode_t *ip, /* incore inode pointer */ | 3838 | xfs_inode_t *ip, /* incore inode pointer */ |
3823 | xfs_extnum_t idx, /* index of entry(entries) inserted */ | 3839 | xfs_extnum_t idx, /* index of entry(entries) inserted */ |
@@ -3846,7 +3862,7 @@ xfs_bmap_trace_insert( | |||
3846 | */ | 3862 | */ |
3847 | STATIC void | 3863 | STATIC void |
3848 | xfs_bmap_trace_post_update( | 3864 | xfs_bmap_trace_post_update( |
3849 | char *fname, /* function name */ | 3865 | const char *fname, /* function name */ |
3850 | char *desc, /* operation description */ | 3866 | char *desc, /* operation description */ |
3851 | xfs_inode_t *ip, /* incore inode pointer */ | 3867 | xfs_inode_t *ip, /* incore inode pointer */ |
3852 | xfs_extnum_t idx, /* index of entry updated */ | 3868 | xfs_extnum_t idx, /* index of entry updated */ |
@@ -3864,7 +3880,7 @@ xfs_bmap_trace_post_update( | |||
3864 | */ | 3880 | */ |
3865 | STATIC void | 3881 | STATIC void |
3866 | xfs_bmap_trace_pre_update( | 3882 | xfs_bmap_trace_pre_update( |
3867 | char *fname, /* function name */ | 3883 | const char *fname, /* function name */ |
3868 | char *desc, /* operation description */ | 3884 | char *desc, /* operation description */ |
3869 | xfs_inode_t *ip, /* incore inode pointer */ | 3885 | xfs_inode_t *ip, /* incore inode pointer */ |
3870 | xfs_extnum_t idx, /* index of entry to be updated */ | 3886 | xfs_extnum_t idx, /* index of entry to be updated */ |
@@ -4481,9 +4497,6 @@ xfs_bmap_read_extents( | |||
4481 | xfs_buf_t *bp; /* buffer for "block" */ | 4497 | xfs_buf_t *bp; /* buffer for "block" */ |
4482 | int error; /* error return value */ | 4498 | int error; /* error return value */ |
4483 | xfs_exntfmt_t exntf; /* XFS_EXTFMT_NOSTATE, if checking */ | 4499 | xfs_exntfmt_t exntf; /* XFS_EXTFMT_NOSTATE, if checking */ |
4484 | #ifdef XFS_BMAP_TRACE | ||
4485 | static char fname[] = "xfs_bmap_read_extents"; | ||
4486 | #endif | ||
4487 | xfs_extnum_t i, j; /* index into the extents list */ | 4500 | xfs_extnum_t i, j; /* index into the extents list */ |
4488 | xfs_ifork_t *ifp; /* fork structure */ | 4501 | xfs_ifork_t *ifp; /* fork structure */ |
4489 | int level; /* btree level, for checking */ | 4502 | int level; /* btree level, for checking */ |
@@ -4600,7 +4613,7 @@ xfs_bmap_read_extents( | |||
4600 | } | 4613 | } |
4601 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); | 4614 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); |
4602 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); | 4615 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); |
4603 | xfs_bmap_trace_exlist(fname, ip, i, whichfork); | 4616 | XFS_BMAP_TRACE_EXLIST(ip, i, whichfork); |
4604 | return 0; | 4617 | return 0; |
4605 | error0: | 4618 | error0: |
4606 | xfs_trans_brelse(tp, bp); | 4619 | xfs_trans_brelse(tp, bp); |
@@ -4613,7 +4626,7 @@ error0: | |||
4613 | */ | 4626 | */ |
4614 | void | 4627 | void |
4615 | xfs_bmap_trace_exlist( | 4628 | xfs_bmap_trace_exlist( |
4616 | char *fname, /* function name */ | 4629 | const char *fname, /* function name */ |
4617 | xfs_inode_t *ip, /* incore inode pointer */ | 4630 | xfs_inode_t *ip, /* incore inode pointer */ |
4618 | xfs_extnum_t cnt, /* count of entries in the list */ | 4631 | xfs_extnum_t cnt, /* count of entries in the list */ |
4619 | int whichfork) /* data or attr fork */ | 4632 | int whichfork) /* data or attr fork */ |
@@ -4628,7 +4641,7 @@ xfs_bmap_trace_exlist( | |||
4628 | for (idx = 0; idx < cnt; idx++) { | 4641 | for (idx = 0; idx < cnt; idx++) { |
4629 | ep = xfs_iext_get_ext(ifp, idx); | 4642 | ep = xfs_iext_get_ext(ifp, idx); |
4630 | xfs_bmbt_get_all(ep, &s); | 4643 | xfs_bmbt_get_all(ep, &s); |
4631 | xfs_bmap_trace_insert(fname, "exlist", ip, idx, 1, &s, NULL, | 4644 | XFS_BMAP_TRACE_INSERT("exlist", ip, idx, 1, &s, NULL, |
4632 | whichfork); | 4645 | whichfork); |
4633 | } | 4646 | } |
4634 | } | 4647 | } |
@@ -4868,12 +4881,7 @@ xfs_bmapi( | |||
4868 | xfs_extlen_t extsz; | 4881 | xfs_extlen_t extsz; |
4869 | 4882 | ||
4870 | /* Figure out the extent size, adjust alen */ | 4883 | /* Figure out the extent size, adjust alen */ |
4871 | if (rt) { | 4884 | extsz = xfs_get_extsz_hint(ip); |
4872 | if (!(extsz = ip->i_d.di_extsize)) | ||
4873 | extsz = mp->m_sb.sb_rextsize; | ||
4874 | } else { | ||
4875 | extsz = ip->i_d.di_extsize; | ||
4876 | } | ||
4877 | if (extsz) { | 4885 | if (extsz) { |
4878 | error = xfs_bmap_extsize_align(mp, | 4886 | error = xfs_bmap_extsize_align(mp, |
4879 | &got, &prev, extsz, | 4887 | &got, &prev, extsz, |
@@ -5219,10 +5227,10 @@ xfs_bmapi( | |||
5219 | * Else go on to the next record. | 5227 | * Else go on to the next record. |
5220 | */ | 5228 | */ |
5221 | ep = xfs_iext_get_ext(ifp, ++lastx); | 5229 | ep = xfs_iext_get_ext(ifp, ++lastx); |
5222 | if (lastx >= nextents) { | 5230 | prev = got; |
5231 | if (lastx >= nextents) | ||
5223 | eof = 1; | 5232 | eof = 1; |
5224 | prev = got; | 5233 | else |
5225 | } else | ||
5226 | xfs_bmbt_get_all(ep, &got); | 5234 | xfs_bmbt_get_all(ep, &got); |
5227 | } | 5235 | } |
5228 | ifp->if_lastex = lastx; | 5236 | ifp->if_lastex = lastx; |
@@ -5813,8 +5821,7 @@ xfs_getbmap( | |||
5813 | ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) | 5821 | ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) |
5814 | return XFS_ERROR(EINVAL); | 5822 | return XFS_ERROR(EINVAL); |
5815 | if (whichfork == XFS_DATA_FORK) { | 5823 | if (whichfork == XFS_DATA_FORK) { |
5816 | if ((ip->i_d.di_extsize && (ip->i_d.di_flags & | 5824 | if (xfs_get_extsz_hint(ip) || |
5817 | (XFS_DIFLAG_REALTIME|XFS_DIFLAG_EXTSIZE))) || | ||
5818 | ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ | 5825 | ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ |
5819 | prealloced = 1; | 5826 | prealloced = 1; |
5820 | fixlen = XFS_MAXIOFFSET(mp); | 5827 | fixlen = XFS_MAXIOFFSET(mp); |