9p: make rpc code common and rework flush code