If this occurred during an ascent, it may be alternobaric vertigo. This is where the two ears equalize at different rates, creating a pressure differential that causes different signals regarding orientation to come from the two different ears. Since there is no way to force equalization on ascent, the only thing you can do is cope with the results. Getting a visual reference is key, or holding onto something until the sensation resolves.
If this was not on ascent, but simply where you were without a visual reference, then I'm sorry. I have the same problem, and it is not easy to manage. What you need is orientation information, and your brain wants it visual, and you don't have that. My solutions are 1) acquire a visual reference. The best one is a stable buddy who doesn't have the problem. I can do ANYTHING with a solid buddy. Failing that, if you are ascending, shoot a bag. The line on the bag helps a lot. 2) Check your bubbles. I have learned that, when I am horizontal in the water, bubbles run up both sides of my face equally. If they are running up one side but not the other, I am on my side; if they are running up the front of me, I am head-down. I dive a dry suit, so I can also use my feet for reference. If they are ballooning, I am head-down; if they are squeezed, I am head-up. 3) As much as conceivably possible, avoid rapid or large head movements when deprived of a visual reference. Apparently they teach this to instrument pilots, to avoid vertigo; it was a pilot who passed this tip on to me. I tell my buddies I CANNOT look for them in midwater. They have to stay where I can see them, or they are on their own. 4) Trust your gauges. For a long time, I simply had to tell myself, "It doesn't MATTER if you are doing somersaults, so long as you are doing them at 20 feet." Depth control is the most important thing -- you can whirl all you want if you don't lose buoyancy control while you are doing it. It isn't fun, but it isn't dangerous, whereas going feet first to the surface IS. And I have done it too many times. 5) Watch the particles in the water. Even in pretty clear water, there are some. They tend, in the absence of significant up or down currents, to stay where they are, so you can watch them and orient yourself and know whether you are moving up or down in the water column. 6) Keep your breathing under control. When you are spinning, it is very tempting to begin to pant out of stress. This will mess up buoyancy control. Keep your breathing steady and even.
I still get vertigo, but it isn't as bad as it once was. Now, I'm okay in blue water; it's when the things on which I am orienting myself visually begin to do unexpected things that I have problems. On our recent Red Sea trip, I was doing deco up a line, but the line was not only bouncing up and down, but being dragged violently sideways as the ship to which it was tied was moved by the waves. I had the dickens of a time staying oriented, and I was acutely uncomfortable through much of the ascent.