I haven't fully and thoroughly reviewed this MR but it does seem to be generally fine. Note to the fellow reviewer: the new get_available_writemask() is a pretty different function from the old one (WRT how it's used mostly), it just happens to cover the same "idea" and thus share the same name.