Even though he can't have his own room, you need to find a way for your son to have his own place to sleep.
My son was actually a great sleeper, but from the time he was little, he would cover every inch of his crib rolling, tossing, scooting, you name it. When he outgrew his crib, he covered every inch of space on his bed.
Since your son is 2, I think he needs a bedtime routine that includes going to bed and sleep before you do. Some kids simply don't co-sleep well and I don't think spanking him is the answer.
Change up the routine and the sleeping arrangements. Get him his own blankets and his own space even in the same room, put him to bed so he's asleep before you go to bed and it will get easier.
It might be rough adjusting at first, but who knows? He might settle down and sleep much better which is a win-win for both of you.
Best wishes.