aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/dquot.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-01-27 09:47:22 -0500
committerJan Kara <jack@suse.cz>2009-03-25 21:18:38 -0400
commit268157ba673e2a868c167211e39fcad4ada5fd1e (patch)
treed6747ab0c15cd0f9daf986f6e749a56d062e1e7f /fs/quota/dquot.c
parent7a2435d874388271cfe5046d180751352a1d30a2 (diff)
quota: Coding style fixes
Wrap long lines, remove assignments from conditions, rewrite two overcomplicated for loops. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r--fs/quota/dquot.c181
1 files changed, 114 insertions, 67 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 4a37b8e32b4e..a1bd5eabbe50 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -156,7 +156,9 @@ void unregister_quota_format(struct quota_format_type *fmt)
156 struct quota_format_type **actqf; 156 struct quota_format_type **actqf;
157 157
158 spin_lock(&dq_list_lock); 158 spin_lock(&dq_list_lock);
159 for (actqf = &quota_formats; *actqf && *actqf != fmt; actqf = &(*actqf)->qf_next); 159 for (actqf = &quota_formats; *actqf && *actqf != fmt;
160 actqf = &(*actqf)->qf_next)
161 ;
160 if (*actqf) 162 if (*actqf)
161 *actqf = (*actqf)->qf_next; 163 *actqf = (*actqf)->qf_next;
162 spin_unlock(&dq_list_lock); 164 spin_unlock(&dq_list_lock);
@@ -168,18 +170,25 @@ static struct quota_format_type *find_quota_format(int id)
168 struct quota_format_type *actqf; 170 struct quota_format_type *actqf;
169 171
170 spin_lock(&dq_list_lock); 172 spin_lock(&dq_list_lock);
171 for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; actqf = actqf->qf_next); 173 for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id;
174 actqf = actqf->qf_next)
175 ;
172 if (!actqf || !try_module_get(actqf->qf_owner)) { 176 if (!actqf || !try_module_get(actqf->qf_owner)) {
173 int qm; 177 int qm;
174 178
175 spin_unlock(&dq_list_lock); 179 spin_unlock(&dq_list_lock);
176 180
177 for (qm = 0; module_names[qm].qm_fmt_id && module_names[qm].qm_fmt_id != id; qm++); 181 for (qm = 0; module_names[qm].qm_fmt_id &&
178 if (!module_names[qm].qm_fmt_id || request_module(module_names[qm].qm_mod_name)) 182 module_names[qm].qm_fmt_id != id; qm++)
183 ;
184 if (!module_names[qm].qm_fmt_id ||
185 request_module(module_names[qm].qm_mod_name))
179 return NULL; 186 return NULL;
180 187
181 spin_lock(&dq_list_lock); 188 spin_lock(&dq_list_lock);
182 for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; actqf = actqf->qf_next); 189 for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id;
190 actqf = actqf->qf_next)
191 ;
183 if (actqf && !try_module_get(actqf->qf_owner)) 192 if (actqf && !try_module_get(actqf->qf_owner))
184 actqf = NULL; 193 actqf = NULL;
185 } 194 }
@@ -234,7 +243,8 @@ hashfn(const struct super_block *sb, unsigned int id, int type)
234 */ 243 */
235static inline void insert_dquot_hash(struct dquot *dquot) 244static inline void insert_dquot_hash(struct dquot *dquot)
236{ 245{
237 struct hlist_head *head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type); 246 struct hlist_head *head;
247 head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type);
238 hlist_add_head(&dquot->dq_hash, head); 248 hlist_add_head(&dquot->dq_hash, head);
239} 249}
240 250
@@ -251,7 +261,8 @@ static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb,
251 261
252 hlist_for_each (node, dquot_hash+hashent) { 262 hlist_for_each (node, dquot_hash+hashent) {
253 dquot = hlist_entry(node, struct dquot, dq_hash); 263 dquot = hlist_entry(node, struct dquot, dq_hash);
254 if (dquot->dq_sb == sb && dquot->dq_id == id && dquot->dq_type == type) 264 if (dquot->dq_sb == sb && dquot->dq_id == id &&
265 dquot->dq_type == type)
255 return dquot; 266 return dquot;
256 } 267 }
257 return NULL; 268 return NULL;
@@ -351,8 +362,10 @@ int dquot_acquire(struct dquot *dquot)
351 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { 362 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
352 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); 363 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot);
353 /* Write the info if needed */ 364 /* Write the info if needed */
354 if (info_dirty(&dqopt->info[dquot->dq_type])) 365 if (info_dirty(&dqopt->info[dquot->dq_type])) {
355 ret2 = dqopt->ops[dquot->dq_type]->write_file_info(dquot->dq_sb, dquot->dq_type); 366 ret2 = dqopt->ops[dquot->dq_type]->write_file_info(
367 dquot->dq_sb, dquot->dq_type);
368 }
356 if (ret < 0) 369 if (ret < 0)
357 goto out_iolock; 370 goto out_iolock;
358 if (ret2 < 0) { 371 if (ret2 < 0) {
@@ -387,8 +400,10 @@ int dquot_commit(struct dquot *dquot)
387 * => we have better not writing it */ 400 * => we have better not writing it */
388 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { 401 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
389 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); 402 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot);
390 if (info_dirty(&dqopt->info[dquot->dq_type])) 403 if (info_dirty(&dqopt->info[dquot->dq_type])) {
391 ret2 = dqopt->ops[dquot->dq_type]->write_file_info(dquot->dq_sb, dquot->dq_type); 404 ret2 = dqopt->ops[dquot->dq_type]->write_file_info(
405 dquot->dq_sb, dquot->dq_type);
406 }
392 if (ret >= 0) 407 if (ret >= 0)
393 ret = ret2; 408 ret = ret2;
394 } 409 }
@@ -414,8 +429,10 @@ int dquot_release(struct dquot *dquot)
414 if (dqopt->ops[dquot->dq_type]->release_dqblk) { 429 if (dqopt->ops[dquot->dq_type]->release_dqblk) {
415 ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot); 430 ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot);
416 /* Write the info */ 431 /* Write the info */
417 if (info_dirty(&dqopt->info[dquot->dq_type])) 432 if (info_dirty(&dqopt->info[dquot->dq_type])) {
418 ret2 = dqopt->ops[dquot->dq_type]->write_file_info(dquot->dq_sb, dquot->dq_type); 433 ret2 = dqopt->ops[dquot->dq_type]->write_file_info(
434 dquot->dq_sb, dquot->dq_type);
435 }
419 if (ret >= 0) 436 if (ret >= 0)
420 ret = ret2; 437 ret = ret2;
421 } 438 }
@@ -543,7 +560,8 @@ int vfs_quota_sync(struct super_block *sb, int type)
543 spin_lock(&dq_list_lock); 560 spin_lock(&dq_list_lock);
544 dirty = &dqopt->info[cnt].dqi_dirty_list; 561 dirty = &dqopt->info[cnt].dqi_dirty_list;
545 while (!list_empty(dirty)) { 562 while (!list_empty(dirty)) {
546 dquot = list_first_entry(dirty, struct dquot, dq_dirty); 563 dquot = list_first_entry(dirty, struct dquot,
564 dq_dirty);
547 /* Dirty and inactive can be only bad dquot... */ 565 /* Dirty and inactive can be only bad dquot... */
548 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { 566 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
549 clear_dquot_dirty(dquot); 567 clear_dquot_dirty(dquot);
@@ -763,11 +781,12 @@ we_slept:
763 dqstats.lookups++; 781 dqstats.lookups++;
764 spin_unlock(&dq_list_lock); 782 spin_unlock(&dq_list_lock);
765 } 783 }
766 /* Wait for dq_lock - after this we know that either dquot_release() is already 784 /* Wait for dq_lock - after this we know that either dquot_release() is
767 * finished or it will be canceled due to dq_count > 1 test */ 785 * already finished or it will be canceled due to dq_count > 1 test */
768 wait_on_dquot(dquot); 786 wait_on_dquot(dquot);
769 /* Read the dquot and instantiate it (everything done only if needed) */ 787 /* Read the dquot / allocate space in quota file */
770 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && sb->dq_op->acquire_dquot(dquot) < 0) { 788 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) &&
789 sb->dq_op->acquire_dquot(dquot) < 0) {
771 dqput(dquot); 790 dqput(dquot);
772 dquot = NULL; 791 dquot = NULL;
773 goto out; 792 goto out;
@@ -828,7 +847,10 @@ static void add_dquot_ref(struct super_block *sb, int type)
828 iput(old_inode); 847 iput(old_inode);
829} 848}
830 849
831/* Return 0 if dqput() won't block (note that 1 doesn't necessarily mean blocking) */ 850/*
851 * Return 0 if dqput() won't block.
852 * (note that 1 doesn't necessarily mean blocking)
853 */
832static inline int dqput_blocks(struct dquot *dquot) 854static inline int dqput_blocks(struct dquot *dquot)
833{ 855{
834 if (atomic_read(&dquot->dq_count) <= 1) 856 if (atomic_read(&dquot->dq_count) <= 1)
@@ -836,8 +858,11 @@ static inline int dqput_blocks(struct dquot *dquot)
836 return 0; 858 return 0;
837} 859}
838 860
839/* Remove references to dquots from inode - add dquot to list for freeing if needed */ 861/*
840/* We can't race with anybody because we hold dqptr_sem for writing... */ 862 * Remove references to dquots from inode and add dquot to list for freeing
863 * if we have the last referece to dquot
864 * We can't race with anybody because we hold dqptr_sem for writing...
865 */
841static int remove_inode_dquot_ref(struct inode *inode, int type, 866static int remove_inode_dquot_ref(struct inode *inode, int type,
842 struct list_head *tofree_head) 867 struct list_head *tofree_head)
843{ 868{
@@ -851,7 +876,9 @@ static int remove_inode_dquot_ref(struct inode *inode, int type,
851 printk(KERN_WARNING "VFS: Adding dquot with dq_count %d to dispose list.\n", atomic_read(&dquot->dq_count)); 876 printk(KERN_WARNING "VFS: Adding dquot with dq_count %d to dispose list.\n", atomic_read(&dquot->dq_count));
852#endif 877#endif
853 spin_lock(&dq_list_lock); 878 spin_lock(&dq_list_lock);
854 list_add(&dquot->dq_free, tofree_head); /* As dquot must have currently users it can't be on the free list... */ 879 /* As dquot must have currently users it can't be on
880 * the free list... */
881 list_add(&dquot->dq_free, tofree_head);
855 spin_unlock(&dq_list_lock); 882 spin_unlock(&dq_list_lock);
856 return 1; 883 return 1;
857 } 884 }
@@ -861,19 +888,22 @@ static int remove_inode_dquot_ref(struct inode *inode, int type,
861 return 0; 888 return 0;
862} 889}
863 890
864/* Free list of dquots - called from inode.c */ 891/*
865/* dquots are removed from inodes, no new references can be got so we are the only ones holding reference */ 892 * Free list of dquots
893 * Dquots are removed from inodes and no new references can be got so we are
894 * the only ones holding reference
895 */
866static void put_dquot_list(struct list_head *tofree_head) 896static void put_dquot_list(struct list_head *tofree_head)
867{ 897{
868 struct list_head *act_head; 898 struct list_head *act_head;
869 struct dquot *dquot; 899 struct dquot *dquot;
870 900
871 act_head = tofree_head->next; 901 act_head = tofree_head->next;
872 /* So now we have dquots on the list... Just free them */
873 while (act_head != tofree_head) { 902 while (act_head != tofree_head) {
874 dquot = list_entry(act_head, struct dquot, dq_free); 903 dquot = list_entry(act_head, struct dquot, dq_free);
875 act_head = act_head->next; 904 act_head = act_head->next;
876 list_del_init(&dquot->dq_free); /* Remove dquot from the list so we won't have problems... */ 905 /* Remove dquot from the list so we won't have problems... */
906 list_del_init(&dquot->dq_free);
877 dqput(dquot); 907 dqput(dquot);
878 } 908 }
879} 909}
@@ -1131,37 +1161,42 @@ static int ignore_hardlimit(struct dquot *dquot)
1131 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; 1161 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type];
1132 1162
1133 return capable(CAP_SYS_RESOURCE) && 1163 return capable(CAP_SYS_RESOURCE) &&
1134 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD || !(info->dqi_flags & V1_DQF_RSQUASH)); 1164 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD ||
1165 !(info->dqi_flags & V1_DQF_RSQUASH));
1135} 1166}
1136 1167
1137/* needs dq_data_lock */ 1168/* needs dq_data_lock */
1138static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) 1169static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
1139{ 1170{
1171 qsize_t newinodes = dquot->dq_dqb.dqb_curinodes + inodes;
1172
1140 *warntype = QUOTA_NL_NOWARN; 1173 *warntype = QUOTA_NL_NOWARN;
1141 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || 1174 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) ||
1142 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1175 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1143 return QUOTA_OK; 1176 return QUOTA_OK;
1144 1177
1145 if (dquot->dq_dqb.dqb_ihardlimit && 1178 if (dquot->dq_dqb.dqb_ihardlimit &&
1146 (dquot->dq_dqb.dqb_curinodes + inodes) > dquot->dq_dqb.dqb_ihardlimit && 1179 newinodes > dquot->dq_dqb.dqb_ihardlimit &&
1147 !ignore_hardlimit(dquot)) { 1180 !ignore_hardlimit(dquot)) {
1148 *warntype = QUOTA_NL_IHARDWARN; 1181 *warntype = QUOTA_NL_IHARDWARN;
1149 return NO_QUOTA; 1182 return NO_QUOTA;
1150 } 1183 }
1151 1184
1152 if (dquot->dq_dqb.dqb_isoftlimit && 1185 if (dquot->dq_dqb.dqb_isoftlimit &&
1153 (dquot->dq_dqb.dqb_curinodes + inodes) > dquot->dq_dqb.dqb_isoftlimit && 1186 newinodes > dquot->dq_dqb.dqb_isoftlimit &&
1154 dquot->dq_dqb.dqb_itime && get_seconds() >= dquot->dq_dqb.dqb_itime && 1187 dquot->dq_dqb.dqb_itime &&
1188 get_seconds() >= dquot->dq_dqb.dqb_itime &&
1155 !ignore_hardlimit(dquot)) { 1189 !ignore_hardlimit(dquot)) {
1156 *warntype = QUOTA_NL_ISOFTLONGWARN; 1190 *warntype = QUOTA_NL_ISOFTLONGWARN;
1157 return NO_QUOTA; 1191 return NO_QUOTA;
1158 } 1192 }
1159 1193
1160 if (dquot->dq_dqb.dqb_isoftlimit && 1194 if (dquot->dq_dqb.dqb_isoftlimit &&
1161 (dquot->dq_dqb.dqb_curinodes + inodes) > dquot->dq_dqb.dqb_isoftlimit && 1195 newinodes > dquot->dq_dqb.dqb_isoftlimit &&
1162 dquot->dq_dqb.dqb_itime == 0) { 1196 dquot->dq_dqb.dqb_itime == 0) {
1163 *warntype = QUOTA_NL_ISOFTWARN; 1197 *warntype = QUOTA_NL_ISOFTWARN;
1164 dquot->dq_dqb.dqb_itime = get_seconds() + sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; 1198 dquot->dq_dqb.dqb_itime = get_seconds() +
1199 sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace;
1165 } 1200 }
1166 1201
1167 return QUOTA_OK; 1202 return QUOTA_OK;
@@ -1171,9 +1206,10 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
1171static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *warntype) 1206static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *warntype)
1172{ 1207{
1173 qsize_t tspace; 1208 qsize_t tspace;
1209 struct super_block *sb = dquot->dq_sb;
1174 1210
1175 *warntype = QUOTA_NL_NOWARN; 1211 *warntype = QUOTA_NL_NOWARN;
1176 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || 1212 if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) ||
1177 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1213 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1178 return QUOTA_OK; 1214 return QUOTA_OK;
1179 1215
@@ -1190,7 +1226,8 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1190 1226
1191 if (dquot->dq_dqb.dqb_bsoftlimit && 1227 if (dquot->dq_dqb.dqb_bsoftlimit &&
1192 tspace > dquot->dq_dqb.dqb_bsoftlimit && 1228 tspace > dquot->dq_dqb.dqb_bsoftlimit &&
1193 dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime && 1229 dquot->dq_dqb.dqb_btime &&
1230 get_seconds() >= dquot->dq_dqb.dqb_btime &&
1194 !ignore_hardlimit(dquot)) { 1231 !ignore_hardlimit(dquot)) {
1195 if (!prealloc) 1232 if (!prealloc)
1196 *warntype = QUOTA_NL_BSOFTLONGWARN; 1233 *warntype = QUOTA_NL_BSOFTLONGWARN;
@@ -1202,7 +1239,8 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1202 dquot->dq_dqb.dqb_btime == 0) { 1239 dquot->dq_dqb.dqb_btime == 0) {
1203 if (!prealloc) { 1240 if (!prealloc) {
1204 *warntype = QUOTA_NL_BSOFTWARN; 1241 *warntype = QUOTA_NL_BSOFTWARN;
1205 dquot->dq_dqb.dqb_btime = get_seconds() + sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_bgrace; 1242 dquot->dq_dqb.dqb_btime = get_seconds() +
1243 sb_dqopt(sb)->info[dquot->dq_type].dqi_bgrace;
1206 } 1244 }
1207 else 1245 else
1208 /* 1246 /*
@@ -1217,15 +1255,18 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1217 1255
1218static int info_idq_free(struct dquot *dquot, qsize_t inodes) 1256static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1219{ 1257{
1258 qsize_t newinodes;
1259
1220 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1260 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1221 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit || 1261 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit ||
1222 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type)) 1262 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type))
1223 return QUOTA_NL_NOWARN; 1263 return QUOTA_NL_NOWARN;
1224 1264
1225 if (dquot->dq_dqb.dqb_curinodes - inodes <= dquot->dq_dqb.dqb_isoftlimit) 1265 newinodes = dquot->dq_dqb.dqb_curinodes - inodes;
1266 if (newinodes <= dquot->dq_dqb.dqb_isoftlimit)
1226 return QUOTA_NL_ISOFTBELOW; 1267 return QUOTA_NL_ISOFTBELOW;
1227 if (dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_ihardlimit && 1268 if (dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_ihardlimit &&
1228 dquot->dq_dqb.dqb_curinodes - inodes < dquot->dq_dqb.dqb_ihardlimit) 1269 newinodes < dquot->dq_dqb.dqb_ihardlimit)
1229 return QUOTA_NL_IHARDBELOW; 1270 return QUOTA_NL_IHARDBELOW;
1230 return QUOTA_NL_NOWARN; 1271 return QUOTA_NL_NOWARN;
1231} 1272}
@@ -1466,7 +1507,8 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number)
1466 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1507 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1467 if (!inode->i_dquot[cnt]) 1508 if (!inode->i_dquot[cnt])
1468 continue; 1509 continue;
1469 if (check_idq(inode->i_dquot[cnt], number, warntype+cnt) == NO_QUOTA) 1510 if (check_idq(inode->i_dquot[cnt], number, warntype+cnt)
1511 == NO_QUOTA)
1470 goto warn_put_all; 1512 goto warn_put_all;
1471 } 1513 }
1472 1514
@@ -1673,19 +1715,13 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1673 transfer_from[cnt] = NULL; 1715 transfer_from[cnt] = NULL;
1674 transfer_to[cnt] = NULL; 1716 transfer_to[cnt] = NULL;
1675 warntype_to[cnt] = QUOTA_NL_NOWARN; 1717 warntype_to[cnt] = QUOTA_NL_NOWARN;
1676 switch (cnt) {
1677 case USRQUOTA:
1678 if (!chuid)
1679 continue;
1680 transfer_to[cnt] = dqget(inode->i_sb, iattr->ia_uid, cnt);
1681 break;
1682 case GRPQUOTA:
1683 if (!chgid)
1684 continue;
1685 transfer_to[cnt] = dqget(inode->i_sb, iattr->ia_gid, cnt);
1686 break;
1687 }
1688 } 1718 }
1719 if (chuid)
1720 transfer_to[USRQUOTA] = dqget(inode->i_sb, iattr->ia_uid,
1721 USRQUOTA);
1722 if (chgid)
1723 transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid,
1724 GRPQUOTA);
1689 1725
1690 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1726 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1691 /* Now recheck reliably when holding dqptr_sem */ 1727 /* Now recheck reliably when holding dqptr_sem */
@@ -1881,8 +1917,8 @@ int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
1881 drop_dquot_ref(sb, cnt); 1917 drop_dquot_ref(sb, cnt);
1882 invalidate_dquots(sb, cnt); 1918 invalidate_dquots(sb, cnt);
1883 /* 1919 /*
1884 * Now all dquots should be invalidated, all writes done so we should be only 1920 * Now all dquots should be invalidated, all writes done so we
1885 * users of the info. No locks needed. 1921 * should be only users of the info. No locks needed.
1886 */ 1922 */
1887 if (info_dirty(&dqopt->info[cnt])) 1923 if (info_dirty(&dqopt->info[cnt]))
1888 sb->dq_op->write_info(sb, cnt); 1924 sb->dq_op->write_info(sb, cnt);
@@ -1920,10 +1956,12 @@ int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
1920 /* If quota was reenabled in the meantime, we have 1956 /* If quota was reenabled in the meantime, we have
1921 * nothing to do */ 1957 * nothing to do */
1922 if (!sb_has_quota_loaded(sb, cnt)) { 1958 if (!sb_has_quota_loaded(sb, cnt)) {
1923 mutex_lock_nested(&toputinode[cnt]->i_mutex, I_MUTEX_QUOTA); 1959 mutex_lock_nested(&toputinode[cnt]->i_mutex,
1960 I_MUTEX_QUOTA);
1924 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | 1961 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
1925 S_NOATIME | S_NOQUOTA); 1962 S_NOATIME | S_NOQUOTA);
1926 truncate_inode_pages(&toputinode[cnt]->i_data, 0); 1963 truncate_inode_pages(&toputinode[cnt]->i_data,
1964 0);
1927 mutex_unlock(&toputinode[cnt]->i_mutex); 1965 mutex_unlock(&toputinode[cnt]->i_mutex);
1928 mark_inode_dirty(toputinode[cnt]); 1966 mark_inode_dirty(toputinode[cnt]);
1929 } 1967 }
@@ -2013,7 +2051,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
2013 * possible) Also nobody should write to the file - we use 2051 * possible) Also nobody should write to the file - we use
2014 * special IO operations which ignore the immutable bit. */ 2052 * special IO operations which ignore the immutable bit. */
2015 down_write(&dqopt->dqptr_sem); 2053 down_write(&dqopt->dqptr_sem);
2016 oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE | S_NOQUOTA); 2054 oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE |
2055 S_NOQUOTA);
2017 inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE; 2056 inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
2018 up_write(&dqopt->dqptr_sem); 2057 up_write(&dqopt->dqptr_sem);
2019 sb->dq_op->drop(inode); 2058 sb->dq_op->drop(inode);
@@ -2032,7 +2071,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
2032 dqopt->info[type].dqi_fmt_id = format_id; 2071 dqopt->info[type].dqi_fmt_id = format_id;
2033 INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list); 2072 INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list);
2034 mutex_lock(&dqopt->dqio_mutex); 2073 mutex_lock(&dqopt->dqio_mutex);
2035 if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) { 2074 error = dqopt->ops[type]->read_file_info(sb, type);
2075 if (error < 0) {
2036 mutex_unlock(&dqopt->dqio_mutex); 2076 mutex_unlock(&dqopt->dqio_mutex);
2037 goto out_file_init; 2077 goto out_file_init;
2038 } 2078 }
@@ -2254,7 +2294,8 @@ static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di)
2254 spin_unlock(&dq_data_lock); 2294 spin_unlock(&dq_data_lock);
2255} 2295}
2256 2296
2257int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di) 2297int vfs_get_dqblk(struct super_block *sb, int type, qid_t id,
2298 struct if_dqblk *di)
2258{ 2299{
2259 struct dquot *dquot; 2300 struct dquot *dquot;
2260 2301
@@ -2318,22 +2359,25 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
2318 } 2359 }
2319 2360
2320 if (check_blim) { 2361 if (check_blim) {
2321 if (!dm->dqb_bsoftlimit || dm->dqb_curspace < dm->dqb_bsoftlimit) { 2362 if (!dm->dqb_bsoftlimit ||
2363 dm->dqb_curspace < dm->dqb_bsoftlimit) {
2322 dm->dqb_btime = 0; 2364 dm->dqb_btime = 0;
2323 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 2365 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
2324 } 2366 } else if (!(di->dqb_valid & QIF_BTIME))
2325 else if (!(di->dqb_valid & QIF_BTIME)) /* Set grace only if user hasn't provided his own... */ 2367 /* Set grace only if user hasn't provided his own... */
2326 dm->dqb_btime = get_seconds() + dqi->dqi_bgrace; 2368 dm->dqb_btime = get_seconds() + dqi->dqi_bgrace;
2327 } 2369 }
2328 if (check_ilim) { 2370 if (check_ilim) {
2329 if (!dm->dqb_isoftlimit || dm->dqb_curinodes < dm->dqb_isoftlimit) { 2371 if (!dm->dqb_isoftlimit ||
2372 dm->dqb_curinodes < dm->dqb_isoftlimit) {
2330 dm->dqb_itime = 0; 2373 dm->dqb_itime = 0;
2331 clear_bit(DQ_INODES_B, &dquot->dq_flags); 2374 clear_bit(DQ_INODES_B, &dquot->dq_flags);
2332 } 2375 } else if (!(di->dqb_valid & QIF_ITIME))
2333 else if (!(di->dqb_valid & QIF_ITIME)) /* Set grace only if user hasn't provided his own... */ 2376 /* Set grace only if user hasn't provided his own... */
2334 dm->dqb_itime = get_seconds() + dqi->dqi_igrace; 2377 dm->dqb_itime = get_seconds() + dqi->dqi_igrace;
2335 } 2378 }
2336 if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit || dm->dqb_isoftlimit) 2379 if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit ||
2380 dm->dqb_isoftlimit)
2337 clear_bit(DQ_FAKE_B, &dquot->dq_flags); 2381 clear_bit(DQ_FAKE_B, &dquot->dq_flags);
2338 else 2382 else
2339 set_bit(DQ_FAKE_B, &dquot->dq_flags); 2383 set_bit(DQ_FAKE_B, &dquot->dq_flags);
@@ -2343,7 +2387,8 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
2343 return 0; 2387 return 0;
2344} 2388}
2345 2389
2346int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di) 2390int vfs_set_dqblk(struct super_block *sb, int type, qid_t id,
2391 struct if_dqblk *di)
2347{ 2392{
2348 struct dquot *dquot; 2393 struct dquot *dquot;
2349 int rc; 2394 int rc;
@@ -2400,7 +2445,8 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
2400 if (ii->dqi_valid & IIF_IGRACE) 2445 if (ii->dqi_valid & IIF_IGRACE)
2401 mi->dqi_igrace = ii->dqi_igrace; 2446 mi->dqi_igrace = ii->dqi_igrace;
2402 if (ii->dqi_valid & IIF_FLAGS) 2447 if (ii->dqi_valid & IIF_FLAGS)
2403 mi->dqi_flags = (mi->dqi_flags & ~DQF_MASK) | (ii->dqi_flags & DQF_MASK); 2448 mi->dqi_flags = (mi->dqi_flags & ~DQF_MASK) |
2449 (ii->dqi_flags & DQF_MASK);
2404 spin_unlock(&dq_data_lock); 2450 spin_unlock(&dq_data_lock);
2405 mark_info_dirty(sb, type); 2451 mark_info_dirty(sb, type);
2406 /* Force write to disk */ 2452 /* Force write to disk */
@@ -2559,7 +2605,8 @@ static int __init dquot_init(void)
2559 2605
2560#ifdef CONFIG_QUOTA_NETLINK_INTERFACE 2606#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
2561 if (genl_register_family(&quota_genl_family) != 0) 2607 if (genl_register_family(&quota_genl_family) != 0)
2562 printk(KERN_ERR "VFS: Failed to create quota netlink interface.\n"); 2608 printk(KERN_ERR
2609 "VFS: Failed to create quota netlink interface.\n");
2563#endif 2610#endif
2564 2611
2565 return 0; 2612 return 0;