aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/quota/quota.c')
-rw-r--r--fs/quota/quota.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 89541bcbe27c..b7f5a468f076 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -20,7 +20,8 @@
20#include <linux/types.h> 20#include <linux/types.h>
21 21
22/* Check validity of generic quotactl commands */ 22/* Check validity of generic quotactl commands */
23static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) 23static int generic_quotactl_valid(struct super_block *sb, int type, int cmd,
24 qid_t id)
24{ 25{
25 if (type >= MAXQUOTAS) 26 if (type >= MAXQUOTAS)
26 return -EINVAL; 27 return -EINVAL;
@@ -72,7 +73,8 @@ static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid
72 case Q_SETINFO: 73 case Q_SETINFO:
73 case Q_SETQUOTA: 74 case Q_SETQUOTA:
74 case Q_GETQUOTA: 75 case Q_GETQUOTA:
75 /* This is just informative test so we are satisfied without a lock */ 76 /* This is just an informative test so we are satisfied
77 * without the lock */
76 if (!sb_has_quota_active(sb, type)) 78 if (!sb_has_quota_active(sb, type))
77 return -ESRCH; 79 return -ESRCH;
78 } 80 }
@@ -92,7 +94,8 @@ static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid
92} 94}
93 95
94/* Check validity of XFS Quota Manager commands */ 96/* Check validity of XFS Quota Manager commands */
95static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) 97static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd,
98 qid_t id)
96{ 99{
97 if (type >= XQM_MAXQUOTAS) 100 if (type >= XQM_MAXQUOTAS)
98 return -EINVAL; 101 return -EINVAL;
@@ -142,7 +145,8 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i
142 return 0; 145 return 0;
143} 146}
144 147
145static int check_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) 148static int check_quotactl_valid(struct super_block *sb, int type, int cmd,
149 qid_t id)
146{ 150{
147 int error; 151 int error;
148 152
@@ -180,7 +184,8 @@ static void quota_sync_sb(struct super_block *sb, int type)
180 continue; 184 continue;
181 if (!sb_has_quota_active(sb, cnt)) 185 if (!sb_has_quota_active(sb, cnt))
182 continue; 186 continue;
183 mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, I_MUTEX_QUOTA); 187 mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex,
188 I_MUTEX_QUOTA);
184 truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0); 189 truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
185 mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex); 190 mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex);
186 } 191 }
@@ -200,14 +205,15 @@ void sync_dquots(struct super_block *sb, int type)
200 spin_lock(&sb_lock); 205 spin_lock(&sb_lock);
201restart: 206restart:
202 list_for_each_entry(sb, &super_blocks, s_list) { 207 list_for_each_entry(sb, &super_blocks, s_list) {
203 /* This test just improves performance so it needn't be reliable... */ 208 /* This test just improves performance so it needn't be
209 * reliable... */
204 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 210 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
205 if (type != -1 && type != cnt) 211 if (type != -1 && type != cnt)
206 continue; 212 continue;
207 if (!sb_has_quota_active(sb, cnt)) 213 if (!sb_has_quota_active(sb, cnt))
208 continue; 214 continue;
209 if (!info_dirty(&sb_dqopt(sb)->info[cnt]) && 215 if (!info_dirty(&sb_dqopt(sb)->info[cnt]) &&
210 list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list)) 216 list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list))
211 continue; 217 continue;
212 break; 218 break;
213 } 219 }
@@ -227,7 +233,8 @@ restart:
227} 233}
228 234
229/* Copy parameters and call proper function */ 235/* Copy parameters and call proper function */
230static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void __user *addr) 236static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
237 void __user *addr)
231{ 238{
232 int ret; 239 int ret;
233 240
@@ -235,7 +242,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
235 case Q_QUOTAON: { 242 case Q_QUOTAON: {
236 char *pathname; 243 char *pathname;
237 244
238 if (IS_ERR(pathname = getname(addr))) 245 pathname = getname(addr);
246 if (IS_ERR(pathname))
239 return PTR_ERR(pathname); 247 return PTR_ERR(pathname);
240 ret = sb->s_qcop->quota_on(sb, type, id, pathname, 0); 248 ret = sb->s_qcop->quota_on(sb, type, id, pathname, 0);
241 putname(pathname); 249 putname(pathname);
@@ -261,7 +269,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
261 case Q_GETINFO: { 269 case Q_GETINFO: {
262 struct if_dqinfo info; 270 struct if_dqinfo info;
263 271
264 if ((ret = sb->s_qcop->get_info(sb, type, &info))) 272 ret = sb->s_qcop->get_info(sb, type, &info);
273 if (ret)
265 return ret; 274 return ret;
266 if (copy_to_user(addr, &info, sizeof(info))) 275 if (copy_to_user(addr, &info, sizeof(info)))
267 return -EFAULT; 276 return -EFAULT;
@@ -277,7 +286,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
277 case Q_GETQUOTA: { 286 case Q_GETQUOTA: {
278 struct if_dqblk idq; 287 struct if_dqblk idq;
279 288
280 if ((ret = sb->s_qcop->get_dqblk(sb, type, id, &idq))) 289 ret = sb->s_qcop->get_dqblk(sb, type, id, &idq);
290 if (ret)
281 return ret; 291 return ret;
282 if (copy_to_user(addr, &idq, sizeof(idq))) 292 if (copy_to_user(addr, &idq, sizeof(idq)))
283 return -EFAULT; 293 return -EFAULT;
@@ -322,7 +332,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
322 case Q_XGETQUOTA: { 332 case Q_XGETQUOTA: {
323 struct fs_disk_quota fdq; 333 struct fs_disk_quota fdq;
324 334
325 if ((ret = sb->s_qcop->get_xquota(sb, type, id, &fdq))) 335 ret = sb->s_qcop->get_xquota(sb, type, id, &fdq);
336 if (ret)
326 return ret; 337 return ret;
327 if (copy_to_user(addr, &fdq, sizeof(fdq))) 338 if (copy_to_user(addr, &fdq, sizeof(fdq)))
328 return -EFAULT; 339 return -EFAULT;