quota: kill the vfs_dq_off and vfs_dq_quota_on_remount wrappers
authorChristoph Hellwig <hch@infradead.org>
Wed, 19 May 2010 11:16:41 +0000 (07:16 -0400)
committerJan Kara <jack@suse.cz>
Mon, 24 May 2010 12:06:40 +0000 (14:06 +0200)
Instead of having wrappers in the VFS namespace export the dquot_suspend
and dquot_resume helpers directly.  Also rename vfs_quota_disable to
dquot_disable while we're at it.

[Jan Kara: Moved dquot_suspend to quotaops.h and made it inline]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext2/super.c
fs/ext3/super.c
fs/ext4/super.c
fs/jfs/super.c
fs/ocfs2/super.c
fs/quota/dquot.c
fs/reiserfs/super.c
fs/udf/super.c
fs/ufs/super.c
include/linux/quotaops.h

index 73346de9af5ced09d0ba2ed68526db032bc745e7..318ebc58bb7b73dcc5230e85c22e88627daefeff 100644 (file)
@@ -1250,9 +1250,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
                es->s_mtime = cpu_to_le32(get_seconds());
                spin_unlock(&sbi->s_lock);
 
-               err = vfs_dq_off(sb, 1);
-               if (err < 0 && err != -ENOSYS) {
-                       err = -EBUSY;
+               err = dquot_suspend(sb, -1);
+               if (err < 0) {
                        spin_lock(&sbi->s_lock);
                        goto restore_opts;
                }
@@ -1281,7 +1280,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
 
                ext2_write_super(sb);
 
-               vfs_dq_quota_on_remount(sb);
+               dquot_resume(sb, -1);
        }
 
        return 0;
index d0f8837b6255666ea37de7b5fc374d2eaa3a1e62..9d5e582b514acf489edd818a1b54040614f45b70 100644 (file)
@@ -2598,11 +2598,9 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
                }
 
                if (*flags & MS_RDONLY) {
-                       err = vfs_dq_off(sb, 1);
-                       if (err < 0 && err != -ENOSYS) {
-                               err = -EBUSY;
+                       err = dquot_suspend(sb, -1);
+                       if (err < 0)
                                goto restore_opts;
-                       }
 
                        /*
                         * First of all, the unconditional stuff we have to do
@@ -2672,7 +2670,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
        unlock_kernel();
 
        if (enable_quota)
-               vfs_dq_quota_on_remount(sb);
+               dquot_resume(sb, -1);
        return 0;
 restore_opts:
        sb->s_flags = old_sb_flags;
index fb1e191d0fa9c9ef4663dedeb768974a504f4869..08d31101eb0597d1eeb04235b71f52f8ce5a3cac 100644 (file)
@@ -3631,11 +3631,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                }
 
                if (*flags & MS_RDONLY) {
-                       err = vfs_dq_off(sb, 1);
-                       if (err < 0 && err != -ENOSYS) {
-                               err = -EBUSY;
+                       err = dquot_suspend(sb, -1);
+                       if (err < 0)
                                goto restore_opts;
-                       }
 
                        /*
                         * First of all, the unconditional stuff we have to do
@@ -3722,7 +3720,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
        unlock_super(sb);
        unlock_kernel();
        if (enable_quota)
-               vfs_dq_quota_on_remount(sb);
+               dquot_resume(sb, -1);
        return 0;
 
 restore_opts:
index 5329d66a970427cd5a421b11e387ee2e0d85043a..b8a07d4c108e528f898e429d84e0f38e1a4114b7 100644 (file)
@@ -401,14 +401,14 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
                sb->s_flags &= ~MS_RDONLY;
 
                unlock_kernel();
-               vfs_dq_quota_on_remount(sb);
+               dquot_resume(sb, -1);
                return ret;
        }
        if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
-               rc = vfs_dq_off(sb, 1);
-               if (rc < 0 && rc != -ENOSYS) {
+               rc = dquot_suspend(sb, -1);
+               if (rc < 0) {
                        unlock_kernel();
-                       return -EBUSY;
+                       return rc;
                }
                rc = jfs_umount_rw(sb);
                JFS_SBI(sb)->flag = flag;
index 66f9984a983c9696d6132499a8ab6ed9e31f37d2..0773873d590a8308e21b8a002290627a0e2652c1 100644 (file)
@@ -879,18 +879,14 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend)
                if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
                        continue;
                if (unsuspend)
-                       status = vfs_quota_enable(
-                                       sb_dqopt(sb)->files[type],
-                                       type, QFMT_OCFS2,
-                                       DQUOT_SUSPENDED);
+                       status = dquot_resume(sb, type);
                else {
                        struct ocfs2_mem_dqinfo *oinfo;
 
                        /* Cancel periodic syncing before suspending */
                        oinfo = sb_dqinfo(sb, type)->dqi_priv;
                        cancel_delayed_work_sync(&oinfo->dqi_sync_work);
-                       status = vfs_quota_disable(sb, type,
-                                                  DQUOT_SUSPENDED);
+                       status = dquot_suspend(sb, type);
                }
                if (status < 0)
                        break;
@@ -958,8 +954,8 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb)
                /* Turn off quotas. This will remove all dquot structures from
                 * memory and so they will be automatically synced to global
                 * quota files */
-               vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED |
-                                           DQUOT_LIMITS_ENABLED);
+               dquot_disable(sb, type, DQUOT_USAGE_ENABLED |
+                                       DQUOT_LIMITS_ENABLED);
                if (!inode)
                        continue;
                iput(inode);
@@ -989,7 +985,7 @@ static int ocfs2_quota_off(struct super_block *sb, int type, int remount)
        if (remount)
                return 0;       /* Ignore now and handle later in
                                 * ocfs2_remount() */
-       return vfs_quota_disable(sb, type, DQUOT_LIMITS_ENABLED);
+       return dquot_disable(sb, type, DQUOT_LIMITS_ENABLED);
 }
 
 static const struct quotactl_ops ocfs2_quotactl_ops = {
index 655a4c52b8c30036a63f8b73857006c97f16de14..cf972283e47493b6dbb85a3b583845b2c076adad 100644 (file)
@@ -1865,7 +1865,7 @@ EXPORT_SYMBOL(dquot_file_open);
 /*
  * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
  */
-int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
+int dquot_disable(struct super_block *sb, int type, unsigned int flags)
 {
        int cnt, ret = 0;
        struct quota_info *dqopt = sb_dqopt(sb);
@@ -1995,14 +1995,16 @@ put_inodes:
                }
        return ret;
 }
-EXPORT_SYMBOL(vfs_quota_disable);
+EXPORT_SYMBOL(dquot_disable);
 
 int vfs_quota_off(struct super_block *sb, int type, int remount)
 {
-       return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED :
-                                (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED));
+       BUG_ON(remount);
+       return dquot_disable(sb, type,
+                            DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
 }
 EXPORT_SYMBOL(vfs_quota_off);
+
 /*
  *     Turn quotas on on a device
  */
@@ -2120,34 +2122,41 @@ out_fmt:
 }
 
 /* Reenable quotas on remount RW */
-static int vfs_quota_on_remount(struct super_block *sb, int type)
+int dquot_resume(struct super_block *sb, int type)
 {
        struct quota_info *dqopt = sb_dqopt(sb);
        struct inode *inode;
-       int ret;
+       int ret = 0, cnt;
        unsigned int flags;
 
-       mutex_lock(&dqopt->dqonoff_mutex);
-       if (!sb_has_quota_suspended(sb, type)) {
+       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+               if (type != -1 && cnt != type)
+                       continue;
+
+               mutex_lock(&dqopt->dqonoff_mutex);
+               if (!sb_has_quota_suspended(sb, cnt)) {
+                       mutex_unlock(&dqopt->dqonoff_mutex);
+                       continue;
+               }
+               inode = dqopt->files[cnt];
+               dqopt->files[cnt] = NULL;
+               spin_lock(&dq_state_lock);
+               flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED |
+                                                       DQUOT_LIMITS_ENABLED,
+                                                       cnt);
+               dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, cnt);
+               spin_unlock(&dq_state_lock);
                mutex_unlock(&dqopt->dqonoff_mutex);
-               return 0;
-       }
-       inode = dqopt->files[type];
-       dqopt->files[type] = NULL;
-       spin_lock(&dq_state_lock);
-       flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED |
-                                               DQUOT_LIMITS_ENABLED, type);
-       dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, type);
-       spin_unlock(&dq_state_lock);
-       mutex_unlock(&dqopt->dqonoff_mutex);
 
-       flags = dquot_generic_flag(flags, type);
-       ret = vfs_load_quota_inode(inode, type, dqopt->info[type].dqi_fmt_id,
-                                  flags);
-       iput(inode);
+               flags = dquot_generic_flag(flags, cnt);
+               ret = vfs_load_quota_inode(inode, cnt,
+                               dqopt->info[cnt].dqi_fmt_id, flags);
+               iput(inode);
+       }
 
        return ret;
 }
+EXPORT_SYMBOL(dquot_resume);
 
 int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
                      struct path *path)
@@ -2172,8 +2181,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name,
        struct path path;
        int error;
 
-       if (remount)
-               return vfs_quota_on_remount(sb, type);
+       BUG_ON(remount);
 
        error = kern_path(name, LOOKUP_FOLLOW, &path);
        if (!error) {
@@ -2196,8 +2204,8 @@ int vfs_quota_enable(struct inode *inode, int type, int format_id,
        struct quota_info *dqopt = sb_dqopt(sb);
 
        /* Just unsuspend quotas? */
-       if (flags & DQUOT_SUSPENDED)
-               return vfs_quota_on_remount(sb, type);
+       BUG_ON(flags & DQUOT_SUSPENDED);
+
        if (!flags)
                return 0;
        /* Just updating flags needed? */
@@ -2263,23 +2271,6 @@ out:
 }
 EXPORT_SYMBOL(vfs_quota_on_mount);
 
-/* Wrapper to turn on quotas when remounting rw */
-int vfs_dq_quota_on_remount(struct super_block *sb)
-{
-       int cnt;
-       int ret = 0, err;
-
-       if (!sb->s_qcop || !sb->s_qcop->quota_on)
-               return -ENOSYS;
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1);
-               if (err < 0 && !ret)
-                       ret = err;
-       }
-       return ret;
-}
-EXPORT_SYMBOL(vfs_dq_quota_on_remount);
-
 static inline qsize_t qbtos(qsize_t blocks)
 {
        return blocks << QIF_DQBLKSIZE_BITS;
index 49a8ba02bc1771911d8482b9f13a9220597f3a00..5dad5a2707bc3bfd817b0aa39d1bd5dae1ffc565 100644 (file)
@@ -1243,11 +1243,9 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
                        /* it is read-only already */
                        goto out_ok;
 
-               err = vfs_dq_off(s, 1);
-               if (err < 0 && err != -ENOSYS) {
-                       err = -EBUSY;
+               err = dquot_suspend(s, -1);
+               if (err < 0)
                        goto out_err;
-               }
 
                /* try to remount file system with read-only permissions */
                if (sb_umount_state(rs) == REISERFS_VALID_FS
@@ -1302,7 +1300,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
        s->s_dirt = 0;
 
        if (!(*mount_flags & MS_RDONLY)) {
-               vfs_dq_quota_on_remount(s);
+               dquot_resume(s, -1);
                finish_unfinished(s);
                reiserfs_xattr_init(s, *mount_flags);
        }
index 9ab4e259404bbc1a7f383ccbf8ced5888bc99786..b154c41a7a9a8f4fcb3c214a145914efc58a1cf9 100644 (file)
@@ -590,15 +590,13 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
        if (*flags & MS_RDONLY) {
                udf_close_lvid(sb);
 
-               error = vfs_dq_off(sb, 1);
-               if (error < 0 && error != -ENOSYS)
-                       error = -EBUSY;
+               error = dquot_suspend(sb, -1);
        } else {
                udf_open_lvid(sb);
 
                /* mark the fs r/w for quota activity */
                sb->s_flags &= ~MS_RDONLY;
-               vfs_dq_quota_on_remount(sb);
+               dquot_resume(sb, -1);
        }
 
 out_unlock:
index be1f7b05bc28c0d9dbdfee29838bdc36336f99f9..495fdc1df7eb7c9a6bffcdc73df0c65b8933e5f1 100644 (file)
@@ -1291,11 +1291,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
         * fs was mouted as rw, remounting ro
         */
        if (*mount_flags & MS_RDONLY) {
-               err = vfs_dq_off(sb, 1);
-               if (err < 0 && err != -ENOSYS) {
+               err = dquot_suspend(sb, -1);
+               if (err < 0) {
                        unlock_super(sb);
                        unlock_kernel();
-                       return -EBUSY;
+                       return err;
                }
 
                ufs_put_super_internal(sb);
@@ -1343,7 +1343,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
        unlock_super(sb);
        unlock_kernel();
        if (enable_quota)
-               vfs_dq_quota_on_remount(sb);
+               dquot_resume(sb, -1);
        return 0;
 }
 
index 370abb1e99cbda13b2615e8353cf5d8a67e41caf..811529241e33a6c4194144a9f1d10d1abbcaa858 100644 (file)
@@ -50,6 +50,14 @@ int dquot_alloc_inode(const struct inode *inode);
 int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
 void dquot_free_inode(const struct inode *inode);
 
+int dquot_disable(struct super_block *sb, int type, unsigned int flags);
+/* Suspend quotas on remount RO */
+static inline int dquot_suspend(struct super_block *sb, int type)
+{
+       return dquot_disable(sb, type, DQUOT_SUSPENDED);
+}
+int dquot_resume(struct super_block *sb, int type);
+
 int dquot_commit(struct dquot *dquot);
 int dquot_acquire(struct dquot *dquot);
 int dquot_release(struct dquot *dquot);
@@ -67,7 +75,6 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
 int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
        int format_id, int type);
 int vfs_quota_off(struct super_block *sb, int type, int remount);
-int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags);
 int vfs_quota_sync(struct super_block *sb, int type, int wait);
 int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
 int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
@@ -78,7 +85,6 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id,
 
 int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
 int dquot_transfer(struct inode *inode, struct iattr *iattr);
-int vfs_dq_quota_on_remount(struct super_block *sb);
 
 static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
 {
@@ -231,11 +237,6 @@ static inline int vfs_dq_off(struct super_block *sb, int remount)
        return 0;
 }
 
-static inline int vfs_dq_quota_on_remount(struct super_block *sb)
-{
-       return 0;
-}
-
 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
        return 0;
@@ -262,6 +263,22 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
        return 0;
 }
 
+static inline int dquot_disable(struct super_block *sb, int type,
+               unsigned int flags)
+{
+       return 0;
+}
+
+static inline int dquot_suspend(struct super_block *sb, int type)
+{
+       return 0;
+}
+
+static inline int dquot_resume(struct super_block *sb, int type)
+{
+       return 0;
+}
+
 #define dquot_file_open                generic_file_open
 
 #endif /* CONFIG_QUOTA */