@@ -1905,7 +1905,7 @@ schedule_bitmap_read(struct vhd_state *s, uint32_t blk)
19051905 return 0 ;
19061906}
19071907
1908- static void
1908+ static bool
19091909schedule_bitmap_write (struct vhd_state * s , uint32_t blk )
19101910{
19111911 uint64_t offset ;
@@ -1919,11 +1919,16 @@ schedule_bitmap_write(struct vhd_state *s, uint32_t blk)
19191919 ASSERT (bm && bitmap_valid (bm ) &&
19201920 !test_vhd_flag (bm -> status , VHD_FLAG_BM_WRITE_PENDING ));
19211921
1922+ if (memcmp (bm -> map , bm -> shadow , vhd_sectors_to_bytes (s -> bm_secs )) == 0 ) {
1923+ /* Bitmap unchanged */
1924+ return true;
1925+ }
1926+
19221927 if (offset == DD_BLK_UNUSED ) {
19231928 ASSERT (bat_locked (s ) && s -> bat .pbw_blk == blk );
19241929 offset = s -> bat .pbw_offset ;
19251930 }
1926-
1931+
19271932 offset = vhd_sectors_to_bytes (offset );
19281933
19291934 req = & bm -> req ;
@@ -1944,6 +1949,7 @@ schedule_bitmap_write(struct vhd_state *s, uint32_t blk)
19441949 DBG (TLOG_DBG , "%s: blk: 0x%04x, sec: 0x%08" PRIx64 ", nr_secs: 0x%04x, "
19451950 "offset: 0x%" PRIx64 "\n" , s -> vhd .file , blk , req -> treq .sec ,
19461951 req -> treq .secs , offset );
1952+ return false;
19471953}
19481954
19491955/*
@@ -2362,15 +2368,18 @@ static void
23622368finish_data_transaction (struct vhd_state * s , struct vhd_bitmap * bm )
23632369{
23642370 struct vhd_transaction * tx = & bm -> tx ;
2371+ bool finish_transaction = true;
23652372
23662373 DBG (TLOG_DBG , "blk: 0x%04x\n" , bm -> blk );
23672374
23682375 tx -> closed = 1 ;
23692376
23702377 if (!tx -> error )
2371- return schedule_bitmap_write (s , bm -> blk );
2378+ finish_transaction = schedule_bitmap_write (s , bm -> blk );
23722379
2373- return finish_bitmap_transaction (s , bm , 0 );
2380+ if (finish_transaction ) {
2381+ return finish_bitmap_transaction (s , bm , 0 );
2382+ }
23742383}
23752384
23762385static void
0 commit comments