Intensity clamping and controlled efficiency of X-ray generation under femtosecond laser interaction with nanostructured target in air and helium