@@ -667,7 +667,7 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,
667
667
write_object_file_prepare (algo , buf , len , type , oid , hdr , & hdrlen );
668
668
}
669
669
670
- struct bulk_checkin_packfile {
670
+ struct transaction_packfile {
671
671
char * pack_tmp_name ;
672
672
struct hashfile * f ;
673
673
off_t offset ;
@@ -682,10 +682,10 @@ struct odb_transaction {
682
682
struct object_database * odb ;
683
683
684
684
struct tmp_objdir * objdir ;
685
- struct bulk_checkin_packfile packfile ;
685
+ struct transaction_packfile packfile ;
686
686
};
687
687
688
- static void prepare_loose_object_bulk_checkin (struct odb_transaction * transaction )
688
+ static void prepare_loose_object_transaction (struct odb_transaction * transaction )
689
689
{
690
690
/*
691
691
* We lazily create the temporary object directory
@@ -701,7 +701,7 @@ static void prepare_loose_object_bulk_checkin(struct odb_transaction *transactio
701
701
tmp_objdir_replace_primary_odb (transaction -> objdir , 0 );
702
702
}
703
703
704
- static void fsync_loose_object_bulk_checkin (struct odb_transaction * transaction ,
704
+ static void fsync_loose_object_transaction (struct odb_transaction * transaction ,
705
705
int fd , const char * filename )
706
706
{
707
707
/*
@@ -722,7 +722,7 @@ static void fsync_loose_object_bulk_checkin(struct odb_transaction *transaction,
722
722
/*
723
723
* Cleanup after batch-mode fsync_object_files.
724
724
*/
725
- static void flush_batch_fsync (struct odb_transaction * transaction )
725
+ static void flush_loose_object_transaction (struct odb_transaction * transaction )
726
726
{
727
727
struct strbuf temp_path = STRBUF_INIT ;
728
728
struct tempfile * temp ;
@@ -733,7 +733,7 @@ static void flush_batch_fsync(struct odb_transaction *transaction)
733
733
/*
734
734
* Issue a full hardware flush against a temporary file to ensure
735
735
* that all objects are durable before any renames occur. The code in
736
- * fsync_loose_object_bulk_checkin has already issued a writeout
736
+ * fsync_loose_object_transaction has already issued a writeout
737
737
* request, but it has not flushed any writeback cache in the storage
738
738
* hardware or any filesystem logs. This fsync call acts as a barrier
739
739
* to ensure that the data in each new object file is durable before
@@ -762,7 +762,7 @@ static void close_loose_object(struct odb_source *source,
762
762
goto out ;
763
763
764
764
if (batch_fsync_enabled (FSYNC_COMPONENT_LOOSE_OBJECT ))
765
- fsync_loose_object_bulk_checkin (source -> odb -> transaction , fd , filename );
765
+ fsync_loose_object_transaction (source -> odb -> transaction , fd , filename );
766
766
else if (fsync_object_files > 0 )
767
767
fsync_or_die (fd , filename );
768
768
else
@@ -940,7 +940,7 @@ static int write_loose_object(struct odb_source *source,
940
940
static struct strbuf filename = STRBUF_INIT ;
941
941
942
942
if (batch_fsync_enabled (FSYNC_COMPONENT_LOOSE_OBJECT ))
943
- prepare_loose_object_bulk_checkin (source -> odb -> transaction );
943
+ prepare_loose_object_transaction (source -> odb -> transaction );
944
944
945
945
odb_loose_path (source , & filename , oid );
946
946
@@ -1029,7 +1029,7 @@ int stream_loose_object(struct odb_source *source,
1029
1029
int hdrlen ;
1030
1030
1031
1031
if (batch_fsync_enabled (FSYNC_COMPONENT_LOOSE_OBJECT ))
1032
- prepare_loose_object_bulk_checkin (source -> odb -> transaction );
1032
+ prepare_loose_object_transaction (source -> odb -> transaction );
1033
1033
1034
1034
/* Since oid is not determined, save tmp file to odb path. */
1035
1035
strbuf_addf (& filename , "%s/" , source -> path );
@@ -1349,10 +1349,10 @@ static int already_written(struct odb_transaction *transaction,
1349
1349
}
1350
1350
1351
1351
/* Lazily create backing packfile for the state */
1352
- static void prepare_to_stream (struct odb_transaction * transaction ,
1353
- unsigned flags )
1352
+ static void prepare_packfile_transaction (struct odb_transaction * transaction ,
1353
+ unsigned flags )
1354
1354
{
1355
- struct bulk_checkin_packfile * state = & transaction -> packfile ;
1355
+ struct transaction_packfile * state = & transaction -> packfile ;
1356
1356
if (!(flags & INDEX_WRITE_OBJECT ) || state -> f )
1357
1357
return ;
1358
1358
@@ -1381,7 +1381,7 @@ static void prepare_to_stream(struct odb_transaction *transaction,
1381
1381
* status before calling us just in case we ask it to call us again
1382
1382
* with a new pack.
1383
1383
*/
1384
- static int stream_blob_to_pack (struct bulk_checkin_packfile * state ,
1384
+ static int stream_blob_to_pack (struct transaction_packfile * state ,
1385
1385
struct git_hash_ctx * ctx , off_t * already_hashed_to ,
1386
1386
int fd , size_t size , const char * path ,
1387
1387
unsigned flags )
@@ -1457,28 +1457,13 @@ static int stream_blob_to_pack(struct bulk_checkin_packfile *state,
1457
1457
return 0 ;
1458
1458
}
1459
1459
1460
- static void finish_tmp_packfile (struct odb_transaction * transaction ,
1461
- struct strbuf * basename ,
1462
- unsigned char hash [])
1460
+ static void flush_packfile_transaction (struct odb_transaction * transaction )
1463
1461
{
1464
- struct bulk_checkin_packfile * state = & transaction -> packfile ;
1465
- struct repository * repo = transaction -> odb -> repo ;
1466
- char * idx_tmp_name = NULL ;
1467
-
1468
- stage_tmp_packfiles (repo , basename , state -> pack_tmp_name ,
1469
- state -> written , state -> nr_written , NULL ,
1470
- & state -> pack_idx_opts , hash , & idx_tmp_name );
1471
- rename_tmp_packfile_idx (repo , basename , & idx_tmp_name );
1472
-
1473
- free (idx_tmp_name );
1474
- }
1475
-
1476
- static void flush_bulk_checkin_packfile (struct odb_transaction * transaction )
1477
- {
1478
- struct bulk_checkin_packfile * state = & transaction -> packfile ;
1462
+ struct transaction_packfile * state = & transaction -> packfile ;
1479
1463
struct repository * repo = transaction -> odb -> repo ;
1480
1464
unsigned char hash [GIT_MAX_RAWSZ ];
1481
1465
struct strbuf packname = STRBUF_INIT ;
1466
+ char * idx_tmp_name = NULL ;
1482
1467
1483
1468
if (!state -> f )
1484
1469
return ;
@@ -1503,11 +1488,16 @@ static void flush_bulk_checkin_packfile(struct odb_transaction *transaction)
1503
1488
repo_get_object_directory (transaction -> odb -> repo ),
1504
1489
hash_to_hex_algop (hash , repo -> hash_algo ));
1505
1490
1506
- finish_tmp_packfile (transaction , & packname , hash );
1491
+ stage_tmp_packfiles (repo , & packname , state -> pack_tmp_name ,
1492
+ state -> written , state -> nr_written , NULL ,
1493
+ & state -> pack_idx_opts , hash , & idx_tmp_name );
1494
+ rename_tmp_packfile_idx (repo , & packname , & idx_tmp_name );
1495
+
1507
1496
for (uint32_t i = 0 ; i < state -> nr_written ; i ++ )
1508
1497
free (state -> written [i ]);
1509
1498
1510
1499
clear_exit :
1500
+ free (idx_tmp_name );
1511
1501
free (state -> pack_tmp_name );
1512
1502
free (state -> written );
1513
1503
memset (state , 0 , sizeof (* state ));
@@ -1535,11 +1525,12 @@ static void flush_bulk_checkin_packfile(struct odb_transaction *transaction)
1535
1525
* binary blobs, they generally do not want to get any conversion, and
1536
1526
* callers should avoid this code path when filters are requested.
1537
1527
*/
1538
- static int index_blob_bulk_checkin (struct odb_transaction * transaction ,
1539
- struct object_id * result_oid , int fd , size_t size ,
1540
- const char * path , unsigned flags )
1528
+ static int index_blob_packfile_transaction (struct odb_transaction * transaction ,
1529
+ struct object_id * result_oid , int fd ,
1530
+ size_t size , const char * path ,
1531
+ unsigned flags )
1541
1532
{
1542
- struct bulk_checkin_packfile * state = & transaction -> packfile ;
1533
+ struct transaction_packfile * state = & transaction -> packfile ;
1543
1534
off_t seekback , already_hashed_to ;
1544
1535
struct git_hash_ctx ctx ;
1545
1536
unsigned char obuf [16384 ];
@@ -1560,14 +1551,14 @@ static int index_blob_bulk_checkin(struct odb_transaction *transaction,
1560
1551
if ((flags & INDEX_WRITE_OBJECT ) != 0 ) {
1561
1552
CALLOC_ARRAY (idx , 1 );
1562
1553
1563
- prepare_to_stream (transaction , flags );
1554
+ prepare_packfile_transaction (transaction , flags );
1564
1555
hashfile_checkpoint_init (state -> f , & checkpoint );
1565
1556
}
1566
1557
1567
1558
already_hashed_to = 0 ;
1568
1559
1569
1560
while (1 ) {
1570
- prepare_to_stream (transaction , flags );
1561
+ prepare_packfile_transaction (transaction , flags );
1571
1562
if (idx ) {
1572
1563
hashfile_checkpoint (state -> f , & checkpoint );
1573
1564
idx -> offset = state -> offset ;
@@ -1585,7 +1576,7 @@ static int index_blob_bulk_checkin(struct odb_transaction *transaction,
1585
1576
BUG ("should not happen" );
1586
1577
hashfile_truncate (state -> f , & checkpoint );
1587
1578
state -> offset = checkpoint .offset ;
1588
- flush_bulk_checkin_packfile (transaction );
1579
+ flush_packfile_transaction (transaction );
1589
1580
if (lseek (fd , seekback , SEEK_SET ) == (off_t )- 1 )
1590
1581
return error ("cannot seek back" );
1591
1582
}
@@ -1632,9 +1623,10 @@ int index_fd(struct index_state *istate, struct object_id *oid,
1632
1623
struct odb_transaction * transaction ;
1633
1624
1634
1625
transaction = begin_odb_transaction (the_repository -> objects );
1635
- ret = index_blob_bulk_checkin (the_repository -> objects -> transaction ,
1636
- oid , fd , xsize_t (st -> st_size ),
1637
- path , flags );
1626
+ ret = index_blob_packfile_transaction (the_repository -> objects -> transaction ,
1627
+ oid , fd ,
1628
+ xsize_t (st -> st_size ),
1629
+ path , flags );
1638
1630
end_odb_transaction (transaction );
1639
1631
}
1640
1632
@@ -1996,8 +1988,8 @@ void end_odb_transaction(struct odb_transaction *transaction)
1996
1988
*/
1997
1989
ASSERT (transaction == transaction -> odb -> transaction );
1998
1990
1999
- flush_batch_fsync (transaction );
2000
- flush_bulk_checkin_packfile (transaction );
1991
+ flush_loose_object_transaction (transaction );
1992
+ flush_packfile_transaction (transaction );
2001
1993
transaction -> odb -> transaction = NULL ;
2002
1994
free (transaction );
2003
1995
}
0 commit comments