47
47
*/
48
48
STATIC int xfs_attr3_leaf_create (struct xfs_da_args * args ,
49
49
xfs_dablk_t which_block , struct xfs_buf * * bpp );
50
- STATIC int xfs_attr3_leaf_add_work (struct xfs_buf * leaf_buffer ,
50
+ STATIC void xfs_attr3_leaf_add_work (struct xfs_buf * leaf_buffer ,
51
51
struct xfs_attr3_icleaf_hdr * ichdr ,
52
52
struct xfs_da_args * args , int freemap_index );
53
53
STATIC void xfs_attr3_leaf_compact (struct xfs_da_args * args ,
@@ -995,10 +995,8 @@ xfs_attr_shortform_to_leaf(
995
995
xfs_attr_sethash (& nargs );
996
996
error = xfs_attr3_leaf_lookup_int (bp , & nargs ); /* set a->index */
997
997
ASSERT (error == - ENOATTR );
998
- error = xfs_attr3_leaf_add (bp , & nargs );
999
- ASSERT (error != - ENOSPC );
1000
- if (error )
1001
- goto out ;
998
+ if (!xfs_attr3_leaf_add (bp , & nargs ))
999
+ ASSERT (0 );
1002
1000
sfe = xfs_attr_sf_nextentry (sfe );
1003
1001
}
1004
1002
error = 0 ;
@@ -1340,8 +1338,9 @@ xfs_attr3_leaf_split(
1340
1338
struct xfs_da_state_blk * oldblk ,
1341
1339
struct xfs_da_state_blk * newblk )
1342
1340
{
1343
- xfs_dablk_t blkno ;
1344
- int error ;
1341
+ bool added ;
1342
+ xfs_dablk_t blkno ;
1343
+ int error ;
1345
1344
1346
1345
trace_xfs_attr_leaf_split (state -> args );
1347
1346
@@ -1376,24 +1375,26 @@ xfs_attr3_leaf_split(
1376
1375
*/
1377
1376
if (state -> inleaf ) {
1378
1377
trace_xfs_attr_leaf_add_old (state -> args );
1379
- error = xfs_attr3_leaf_add (oldblk -> bp , state -> args );
1378
+ added = xfs_attr3_leaf_add (oldblk -> bp , state -> args );
1380
1379
} else {
1381
1380
trace_xfs_attr_leaf_add_new (state -> args );
1382
- error = xfs_attr3_leaf_add (newblk -> bp , state -> args );
1381
+ added = xfs_attr3_leaf_add (newblk -> bp , state -> args );
1383
1382
}
1384
1383
1385
1384
/*
1386
1385
* Update last hashval in each block since we added the name.
1387
1386
*/
1388
1387
oldblk -> hashval = xfs_attr_leaf_lasthash (oldblk -> bp , NULL );
1389
1388
newblk -> hashval = xfs_attr_leaf_lasthash (newblk -> bp , NULL );
1390
- return error ;
1389
+ if (!added )
1390
+ return - ENOSPC ;
1391
+ return 0 ;
1391
1392
}
1392
1393
1393
1394
/*
1394
1395
* Add a name to the leaf attribute list structure.
1395
1396
*/
1396
- int
1397
+ bool
1397
1398
xfs_attr3_leaf_add (
1398
1399
struct xfs_buf * bp ,
1399
1400
struct xfs_da_args * args )
@@ -1402,6 +1403,7 @@ xfs_attr3_leaf_add(
1402
1403
struct xfs_attr3_icleaf_hdr ichdr ;
1403
1404
int tablesize ;
1404
1405
int entsize ;
1406
+ bool added = true;
1405
1407
int sum ;
1406
1408
int tmp ;
1407
1409
int i ;
@@ -1430,7 +1432,7 @@ xfs_attr3_leaf_add(
1430
1432
if (ichdr .freemap [i ].base < ichdr .firstused )
1431
1433
tmp += sizeof (xfs_attr_leaf_entry_t );
1432
1434
if (ichdr .freemap [i ].size >= tmp ) {
1433
- tmp = xfs_attr3_leaf_add_work (bp , & ichdr , args , i );
1435
+ xfs_attr3_leaf_add_work (bp , & ichdr , args , i );
1434
1436
goto out_log_hdr ;
1435
1437
}
1436
1438
sum += ichdr .freemap [i ].size ;
@@ -1442,7 +1444,7 @@ xfs_attr3_leaf_add(
1442
1444
* no good and we should just give up.
1443
1445
*/
1444
1446
if (!ichdr .holes && sum < entsize )
1445
- return - ENOSPC ;
1447
+ return false ;
1446
1448
1447
1449
/*
1448
1450
* Compact the entries to coalesce free space.
@@ -1455,24 +1457,24 @@ xfs_attr3_leaf_add(
1455
1457
* free region, in freemap[0]. If it is not big enough, give up.
1456
1458
*/
1457
1459
if (ichdr .freemap [0 ].size < (entsize + sizeof (xfs_attr_leaf_entry_t ))) {
1458
- tmp = - ENOSPC ;
1460
+ added = false ;
1459
1461
goto out_log_hdr ;
1460
1462
}
1461
1463
1462
- tmp = xfs_attr3_leaf_add_work (bp , & ichdr , args , 0 );
1464
+ xfs_attr3_leaf_add_work (bp , & ichdr , args , 0 );
1463
1465
1464
1466
out_log_hdr :
1465
1467
xfs_attr3_leaf_hdr_to_disk (args -> geo , leaf , & ichdr );
1466
1468
xfs_trans_log_buf (args -> trans , bp ,
1467
1469
XFS_DA_LOGRANGE (leaf , & leaf -> hdr ,
1468
1470
xfs_attr3_leaf_hdr_size (leaf )));
1469
- return tmp ;
1471
+ return added ;
1470
1472
}
1471
1473
1472
1474
/*
1473
1475
* Add a name to a leaf attribute list structure.
1474
1476
*/
1475
- STATIC int
1477
+ STATIC void
1476
1478
xfs_attr3_leaf_add_work (
1477
1479
struct xfs_buf * bp ,
1478
1480
struct xfs_attr3_icleaf_hdr * ichdr ,
@@ -1590,7 +1592,6 @@ xfs_attr3_leaf_add_work(
1590
1592
}
1591
1593
}
1592
1594
ichdr -> usedbytes += xfs_attr_leaf_entsize (leaf , args -> index );
1593
- return 0 ;
1594
1595
}
1595
1596
1596
1597
/*
0 commit comments