I've installed XFS on USB HDD. Usually I remember to unmount it safely before I disconnect it. But there were several cases when I forgotten about it. It never caused a problem before as I could mount it again and everything could be repaired at mount time. Recently I updated kernel to version 4.0.5 on my Gentoo machine. Everything was fine until today. I've forgotten to unmount filesystem when I disconnected my USB HDD. So I connected it again hoping that what I did will be fixed during mount. Unfortunately, mount did not work. What I found is that drive which was usually /dev/sdf now was reported /dev/sdg. It is certain that /dev/sdf entry was still in use. And indeed in dmesg I've found that kernel is still fighting with suddenly disconnected XFS on /dev/sdf1. I entered errror message in a google and found that it occured to others too, see RedHat bugzilla ticket with the same error message: https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=1103792 'sync' command couldn't complete, I couldn't reboot my machine, I couldn't shutdown it gracefully, I could only pull the plug! Dmesg was growing due to XFS metadata error on /dev/sdf1 messages repeated again and again. That wasn't nice, so I don't plan to reproduce it.
This was a raw morning. I did not notice that on this machine kernel wasn't updated yet. It is still 3.18.12. Sorry for misleading statement.
It would be good to be more graceful about this, and there are other scenarios where better recovery is needed. Today, XFS just keeps trying, hoping the device will come back (as it might on a SAN that is having trouble). In the future, you can do: # xfs_io -c "shutdown" /dev/sdf1 and it should be unmountable after that.
I'm batch-closing all xfs bugs which are more than 1 year old, sorry about that. If you still have this issue on a current kernel, please retest and re-open with this information. Thanks, -Eric
192852b xfs: configurable error behavior via sysfs and followon patches in v4.7 start to address this problem, FWIW.