refs.c: log_ref_write should try to return meaningful errno