aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-10-08 09:56:21 -0400
committerJan Kara <jack@suse.cz>2015-01-30 06:49:40 -0500
commit38e478c4489a845a5e8baf7849c286af5fed5b66 (patch)
treef001a8e58e17e32d3969ad3069621919ea4b9dcf /fs
parent1cd6b7be92016538ea1f2a8e1f955e9b974d93ea (diff)
quota: Split ->set_xstate callback into two
Split ->set_xstate callback into two callbacks - one for turning quotas on (->quota_enable) and one for turning quotas off (->quota_disable). That way we don't have to pass quotactl command into the callback which seems cleaner. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/quota/quota.c20
-rw-r--r--fs/xfs/xfs_quotaops.c59
2 files changed, 53 insertions, 26 deletions
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 6f3856328eea..e2ae2b99e555 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -208,15 +208,26 @@ static int quota_setquota(struct super_block *sb, int type, qid_t id,
208 return sb->s_qcop->set_dqblk(sb, qid, &fdq); 208 return sb->s_qcop->set_dqblk(sb, qid, &fdq);
209} 209}
210 210
211static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) 211static int quota_enable(struct super_block *sb, void __user *addr)
212{ 212{
213 __u32 flags; 213 __u32 flags;
214 214
215 if (copy_from_user(&flags, addr, sizeof(flags))) 215 if (copy_from_user(&flags, addr, sizeof(flags)))
216 return -EFAULT; 216 return -EFAULT;
217 if (!sb->s_qcop->set_xstate) 217 if (!sb->s_qcop->quota_enable)
218 return -ENOSYS; 218 return -ENOSYS;
219 return sb->s_qcop->set_xstate(sb, flags, cmd); 219 return sb->s_qcop->quota_enable(sb, flags);
220}
221
222static int quota_disable(struct super_block *sb, void __user *addr)
223{
224 __u32 flags;
225
226 if (copy_from_user(&flags, addr, sizeof(flags)))
227 return -EFAULT;
228 if (!sb->s_qcop->quota_disable)
229 return -ENOSYS;
230 return sb->s_qcop->quota_disable(sb, flags);
220} 231}
221 232
222static int quota_getxstate(struct super_block *sb, void __user *addr) 233static int quota_getxstate(struct super_block *sb, void __user *addr)
@@ -447,8 +458,9 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
447 return -ENOSYS; 458 return -ENOSYS;
448 return sb->s_qcop->quota_sync(sb, type); 459 return sb->s_qcop->quota_sync(sb, type);
449 case Q_XQUOTAON: 460 case Q_XQUOTAON:
461 return quota_enable(sb, addr);
450 case Q_XQUOTAOFF: 462 case Q_XQUOTAOFF:
451 return quota_setxstate(sb, cmd, addr); 463 return quota_disable(sb, addr);
452 case Q_XQUOTARM: 464 case Q_XQUOTARM:
453 return quota_rmxquota(sb, addr); 465 return quota_rmxquota(sb, addr);
454 case Q_XGETQSTAT: 466 case Q_XGETQSTAT:
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index a226203fa46a..6923905ab33d 100644
--- a/fs/xfs/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -64,19 +64,10 @@ xfs_fs_get_xstatev(
64 return xfs_qm_scall_getqstatv(mp, fqs); 64 return xfs_qm_scall_getqstatv(mp, fqs);
65} 65}
66 66
67STATIC int 67static unsigned int
68xfs_fs_set_xstate( 68xfs_quota_flags(unsigned int uflags)
69 struct super_block *sb,
70 unsigned int uflags,
71 int op)
72{ 69{
73 struct xfs_mount *mp = XFS_M(sb); 70 unsigned int flags = 0;
74 unsigned int flags = 0;
75
76 if (sb->s_flags & MS_RDONLY)
77 return -EROFS;
78 if (!XFS_IS_QUOTA_RUNNING(mp))
79 return -ENOSYS;
80 71
81 if (uflags & FS_QUOTA_UDQ_ACCT) 72 if (uflags & FS_QUOTA_UDQ_ACCT)
82 flags |= XFS_UQUOTA_ACCT; 73 flags |= XFS_UQUOTA_ACCT;
@@ -91,16 +82,39 @@ xfs_fs_set_xstate(
91 if (uflags & FS_QUOTA_PDQ_ENFD) 82 if (uflags & FS_QUOTA_PDQ_ENFD)
92 flags |= XFS_PQUOTA_ENFD; 83 flags |= XFS_PQUOTA_ENFD;
93 84
94 switch (op) { 85 return flags;
95 case Q_XQUOTAON: 86}
96 return xfs_qm_scall_quotaon(mp, flags); 87
97 case Q_XQUOTAOFF: 88STATIC int
98 if (!XFS_IS_QUOTA_ON(mp)) 89xfs_quota_enable(
99 return -EINVAL; 90 struct super_block *sb,
100 return xfs_qm_scall_quotaoff(mp, flags); 91 unsigned int uflags)
101 } 92{
93 struct xfs_mount *mp = XFS_M(sb);
94
95 if (sb->s_flags & MS_RDONLY)
96 return -EROFS;
97 if (!XFS_IS_QUOTA_RUNNING(mp))
98 return -ENOSYS;
99
100 return xfs_qm_scall_quotaon(mp, xfs_quota_flags(uflags));
101}
102
103STATIC int
104xfs_quota_disable(
105 struct super_block *sb,
106 unsigned int uflags)
107{
108 struct xfs_mount *mp = XFS_M(sb);
109
110 if (sb->s_flags & MS_RDONLY)
111 return -EROFS;
112 if (!XFS_IS_QUOTA_RUNNING(mp))
113 return -ENOSYS;
114 if (!XFS_IS_QUOTA_ON(mp))
115 return -EINVAL;
102 116
103 return -EINVAL; 117 return xfs_qm_scall_quotaoff(mp, xfs_quota_flags(uflags));
104} 118}
105 119
106STATIC int 120STATIC int
@@ -166,7 +180,8 @@ xfs_fs_set_dqblk(
166const struct quotactl_ops xfs_quotactl_operations = { 180const struct quotactl_ops xfs_quotactl_operations = {
167 .get_xstatev = xfs_fs_get_xstatev, 181 .get_xstatev = xfs_fs_get_xstatev,
168 .get_xstate = xfs_fs_get_xstate, 182 .get_xstate = xfs_fs_get_xstate,
169 .set_xstate = xfs_fs_set_xstate, 183 .quota_enable = xfs_quota_enable,
184 .quota_disable = xfs_quota_disable,
170 .rm_xquota = xfs_fs_rm_xquota, 185 .rm_xquota = xfs_fs_rm_xquota,
171 .get_dqblk = xfs_fs_get_dqblk, 186 .get_dqblk = xfs_fs_get_dqblk,
172 .set_dqblk = xfs_fs_set_dqblk, 187 .set_dqblk = xfs_fs_set_dqblk,