aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-01-26 10:01:43 -0500
committerJan Kara <jack@suse.cz>2009-03-25 21:18:35 -0400
commitdd6f3c6d5a26a282521f15a183fdc2d6f35cfa0f (patch)
treebf10e23743f9399c7c36c0137356df1b14affc3e /fs/quota
parentc516610cfec5c50f84ff8cc315628548481f4990 (diff)
quota: Remove NODQUOT macro
Remove this macro which is just a definition of NULL. Fix a few coding style issues along the way. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/dquot.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index e840fa2b112e..4881db32e56d 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -253,7 +253,7 @@ static inline struct dquot *find_dquot(unsigned int hashent, struct super_block
253 if (dquot->dq_sb == sb && dquot->dq_id == id && dquot->dq_type == type) 253 if (dquot->dq_sb == sb && dquot->dq_id == id && dquot->dq_type == type)
254 return dquot; 254 return dquot;
255 } 255 }
256 return NODQUOT; 256 return NULL;
257} 257}
258 258
259/* Add a dquot to the tail of the free list */ 259/* Add a dquot to the tail of the free list */
@@ -696,7 +696,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
696 696
697 dquot = sb->dq_op->alloc_dquot(sb, type); 697 dquot = sb->dq_op->alloc_dquot(sb, type);
698 if(!dquot) 698 if(!dquot)
699 return NODQUOT; 699 return NULL;
700 700
701 mutex_init(&dquot->dq_lock); 701 mutex_init(&dquot->dq_lock);
702 INIT_LIST_HEAD(&dquot->dq_free); 702 INIT_LIST_HEAD(&dquot->dq_free);
@@ -722,10 +722,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
722struct dquot *dqget(struct super_block *sb, unsigned int id, int type) 722struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
723{ 723{
724 unsigned int hashent = hashfn(sb, id, type); 724 unsigned int hashent = hashfn(sb, id, type);
725 struct dquot *dquot = NODQUOT, *empty = NODQUOT; 725 struct dquot *dquot = NULL, *empty = NULL;
726 726
727 if (!sb_has_quota_active(sb, type)) 727 if (!sb_has_quota_active(sb, type))
728 return NODQUOT; 728 return NULL;
729we_slept: 729we_slept:
730 spin_lock(&dq_list_lock); 730 spin_lock(&dq_list_lock);
731 spin_lock(&dq_state_lock); 731 spin_lock(&dq_state_lock);
@@ -736,15 +736,17 @@ we_slept:
736 } 736 }
737 spin_unlock(&dq_state_lock); 737 spin_unlock(&dq_state_lock);
738 738
739 if ((dquot = find_dquot(hashent, sb, id, type)) == NODQUOT) { 739 dquot = find_dquot(hashent, sb, id, type);
740 if (empty == NODQUOT) { 740 if (!dquot) {
741 if (!empty) {
741 spin_unlock(&dq_list_lock); 742 spin_unlock(&dq_list_lock);
742 if ((empty = get_empty_dquot(sb, type)) == NODQUOT) 743 empty = get_empty_dquot(sb, type);
744 if (!empty)
743 schedule(); /* Try to wait for a moment... */ 745 schedule(); /* Try to wait for a moment... */
744 goto we_slept; 746 goto we_slept;
745 } 747 }
746 dquot = empty; 748 dquot = empty;
747 empty = NODQUOT; 749 empty = NULL;
748 dquot->dq_id = id; 750 dquot->dq_id = id;
749 /* all dquots go on the inuse_list */ 751 /* all dquots go on the inuse_list */
750 put_inuse(dquot); 752 put_inuse(dquot);
@@ -766,7 +768,7 @@ we_slept:
766 /* Read the dquot and instantiate it (everything done only if needed) */ 768 /* Read the dquot and instantiate it (everything done only if needed) */
767 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && sb->dq_op->acquire_dquot(dquot) < 0) { 769 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && sb->dq_op->acquire_dquot(dquot) < 0) {
768 dqput(dquot); 770 dqput(dquot);
769 dquot = NODQUOT; 771 dquot = NULL;
770 goto out; 772 goto out;
771 } 773 }
772#ifdef __DQUOT_PARANOIA 774#ifdef __DQUOT_PARANOIA
@@ -787,9 +789,9 @@ static int dqinit_needed(struct inode *inode, int type)
787 if (IS_NOQUOTA(inode)) 789 if (IS_NOQUOTA(inode))
788 return 0; 790 return 0;
789 if (type != -1) 791 if (type != -1)
790 return inode->i_dquot[type] == NODQUOT; 792 return !inode->i_dquot[type];
791 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 793 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
792 if (inode->i_dquot[cnt] == NODQUOT) 794 if (!inode->i_dquot[cnt])
793 return 1; 795 return 1;
794 return 0; 796 return 0;
795} 797}
@@ -840,8 +842,8 @@ static int remove_inode_dquot_ref(struct inode *inode, int type,
840{ 842{
841 struct dquot *dquot = inode->i_dquot[type]; 843 struct dquot *dquot = inode->i_dquot[type];
842 844
843 inode->i_dquot[type] = NODQUOT; 845 inode->i_dquot[type] = NULL;
844 if (dquot != NODQUOT) { 846 if (dquot) {
845 if (dqput_blocks(dquot)) { 847 if (dqput_blocks(dquot)) {
846#ifdef __DQUOT_PARANOIA 848#ifdef __DQUOT_PARANOIA
847 if (atomic_read(&dquot->dq_count) != 1) 849 if (atomic_read(&dquot->dq_count) != 1)
@@ -1112,7 +1114,7 @@ static inline void flush_warnings(struct dquot * const *dquots, char *warntype)
1112 int i; 1114 int i;
1113 1115
1114 for (i = 0; i < MAXQUOTAS; i++) 1116 for (i = 0; i < MAXQUOTAS; i++)
1115 if (dquots[i] != NODQUOT && warntype[i] != QUOTA_NL_NOWARN && 1117 if (dquots[i] && warntype[i] != QUOTA_NL_NOWARN &&
1116 !warning_issued(dquots[i], warntype[i])) { 1118 !warning_issued(dquots[i], warntype[i])) {
1117#ifdef CONFIG_PRINT_QUOTA_WARNING 1119#ifdef CONFIG_PRINT_QUOTA_WARNING
1118 print_warning(dquots[i], warntype[i]); 1120 print_warning(dquots[i], warntype[i]);
@@ -1249,7 +1251,7 @@ int dquot_initialize(struct inode *inode, int type)
1249{ 1251{
1250 unsigned int id = 0; 1252 unsigned int id = 0;
1251 int cnt, ret = 0; 1253 int cnt, ret = 0;
1252 struct dquot *got[MAXQUOTAS] = { NODQUOT, NODQUOT }; 1254 struct dquot *got[MAXQUOTAS] = { NULL, NULL };
1253 struct super_block *sb = inode->i_sb; 1255 struct super_block *sb = inode->i_sb;
1254 1256
1255 /* First test before acquiring mutex - solves deadlocks when we 1257 /* First test before acquiring mutex - solves deadlocks when we
@@ -1282,9 +1284,9 @@ int dquot_initialize(struct inode *inode, int type)
1282 /* Avoid races with quotaoff() */ 1284 /* Avoid races with quotaoff() */
1283 if (!sb_has_quota_active(sb, cnt)) 1285 if (!sb_has_quota_active(sb, cnt))
1284 continue; 1286 continue;
1285 if (inode->i_dquot[cnt] == NODQUOT) { 1287 if (!inode->i_dquot[cnt]) {
1286 inode->i_dquot[cnt] = got[cnt]; 1288 inode->i_dquot[cnt] = got[cnt];
1287 got[cnt] = NODQUOT; 1289 got[cnt] = NULL;
1288 } 1290 }
1289 } 1291 }
1290out_err: 1292out_err:
@@ -1307,7 +1309,7 @@ int dquot_drop(struct inode *inode)
1307 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1309 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1308 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1310 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1309 put[cnt] = inode->i_dquot[cnt]; 1311 put[cnt] = inode->i_dquot[cnt];
1310 inode->i_dquot[cnt] = NODQUOT; 1312 inode->i_dquot[cnt] = NULL;
1311 } 1313 }
1312 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1314 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1313 1315
@@ -1332,7 +1334,7 @@ void vfs_dq_drop(struct inode *inode)
1332 * must assure that nobody can come after the DQUOT_DROP and 1334 * must assure that nobody can come after the DQUOT_DROP and
1333 * add quota pointers back anyway */ 1335 * add quota pointers back anyway */
1334 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1336 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
1335 if (inode->i_dquot[cnt] != NODQUOT) 1337 if (inode->i_dquot[cnt])
1336 break; 1338 break;
1337 if (cnt < MAXQUOTAS) 1339 if (cnt < MAXQUOTAS)
1338 inode->i_sb->dq_op->drop(inode); 1340 inode->i_sb->dq_op->drop(inode);
@@ -1363,7 +1365,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
1363 1365
1364 spin_lock(&dq_data_lock); 1366 spin_lock(&dq_data_lock);
1365 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1367 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1366 if (inode->i_dquot[cnt] == NODQUOT) 1368 if (!inode->i_dquot[cnt])
1367 continue; 1369 continue;
1368 if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt) 1370 if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt)
1369 == NO_QUOTA) { 1371 == NO_QUOTA) {
@@ -1372,7 +1374,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
1372 } 1374 }
1373 } 1375 }
1374 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1376 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1375 if (inode->i_dquot[cnt] == NODQUOT) 1377 if (!inode->i_dquot[cnt])
1376 continue; 1378 continue;
1377 if (reserve) 1379 if (reserve)
1378 dquot_resv_space(inode->i_dquot[cnt], number); 1380 dquot_resv_space(inode->i_dquot[cnt], number);
@@ -1461,14 +1463,14 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number)
1461 } 1463 }
1462 spin_lock(&dq_data_lock); 1464 spin_lock(&dq_data_lock);
1463 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1465 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1464 if (inode->i_dquot[cnt] == NODQUOT) 1466 if (!inode->i_dquot[cnt])
1465 continue; 1467 continue;
1466 if (check_idq(inode->i_dquot[cnt], number, warntype+cnt) == NO_QUOTA) 1468 if (check_idq(inode->i_dquot[cnt], number, warntype+cnt) == NO_QUOTA)
1467 goto warn_put_all; 1469 goto warn_put_all;
1468 } 1470 }
1469 1471
1470 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1472 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1471 if (inode->i_dquot[cnt] == NODQUOT) 1473 if (!inode->i_dquot[cnt])
1472 continue; 1474 continue;
1473 dquot_incr_inodes(inode->i_dquot[cnt], number); 1475 dquot_incr_inodes(inode->i_dquot[cnt], number);
1474 } 1476 }
@@ -1506,7 +1508,7 @@ int dquot_claim_space(struct inode *inode, qsize_t number)
1506 spin_lock(&dq_data_lock); 1508 spin_lock(&dq_data_lock);
1507 /* Claim reserved quotas to allocated quotas */ 1509 /* Claim reserved quotas to allocated quotas */
1508 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1510 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1509 if (inode->i_dquot[cnt] != NODQUOT) 1511 if (inode->i_dquot[cnt])
1510 dquot_claim_reserved_space(inode->i_dquot[cnt], 1512 dquot_claim_reserved_space(inode->i_dquot[cnt],
1511 number); 1513 number);
1512 } 1514 }
@@ -1540,7 +1542,7 @@ void dquot_release_reserved_space(struct inode *inode, qsize_t number)
1540 spin_lock(&dq_data_lock); 1542 spin_lock(&dq_data_lock);
1541 /* Release reserved dquots */ 1543 /* Release reserved dquots */
1542 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1544 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1543 if (inode->i_dquot[cnt] != NODQUOT) 1545 if (inode->i_dquot[cnt])
1544 dquot_free_reserved_space(inode->i_dquot[cnt], number); 1546 dquot_free_reserved_space(inode->i_dquot[cnt], number);
1545 } 1547 }
1546 spin_unlock(&dq_data_lock); 1548 spin_unlock(&dq_data_lock);
@@ -1576,7 +1578,7 @@ out_sub:
1576 } 1578 }
1577 spin_lock(&dq_data_lock); 1579 spin_lock(&dq_data_lock);
1578 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1580 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1579 if (inode->i_dquot[cnt] == NODQUOT) 1581 if (!inode->i_dquot[cnt])
1580 continue; 1582 continue;
1581 warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number); 1583 warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number);
1582 dquot_decr_space(inode->i_dquot[cnt], number); 1584 dquot_decr_space(inode->i_dquot[cnt], number);
@@ -1614,7 +1616,7 @@ int dquot_free_inode(const struct inode *inode, qsize_t number)
1614 } 1616 }
1615 spin_lock(&dq_data_lock); 1617 spin_lock(&dq_data_lock);
1616 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1618 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1617 if (inode->i_dquot[cnt] == NODQUOT) 1619 if (!inode->i_dquot[cnt])
1618 continue; 1620 continue;
1619 warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number); 1621 warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number);
1620 dquot_decr_inodes(inode->i_dquot[cnt], number); 1622 dquot_decr_inodes(inode->i_dquot[cnt], number);
@@ -1667,8 +1669,8 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1667 return QUOTA_OK; 1669 return QUOTA_OK;
1668 /* Initialize the arrays */ 1670 /* Initialize the arrays */
1669 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1671 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1670 transfer_from[cnt] = NODQUOT; 1672 transfer_from[cnt] = NULL;
1671 transfer_to[cnt] = NODQUOT; 1673 transfer_to[cnt] = NULL;
1672 warntype_to[cnt] = QUOTA_NL_NOWARN; 1674 warntype_to[cnt] = QUOTA_NL_NOWARN;
1673 switch (cnt) { 1675 switch (cnt) {
1674 case USRQUOTA: 1676 case USRQUOTA:
@@ -1696,7 +1698,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1696 space = cur_space + rsv_space; 1698 space = cur_space + rsv_space;
1697 /* Build the transfer_from list and check the limits */ 1699 /* Build the transfer_from list and check the limits */
1698 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1700 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1699 if (transfer_to[cnt] == NODQUOT) 1701 if (!transfer_to[cnt])
1700 continue; 1702 continue;
1701 transfer_from[cnt] = inode->i_dquot[cnt]; 1703 transfer_from[cnt] = inode->i_dquot[cnt];
1702 if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) == 1704 if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) ==
@@ -1712,7 +1714,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1712 /* 1714 /*
1713 * Skip changes for same uid or gid or for turned off quota-type. 1715 * Skip changes for same uid or gid or for turned off quota-type.
1714 */ 1716 */
1715 if (transfer_to[cnt] == NODQUOT) 1717 if (!transfer_to[cnt])
1716 continue; 1718 continue;
1717 1719
1718 /* Due to IO error we might not have transfer_from[] structure */ 1720 /* Due to IO error we might not have transfer_from[] structure */
@@ -1743,7 +1745,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1743 if (transfer_to[cnt]) { 1745 if (transfer_to[cnt]) {
1744 mark_dquot_dirty(transfer_to[cnt]); 1746 mark_dquot_dirty(transfer_to[cnt]);
1745 /* The reference we got is transferred to the inode */ 1747 /* The reference we got is transferred to the inode */
1746 transfer_to[cnt] = NODQUOT; 1748 transfer_to[cnt] = NULL;
1747 } 1749 }
1748 } 1750 }
1749warn_put_all: 1751warn_put_all:
@@ -1761,7 +1763,7 @@ over_quota:
1761 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1763 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1762 /* Clear dquot pointers we don't want to dqput() */ 1764 /* Clear dquot pointers we don't want to dqput() */
1763 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1765 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
1764 transfer_from[cnt] = NODQUOT; 1766 transfer_from[cnt] = NULL;
1765 ret = NO_QUOTA; 1767 ret = NO_QUOTA;
1766 goto warn_put_all; 1768 goto warn_put_all;
1767} 1769}
@@ -2256,7 +2258,7 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
2256 struct dquot *dquot; 2258 struct dquot *dquot;
2257 2259
2258 dquot = dqget(sb, id, type); 2260 dquot = dqget(sb, id, type);
2259 if (dquot == NODQUOT) 2261 if (!dquot)
2260 return -ESRCH; 2262 return -ESRCH;
2261 do_get_dqblk(dquot, di); 2263 do_get_dqblk(dquot, di);
2262 dqput(dquot); 2264 dqput(dquot);