@@ -331,46 +331,66 @@ const struct xfs_buf_ops xfs_da3_node_buf_ops = {
331
331
.verify_struct = xfs_da3_node_verify_struct ,
332
332
};
333
333
334
+ static int
335
+ xfs_da3_node_set_type (
336
+ struct xfs_trans * tp ,
337
+ struct xfs_buf * bp )
338
+ {
339
+ struct xfs_da_blkinfo * info = bp -> b_addr ;
340
+
341
+ switch (be16_to_cpu (info -> magic )) {
342
+ case XFS_DA_NODE_MAGIC :
343
+ case XFS_DA3_NODE_MAGIC :
344
+ xfs_trans_buf_set_type (tp , bp , XFS_BLFT_DA_NODE_BUF );
345
+ return 0 ;
346
+ case XFS_ATTR_LEAF_MAGIC :
347
+ case XFS_ATTR3_LEAF_MAGIC :
348
+ xfs_trans_buf_set_type (tp , bp , XFS_BLFT_ATTR_LEAF_BUF );
349
+ return 0 ;
350
+ case XFS_DIR2_LEAFN_MAGIC :
351
+ case XFS_DIR3_LEAFN_MAGIC :
352
+ xfs_trans_buf_set_type (tp , bp , XFS_BLFT_DIR_LEAFN_BUF );
353
+ return 0 ;
354
+ default :
355
+ XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW , tp -> t_mountp ,
356
+ info , sizeof (* info ));
357
+ xfs_trans_brelse (tp , bp );
358
+ return - EFSCORRUPTED ;
359
+ }
360
+ }
361
+
334
362
int
335
363
xfs_da3_node_read (
336
364
struct xfs_trans * tp ,
337
365
struct xfs_inode * dp ,
338
366
xfs_dablk_t bno ,
339
- xfs_daddr_t mappedbno ,
340
367
struct xfs_buf * * bpp ,
341
- int which_fork )
368
+ int whichfork )
342
369
{
343
- int err ;
370
+ int error ;
344
371
345
- err = xfs_da_read_buf (tp , dp , bno , mappedbno , bpp ,
346
- which_fork , & xfs_da3_node_buf_ops );
347
- if (!err && tp && * bpp ) {
348
- struct xfs_da_blkinfo * info = (* bpp )-> b_addr ;
349
- int type ;
372
+ error = xfs_da_read_buf (tp , dp , bno , -1 , bpp , whichfork ,
373
+ & xfs_da3_node_buf_ops );
374
+ if (error || !* bpp || !tp )
375
+ return error ;
376
+ return xfs_da3_node_set_type (tp , * bpp );
377
+ }
350
378
351
- switch (be16_to_cpu (info -> magic )) {
352
- case XFS_DA_NODE_MAGIC :
353
- case XFS_DA3_NODE_MAGIC :
354
- type = XFS_BLFT_DA_NODE_BUF ;
355
- break ;
356
- case XFS_ATTR_LEAF_MAGIC :
357
- case XFS_ATTR3_LEAF_MAGIC :
358
- type = XFS_BLFT_ATTR_LEAF_BUF ;
359
- break ;
360
- case XFS_DIR2_LEAFN_MAGIC :
361
- case XFS_DIR3_LEAFN_MAGIC :
362
- type = XFS_BLFT_DIR_LEAFN_BUF ;
363
- break ;
364
- default :
365
- XFS_CORRUPTION_ERROR (__func__ , XFS_ERRLEVEL_LOW ,
366
- tp -> t_mountp , info , sizeof (* info ));
367
- xfs_trans_brelse (tp , * bpp );
368
- * bpp = NULL ;
369
- return - EFSCORRUPTED ;
370
- }
371
- xfs_trans_buf_set_type (tp , * bpp , type );
372
- }
373
- return err ;
379
+ int
380
+ xfs_da3_node_read_mapped (
381
+ struct xfs_trans * tp ,
382
+ struct xfs_inode * dp ,
383
+ xfs_daddr_t mappedbno ,
384
+ struct xfs_buf * * bpp ,
385
+ int whichfork )
386
+ {
387
+ int error ;
388
+
389
+ error = xfs_da_read_buf (tp , dp , 0 , mappedbno , bpp , whichfork ,
390
+ & xfs_da3_node_buf_ops );
391
+ if (error || !* bpp || !tp )
392
+ return error ;
393
+ return xfs_da3_node_set_type (tp , * bpp );
374
394
}
375
395
376
396
/*========================================================================
@@ -1166,8 +1186,7 @@ xfs_da3_root_join(
1166
1186
*/
1167
1187
child = be32_to_cpu (oldroothdr .btree [0 ].before );
1168
1188
ASSERT (child != 0 );
1169
- error = xfs_da3_node_read (args -> trans , dp , child , -1 , & bp ,
1170
- args -> whichfork );
1189
+ error = xfs_da3_node_read (args -> trans , dp , child , & bp , args -> whichfork );
1171
1190
if (error )
1172
1191
return error ;
1173
1192
xfs_da_blkinfo_onlychild_validate (bp -> b_addr , oldroothdr .level );
@@ -1281,8 +1300,8 @@ xfs_da3_node_toosmall(
1281
1300
blkno = nodehdr .back ;
1282
1301
if (blkno == 0 )
1283
1302
continue ;
1284
- error = xfs_da3_node_read (state -> args -> trans , dp ,
1285
- blkno , -1 , & bp , state -> args -> whichfork );
1303
+ error = xfs_da3_node_read (state -> args -> trans , dp , blkno , & bp ,
1304
+ state -> args -> whichfork );
1286
1305
if (error )
1287
1306
return error ;
1288
1307
@@ -1570,7 +1589,7 @@ xfs_da3_node_lookup_int(
1570
1589
*/
1571
1590
blk -> blkno = blkno ;
1572
1591
error = xfs_da3_node_read (args -> trans , args -> dp , blkno ,
1573
- -1 , & blk -> bp , args -> whichfork );
1592
+ & blk -> bp , args -> whichfork );
1574
1593
if (error ) {
1575
1594
blk -> blkno = 0 ;
1576
1595
state -> path .active -- ;
@@ -1804,7 +1823,7 @@ xfs_da3_blk_link(
1804
1823
if (old_info -> back ) {
1805
1824
error = xfs_da3_node_read (args -> trans , dp ,
1806
1825
be32_to_cpu (old_info -> back ),
1807
- -1 , & bp , args -> whichfork );
1826
+ & bp , args -> whichfork );
1808
1827
if (error )
1809
1828
return error ;
1810
1829
ASSERT (bp != NULL );
@@ -1825,7 +1844,7 @@ xfs_da3_blk_link(
1825
1844
if (old_info -> forw ) {
1826
1845
error = xfs_da3_node_read (args -> trans , dp ,
1827
1846
be32_to_cpu (old_info -> forw ),
1828
- -1 , & bp , args -> whichfork );
1847
+ & bp , args -> whichfork );
1829
1848
if (error )
1830
1849
return error ;
1831
1850
ASSERT (bp != NULL );
@@ -1884,7 +1903,7 @@ xfs_da3_blk_unlink(
1884
1903
if (drop_info -> back ) {
1885
1904
error = xfs_da3_node_read (args -> trans , args -> dp ,
1886
1905
be32_to_cpu (drop_info -> back ),
1887
- -1 , & bp , args -> whichfork );
1906
+ & bp , args -> whichfork );
1888
1907
if (error )
1889
1908
return error ;
1890
1909
ASSERT (bp != NULL );
@@ -1901,7 +1920,7 @@ xfs_da3_blk_unlink(
1901
1920
if (drop_info -> forw ) {
1902
1921
error = xfs_da3_node_read (args -> trans , args -> dp ,
1903
1922
be32_to_cpu (drop_info -> forw ),
1904
- -1 , & bp , args -> whichfork );
1923
+ & bp , args -> whichfork );
1905
1924
if (error )
1906
1925
return error ;
1907
1926
ASSERT (bp != NULL );
@@ -1985,7 +2004,7 @@ xfs_da3_path_shift(
1985
2004
/*
1986
2005
* Read the next child block into a local buffer.
1987
2006
*/
1988
- error = xfs_da3_node_read (args -> trans , dp , blkno , -1 , & bp ,
2007
+ error = xfs_da3_node_read (args -> trans , dp , blkno , & bp ,
1989
2008
args -> whichfork );
1990
2009
if (error )
1991
2010
return error ;
@@ -2263,7 +2282,7 @@ xfs_da3_swap_lastblock(
2263
2282
* Read the last block in the btree space.
2264
2283
*/
2265
2284
last_blkno = (xfs_dablk_t )lastoff - args -> geo -> fsbcount ;
2266
- error = xfs_da3_node_read (tp , dp , last_blkno , -1 , & last_buf , w );
2285
+ error = xfs_da3_node_read (tp , dp , last_blkno , & last_buf , w );
2267
2286
if (error )
2268
2287
return error ;
2269
2288
/*
@@ -2300,7 +2319,7 @@ xfs_da3_swap_lastblock(
2300
2319
* If the moved block has a left sibling, fix up the pointers.
2301
2320
*/
2302
2321
if ((sib_blkno = be32_to_cpu (dead_info -> back ))) {
2303
- error = xfs_da3_node_read (tp , dp , sib_blkno , -1 , & sib_buf , w );
2322
+ error = xfs_da3_node_read (tp , dp , sib_blkno , & sib_buf , w );
2304
2323
if (error )
2305
2324
goto done ;
2306
2325
sib_info = sib_buf -> b_addr ;
@@ -2320,7 +2339,7 @@ xfs_da3_swap_lastblock(
2320
2339
* If the moved block has a right sibling, fix up the pointers.
2321
2340
*/
2322
2341
if ((sib_blkno = be32_to_cpu (dead_info -> forw ))) {
2323
- error = xfs_da3_node_read (tp , dp , sib_blkno , -1 , & sib_buf , w );
2342
+ error = xfs_da3_node_read (tp , dp , sib_blkno , & sib_buf , w );
2324
2343
if (error )
2325
2344
goto done ;
2326
2345
sib_info = sib_buf -> b_addr ;
@@ -2342,7 +2361,7 @@ xfs_da3_swap_lastblock(
2342
2361
* Walk down the tree looking for the parent of the moved block.
2343
2362
*/
2344
2363
for (;;) {
2345
- error = xfs_da3_node_read (tp , dp , par_blkno , -1 , & par_buf , w );
2364
+ error = xfs_da3_node_read (tp , dp , par_blkno , & par_buf , w );
2346
2365
if (error )
2347
2366
goto done ;
2348
2367
par_node = par_buf -> b_addr ;
@@ -2388,7 +2407,7 @@ xfs_da3_swap_lastblock(
2388
2407
error = - EFSCORRUPTED ;
2389
2408
goto done ;
2390
2409
}
2391
- error = xfs_da3_node_read (tp , dp , par_blkno , -1 , & par_buf , w );
2410
+ error = xfs_da3_node_read (tp , dp , par_blkno , & par_buf , w );
2392
2411
if (error )
2393
2412
goto done ;
2394
2413
par_node = par_buf -> b_addr ;
0 commit comments