Fix and Refactor dm_safe_io_

fix:
dm_safe_io now accepts NULL for err_bits

refactor:
change args orderings
swap regions and nr_regions.
minor code clean
add warning if header atomicity broken
refactor sysfs
add validate_cond macro