#include "xfs_health.h"
 #include "xfs_da_format.h"
 #include "xfs_metafile.h"
+#include "xfs_rtgroup.h"
 
 /*
  * The global quota manager. There is only one of these for the entire
        }
 }
 
+static void
+xfs_qm_unmount_rt(
+       struct xfs_mount        *mp)
+{
+       if (mp->m_rbmip)
+               xfs_qm_dqdetach(mp->m_rbmip);
+       if (mp->m_rsumip)
+               xfs_qm_dqdetach(mp->m_rsumip);
+}
+
 /*
  * Called from the vfsops layer.
  */
         */
        ASSERT(mp->m_rootip);
        xfs_qm_dqdetach(mp->m_rootip);
-       if (mp->m_rbmip)
-               xfs_qm_dqdetach(mp->m_rbmip);
-       if (mp->m_rsumip)
-               xfs_qm_dqdetach(mp->m_rsumip);
+
+       /*
+        * For pre-RTG file systems, the RT inodes have quotas attached,
+        * detach them now.
+        */
+       if (!xfs_has_rtgroups(mp))
+               xfs_qm_unmount_rt(mp);
 
        /*
         * Release the quota inodes.