I am trying to rig a hydraulic cylinder. Everything is fine when I move control bone, but I am have problem when I try to rotate it. The child bone does not roll with parent bone. I hope the image shows the problem I am having more clearly. Also I am attaching .blend file.
Use real parenting instead of a child-of constraint. This is so your child bone has local axes that are appropriate to it, that change with changes in the rotation of its parent, which we’ll use shortly:
Use a locked track constraint instead of a track-to constraint. The locked track will only ever rotate it in a single local axis, which is appropriate to the object you’re showing here.