mount: Refactor write worker

This commit refarors write_worker function in mount. It does not
change the behavior in any way, just makes the code easier to
understand for future developers.