#include <linux/capability.h>
 #include <linux/quotaops.h>
 #include <linux/types.h>
+#include <linux/writeback.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
 
 {
        int cnt;
 
-       if (!sb->s_qcop->quota_sync)
+       if (!sb->s_qcop || !sb->s_qcop->quota_sync)
                return;
 
        sb->s_qcop->quota_sync(sb, type);
        case Q_XGETQUOTA:
                return quota_getxquota(sb, type, id, addr);
        case Q_XQUOTASYNC:
-               if (!sb->s_qcop->quota_sync)
-                       return -ENOSYS;
-               return sb->s_qcop->quota_sync(sb, type);
+               /* caller already holds s_umount */
+               if (sb->s_flags & MS_RDONLY)
+                       return -EROFS;
+               writeback_inodes_sb(sb);
+               return 0;
        default:
                return -EINVAL;
        }
 
        }
 }
 
-STATIC int
-xfs_fs_quota_sync(
-       struct super_block      *sb,
-       int                     type)
-{
-       struct xfs_mount        *mp = XFS_M(sb);
-
-       if (sb->s_flags & MS_RDONLY)
-               return -EROFS;
-       if (!XFS_IS_QUOTA_RUNNING(mp))
-               return -ENOSYS;
-       return -xfs_sync_data(mp, 0);
-}
-
 STATIC int
 xfs_fs_get_xstate(
        struct super_block      *sb,
 }
 
 const struct quotactl_ops xfs_quotactl_operations = {
-       .quota_sync             = xfs_fs_quota_sync,
        .get_xstate             = xfs_fs_get_xstate,
        .set_xstate             = xfs_fs_set_xstate,
        .get_xquota             = xfs_fs_get_xquota,
 
 void sync_quota_sb(struct super_block *sb, int type);
 static inline void writeout_quota_sb(struct super_block *sb, int type)
 {
-       if (sb->s_qcop->quota_sync)
+       if (sb->s_qcop && sb->s_qcop->quota_sync)
                sb->s_qcop->quota_sync(sb, type);
 }