aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.c')
-rw-r--r--fs/xfs/xfs_bmap_btree.c255
1 files changed, 96 insertions, 159 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 89b891f51cfb..32b49ec00fb5 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -260,13 +260,14 @@ xfs_bmbt_trace_cursor(
260 char *s, 260 char *s,
261 int line) 261 int line)
262{ 262{
263 xfs_bmbt_rec_t r; 263 xfs_bmbt_rec_host_t r;
264 264
265 xfs_bmbt_set_all(&r, &cur->bc_rec.b); 265 xfs_bmbt_set_all(&r, &cur->bc_rec.b);
266 xfs_bmbt_trace_enter(func, cur, s, XFS_BMBT_KTRACE_CUR, line, 266 xfs_bmbt_trace_enter(func, cur, s, XFS_BMBT_KTRACE_CUR, line,
267 (cur->bc_nlevels << 24) | (cur->bc_private.b.flags << 16) | 267 (cur->bc_nlevels << 24) | (cur->bc_private.b.flags << 16) |
268 cur->bc_private.b.allocated, 268 cur->bc_private.b.allocated,
269 INT_GET(r.l0, ARCH_CONVERT) >> 32, (int)INT_GET(r.l0, ARCH_CONVERT), INT_GET(r.l1, ARCH_CONVERT) >> 32, (int)INT_GET(r.l1, ARCH_CONVERT), 269 r.l0 >> 32, (int)r.l0,
270 r.l1 >> 32, (int)r.l1,
270 (unsigned long)cur->bc_bufs[0], (unsigned long)cur->bc_bufs[1], 271 (unsigned long)cur->bc_bufs[0], (unsigned long)cur->bc_bufs[1],
271 (unsigned long)cur->bc_bufs[2], (unsigned long)cur->bc_bufs[3], 272 (unsigned long)cur->bc_bufs[2], (unsigned long)cur->bc_bufs[3],
272 (cur->bc_ptrs[0] << 16) | cur->bc_ptrs[1], 273 (cur->bc_ptrs[0] << 16) | cur->bc_ptrs[1],
@@ -383,7 +384,7 @@ xfs_bmbt_delrec(
383 if (ptr < numrecs) { 384 if (ptr < numrecs) {
384 memmove(&kp[ptr - 1], &kp[ptr], 385 memmove(&kp[ptr - 1], &kp[ptr],
385 (numrecs - ptr) * sizeof(*kp)); 386 (numrecs - ptr) * sizeof(*kp));
386 memmove(&pp[ptr - 1], &pp[ptr], /* INT_: direct copy */ 387 memmove(&pp[ptr - 1], &pp[ptr],
387 (numrecs - ptr) * sizeof(*pp)); 388 (numrecs - ptr) * sizeof(*pp));
388 xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs - 1); 389 xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs - 1);
389 xfs_bmbt_log_keys(cur, bp, ptr, numrecs - 1); 390 xfs_bmbt_log_keys(cur, bp, ptr, numrecs - 1);
@@ -815,7 +816,7 @@ xfs_bmbt_insrec(
815#endif 816#endif
816 memmove(&kp[ptr], &kp[ptr - 1], 817 memmove(&kp[ptr], &kp[ptr - 1],
817 (numrecs - ptr + 1) * sizeof(*kp)); 818 (numrecs - ptr + 1) * sizeof(*kp));
818 memmove(&pp[ptr], &pp[ptr - 1], /* INT_: direct copy */ 819 memmove(&pp[ptr], &pp[ptr - 1],
819 (numrecs - ptr + 1) * sizeof(*pp)); 820 (numrecs - ptr + 1) * sizeof(*pp));
820#ifdef DEBUG 821#ifdef DEBUG
821 if ((error = xfs_btree_check_lptr(cur, *bnop, level))) { 822 if ((error = xfs_btree_check_lptr(cur, *bnop, level))) {
@@ -1250,7 +1251,7 @@ xfs_bmbt_lshift(
1250 return error; 1251 return error;
1251 } 1252 }
1252#endif 1253#endif
1253 *lpp = *rpp; /* INT_: direct copy */ 1254 *lpp = *rpp;
1254 xfs_bmbt_log_ptrs(cur, lbp, lrecs, lrecs); 1255 xfs_bmbt_log_ptrs(cur, lbp, lrecs, lrecs);
1255 } else { 1256 } else {
1256 lrp = XFS_BMAP_REC_IADDR(left, lrecs, cur); 1257 lrp = XFS_BMAP_REC_IADDR(left, lrecs, cur);
@@ -1388,7 +1389,7 @@ xfs_bmbt_rshift(
1388 } 1389 }
1389#endif 1390#endif
1390 *rkp = *lkp; 1391 *rkp = *lkp;
1391 *rpp = *lpp; /* INT_: direct copy */ 1392 *rpp = *lpp;
1392 xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); 1393 xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1393 xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); 1394 xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1394 } else { 1395 } else {
@@ -1826,7 +1827,7 @@ __xfs_bmbt_get_all(
1826 1827
1827void 1828void
1828xfs_bmbt_get_all( 1829xfs_bmbt_get_all(
1829 xfs_bmbt_rec_t *r, 1830 xfs_bmbt_rec_host_t *r,
1830 xfs_bmbt_irec_t *s) 1831 xfs_bmbt_irec_t *s)
1831{ 1832{
1832 __xfs_bmbt_get_all(r->l0, r->l1, s); 1833 __xfs_bmbt_get_all(r->l0, r->l1, s);
@@ -1862,7 +1863,7 @@ xfs_bmbt_get_block(
1862 */ 1863 */
1863xfs_filblks_t 1864xfs_filblks_t
1864xfs_bmbt_get_blockcount( 1865xfs_bmbt_get_blockcount(
1865 xfs_bmbt_rec_t *r) 1866 xfs_bmbt_rec_host_t *r)
1866{ 1867{
1867 return (xfs_filblks_t)(r->l1 & XFS_MASK64LO(21)); 1868 return (xfs_filblks_t)(r->l1 & XFS_MASK64LO(21));
1868} 1869}
@@ -1872,7 +1873,7 @@ xfs_bmbt_get_blockcount(
1872 */ 1873 */
1873xfs_fsblock_t 1874xfs_fsblock_t
1874xfs_bmbt_get_startblock( 1875xfs_bmbt_get_startblock(
1875 xfs_bmbt_rec_t *r) 1876 xfs_bmbt_rec_host_t *r)
1876{ 1877{
1877#if XFS_BIG_BLKNOS 1878#if XFS_BIG_BLKNOS
1878 return (((xfs_fsblock_t)r->l0 & XFS_MASK64LO(9)) << 43) | 1879 return (((xfs_fsblock_t)r->l0 & XFS_MASK64LO(9)) << 43) |
@@ -1896,7 +1897,7 @@ xfs_bmbt_get_startblock(
1896 */ 1897 */
1897xfs_fileoff_t 1898xfs_fileoff_t
1898xfs_bmbt_get_startoff( 1899xfs_bmbt_get_startoff(
1899 xfs_bmbt_rec_t *r) 1900 xfs_bmbt_rec_host_t *r)
1900{ 1901{
1901 return ((xfs_fileoff_t)r->l0 & 1902 return ((xfs_fileoff_t)r->l0 &
1902 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; 1903 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
@@ -1904,7 +1905,7 @@ xfs_bmbt_get_startoff(
1904 1905
1905xfs_exntst_t 1906xfs_exntst_t
1906xfs_bmbt_get_state( 1907xfs_bmbt_get_state(
1907 xfs_bmbt_rec_t *r) 1908 xfs_bmbt_rec_host_t *r)
1908{ 1909{
1909 int ext_flag; 1910 int ext_flag;
1910 1911
@@ -1913,19 +1914,13 @@ xfs_bmbt_get_state(
1913 ext_flag); 1914 ext_flag);
1914} 1915}
1915 1916
1916#ifndef XFS_NATIVE_HOST
1917/* Endian flipping versions of the bmbt extraction functions */ 1917/* Endian flipping versions of the bmbt extraction functions */
1918void 1918void
1919xfs_bmbt_disk_get_all( 1919xfs_bmbt_disk_get_all(
1920 xfs_bmbt_rec_t *r, 1920 xfs_bmbt_rec_t *r,
1921 xfs_bmbt_irec_t *s) 1921 xfs_bmbt_irec_t *s)
1922{ 1922{
1923 __uint64_t l0, l1; 1923 __xfs_bmbt_get_all(be64_to_cpu(r->l0), be64_to_cpu(r->l1), s);
1924
1925 l0 = INT_GET(r->l0, ARCH_CONVERT);
1926 l1 = INT_GET(r->l1, ARCH_CONVERT);
1927
1928 __xfs_bmbt_get_all(l0, l1, s);
1929} 1924}
1930 1925
1931/* 1926/*
@@ -1935,7 +1930,7 @@ xfs_filblks_t
1935xfs_bmbt_disk_get_blockcount( 1930xfs_bmbt_disk_get_blockcount(
1936 xfs_bmbt_rec_t *r) 1931 xfs_bmbt_rec_t *r)
1937{ 1932{
1938 return (xfs_filblks_t)(INT_GET(r->l1, ARCH_CONVERT) & XFS_MASK64LO(21)); 1933 return (xfs_filblks_t)(be64_to_cpu(r->l1) & XFS_MASK64LO(21));
1939} 1934}
1940 1935
1941/* 1936/*
@@ -1945,11 +1940,9 @@ xfs_fileoff_t
1945xfs_bmbt_disk_get_startoff( 1940xfs_bmbt_disk_get_startoff(
1946 xfs_bmbt_rec_t *r) 1941 xfs_bmbt_rec_t *r)
1947{ 1942{
1948 return ((xfs_fileoff_t)INT_GET(r->l0, ARCH_CONVERT) & 1943 return ((xfs_fileoff_t)be64_to_cpu(r->l0) &
1949 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9; 1944 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
1950} 1945}
1951#endif /* XFS_NATIVE_HOST */
1952
1953 1946
1954/* 1947/*
1955 * Increment cursor by one record at the level. 1948 * Increment cursor by one record at the level.
@@ -2290,185 +2283,131 @@ xfs_bmbt_newroot(
2290} 2283}
2291 2284
2292/* 2285/*
2293 * Set all the fields in a bmap extent record from the uncompressed form.
2294 */
2295void
2296xfs_bmbt_set_all(
2297 xfs_bmbt_rec_t *r,
2298 xfs_bmbt_irec_t *s)
2299{
2300 int extent_flag;
2301
2302 ASSERT((s->br_state == XFS_EXT_NORM) ||
2303 (s->br_state == XFS_EXT_UNWRITTEN));
2304 extent_flag = (s->br_state == XFS_EXT_NORM) ? 0 : 1;
2305 ASSERT((s->br_startoff & XFS_MASK64HI(9)) == 0);
2306 ASSERT((s->br_blockcount & XFS_MASK64HI(43)) == 0);
2307#if XFS_BIG_BLKNOS
2308 ASSERT((s->br_startblock & XFS_MASK64HI(12)) == 0);
2309 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2310 ((xfs_bmbt_rec_base_t)s->br_startoff << 9) |
2311 ((xfs_bmbt_rec_base_t)s->br_startblock >> 43);
2312 r->l1 = ((xfs_bmbt_rec_base_t)s->br_startblock << 21) |
2313 ((xfs_bmbt_rec_base_t)s->br_blockcount &
2314 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21));
2315#else /* !XFS_BIG_BLKNOS */
2316 if (ISNULLSTARTBLOCK(s->br_startblock)) {
2317 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2318 ((xfs_bmbt_rec_base_t)s->br_startoff << 9) |
2319 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9);
2320 r->l1 = XFS_MASK64HI(11) |
2321 ((xfs_bmbt_rec_base_t)s->br_startblock << 21) |
2322 ((xfs_bmbt_rec_base_t)s->br_blockcount &
2323 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21));
2324 } else {
2325 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2326 ((xfs_bmbt_rec_base_t)s->br_startoff << 9);
2327 r->l1 = ((xfs_bmbt_rec_base_t)s->br_startblock << 21) |
2328 ((xfs_bmbt_rec_base_t)s->br_blockcount &
2329 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21));
2330 }
2331#endif /* XFS_BIG_BLKNOS */
2332}
2333
2334/*
2335 * Set all the fields in a bmap extent record from the arguments. 2286 * Set all the fields in a bmap extent record from the arguments.
2336 */ 2287 */
2337void 2288void
2338xfs_bmbt_set_allf( 2289xfs_bmbt_set_allf(
2339 xfs_bmbt_rec_t *r, 2290 xfs_bmbt_rec_host_t *r,
2340 xfs_fileoff_t o, 2291 xfs_fileoff_t startoff,
2341 xfs_fsblock_t b, 2292 xfs_fsblock_t startblock,
2342 xfs_filblks_t c, 2293 xfs_filblks_t blockcount,
2343 xfs_exntst_t v) 2294 xfs_exntst_t state)
2344{ 2295{
2345 int extent_flag; 2296 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1;
2297
2298 ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN);
2299 ASSERT((startoff & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0);
2300 ASSERT((blockcount & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0);
2346 2301
2347 ASSERT((v == XFS_EXT_NORM) || (v == XFS_EXT_UNWRITTEN));
2348 extent_flag = (v == XFS_EXT_NORM) ? 0 : 1;
2349 ASSERT((o & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0);
2350 ASSERT((c & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0);
2351#if XFS_BIG_BLKNOS 2302#if XFS_BIG_BLKNOS
2352 ASSERT((b & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); 2303 ASSERT((startblock & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0);
2304
2353 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | 2305 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2354 ((xfs_bmbt_rec_base_t)o << 9) | 2306 ((xfs_bmbt_rec_base_t)startoff << 9) |
2355 ((xfs_bmbt_rec_base_t)b >> 43); 2307 ((xfs_bmbt_rec_base_t)startblock >> 43);
2356 r->l1 = ((xfs_bmbt_rec_base_t)b << 21) | 2308 r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) |
2357 ((xfs_bmbt_rec_base_t)c & 2309 ((xfs_bmbt_rec_base_t)blockcount &
2358 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 2310 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21));
2359#else /* !XFS_BIG_BLKNOS */ 2311#else /* !XFS_BIG_BLKNOS */
2360 if (ISNULLSTARTBLOCK(b)) { 2312 if (ISNULLSTARTBLOCK(startblock)) {
2361 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | 2313 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2362 ((xfs_bmbt_rec_base_t)o << 9) | 2314 ((xfs_bmbt_rec_base_t)startoff << 9) |
2363 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9); 2315 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9);
2364 r->l1 = XFS_MASK64HI(11) | 2316 r->l1 = XFS_MASK64HI(11) |
2365 ((xfs_bmbt_rec_base_t)b << 21) | 2317 ((xfs_bmbt_rec_base_t)startblock << 21) |
2366 ((xfs_bmbt_rec_base_t)c & 2318 ((xfs_bmbt_rec_base_t)blockcount &
2367 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 2319 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21));
2368 } else { 2320 } else {
2369 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | 2321 r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2370 ((xfs_bmbt_rec_base_t)o << 9); 2322 ((xfs_bmbt_rec_base_t)startoff << 9);
2371 r->l1 = ((xfs_bmbt_rec_base_t)b << 21) | 2323 r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) |
2372 ((xfs_bmbt_rec_base_t)c & 2324 ((xfs_bmbt_rec_base_t)blockcount &
2373 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); 2325 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21));
2374 } 2326 }
2375#endif /* XFS_BIG_BLKNOS */ 2327#endif /* XFS_BIG_BLKNOS */
2376} 2328}
2377 2329
2378#ifndef XFS_NATIVE_HOST
2379/* 2330/*
2380 * Set all the fields in a bmap extent record from the uncompressed form. 2331 * Set all the fields in a bmap extent record from the uncompressed form.
2381 */ 2332 */
2382void 2333void
2383xfs_bmbt_disk_set_all( 2334xfs_bmbt_set_all(
2384 xfs_bmbt_rec_t *r, 2335 xfs_bmbt_rec_host_t *r,
2385 xfs_bmbt_irec_t *s) 2336 xfs_bmbt_irec_t *s)
2386{ 2337{
2387 int extent_flag; 2338 xfs_bmbt_set_allf(r, s->br_startoff, s->br_startblock,
2388 2339 s->br_blockcount, s->br_state);
2389 ASSERT((s->br_state == XFS_EXT_NORM) ||
2390 (s->br_state == XFS_EXT_UNWRITTEN));
2391 extent_flag = (s->br_state == XFS_EXT_NORM) ? 0 : 1;
2392 ASSERT((s->br_startoff & XFS_MASK64HI(9)) == 0);
2393 ASSERT((s->br_blockcount & XFS_MASK64HI(43)) == 0);
2394#if XFS_BIG_BLKNOS
2395 ASSERT((s->br_startblock & XFS_MASK64HI(12)) == 0);
2396 INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2397 ((xfs_bmbt_rec_base_t)s->br_startoff << 9) |
2398 ((xfs_bmbt_rec_base_t)s->br_startblock >> 43));
2399 INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)s->br_startblock << 21) |
2400 ((xfs_bmbt_rec_base_t)s->br_blockcount &
2401 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)));
2402#else /* !XFS_BIG_BLKNOS */
2403 if (ISNULLSTARTBLOCK(s->br_startblock)) {
2404 INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2405 ((xfs_bmbt_rec_base_t)s->br_startoff << 9) |
2406 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9));
2407 INT_SET(r->l1, ARCH_CONVERT, XFS_MASK64HI(11) |
2408 ((xfs_bmbt_rec_base_t)s->br_startblock << 21) |
2409 ((xfs_bmbt_rec_base_t)s->br_blockcount &
2410 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)));
2411 } else {
2412 INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2413 ((xfs_bmbt_rec_base_t)s->br_startoff << 9));
2414 INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)s->br_startblock << 21) |
2415 ((xfs_bmbt_rec_base_t)s->br_blockcount &
2416 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)));
2417 }
2418#endif /* XFS_BIG_BLKNOS */
2419} 2340}
2420 2341
2342
2421/* 2343/*
2422 * Set all the fields in a disk format bmap extent record from the arguments. 2344 * Set all the fields in a disk format bmap extent record from the arguments.
2423 */ 2345 */
2424void 2346void
2425xfs_bmbt_disk_set_allf( 2347xfs_bmbt_disk_set_allf(
2426 xfs_bmbt_rec_t *r, 2348 xfs_bmbt_rec_t *r,
2427 xfs_fileoff_t o, 2349 xfs_fileoff_t startoff,
2428 xfs_fsblock_t b, 2350 xfs_fsblock_t startblock,
2429 xfs_filblks_t c, 2351 xfs_filblks_t blockcount,
2430 xfs_exntst_t v) 2352 xfs_exntst_t state)
2431{ 2353{
2432 int extent_flag; 2354 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1;
2355
2356 ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN);
2357 ASSERT((startoff & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0);
2358 ASSERT((blockcount & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0);
2433 2359
2434 ASSERT((v == XFS_EXT_NORM) || (v == XFS_EXT_UNWRITTEN));
2435 extent_flag = (v == XFS_EXT_NORM) ? 0 : 1;
2436 ASSERT((o & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0);
2437 ASSERT((c & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0);
2438#if XFS_BIG_BLKNOS 2360#if XFS_BIG_BLKNOS
2439 ASSERT((b & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); 2361 ASSERT((startblock & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0);
2440 INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | 2362
2441 ((xfs_bmbt_rec_base_t)o << 9) | 2363 r->l0 = cpu_to_be64(
2442 ((xfs_bmbt_rec_base_t)b >> 43)); 2364 ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2443 INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)b << 21) | 2365 ((xfs_bmbt_rec_base_t)startoff << 9) |
2444 ((xfs_bmbt_rec_base_t)c & 2366 ((xfs_bmbt_rec_base_t)startblock >> 43));
2445 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); 2367 r->l1 = cpu_to_be64(
2368 ((xfs_bmbt_rec_base_t)startblock << 21) |
2369 ((xfs_bmbt_rec_base_t)blockcount &
2370 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)));
2446#else /* !XFS_BIG_BLKNOS */ 2371#else /* !XFS_BIG_BLKNOS */
2447 if (ISNULLSTARTBLOCK(b)) { 2372 if (ISNULLSTARTBLOCK(startblock)) {
2448 INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | 2373 r->l0 = cpu_to_be64(
2449 ((xfs_bmbt_rec_base_t)o << 9) | 2374 ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2450 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9)); 2375 ((xfs_bmbt_rec_base_t)startoff << 9) |
2451 INT_SET(r->l1, ARCH_CONVERT, XFS_MASK64HI(11) | 2376 (xfs_bmbt_rec_base_t)XFS_MASK64LO(9));
2452 ((xfs_bmbt_rec_base_t)b << 21) | 2377 r->l1 = cpu_to_be64(XFS_MASK64HI(11) |
2453 ((xfs_bmbt_rec_base_t)c & 2378 ((xfs_bmbt_rec_base_t)startblock << 21) |
2379 ((xfs_bmbt_rec_base_t)blockcount &
2454 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); 2380 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)));
2455 } else { 2381 } else {
2456 INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | 2382 r->l0 = cpu_to_be64(
2457 ((xfs_bmbt_rec_base_t)o << 9)); 2383 ((xfs_bmbt_rec_base_t)extent_flag << 63) |
2458 INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)b << 21) | 2384 ((xfs_bmbt_rec_base_t)startoff << 9));
2459 ((xfs_bmbt_rec_base_t)c & 2385 r->l1 = cpu_to_be64(
2460 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); 2386 ((xfs_bmbt_rec_base_t)startblock << 21) |
2387 ((xfs_bmbt_rec_base_t)blockcount &
2388 (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)));
2461 } 2389 }
2462#endif /* XFS_BIG_BLKNOS */ 2390#endif /* XFS_BIG_BLKNOS */
2463} 2391}
2464#endif /* XFS_NATIVE_HOST */ 2392
2393/*
2394 * Set all the fields in a bmap extent record from the uncompressed form.
2395 */
2396void
2397xfs_bmbt_disk_set_all(
2398 xfs_bmbt_rec_t *r,
2399 xfs_bmbt_irec_t *s)
2400{
2401 xfs_bmbt_disk_set_allf(r, s->br_startoff, s->br_startblock,
2402 s->br_blockcount, s->br_state);
2403}
2465 2404
2466/* 2405/*
2467 * Set the blockcount field in a bmap extent record. 2406 * Set the blockcount field in a bmap extent record.
2468 */ 2407 */
2469void 2408void
2470xfs_bmbt_set_blockcount( 2409xfs_bmbt_set_blockcount(
2471 xfs_bmbt_rec_t *r, 2410 xfs_bmbt_rec_host_t *r,
2472 xfs_filblks_t v) 2411 xfs_filblks_t v)
2473{ 2412{
2474 ASSERT((v & XFS_MASK64HI(43)) == 0); 2413 ASSERT((v & XFS_MASK64HI(43)) == 0);
@@ -2481,7 +2420,7 @@ xfs_bmbt_set_blockcount(
2481 */ 2420 */
2482void 2421void
2483xfs_bmbt_set_startblock( 2422xfs_bmbt_set_startblock(
2484 xfs_bmbt_rec_t *r, 2423 xfs_bmbt_rec_host_t *r,
2485 xfs_fsblock_t v) 2424 xfs_fsblock_t v)
2486{ 2425{
2487#if XFS_BIG_BLKNOS 2426#if XFS_BIG_BLKNOS
@@ -2509,7 +2448,7 @@ xfs_bmbt_set_startblock(
2509 */ 2448 */
2510void 2449void
2511xfs_bmbt_set_startoff( 2450xfs_bmbt_set_startoff(
2512 xfs_bmbt_rec_t *r, 2451 xfs_bmbt_rec_host_t *r,
2513 xfs_fileoff_t v) 2452 xfs_fileoff_t v)
2514{ 2453{
2515 ASSERT((v & XFS_MASK64HI(9)) == 0); 2454 ASSERT((v & XFS_MASK64HI(9)) == 0);
@@ -2523,7 +2462,7 @@ xfs_bmbt_set_startoff(
2523 */ 2462 */
2524void 2463void
2525xfs_bmbt_set_state( 2464xfs_bmbt_set_state(
2526 xfs_bmbt_rec_t *r, 2465 xfs_bmbt_rec_host_t *r,
2527 xfs_exntst_t v) 2466 xfs_exntst_t v)
2528{ 2467{
2529 ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN); 2468 ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN);
@@ -2624,10 +2563,8 @@ xfs_check_nostate_extents(
2624 xfs_extnum_t idx, 2563 xfs_extnum_t idx,
2625 xfs_extnum_t num) 2564 xfs_extnum_t num)
2626{ 2565{
2627 xfs_bmbt_rec_t *ep;
2628
2629 for (; num > 0; num--, idx++) { 2566 for (; num > 0; num--, idx++) {
2630 ep = xfs_iext_get_ext(ifp, idx); 2567 xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
2631 if ((ep->l0 >> 2568 if ((ep->l0 >>
2632 (64 - BMBT_EXNTFLAG_BITLEN)) != 0) { 2569 (64 - BMBT_EXNTFLAG_BITLEN)) != 0) {
2633 ASSERT(0); 2570 ASSERT(0);