Thanks Lei (Eddy) Xu so much for the review!
All your comments above are addressed in patch 4, except:
Can you move TestDatanodeImpl#testRemoveVolumeBeingWritten to TestDataNodeHotSwapVolumes?
I put it in TestFsDatasetImpl because we need to call methods (e.g. createRbw, finalizeBlock) directly on FsDatasetImpl to control the timing of the 'holding reference but not finalized yet' scenario. Putting it into TestDataNodeHotSwapVolumes will be harder to test. I understand your concern that this is a hot swap related test, but it's also on FsDatasetImpl. I'll try moving it if you insist.
Could you verify that during removing a volume, block report can be sent in the test.
I added a block report call in patch 4, though not strictly controlled it to be in the middle of removing - I'm not sure how to let it run exactly when the remove is in waitVolumeRemoved step.... please advice.