I see you use flags to determine if a file needs syncing. When we used fiemap within GNU cp we required FIEMAP_FLAG_SYNC to get robust operation.
(We have since removed the fiemap code from cp, and replaced it with LSEEK_DATA, LSEEK_HOLE)
(We have since removed the fiemap code from cp, and replaced it with LSEEK_DATA, LSEEK_HOLE)