@@ -1905,7 +1905,7 @@ schedule_bitmap_read(struct vhd_state *s, uint32_t blk)
1905
1905
return 0 ;
1906
1906
}
1907
1907
1908
- static void
1908
+ static bool
1909
1909
schedule_bitmap_write (struct vhd_state * s , uint32_t blk )
1910
1910
{
1911
1911
uint64_t offset ;
@@ -1919,11 +1919,16 @@ schedule_bitmap_write(struct vhd_state *s, uint32_t blk)
1919
1919
ASSERT (bm && bitmap_valid (bm ) &&
1920
1920
!test_vhd_flag (bm -> status , VHD_FLAG_BM_WRITE_PENDING ));
1921
1921
1922
+ if (memcmp (bm -> map , bm -> shadow , vhd_sectors_to_bytes (s -> bm_secs )) == 0 ) {
1923
+ /* Bitmap unchanged */
1924
+ return true;
1925
+ }
1926
+
1922
1927
if (offset == DD_BLK_UNUSED ) {
1923
1928
ASSERT (bat_locked (s ) && s -> bat .pbw_blk == blk );
1924
1929
offset = s -> bat .pbw_offset ;
1925
1930
}
1926
-
1931
+
1927
1932
offset = vhd_sectors_to_bytes (offset );
1928
1933
1929
1934
req = & bm -> req ;
@@ -1944,6 +1949,7 @@ schedule_bitmap_write(struct vhd_state *s, uint32_t blk)
1944
1949
DBG (TLOG_DBG , "%s: blk: 0x%04x, sec: 0x%08" PRIx64 ", nr_secs: 0x%04x, "
1945
1950
"offset: 0x%" PRIx64 "\n" , s -> vhd .file , blk , req -> treq .sec ,
1946
1951
req -> treq .secs , offset );
1952
+ return false;
1947
1953
}
1948
1954
1949
1955
/*
@@ -2362,15 +2368,18 @@ static void
2362
2368
finish_data_transaction (struct vhd_state * s , struct vhd_bitmap * bm )
2363
2369
{
2364
2370
struct vhd_transaction * tx = & bm -> tx ;
2371
+ bool finish_transaction = true;
2365
2372
2366
2373
DBG (TLOG_DBG , "blk: 0x%04x\n" , bm -> blk );
2367
2374
2368
2375
tx -> closed = 1 ;
2369
2376
2370
2377
if (!tx -> error )
2371
- return schedule_bitmap_write (s , bm -> blk );
2378
+ finish_transaction = schedule_bitmap_write (s , bm -> blk );
2372
2379
2373
- return finish_bitmap_transaction (s , bm , 0 );
2380
+ if (finish_transaction ) {
2381
+ return finish_bitmap_transaction (s , bm , 0 );
2382
+ }
2374
2383
}
2375
2384
2376
2385
static void
0 commit comments