My u-lock carrying strategy is a lot like lelak's; I put the shackle around the seatpost and one side of the little raised "handle" at the front of the rack, then close it. I have two bungee cords running lengthwise down my rack, so I just hook them over each end of the cylinder to hold it in place. Works great.
I was using the bracket that my u-lock came with, but this took up too much space inside the frame triangle, so there wasn't room for a water bottle in there at the same time, which is why I switched to carrying it on the rear rack.
For my cable lock, I unlock it, then put each end through the handle in opposite directions, then lock it back together. This holds it pretty well, keeps it from flopping around very much.