aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/quota_tree.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/quota_tree.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/quota_tree.c')
-rw-r--r--fs/quota/quota_tree.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
index 48e35a48f1c..f81f4bcfb17 100644
--- a/fs/quota/quota_tree.c
+++ b/fs/quota/quota_tree.c
@@ -43,7 +43,8 @@ static char *getdqbuf(size_t size)
43{ 43{
44 char *buf = kmalloc(size, GFP_NOFS); 44 char *buf = kmalloc(size, GFP_NOFS);
45 if (!buf) 45 if (!buf)
46 printk(KERN_WARNING "VFS: Not enough memory for quota buffers.\n"); 46 printk(KERN_WARNING
47 "VFS: Not enough memory for quota buffers.\n");
47 return buf; 48 return buf;
48} 49}
49 50
@@ -113,7 +114,8 @@ static int put_free_dqblk(struct qtree_mem_dqinfo *info, char *buf, uint blk)
113} 114}
114 115
115/* Remove given block from the list of blocks with free entries */ 116/* Remove given block from the list of blocks with free entries */
116static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, uint blk) 117static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
118 uint blk)
117{ 119{
118 char *tmpbuf = getdqbuf(info->dqi_usable_bs); 120 char *tmpbuf = getdqbuf(info->dqi_usable_bs);
119 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; 121 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
@@ -150,7 +152,9 @@ static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, uint bl
150 dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0); 152 dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0);
151 /* No matter whether write succeeds block is out of list */ 153 /* No matter whether write succeeds block is out of list */
152 if (write_blk(info, blk, buf) < 0) 154 if (write_blk(info, blk, buf) < 0)
153 printk(KERN_ERR "VFS: Can't write block (%u) with free entries.\n", blk); 155 printk(KERN_ERR
156 "VFS: Can't write block (%u) with free entries.\n",
157 blk);
154 return 0; 158 return 0;
155out_buf: 159out_buf:
156 kfree(tmpbuf); 160 kfree(tmpbuf);
@@ -158,7 +162,8 @@ out_buf:
158} 162}
159 163
160/* Insert given block to the beginning of list with free entries */ 164/* Insert given block to the beginning of list with free entries */
161static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, uint blk) 165static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
166 uint blk)
162{ 167{
163 char *tmpbuf = getdqbuf(info->dqi_usable_bs); 168 char *tmpbuf = getdqbuf(info->dqi_usable_bs);
164 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf; 169 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
@@ -230,7 +235,8 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
230 return 0; 235 return 0;
231 } 236 }
232 memset(buf, 0, info->dqi_usable_bs); 237 memset(buf, 0, info->dqi_usable_bs);
233 /* This is enough as block is already zeroed and entry list is empty... */ 238 /* This is enough as the block is already zeroed and the entry
239 * list is empty... */
234 info->dqi_free_entry = blk; 240 info->dqi_free_entry = blk;
235 mark_info_dirty(dquot->dq_sb, dquot->dq_type); 241 mark_info_dirty(dquot->dq_sb, dquot->dq_type);
236 } 242 }
@@ -246,10 +252,12 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
246 } 252 }
247 le16_add_cpu(&dh->dqdh_entries, 1); 253 le16_add_cpu(&dh->dqdh_entries, 1);
248 /* Find free structure in block */ 254 /* Find free structure in block */
249 for (i = 0, ddquot = buf + sizeof(struct qt_disk_dqdbheader); 255 ddquot = buf + sizeof(struct qt_disk_dqdbheader);
250 i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot); 256 for (i = 0; i < qtree_dqstr_in_blk(info); i++) {
251 i++, ddquot += info->dqi_entry_size) 257 if (qtree_entry_unused(info, ddquot))
252 ; 258 break;
259 ddquot += info->dqi_entry_size;
260 }
253#ifdef __QUOTA_QT_PARANOIA 261#ifdef __QUOTA_QT_PARANOIA
254 if (i == qtree_dqstr_in_blk(info)) { 262 if (i == qtree_dqstr_in_blk(info)) {
255 printk(KERN_ERR "VFS: find_free_dqentry(): Data block full " 263 printk(KERN_ERR "VFS: find_free_dqentry(): Data block full "
@@ -340,7 +348,8 @@ static inline int dq_insert_tree(struct qtree_mem_dqinfo *info,
340} 348}
341 349
342/* 350/*
343 * We don't have to be afraid of deadlocks as we never have quotas on quota files... 351 * We don't have to be afraid of deadlocks as we never have quotas on quota
352 * files...
344 */ 353 */
345int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) 354int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
346{ 355{
@@ -515,10 +524,12 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
515 printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); 524 printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
516 goto out_buf; 525 goto out_buf;
517 } 526 }
518 for (i = 0, ddquot = buf + sizeof(struct qt_disk_dqdbheader); 527 ddquot = buf + sizeof(struct qt_disk_dqdbheader);
519 i < qtree_dqstr_in_blk(info) && !info->dqi_ops->is_id(ddquot, dquot); 528 for (i = 0; i < qtree_dqstr_in_blk(info); i++) {
520 i++, ddquot += info->dqi_entry_size) 529 if (info->dqi_ops->is_id(ddquot, dquot))
521 ; 530 break;
531 ddquot += info->dqi_entry_size;
532 }
522 if (i == qtree_dqstr_in_blk(info)) { 533 if (i == qtree_dqstr_in_blk(info)) {
523 printk(KERN_ERR "VFS: Quota for id %u referenced " 534 printk(KERN_ERR "VFS: Quota for id %u referenced "
524 "but not present.\n", dquot->dq_id); 535 "but not present.\n", dquot->dq_id);
@@ -632,7 +643,8 @@ EXPORT_SYMBOL(qtree_read_dquot);
632 * the only one operating on dquot (thanks to dq_lock) */ 643 * the only one operating on dquot (thanks to dq_lock) */
633int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) 644int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
634{ 645{
635 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) && !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace)) 646 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) &&
647 !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace))
636 return qtree_delete_dquot(info, dquot); 648 return qtree_delete_dquot(info, dquot);
637 return 0; 649 return 0;
638} 650}