aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dquot.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2008-08-20 08:45:12 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:36:55 -0500
commit12095460f7f315f8ef67a55b2194195d325d48d7 (patch)
tree4e878139ccd29a2adeb2a9fa6fcd9c279e8ce6f4 /fs/dquot.c
parent74f783af95c982aef6d3a1415275650dcf511666 (diff)
quota: Increase size of variables for limits and inode usage
So far quota was fine with quota block limits and inode limits/numbers in a 32-bit type. Now with rapid increase in storage sizes there are coming requests to be able to handle quota limits above 4TB / more that 2^32 inodes. So bump up sizes of types in mem_dqblk structure to 64-bits to be able to handle this. Also update inode allocation / checking functions to use qsize_t and make global structure keep quota limits in bytes so that things are consistent. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/dquot.c')
-rw-r--r--fs/dquot.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/fs/dquot.c b/fs/dquot.c
index 1b5fc4b7fbeb..c02223b6aeb2 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -835,7 +835,7 @@ static void drop_dquot_ref(struct super_block *sb, int type)
835 } 835 }
836} 836}
837 837
838static inline void dquot_incr_inodes(struct dquot *dquot, unsigned long number) 838static inline void dquot_incr_inodes(struct dquot *dquot, qsize_t number)
839{ 839{
840 dquot->dq_dqb.dqb_curinodes += number; 840 dquot->dq_dqb.dqb_curinodes += number;
841} 841}
@@ -845,7 +845,7 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number)
845 dquot->dq_dqb.dqb_curspace += number; 845 dquot->dq_dqb.dqb_curspace += number;
846} 846}
847 847
848static inline void dquot_decr_inodes(struct dquot *dquot, unsigned long number) 848static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
849{ 849{
850 if (dquot->dq_dqb.dqb_curinodes > number) 850 if (dquot->dq_dqb.dqb_curinodes > number)
851 dquot->dq_dqb.dqb_curinodes -= number; 851 dquot->dq_dqb.dqb_curinodes -= number;
@@ -862,7 +862,7 @@ static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
862 dquot->dq_dqb.dqb_curspace -= number; 862 dquot->dq_dqb.dqb_curspace -= number;
863 else 863 else
864 dquot->dq_dqb.dqb_curspace = 0; 864 dquot->dq_dqb.dqb_curspace = 0;
865 if (toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit) 865 if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
866 dquot->dq_dqb.dqb_btime = (time_t) 0; 866 dquot->dq_dqb.dqb_btime = (time_t) 0;
867 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 867 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
868} 868}
@@ -1038,7 +1038,7 @@ static inline char ignore_hardlimit(struct dquot *dquot)
1038} 1038}
1039 1039
1040/* needs dq_data_lock */ 1040/* needs dq_data_lock */
1041static int check_idq(struct dquot *dquot, ulong inodes, char *warntype) 1041static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
1042{ 1042{
1043 *warntype = QUOTA_NL_NOWARN; 1043 *warntype = QUOTA_NL_NOWARN;
1044 if (inodes <= 0 || test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1044 if (inodes <= 0 || test_bit(DQ_FAKE_B, &dquot->dq_flags))
@@ -1077,7 +1077,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1077 return QUOTA_OK; 1077 return QUOTA_OK;
1078 1078
1079 if (dquot->dq_dqb.dqb_bhardlimit && 1079 if (dquot->dq_dqb.dqb_bhardlimit &&
1080 toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bhardlimit && 1080 dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bhardlimit &&
1081 !ignore_hardlimit(dquot)) { 1081 !ignore_hardlimit(dquot)) {
1082 if (!prealloc) 1082 if (!prealloc)
1083 *warntype = QUOTA_NL_BHARDWARN; 1083 *warntype = QUOTA_NL_BHARDWARN;
@@ -1085,7 +1085,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1085 } 1085 }
1086 1086
1087 if (dquot->dq_dqb.dqb_bsoftlimit && 1087 if (dquot->dq_dqb.dqb_bsoftlimit &&
1088 toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bsoftlimit && 1088 dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit &&
1089 dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime && 1089 dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime &&
1090 !ignore_hardlimit(dquot)) { 1090 !ignore_hardlimit(dquot)) {
1091 if (!prealloc) 1091 if (!prealloc)
@@ -1094,7 +1094,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1094 } 1094 }
1095 1095
1096 if (dquot->dq_dqb.dqb_bsoftlimit && 1096 if (dquot->dq_dqb.dqb_bsoftlimit &&
1097 toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bsoftlimit && 1097 dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit &&
1098 dquot->dq_dqb.dqb_btime == 0) { 1098 dquot->dq_dqb.dqb_btime == 0) {
1099 if (!prealloc) { 1099 if (!prealloc) {
1100 *warntype = QUOTA_NL_BSOFTWARN; 1100 *warntype = QUOTA_NL_BSOFTWARN;
@@ -1111,7 +1111,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1111 return QUOTA_OK; 1111 return QUOTA_OK;
1112} 1112}
1113 1113
1114static int info_idq_free(struct dquot *dquot, ulong inodes) 1114static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1115{ 1115{
1116 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1116 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1117 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit) 1117 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit)
@@ -1128,15 +1128,13 @@ static int info_idq_free(struct dquot *dquot, ulong inodes)
1128static int info_bdq_free(struct dquot *dquot, qsize_t space) 1128static int info_bdq_free(struct dquot *dquot, qsize_t space)
1129{ 1129{
1130 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1130 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1131 toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit) 1131 dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
1132 return QUOTA_NL_NOWARN; 1132 return QUOTA_NL_NOWARN;
1133 1133
1134 if (toqb(dquot->dq_dqb.dqb_curspace - space) <= 1134 if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
1135 dquot->dq_dqb.dqb_bsoftlimit)
1136 return QUOTA_NL_BSOFTBELOW; 1135 return QUOTA_NL_BSOFTBELOW;
1137 if (toqb(dquot->dq_dqb.dqb_curspace) >= dquot->dq_dqb.dqb_bhardlimit && 1136 if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit &&
1138 toqb(dquot->dq_dqb.dqb_curspace - space) < 1137 dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit)
1139 dquot->dq_dqb.dqb_bhardlimit)
1140 return QUOTA_NL_BHARDBELOW; 1138 return QUOTA_NL_BHARDBELOW;
1141 return QUOTA_NL_NOWARN; 1139 return QUOTA_NL_NOWARN;
1142} 1140}
@@ -1279,7 +1277,7 @@ warn_put_all:
1279/* 1277/*
1280 * This operation can block, but only after everything is updated 1278 * This operation can block, but only after everything is updated
1281 */ 1279 */
1282int dquot_alloc_inode(const struct inode *inode, unsigned long number) 1280int dquot_alloc_inode(const struct inode *inode, qsize_t number)
1283{ 1281{
1284 int cnt, ret = NO_QUOTA; 1282 int cnt, ret = NO_QUOTA;
1285 char warntype[MAXQUOTAS]; 1283 char warntype[MAXQUOTAS];
@@ -1364,7 +1362,7 @@ out_sub:
1364/* 1362/*
1365 * This operation can block, but only after everything is updated 1363 * This operation can block, but only after everything is updated
1366 */ 1364 */
1367int dquot_free_inode(const struct inode *inode, unsigned long number) 1365int dquot_free_inode(const struct inode *inode, qsize_t number)
1368{ 1366{
1369 unsigned int cnt; 1367 unsigned int cnt;
1370 char warntype[MAXQUOTAS]; 1368 char warntype[MAXQUOTAS];
@@ -1883,14 +1881,24 @@ int vfs_dq_quota_on_remount(struct super_block *sb)
1883 return ret; 1881 return ret;
1884} 1882}
1885 1883
1884static inline qsize_t qbtos(qsize_t blocks)
1885{
1886 return blocks << QIF_DQBLKSIZE_BITS;
1887}
1888
1889static inline qsize_t stoqb(qsize_t space)
1890{
1891 return (space + QIF_DQBLKSIZE - 1) >> QIF_DQBLKSIZE_BITS;
1892}
1893
1886/* Generic routine for getting common part of quota structure */ 1894/* Generic routine for getting common part of quota structure */
1887static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di) 1895static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di)
1888{ 1896{
1889 struct mem_dqblk *dm = &dquot->dq_dqb; 1897 struct mem_dqblk *dm = &dquot->dq_dqb;
1890 1898
1891 spin_lock(&dq_data_lock); 1899 spin_lock(&dq_data_lock);
1892 di->dqb_bhardlimit = dm->dqb_bhardlimit; 1900 di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit);
1893 di->dqb_bsoftlimit = dm->dqb_bsoftlimit; 1901 di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit);
1894 di->dqb_curspace = dm->dqb_curspace; 1902 di->dqb_curspace = dm->dqb_curspace;
1895 di->dqb_ihardlimit = dm->dqb_ihardlimit; 1903 di->dqb_ihardlimit = dm->dqb_ihardlimit;
1896 di->dqb_isoftlimit = dm->dqb_isoftlimit; 1904 di->dqb_isoftlimit = dm->dqb_isoftlimit;
@@ -1937,8 +1945,8 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1937 check_blim = 1; 1945 check_blim = 1;
1938 } 1946 }
1939 if (di->dqb_valid & QIF_BLIMITS) { 1947 if (di->dqb_valid & QIF_BLIMITS) {
1940 dm->dqb_bsoftlimit = di->dqb_bsoftlimit; 1948 dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
1941 dm->dqb_bhardlimit = di->dqb_bhardlimit; 1949 dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
1942 check_blim = 1; 1950 check_blim = 1;
1943 } 1951 }
1944 if (di->dqb_valid & QIF_INODES) { 1952 if (di->dqb_valid & QIF_INODES) {
@@ -1956,7 +1964,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1956 dm->dqb_itime = di->dqb_itime; 1964 dm->dqb_itime = di->dqb_itime;
1957 1965
1958 if (check_blim) { 1966 if (check_blim) {
1959 if (!dm->dqb_bsoftlimit || toqb(dm->dqb_curspace) < dm->dqb_bsoftlimit) { 1967 if (!dm->dqb_bsoftlimit || dm->dqb_curspace < dm->dqb_bsoftlimit) {
1960 dm->dqb_btime = 0; 1968 dm->dqb_btime = 0;
1961 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 1969 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1962 } 1970 }