diff options
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.c')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 113 |
1 files changed, 52 insertions, 61 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 18fb7385d719..a7b835bf870a 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -58,7 +58,7 @@ STATIC void xfs_bmbt_log_ptrs(xfs_btree_cur_t *, xfs_buf_t *, int, int); | |||
58 | STATIC int xfs_bmbt_lshift(xfs_btree_cur_t *, int, int *); | 58 | STATIC int xfs_bmbt_lshift(xfs_btree_cur_t *, int, int *); |
59 | STATIC int xfs_bmbt_rshift(xfs_btree_cur_t *, int, int *); | 59 | STATIC int xfs_bmbt_rshift(xfs_btree_cur_t *, int, int *); |
60 | STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *, | 60 | STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *, |
61 | xfs_bmbt_key_t *, xfs_btree_cur_t **, int *); | 61 | __uint64_t *, xfs_btree_cur_t **, int *); |
62 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); | 62 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); |
63 | 63 | ||
64 | 64 | ||
@@ -192,16 +192,11 @@ xfs_bmbt_trace_argifk( | |||
192 | xfs_btree_cur_t *cur, | 192 | xfs_btree_cur_t *cur, |
193 | int i, | 193 | int i, |
194 | xfs_fsblock_t f, | 194 | xfs_fsblock_t f, |
195 | xfs_bmbt_key_t *k, | 195 | xfs_dfiloff_t o, |
196 | int line) | 196 | int line) |
197 | { | 197 | { |
198 | xfs_dfsbno_t d; | ||
199 | xfs_dfiloff_t o; | ||
200 | |||
201 | d = (xfs_dfsbno_t)f; | ||
202 | o = INT_GET(k->br_startoff, ARCH_CONVERT); | ||
203 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, | 198 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, |
204 | i, d >> 32, (int)d, o >> 32, | 199 | i, (xfs_dfsbno_t)f >> 32, (int)f, o >> 32, |
205 | (int)o, 0, 0, 0, | 200 | (int)o, 0, 0, 0, |
206 | 0, 0, 0); | 201 | 0, 0, 0); |
207 | } | 202 | } |
@@ -248,7 +243,7 @@ xfs_bmbt_trace_argik( | |||
248 | { | 243 | { |
249 | xfs_dfiloff_t o; | 244 | xfs_dfiloff_t o; |
250 | 245 | ||
251 | o = INT_GET(k->br_startoff, ARCH_CONVERT); | 246 | o = be64_to_cpu(k->br_startoff); |
252 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, | 247 | xfs_bmbt_trace_enter(func, cur, ARGS, XFS_BMBT_KTRACE_ARGIFK, line, |
253 | i, o >> 32, (int)o, 0, | 248 | i, o >> 32, (int)o, 0, |
254 | 0, 0, 0, 0, | 249 | 0, 0, 0, 0, |
@@ -286,8 +281,8 @@ xfs_bmbt_trace_cursor( | |||
286 | xfs_bmbt_trace_argfffi(fname, c, o, b, i, j, __LINE__) | 281 | xfs_bmbt_trace_argfffi(fname, c, o, b, i, j, __LINE__) |
287 | #define XFS_BMBT_TRACE_ARGI(c,i) \ | 282 | #define XFS_BMBT_TRACE_ARGI(c,i) \ |
288 | xfs_bmbt_trace_argi(fname, c, i, __LINE__) | 283 | xfs_bmbt_trace_argi(fname, c, i, __LINE__) |
289 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,k) \ | 284 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) \ |
290 | xfs_bmbt_trace_argifk(fname, c, i, f, k, __LINE__) | 285 | xfs_bmbt_trace_argifk(fname, c, i, f, s, __LINE__) |
291 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \ | 286 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \ |
292 | xfs_bmbt_trace_argifr(fname, c, i, f, r, __LINE__) | 287 | xfs_bmbt_trace_argifr(fname, c, i, f, r, __LINE__) |
293 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) \ | 288 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) \ |
@@ -299,7 +294,7 @@ xfs_bmbt_trace_cursor( | |||
299 | #define XFS_BMBT_TRACE_ARGBII(c,b,i,j) | 294 | #define XFS_BMBT_TRACE_ARGBII(c,b,i,j) |
300 | #define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) | 295 | #define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) |
301 | #define XFS_BMBT_TRACE_ARGI(c,i) | 296 | #define XFS_BMBT_TRACE_ARGI(c,i) |
302 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,k) | 297 | #define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) |
303 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) | 298 | #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) |
304 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) | 299 | #define XFS_BMBT_TRACE_ARGIK(c,i,k) |
305 | #define XFS_BMBT_TRACE_CURSOR(c,s) | 300 | #define XFS_BMBT_TRACE_CURSOR(c,s) |
@@ -357,7 +352,7 @@ xfs_bmbt_delrec( | |||
357 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 352 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
358 | XFS_BMBT_TRACE_ARGI(cur, level); | 353 | XFS_BMBT_TRACE_ARGI(cur, level); |
359 | ptr = cur->bc_ptrs[level]; | 354 | ptr = cur->bc_ptrs[level]; |
360 | tcur = (xfs_btree_cur_t *)0; | 355 | tcur = NULL; |
361 | if (ptr == 0) { | 356 | if (ptr == 0) { |
362 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 357 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
363 | *stat = 0; | 358 | *stat = 0; |
@@ -382,7 +377,7 @@ xfs_bmbt_delrec( | |||
382 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 377 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
383 | #ifdef DEBUG | 378 | #ifdef DEBUG |
384 | for (i = ptr; i < numrecs; i++) { | 379 | for (i = ptr; i < numrecs; i++) { |
385 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { | 380 | if ((error = xfs_btree_check_lptr_disk(cur, pp[i], level))) { |
386 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 381 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
387 | goto error0; | 382 | goto error0; |
388 | } | 383 | } |
@@ -404,7 +399,8 @@ xfs_bmbt_delrec( | |||
404 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs - 1); | 399 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs - 1); |
405 | } | 400 | } |
406 | if (ptr == 1) { | 401 | if (ptr == 1) { |
407 | INT_SET(key.br_startoff, ARCH_CONVERT, xfs_bmbt_disk_get_startoff(rp)); | 402 | key.br_startoff = |
403 | cpu_to_be64(xfs_bmbt_disk_get_startoff(rp)); | ||
408 | kp = &key; | 404 | kp = &key; |
409 | } | 405 | } |
410 | } | 406 | } |
@@ -621,7 +617,7 @@ xfs_bmbt_delrec( | |||
621 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 617 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
622 | #ifdef DEBUG | 618 | #ifdef DEBUG |
623 | for (i = 0; i < numrrecs; i++) { | 619 | for (i = 0; i < numrrecs; i++) { |
624 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { | 620 | if ((error = xfs_btree_check_lptr_disk(cur, rpp[i], level))) { |
625 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 621 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
626 | goto error0; | 622 | goto error0; |
627 | } | 623 | } |
@@ -748,7 +744,7 @@ xfs_bmbt_insrec( | |||
748 | int logflags; /* inode logging flags */ | 744 | int logflags; /* inode logging flags */ |
749 | xfs_fsblock_t nbno; /* new block number */ | 745 | xfs_fsblock_t nbno; /* new block number */ |
750 | struct xfs_btree_cur *ncur; /* new btree cursor */ | 746 | struct xfs_btree_cur *ncur; /* new btree cursor */ |
751 | xfs_bmbt_key_t nkey; /* new btree key value */ | 747 | __uint64_t startoff; /* new btree key value */ |
752 | xfs_bmbt_rec_t nrec; /* new record count */ | 748 | xfs_bmbt_rec_t nrec; /* new record count */ |
753 | int optr; /* old key/record index */ | 749 | int optr; /* old key/record index */ |
754 | xfs_bmbt_ptr_t *pp; /* pointer to bmap block addr */ | 750 | xfs_bmbt_ptr_t *pp; /* pointer to bmap block addr */ |
@@ -759,9 +755,8 @@ xfs_bmbt_insrec( | |||
759 | ASSERT(level < cur->bc_nlevels); | 755 | ASSERT(level < cur->bc_nlevels); |
760 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 756 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
761 | XFS_BMBT_TRACE_ARGIFR(cur, level, *bnop, recp); | 757 | XFS_BMBT_TRACE_ARGIFR(cur, level, *bnop, recp); |
762 | ncur = (xfs_btree_cur_t *)0; | 758 | ncur = NULL; |
763 | INT_SET(key.br_startoff, ARCH_CONVERT, | 759 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(recp)); |
764 | xfs_bmbt_disk_get_startoff(recp)); | ||
765 | optr = ptr = cur->bc_ptrs[level]; | 760 | optr = ptr = cur->bc_ptrs[level]; |
766 | if (ptr == 0) { | 761 | if (ptr == 0) { |
767 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 762 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -820,7 +815,7 @@ xfs_bmbt_insrec( | |||
820 | optr = ptr = cur->bc_ptrs[level]; | 815 | optr = ptr = cur->bc_ptrs[level]; |
821 | } else { | 816 | } else { |
822 | if ((error = xfs_bmbt_split(cur, level, | 817 | if ((error = xfs_bmbt_split(cur, level, |
823 | &nbno, &nkey, &ncur, | 818 | &nbno, &startoff, &ncur, |
824 | &i))) { | 819 | &i))) { |
825 | XFS_BMBT_TRACE_CURSOR(cur, | 820 | XFS_BMBT_TRACE_CURSOR(cur, |
826 | ERROR); | 821 | ERROR); |
@@ -840,7 +835,7 @@ xfs_bmbt_insrec( | |||
840 | #endif | 835 | #endif |
841 | ptr = cur->bc_ptrs[level]; | 836 | ptr = cur->bc_ptrs[level]; |
842 | xfs_bmbt_disk_set_allf(&nrec, | 837 | xfs_bmbt_disk_set_allf(&nrec, |
843 | nkey.br_startoff, 0, 0, | 838 | startoff, 0, 0, |
844 | XFS_EXT_NORM); | 839 | XFS_EXT_NORM); |
845 | } else { | 840 | } else { |
846 | XFS_BMBT_TRACE_CURSOR(cur, | 841 | XFS_BMBT_TRACE_CURSOR(cur, |
@@ -858,7 +853,7 @@ xfs_bmbt_insrec( | |||
858 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 853 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
859 | #ifdef DEBUG | 854 | #ifdef DEBUG |
860 | for (i = numrecs; i >= ptr; i--) { | 855 | for (i = numrecs; i >= ptr; i--) { |
861 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), | 856 | if ((error = xfs_btree_check_lptr_disk(cur, pp[i - 1], |
862 | level))) { | 857 | level))) { |
863 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 858 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
864 | return error; | 859 | return error; |
@@ -870,14 +865,13 @@ xfs_bmbt_insrec( | |||
870 | memmove(&pp[ptr], &pp[ptr - 1], /* INT_: direct copy */ | 865 | memmove(&pp[ptr], &pp[ptr - 1], /* INT_: direct copy */ |
871 | (numrecs - ptr + 1) * sizeof(*pp)); | 866 | (numrecs - ptr + 1) * sizeof(*pp)); |
872 | #ifdef DEBUG | 867 | #ifdef DEBUG |
873 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)*bnop, | 868 | if ((error = xfs_btree_check_lptr(cur, *bnop, level))) { |
874 | level))) { | ||
875 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 869 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
876 | return error; | 870 | return error; |
877 | } | 871 | } |
878 | #endif | 872 | #endif |
879 | kp[ptr - 1] = key; | 873 | kp[ptr - 1] = key; |
880 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); | 874 | pp[ptr - 1] = cpu_to_be64(*bnop); |
881 | numrecs++; | 875 | numrecs++; |
882 | block->bb_numrecs = cpu_to_be16(numrecs); | 876 | block->bb_numrecs = cpu_to_be16(numrecs); |
883 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); | 877 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); |
@@ -988,7 +982,7 @@ xfs_bmbt_killroot( | |||
988 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 982 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
989 | #ifdef DEBUG | 983 | #ifdef DEBUG |
990 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { | 984 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
991 | if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { | 985 | if ((error = xfs_btree_check_lptr_disk(cur, cpp[i], level - 1))) { |
992 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 986 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
993 | return error; | 987 | return error; |
994 | } | 988 | } |
@@ -1132,7 +1126,7 @@ xfs_bmbt_lookup( | |||
1132 | d = XFS_FSB_TO_DADDR(mp, fsbno); | 1126 | d = XFS_FSB_TO_DADDR(mp, fsbno); |
1133 | bp = cur->bc_bufs[level]; | 1127 | bp = cur->bc_bufs[level]; |
1134 | if (bp && XFS_BUF_ADDR(bp) != d) | 1128 | if (bp && XFS_BUF_ADDR(bp) != d) |
1135 | bp = (xfs_buf_t *)0; | 1129 | bp = NULL; |
1136 | if (!bp) { | 1130 | if (!bp) { |
1137 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, | 1131 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, |
1138 | 0, &bp, XFS_BMAP_BTREE_REF))) { | 1132 | 0, &bp, XFS_BMAP_BTREE_REF))) { |
@@ -1170,7 +1164,7 @@ xfs_bmbt_lookup( | |||
1170 | keyno = (low + high) >> 1; | 1164 | keyno = (low + high) >> 1; |
1171 | if (level > 0) { | 1165 | if (level > 0) { |
1172 | kkp = kkbase + keyno - 1; | 1166 | kkp = kkbase + keyno - 1; |
1173 | startoff = INT_GET(kkp->br_startoff, ARCH_CONVERT); | 1167 | startoff = be64_to_cpu(kkp->br_startoff); |
1174 | } else { | 1168 | } else { |
1175 | krp = krbase + keyno - 1; | 1169 | krp = krbase + keyno - 1; |
1176 | startoff = xfs_bmbt_disk_get_startoff(krp); | 1170 | startoff = xfs_bmbt_disk_get_startoff(krp); |
@@ -1189,13 +1183,13 @@ xfs_bmbt_lookup( | |||
1189 | if (diff > 0 && --keyno < 1) | 1183 | if (diff > 0 && --keyno < 1) |
1190 | keyno = 1; | 1184 | keyno = 1; |
1191 | pp = XFS_BMAP_PTR_IADDR(block, keyno, cur); | 1185 | pp = XFS_BMAP_PTR_IADDR(block, keyno, cur); |
1186 | fsbno = be64_to_cpu(*pp); | ||
1192 | #ifdef DEBUG | 1187 | #ifdef DEBUG |
1193 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*pp, ARCH_CONVERT), level))) { | 1188 | if ((error = xfs_btree_check_lptr(cur, fsbno, level))) { |
1194 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1189 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1195 | return error; | 1190 | return error; |
1196 | } | 1191 | } |
1197 | #endif | 1192 | #endif |
1198 | fsbno = INT_GET(*pp, ARCH_CONVERT); | ||
1199 | cur->bc_ptrs[level] = keyno; | 1193 | cur->bc_ptrs[level] = keyno; |
1200 | } | 1194 | } |
1201 | } | 1195 | } |
@@ -1313,7 +1307,7 @@ xfs_bmbt_lshift( | |||
1313 | lpp = XFS_BMAP_PTR_IADDR(left, lrecs, cur); | 1307 | lpp = XFS_BMAP_PTR_IADDR(left, lrecs, cur); |
1314 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1308 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1315 | #ifdef DEBUG | 1309 | #ifdef DEBUG |
1316 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))) { | 1310 | if ((error = xfs_btree_check_lptr_disk(cur, *rpp, level))) { |
1317 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1311 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1318 | return error; | 1312 | return error; |
1319 | } | 1313 | } |
@@ -1340,7 +1334,7 @@ xfs_bmbt_lshift( | |||
1340 | if (level > 0) { | 1334 | if (level > 0) { |
1341 | #ifdef DEBUG | 1335 | #ifdef DEBUG |
1342 | for (i = 0; i < rrecs; i++) { | 1336 | for (i = 0; i < rrecs; i++) { |
1343 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT), | 1337 | if ((error = xfs_btree_check_lptr_disk(cur, rpp[i + 1], |
1344 | level))) { | 1338 | level))) { |
1345 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1339 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1346 | return error; | 1340 | return error; |
@@ -1354,8 +1348,7 @@ xfs_bmbt_lshift( | |||
1354 | } else { | 1348 | } else { |
1355 | memmove(rrp, rrp + 1, rrecs * sizeof(*rrp)); | 1349 | memmove(rrp, rrp + 1, rrecs * sizeof(*rrp)); |
1356 | xfs_bmbt_log_recs(cur, rbp, 1, rrecs); | 1350 | xfs_bmbt_log_recs(cur, rbp, 1, rrecs); |
1357 | INT_SET(key.br_startoff, ARCH_CONVERT, | 1351 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(rrp)); |
1358 | xfs_bmbt_disk_get_startoff(rrp)); | ||
1359 | rkp = &key; | 1352 | rkp = &key; |
1360 | } | 1353 | } |
1361 | if ((error = xfs_bmbt_updkey(cur, rkp, level + 1))) { | 1354 | if ((error = xfs_bmbt_updkey(cur, rkp, level + 1))) { |
@@ -1445,7 +1438,7 @@ xfs_bmbt_rshift( | |||
1445 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1438 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1446 | #ifdef DEBUG | 1439 | #ifdef DEBUG |
1447 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { | 1440 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { |
1448 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { | 1441 | if ((error = xfs_btree_check_lptr_disk(cur, rpp[i], level))) { |
1449 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1442 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1450 | return error; | 1443 | return error; |
1451 | } | 1444 | } |
@@ -1454,7 +1447,7 @@ xfs_bmbt_rshift( | |||
1454 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); | 1447 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1455 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); | 1448 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1456 | #ifdef DEBUG | 1449 | #ifdef DEBUG |
1457 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { | 1450 | if ((error = xfs_btree_check_lptr_disk(cur, *lpp, level))) { |
1458 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1451 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1459 | return error; | 1452 | return error; |
1460 | } | 1453 | } |
@@ -1469,8 +1462,7 @@ xfs_bmbt_rshift( | |||
1469 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1462 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1470 | *rrp = *lrp; | 1463 | *rrp = *lrp; |
1471 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); | 1464 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1472 | INT_SET(key.br_startoff, ARCH_CONVERT, | 1465 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(rrp)); |
1473 | xfs_bmbt_disk_get_startoff(rrp)); | ||
1474 | rkp = &key; | 1466 | rkp = &key; |
1475 | } | 1467 | } |
1476 | be16_add(&left->bb_numrecs, -1); | 1468 | be16_add(&left->bb_numrecs, -1); |
@@ -1535,7 +1527,7 @@ xfs_bmbt_split( | |||
1535 | xfs_btree_cur_t *cur, | 1527 | xfs_btree_cur_t *cur, |
1536 | int level, | 1528 | int level, |
1537 | xfs_fsblock_t *bnop, | 1529 | xfs_fsblock_t *bnop, |
1538 | xfs_bmbt_key_t *keyp, | 1530 | __uint64_t *startoff, |
1539 | xfs_btree_cur_t **curp, | 1531 | xfs_btree_cur_t **curp, |
1540 | int *stat) /* success/failure */ | 1532 | int *stat) /* success/failure */ |
1541 | { | 1533 | { |
@@ -1560,7 +1552,7 @@ xfs_bmbt_split( | |||
1560 | xfs_bmbt_rec_t *rrp; /* right record pointer */ | 1552 | xfs_bmbt_rec_t *rrp; /* right record pointer */ |
1561 | 1553 | ||
1562 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 1554 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
1563 | XFS_BMBT_TRACE_ARGIFK(cur, level, *bnop, keyp); | 1555 | XFS_BMBT_TRACE_ARGIFK(cur, level, *bnop, *startoff); |
1564 | args.tp = cur->bc_tp; | 1556 | args.tp = cur->bc_tp; |
1565 | args.mp = cur->bc_mp; | 1557 | args.mp = cur->bc_mp; |
1566 | lbp = cur->bc_bufs[level]; | 1558 | lbp = cur->bc_bufs[level]; |
@@ -1619,7 +1611,7 @@ xfs_bmbt_split( | |||
1619 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1611 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1620 | #ifdef DEBUG | 1612 | #ifdef DEBUG |
1621 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { | 1613 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1622 | if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { | 1614 | if ((error = xfs_btree_check_lptr_disk(cur, lpp[i], level))) { |
1623 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1615 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1624 | return error; | 1616 | return error; |
1625 | } | 1617 | } |
@@ -1629,13 +1621,13 @@ xfs_bmbt_split( | |||
1629 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); | 1621 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1630 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1622 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1631 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1623 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1632 | keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); | 1624 | *startoff = be64_to_cpu(rkp->br_startoff); |
1633 | } else { | 1625 | } else { |
1634 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); | 1626 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); |
1635 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); | 1627 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); |
1636 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); | 1628 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1637 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); | 1629 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1638 | keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); | 1630 | *startoff = xfs_bmbt_disk_get_startoff(rrp); |
1639 | } | 1631 | } |
1640 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); | 1632 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); |
1641 | right->bb_rightsib = left->bb_rightsib; | 1633 | right->bb_rightsib = left->bb_rightsib; |
@@ -1728,9 +1720,9 @@ xfs_bmdr_to_bmbt( | |||
1728 | { | 1720 | { |
1729 | int dmxr; | 1721 | int dmxr; |
1730 | xfs_bmbt_key_t *fkp; | 1722 | xfs_bmbt_key_t *fkp; |
1731 | xfs_bmbt_ptr_t *fpp; | 1723 | __be64 *fpp; |
1732 | xfs_bmbt_key_t *tkp; | 1724 | xfs_bmbt_key_t *tkp; |
1733 | xfs_bmbt_ptr_t *tpp; | 1725 | __be64 *tpp; |
1734 | 1726 | ||
1735 | rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); | 1727 | rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
1736 | rblock->bb_level = dblock->bb_level; | 1728 | rblock->bb_level = dblock->bb_level; |
@@ -1745,7 +1737,7 @@ xfs_bmdr_to_bmbt( | |||
1745 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); | 1737 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); |
1746 | dmxr = be16_to_cpu(dblock->bb_numrecs); | 1738 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
1747 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 1739 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
1748 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 1740 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); |
1749 | } | 1741 | } |
1750 | 1742 | ||
1751 | /* | 1743 | /* |
@@ -1805,7 +1797,7 @@ xfs_bmbt_decrement( | |||
1805 | tp = cur->bc_tp; | 1797 | tp = cur->bc_tp; |
1806 | mp = cur->bc_mp; | 1798 | mp = cur->bc_mp; |
1807 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { | 1799 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { |
1808 | fsbno = INT_GET(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 1800 | fsbno = be64_to_cpu(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur)); |
1809 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, | 1801 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, |
1810 | XFS_BMAP_BTREE_REF))) { | 1802 | XFS_BMAP_BTREE_REF))) { |
1811 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1803 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -2135,7 +2127,7 @@ xfs_bmbt_increment( | |||
2135 | tp = cur->bc_tp; | 2127 | tp = cur->bc_tp; |
2136 | mp = cur->bc_mp; | 2128 | mp = cur->bc_mp; |
2137 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { | 2129 | for (block = xfs_bmbt_get_block(cur, lev, &bp); lev > level; ) { |
2138 | fsbno = INT_GET(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 2130 | fsbno = be64_to_cpu(*XFS_BMAP_PTR_IADDR(block, cur->bc_ptrs[lev], cur)); |
2139 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, | 2131 | if ((error = xfs_btree_read_bufl(mp, tp, fsbno, 0, &bp, |
2140 | XFS_BMAP_BTREE_REF))) { | 2132 | XFS_BMAP_BTREE_REF))) { |
2141 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2133 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -2178,7 +2170,7 @@ xfs_bmbt_insert( | |||
2178 | level = 0; | 2170 | level = 0; |
2179 | nbno = NULLFSBLOCK; | 2171 | nbno = NULLFSBLOCK; |
2180 | xfs_bmbt_disk_set_all(&nrec, &cur->bc_rec.b); | 2172 | xfs_bmbt_disk_set_all(&nrec, &cur->bc_rec.b); |
2181 | ncur = (xfs_btree_cur_t *)0; | 2173 | ncur = NULL; |
2182 | pcur = cur; | 2174 | pcur = cur; |
2183 | do { | 2175 | do { |
2184 | if ((error = xfs_bmbt_insrec(pcur, level++, &nbno, &nrec, &ncur, | 2176 | if ((error = xfs_bmbt_insrec(pcur, level++, &nbno, &nrec, &ncur, |
@@ -2205,7 +2197,7 @@ xfs_bmbt_insert( | |||
2205 | } | 2197 | } |
2206 | if (ncur) { | 2198 | if (ncur) { |
2207 | pcur = ncur; | 2199 | pcur = ncur; |
2208 | ncur = (xfs_btree_cur_t *)0; | 2200 | ncur = NULL; |
2209 | } | 2201 | } |
2210 | } while (nbno != NULLFSBLOCK); | 2202 | } while (nbno != NULLFSBLOCK); |
2211 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2203 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -2356,12 +2348,12 @@ xfs_bmbt_newroot( | |||
2356 | args.firstblock = args.fsbno; | 2348 | args.firstblock = args.fsbno; |
2357 | if (args.fsbno == NULLFSBLOCK) { | 2349 | if (args.fsbno == NULLFSBLOCK) { |
2358 | #ifdef DEBUG | 2350 | #ifdef DEBUG |
2359 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*pp, ARCH_CONVERT), level))) { | 2351 | if ((error = xfs_btree_check_lptr_disk(cur, *pp, level))) { |
2360 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2352 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2361 | return error; | 2353 | return error; |
2362 | } | 2354 | } |
2363 | #endif | 2355 | #endif |
2364 | args.fsbno = INT_GET(*pp, ARCH_CONVERT); | 2356 | args.fsbno = be64_to_cpu(*pp); |
2365 | args.type = XFS_ALLOCTYPE_START_BNO; | 2357 | args.type = XFS_ALLOCTYPE_START_BNO; |
2366 | } else | 2358 | } else |
2367 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 2359 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
@@ -2393,7 +2385,7 @@ xfs_bmbt_newroot( | |||
2393 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 2385 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
2394 | #ifdef DEBUG | 2386 | #ifdef DEBUG |
2395 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { | 2387 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
2396 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { | 2388 | if ((error = xfs_btree_check_lptr_disk(cur, pp[i], level))) { |
2397 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2389 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2398 | return error; | 2390 | return error; |
2399 | } | 2391 | } |
@@ -2401,13 +2393,12 @@ xfs_bmbt_newroot( | |||
2401 | #endif | 2393 | #endif |
2402 | memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp)); | 2394 | memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp)); |
2403 | #ifdef DEBUG | 2395 | #ifdef DEBUG |
2404 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, | 2396 | if ((error = xfs_btree_check_lptr(cur, args.fsbno, level))) { |
2405 | level))) { | ||
2406 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2397 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2407 | return error; | 2398 | return error; |
2408 | } | 2399 | } |
2409 | #endif | 2400 | #endif |
2410 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); | 2401 | *pp = cpu_to_be64(args.fsbno); |
2411 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs), | 2402 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs), |
2412 | cur->bc_private.b.whichfork); | 2403 | cur->bc_private.b.whichfork); |
2413 | xfs_btree_setbuf(cur, level, bp); | 2404 | xfs_btree_setbuf(cur, level, bp); |
@@ -2681,9 +2672,9 @@ xfs_bmbt_to_bmdr( | |||
2681 | { | 2672 | { |
2682 | int dmxr; | 2673 | int dmxr; |
2683 | xfs_bmbt_key_t *fkp; | 2674 | xfs_bmbt_key_t *fkp; |
2684 | xfs_bmbt_ptr_t *fpp; | 2675 | __be64 *fpp; |
2685 | xfs_bmbt_key_t *tkp; | 2676 | xfs_bmbt_key_t *tkp; |
2686 | xfs_bmbt_ptr_t *tpp; | 2677 | __be64 *tpp; |
2687 | 2678 | ||
2688 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); | 2679 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); |
2689 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); | 2680 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); |
@@ -2698,7 +2689,7 @@ xfs_bmbt_to_bmdr( | |||
2698 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 2689 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
2699 | dmxr = be16_to_cpu(dblock->bb_numrecs); | 2690 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
2700 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 2691 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
2701 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 2692 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); |
2702 | } | 2693 | } |
2703 | 2694 | ||
2704 | /* | 2695 | /* |
@@ -2740,7 +2731,7 @@ xfs_bmbt_update( | |||
2740 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2731 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2741 | return 0; | 2732 | return 0; |
2742 | } | 2733 | } |
2743 | INT_SET(key.br_startoff, ARCH_CONVERT, off); | 2734 | key.br_startoff = cpu_to_be64(off); |
2744 | if ((error = xfs_bmbt_updkey(cur, &key, 1))) { | 2735 | if ((error = xfs_bmbt_updkey(cur, &key, 1))) { |
2745 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2736 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2746 | return error; | 2737 | return error; |