s3: Move the share_mode_lock handling to its own file