@@ -382,7 +382,9 @@ tdb_alloc_blk(TdbHdr *dbh)
382
382
* This is only for first blocks in extents, so we lose only
383
383
* TDB_HTRIE_MINDREC - L1_CACHE_BYTES per extent.
384
384
*/
385
- return TDB_HTRIE_DALIGN (rptr );
385
+ rptr = TDB_HTRIE_DALIGN (rptr );
386
+ tdb_get_blk (dbh , rptr );
387
+ return rptr ;
386
388
}
387
389
388
390
static void
@@ -414,6 +416,7 @@ tdb_alloc_blk_freelist(TdbHdr *dbh)
414
416
next = TDB_PTR (dbh , rptr );
415
417
this_cpu_ptr (dbh -> pcpu )-> freelist = * next ;
416
418
419
+ tdb_get_blk (dbh , rptr );
417
420
return rptr ;
418
421
}
419
422
@@ -465,7 +468,6 @@ tdb_alloc_data(TdbHdr *dbh, size_t *len)
465
468
goto out ;
466
469
467
470
BUG_ON (old_rptr == 0 );
468
- tdb_get_blk (dbh , rptr );
469
471
tdb_put_blk (dbh , old_rptr );
470
472
471
473
max_data_len = TDB_BLK_SZ - (rptr & ~TDB_BLK_MASK );
@@ -492,6 +494,9 @@ tdb_alloc_data(TdbHdr *dbh, size_t *len)
492
494
493
495
/**
494
496
* Allocates a new bucket.
497
+ *
498
+ * Never do tdb_htrie_put_rec with bucket block, buckets live forever.
499
+ *
495
500
* @return byte offset of the block.
496
501
*/
497
502
static unsigned long
@@ -515,9 +520,6 @@ tdb_alloc_bucket(TdbHdr *dbh)
515
520
rptr = tdb_alloc_blk (dbh );
516
521
if (!rptr )
517
522
goto out ;
518
-
519
- /* Never put bucket block, buckets live forever */
520
- tdb_get_blk (dbh , rptr );
521
523
}
522
524
523
525
TDB_DBG ("alloc bucket %#lx\n" , rptr );
@@ -534,6 +536,8 @@ tdb_alloc_bucket(TdbHdr *dbh)
534
536
535
537
/**
536
538
* Allocates a new index block.
539
+ *
540
+ * Never do tdb_htrie_put_rec with index block, indexes live forever.
537
541
* @return byte offset of the block.
538
542
*/
539
543
static unsigned long
@@ -556,9 +560,6 @@ tdb_alloc_index(TdbHdr *dbh)
556
560
rptr = tdb_alloc_blk (dbh );
557
561
if (!rptr )
558
562
goto out ;
559
-
560
- /* Never put index block, indexes live forever */
561
- tdb_get_blk (dbh , rptr );
562
563
}
563
564
564
565
TDB_DBG ("alloc iblk %#lx\n" , rptr );
@@ -662,7 +663,6 @@ tdb_htrie_burst(TdbHdr *dbh, TdbHtrieNode **node, TdbBucket *bckt,
662
663
if (!n )
663
664
return - ENOMEM ;
664
665
new_in = TDB_PTR (dbh , n );
665
- tdb_get_blk (dbh , n );
666
666
new_in_idx = TDB_O2II (n );
667
667
668
668
/* We must not burst empty bucket, just reuse it. */
@@ -1367,9 +1367,6 @@ tdb_htrie_init(void *p, size_t db_size, unsigned int rec_len)
1367
1367
p -> b_wcl = tdb_alloc_blk (hdr );
1368
1368
p -> i_wcl = tdb_alloc_blk (hdr );
1369
1369
p -> d_wcl = tdb_alloc_blk (hdr );
1370
- tdb_get_blk (hdr , p -> b_wcl & TDB_BLK_MASK );
1371
- tdb_get_blk (hdr , p -> i_wcl & TDB_BLK_MASK );
1372
- tdb_get_blk (hdr , p -> d_wcl & TDB_BLK_MASK );
1373
1370
}
1374
1371
1375
1372
TDB_DBG ("init db header: nwb=%llu db_size=%lu rec_len=%u\n" ,
0 commit comments