diff options
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.c')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 200 |
1 files changed, 74 insertions, 126 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index e54c71e20e0e..abe35553969b 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -2291,177 +2291,125 @@ xfs_bmbt_newroot( | |||
2291 | } | 2291 | } |
2292 | 2292 | ||
2293 | /* | 2293 | /* |
2294 | * Set all the fields in a bmap extent record from the uncompressed form. | ||
2295 | */ | ||
2296 | void | ||
2297 | xfs_bmbt_set_all( | ||
2298 | xfs_bmbt_rec_host_t *r, | ||
2299 | xfs_bmbt_irec_t *s) | ||
2300 | { | ||
2301 | int extent_flag; | ||
2302 | |||
2303 | ASSERT((s->br_state == XFS_EXT_NORM) || | ||
2304 | (s->br_state == XFS_EXT_UNWRITTEN)); | ||
2305 | extent_flag = (s->br_state == XFS_EXT_NORM) ? 0 : 1; | ||
2306 | ASSERT((s->br_startoff & XFS_MASK64HI(9)) == 0); | ||
2307 | ASSERT((s->br_blockcount & XFS_MASK64HI(43)) == 0); | ||
2308 | #if XFS_BIG_BLKNOS | ||
2309 | ASSERT((s->br_startblock & XFS_MASK64HI(12)) == 0); | ||
2310 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
2311 | ((xfs_bmbt_rec_base_t)s->br_startoff << 9) | | ||
2312 | ((xfs_bmbt_rec_base_t)s->br_startblock >> 43); | ||
2313 | r->l1 = ((xfs_bmbt_rec_base_t)s->br_startblock << 21) | | ||
2314 | ((xfs_bmbt_rec_base_t)s->br_blockcount & | ||
2315 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); | ||
2316 | #else /* !XFS_BIG_BLKNOS */ | ||
2317 | if (ISNULLSTARTBLOCK(s->br_startblock)) { | ||
2318 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
2319 | ((xfs_bmbt_rec_base_t)s->br_startoff << 9) | | ||
2320 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(9); | ||
2321 | r->l1 = XFS_MASK64HI(11) | | ||
2322 | ((xfs_bmbt_rec_base_t)s->br_startblock << 21) | | ||
2323 | ((xfs_bmbt_rec_base_t)s->br_blockcount & | ||
2324 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); | ||
2325 | } else { | ||
2326 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
2327 | ((xfs_bmbt_rec_base_t)s->br_startoff << 9); | ||
2328 | r->l1 = ((xfs_bmbt_rec_base_t)s->br_startblock << 21) | | ||
2329 | ((xfs_bmbt_rec_base_t)s->br_blockcount & | ||
2330 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); | ||
2331 | } | ||
2332 | #endif /* XFS_BIG_BLKNOS */ | ||
2333 | } | ||
2334 | |||
2335 | /* | ||
2336 | * Set all the fields in a bmap extent record from the arguments. | 2294 | * Set all the fields in a bmap extent record from the arguments. |
2337 | */ | 2295 | */ |
2338 | void | 2296 | void |
2339 | xfs_bmbt_set_allf( | 2297 | xfs_bmbt_set_allf( |
2340 | xfs_bmbt_rec_host_t *r, | 2298 | xfs_bmbt_rec_host_t *r, |
2341 | xfs_fileoff_t o, | 2299 | xfs_fileoff_t startoff, |
2342 | xfs_fsblock_t b, | 2300 | xfs_fsblock_t startblock, |
2343 | xfs_filblks_t c, | 2301 | xfs_filblks_t blockcount, |
2344 | xfs_exntst_t v) | 2302 | xfs_exntst_t state) |
2345 | { | 2303 | { |
2346 | int extent_flag; | 2304 | int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1; |
2305 | |||
2306 | ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN); | ||
2307 | ASSERT((startoff & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0); | ||
2308 | ASSERT((blockcount & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); | ||
2347 | 2309 | ||
2348 | ASSERT((v == XFS_EXT_NORM) || (v == XFS_EXT_UNWRITTEN)); | ||
2349 | extent_flag = (v == XFS_EXT_NORM) ? 0 : 1; | ||
2350 | ASSERT((o & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0); | ||
2351 | ASSERT((c & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); | ||
2352 | #if XFS_BIG_BLKNOS | 2310 | #if XFS_BIG_BLKNOS |
2353 | ASSERT((b & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); | 2311 | ASSERT((startblock & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); |
2312 | |||
2354 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 2313 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
2355 | ((xfs_bmbt_rec_base_t)o << 9) | | 2314 | ((xfs_bmbt_rec_base_t)startoff << 9) | |
2356 | ((xfs_bmbt_rec_base_t)b >> 43); | 2315 | ((xfs_bmbt_rec_base_t)startblock >> 43); |
2357 | r->l1 = ((xfs_bmbt_rec_base_t)b << 21) | | 2316 | r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | |
2358 | ((xfs_bmbt_rec_base_t)c & | 2317 | ((xfs_bmbt_rec_base_t)blockcount & |
2359 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); | 2318 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); |
2360 | #else /* !XFS_BIG_BLKNOS */ | 2319 | #else /* !XFS_BIG_BLKNOS */ |
2361 | if (ISNULLSTARTBLOCK(b)) { | 2320 | if (ISNULLSTARTBLOCK(b)) { |
2362 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 2321 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
2363 | ((xfs_bmbt_rec_base_t)o << 9) | | 2322 | ((xfs_bmbt_rec_base_t)startoff << 9) | |
2364 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(9); | 2323 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(9); |
2365 | r->l1 = XFS_MASK64HI(11) | | 2324 | r->l1 = XFS_MASK64HI(11) | |
2366 | ((xfs_bmbt_rec_base_t)b << 21) | | 2325 | ((xfs_bmbt_rec_base_t)startblock << 21) | |
2367 | ((xfs_bmbt_rec_base_t)c & | 2326 | ((xfs_bmbt_rec_base_t)blockcount & |
2368 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); | 2327 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); |
2369 | } else { | 2328 | } else { |
2370 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 2329 | r->l0 = ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
2371 | ((xfs_bmbt_rec_base_t)o << 9); | 2330 | ((xfs_bmbt_rec_base_t)startoff << 9); |
2372 | r->l1 = ((xfs_bmbt_rec_base_t)b << 21) | | 2331 | r->l1 = ((xfs_bmbt_rec_base_t)startblock << 21) | |
2373 | ((xfs_bmbt_rec_base_t)c & | 2332 | ((xfs_bmbt_rec_base_t)blockcount & |
2374 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); | 2333 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21)); |
2375 | } | 2334 | } |
2376 | #endif /* XFS_BIG_BLKNOS */ | 2335 | #endif /* XFS_BIG_BLKNOS */ |
2377 | } | 2336 | } |
2378 | 2337 | ||
2379 | #ifndef XFS_NATIVE_HOST | ||
2380 | /* | 2338 | /* |
2381 | * Set all the fields in a bmap extent record from the uncompressed form. | 2339 | * Set all the fields in a bmap extent record from the uncompressed form. |
2382 | */ | 2340 | */ |
2383 | void | 2341 | void |
2384 | xfs_bmbt_disk_set_all( | 2342 | xfs_bmbt_set_all( |
2385 | xfs_bmbt_rec_t *r, | 2343 | xfs_bmbt_rec_host_t *r, |
2386 | xfs_bmbt_irec_t *s) | 2344 | xfs_bmbt_irec_t *s) |
2387 | { | 2345 | { |
2388 | int extent_flag; | 2346 | xfs_bmbt_set_allf(r, s->br_startoff, s->br_startblock, |
2389 | 2347 | s->br_blockcount, s->br_state); | |
2390 | ASSERT((s->br_state == XFS_EXT_NORM) || | ||
2391 | (s->br_state == XFS_EXT_UNWRITTEN)); | ||
2392 | extent_flag = (s->br_state == XFS_EXT_NORM) ? 0 : 1; | ||
2393 | ASSERT((s->br_startoff & XFS_MASK64HI(9)) == 0); | ||
2394 | ASSERT((s->br_blockcount & XFS_MASK64HI(43)) == 0); | ||
2395 | #if XFS_BIG_BLKNOS | ||
2396 | ASSERT((s->br_startblock & XFS_MASK64HI(12)) == 0); | ||
2397 | INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
2398 | ((xfs_bmbt_rec_base_t)s->br_startoff << 9) | | ||
2399 | ((xfs_bmbt_rec_base_t)s->br_startblock >> 43)); | ||
2400 | INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)s->br_startblock << 21) | | ||
2401 | ((xfs_bmbt_rec_base_t)s->br_blockcount & | ||
2402 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | ||
2403 | #else /* !XFS_BIG_BLKNOS */ | ||
2404 | if (ISNULLSTARTBLOCK(s->br_startblock)) { | ||
2405 | INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
2406 | ((xfs_bmbt_rec_base_t)s->br_startoff << 9) | | ||
2407 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(9)); | ||
2408 | INT_SET(r->l1, ARCH_CONVERT, XFS_MASK64HI(11) | | ||
2409 | ((xfs_bmbt_rec_base_t)s->br_startblock << 21) | | ||
2410 | ((xfs_bmbt_rec_base_t)s->br_blockcount & | ||
2411 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | ||
2412 | } else { | ||
2413 | INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | | ||
2414 | ((xfs_bmbt_rec_base_t)s->br_startoff << 9)); | ||
2415 | INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)s->br_startblock << 21) | | ||
2416 | ((xfs_bmbt_rec_base_t)s->br_blockcount & | ||
2417 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | ||
2418 | } | ||
2419 | #endif /* XFS_BIG_BLKNOS */ | ||
2420 | } | 2348 | } |
2421 | 2349 | ||
2350 | |||
2351 | #ifndef XFS_NATIVE_HOST | ||
2422 | /* | 2352 | /* |
2423 | * Set all the fields in a disk format bmap extent record from the arguments. | 2353 | * Set all the fields in a disk format bmap extent record from the arguments. |
2424 | */ | 2354 | */ |
2425 | void | 2355 | void |
2426 | xfs_bmbt_disk_set_allf( | 2356 | xfs_bmbt_disk_set_allf( |
2427 | xfs_bmbt_rec_t *r, | 2357 | xfs_bmbt_rec_t *r, |
2428 | xfs_fileoff_t o, | 2358 | xfs_fileoff_t startoff, |
2429 | xfs_fsblock_t b, | 2359 | xfs_fsblock_t startblock, |
2430 | xfs_filblks_t c, | 2360 | xfs_filblks_t blockcount, |
2431 | xfs_exntst_t v) | 2361 | xfs_exntst_t state) |
2432 | { | 2362 | { |
2433 | int extent_flag; | 2363 | int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1; |
2364 | |||
2365 | ASSERT(state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN); | ||
2366 | ASSERT((startoff & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0); | ||
2367 | ASSERT((blockcount & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); | ||
2434 | 2368 | ||
2435 | ASSERT((v == XFS_EXT_NORM) || (v == XFS_EXT_UNWRITTEN)); | ||
2436 | extent_flag = (v == XFS_EXT_NORM) ? 0 : 1; | ||
2437 | ASSERT((o & XFS_MASK64HI(64-BMBT_STARTOFF_BITLEN)) == 0); | ||
2438 | ASSERT((c & XFS_MASK64HI(64-BMBT_BLOCKCOUNT_BITLEN)) == 0); | ||
2439 | #if XFS_BIG_BLKNOS | 2369 | #if XFS_BIG_BLKNOS |
2440 | ASSERT((b & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); | 2370 | ASSERT((startblock & XFS_MASK64HI(64-BMBT_STARTBLOCK_BITLEN)) == 0); |
2441 | INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 2371 | |
2442 | ((xfs_bmbt_rec_base_t)o << 9) | | 2372 | INT_SET(r->l0, ARCH_CONVERT, |
2443 | ((xfs_bmbt_rec_base_t)b >> 43)); | 2373 | ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
2444 | INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)b << 21) | | 2374 | ((xfs_bmbt_rec_base_t)startoff << 9) | |
2445 | ((xfs_bmbt_rec_base_t)c & | 2375 | ((xfs_bmbt_rec_base_t)startblock >> 43)); |
2446 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | 2376 | INT_SET(r->l1, ARCH_CONVERT, |
2377 | ((xfs_bmbt_rec_base_t)startblock << 21) | | ||
2378 | ((xfs_bmbt_rec_base_t)blockcount & | ||
2379 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | ||
2447 | #else /* !XFS_BIG_BLKNOS */ | 2380 | #else /* !XFS_BIG_BLKNOS */ |
2448 | if (ISNULLSTARTBLOCK(b)) { | 2381 | if (ISNULLSTARTBLOCK(b)) { |
2449 | INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 2382 | INT_SET(r->l0, ARCH_CONVERT, |
2450 | ((xfs_bmbt_rec_base_t)o << 9) | | 2383 | ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
2451 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(9)); | 2384 | ((xfs_bmbt_rec_base_t)startoff << 9) | |
2385 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(9)); | ||
2452 | INT_SET(r->l1, ARCH_CONVERT, XFS_MASK64HI(11) | | 2386 | INT_SET(r->l1, ARCH_CONVERT, XFS_MASK64HI(11) | |
2453 | ((xfs_bmbt_rec_base_t)b << 21) | | 2387 | ((xfs_bmbt_rec_base_t)startblock << 21) | |
2454 | ((xfs_bmbt_rec_base_t)c & | 2388 | ((xfs_bmbt_rec_base_t)blockcount & |
2455 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | 2389 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); |
2456 | } else { | 2390 | } else { |
2457 | INT_SET(r->l0, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)extent_flag << 63) | | 2391 | INT_SET(r->l0, ARCH_CONVERT, |
2458 | ((xfs_bmbt_rec_base_t)o << 9)); | 2392 | ((xfs_bmbt_rec_base_t)extent_flag << 63) | |
2459 | INT_SET(r->l1, ARCH_CONVERT, ((xfs_bmbt_rec_base_t)b << 21) | | 2393 | ((xfs_bmbt_rec_base_t)startoff << 9)); |
2460 | ((xfs_bmbt_rec_base_t)c & | 2394 | INT_SET(r->l1, ARCH_CONVERT, |
2461 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | 2395 | ((xfs_bmbt_rec_base_t)startblock << 21) | |
2396 | ((xfs_bmbt_rec_base_t)blockcount & | ||
2397 | (xfs_bmbt_rec_base_t)XFS_MASK64LO(21))); | ||
2462 | } | 2398 | } |
2463 | #endif /* XFS_BIG_BLKNOS */ | 2399 | #endif /* XFS_BIG_BLKNOS */ |
2464 | } | 2400 | } |
2401 | |||
2402 | /* | ||
2403 | * Set all the fields in a bmap extent record from the uncompressed form. | ||
2404 | */ | ||
2405 | void | ||
2406 | xfs_bmbt_disk_set_all( | ||
2407 | xfs_bmbt_rec_t *r, | ||
2408 | xfs_bmbt_irec_t *s) | ||
2409 | { | ||
2410 | xfs_bmbt_disk_set_allf(r, s->br_startoff, s->br_startblock, | ||
2411 | s->br_blockcount, s->br_state); | ||
2412 | } | ||
2465 | #endif /* XFS_NATIVE_HOST */ | 2413 | #endif /* XFS_NATIVE_HOST */ |
2466 | 2414 | ||
2467 | /* | 2415 | /* |