os: Simplify collection_list* funcs by removing dynamic_cast

Signed-off-by: David Zafman <david.zafman@inktank.com>
osd: In read_meta() leave an extra byte in buffer to nul terminate

Signed-off-by: David Zafman <david.zafman@inktank.com>
common, os, osd: Use common functions for safe file reading and writing

Add new safe_read_file() and safe_write_file() to update files atomically
Used instead of original OSD::read_meta(), OSD::write_meta() they are based on
Used by read_superblock() and write_superblock()
Used by write_version_stamp() and version_stamp_is_valid()

Fixes: #6422

Signed-off-by: David Zafman <david.zafman@inktank.com>
Merge pull request #649 from ceph/wip-6422

#6422

Reviewed-by: Sage Weil <sage@inktank.com>