aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/quota.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-02-16 03:44:49 -0500
committerJan Kara <jack@suse.cz>2010-03-04 18:20:22 -0500
commit6ae09575b3c951ad77c07d068b8dbbc09031b2d1 (patch)
tree772a3cccbe12d98ecc33acb31f7fdb05c4e4b957 /fs/quota/quota.c
parentf450d4fee42c52e8045131a355b2de03094aa066 (diff)
quota: special case Q_SYNC without device name
The Q_SYNC command can be called without the path to a device, in which case it iterates over all superblocks. Special case this variant directly in sys_quotactl so that the other code always gets a superblock and doesn't need to deal with this case. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/quota.c')
-rw-r--r--fs/quota/quota.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index dcf7db91fc95..9fde5cd84f8d 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -124,10 +124,17 @@ void sync_quota_sb(struct super_block *sb, int type)
124} 124}
125#endif 125#endif
126 126
127static void sync_dquots(int type) 127static int quota_sync_all(int type)
128{ 128{
129 struct super_block *sb; 129 struct super_block *sb;
130 int cnt; 130 int cnt;
131 int ret;
132
133 if (type >= MAXQUOTAS)
134 return -EINVAL;
135 ret = security_quotactl(Q_SYNC, type, 0, NULL);
136 if (ret)
137 return ret;
131 138
132 spin_lock(&sb_lock); 139 spin_lock(&sb_lock);
133restart: 140restart:
@@ -157,6 +164,8 @@ restart:
157 goto restart; 164 goto restart;
158 } 165 }
159 spin_unlock(&sb_lock); 166 spin_unlock(&sb_lock);
167
168 return 0;
160} 169}
161 170
162static int quota_quotaon(struct super_block *sb, int type, int cmd, qid_t id, 171static int quota_quotaon(struct super_block *sb, int type, int cmd, qid_t id,
@@ -322,12 +331,9 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
322 case Q_SETQUOTA: 331 case Q_SETQUOTA:
323 return quota_setquota(sb, type, id, addr); 332 return quota_setquota(sb, type, id, addr);
324 case Q_SYNC: 333 case Q_SYNC:
325 if (sb) { 334 if (!sb->s_qcop->quota_sync)
326 if (!sb->s_qcop->quota_sync) 335 return -ENOSYS;
327 return -ENOSYS; 336 sync_quota_sb(sb, type);
328 sync_quota_sb(sb, type);
329 } else
330 sync_dquots(type);
331 return 0; 337 return 0;
332 case Q_XQUOTAON: 338 case Q_XQUOTAON:
333 case Q_XQUOTAOFF: 339 case Q_XQUOTAOFF:
@@ -392,18 +398,26 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,
392 cmds = cmd >> SUBCMDSHIFT; 398 cmds = cmd >> SUBCMDSHIFT;
393 type = cmd & SUBCMDMASK; 399 type = cmd & SUBCMDMASK;
394 400
395 if (cmds != Q_SYNC || special) { 401 /*
396 sb = quotactl_block(special); 402 * As a special case Q_SYNC can be called without a specific device.
397 if (IS_ERR(sb)) 403 * It will iterate all superblocks that have quota enabled and call
398 return PTR_ERR(sb); 404 * the sync action on each of them.
405 */
406 if (!special) {
407 if (cmds == Q_SYNC)
408 return quota_sync_all(type);
409 return -ENODEV;
399 } 410 }
400 411
412 sb = quotactl_block(special);
413 if (IS_ERR(sb))
414 return PTR_ERR(sb);
415
401 ret = check_quotactl_valid(sb, type, cmds, id); 416 ret = check_quotactl_valid(sb, type, cmds, id);
402 if (ret >= 0) 417 if (ret >= 0)
403 ret = do_quotactl(sb, type, cmds, id, addr); 418 ret = do_quotactl(sb, type, cmds, id, addr);
404 if (sb)
405 drop_super(sb);
406 419
420 drop_super(sb);
407 return ret; 421 return ret;
408} 422}
409 423