I had the same problem on an installation of a kernel that didn't boot atop a CM rom. When it bootlooped, I went into recovery and found the infamous could not mount /data. I tried rootSU's recommendation about wiping cache several times and flashing a cache.img but it didn't work for me. I was about to do the whole factory stock image thing (and thus wipe my sdcard) when out of desperation to avoid that, I tried something that surprisingly succeeded. The following steps are for a newbie but presupposes a working knowledge of how to use adb and fastboot commands.
1. Download and copy a known stable ROM's zip file into your SDK's platform-tools, renaming it ROM.zip
2. Boot you phone into (TWRP 18.104.22.168) recovery
2. Choose ADB sideload in Advanced
3. From your computer's DOS prompt in the SDK platform-tools directory, type adb sideload ROM.zip
When it's done sideloading, it will flash
4. Choose reboot system
It will boot and get a series of FC's of android process and dialer
5. Hard reset into bootloader (hold down the power button until screen goes off (in like 7 secs) immediately hit vol-down) and choose recovery
Voila! Rebooted into recovery for me with data mounted as normal. No need to flash factory images!
Hope this helps and good luck!