aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/dquot.c50
-rw-r--r--fs/quota_v1.c25
-rw-r--r--fs/quota_v2.c21
3 files changed, 65 insertions, 31 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 }
diff --git a/fs/quota_v1.c b/fs/quota_v1.c
index 5ae15b13eeb0..3e078eee5644 100644
--- a/fs/quota_v1.c
+++ b/fs/quota_v1.c
@@ -14,14 +14,27 @@ MODULE_AUTHOR("Jan Kara");
14MODULE_DESCRIPTION("Old quota format support"); 14MODULE_DESCRIPTION("Old quota format support");
15MODULE_LICENSE("GPL"); 15MODULE_LICENSE("GPL");
16 16
17#define QUOTABLOCK_BITS 10
18#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
19
20static inline qsize_t v1_stoqb(qsize_t space)
21{
22 return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
23}
24
25static inline qsize_t v1_qbtos(qsize_t blocks)
26{
27 return blocks << QUOTABLOCK_BITS;
28}
29
17static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d) 30static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d)
18{ 31{
19 m->dqb_ihardlimit = d->dqb_ihardlimit; 32 m->dqb_ihardlimit = d->dqb_ihardlimit;
20 m->dqb_isoftlimit = d->dqb_isoftlimit; 33 m->dqb_isoftlimit = d->dqb_isoftlimit;
21 m->dqb_curinodes = d->dqb_curinodes; 34 m->dqb_curinodes = d->dqb_curinodes;
22 m->dqb_bhardlimit = d->dqb_bhardlimit; 35 m->dqb_bhardlimit = v1_qbtos(d->dqb_bhardlimit);
23 m->dqb_bsoftlimit = d->dqb_bsoftlimit; 36 m->dqb_bsoftlimit = v1_qbtos(d->dqb_bsoftlimit);
24 m->dqb_curspace = ((qsize_t)d->dqb_curblocks) << QUOTABLOCK_BITS; 37 m->dqb_curspace = v1_qbtos(d->dqb_curblocks);
25 m->dqb_itime = d->dqb_itime; 38 m->dqb_itime = d->dqb_itime;
26 m->dqb_btime = d->dqb_btime; 39 m->dqb_btime = d->dqb_btime;
27} 40}
@@ -31,9 +44,9 @@ static void v1_mem2disk_dqblk(struct v1_disk_dqblk *d, struct mem_dqblk *m)
31 d->dqb_ihardlimit = m->dqb_ihardlimit; 44 d->dqb_ihardlimit = m->dqb_ihardlimit;
32 d->dqb_isoftlimit = m->dqb_isoftlimit; 45 d->dqb_isoftlimit = m->dqb_isoftlimit;
33 d->dqb_curinodes = m->dqb_curinodes; 46 d->dqb_curinodes = m->dqb_curinodes;
34 d->dqb_bhardlimit = m->dqb_bhardlimit; 47 d->dqb_bhardlimit = v1_stoqb(m->dqb_bhardlimit);
35 d->dqb_bsoftlimit = m->dqb_bsoftlimit; 48 d->dqb_bsoftlimit = v1_stoqb(m->dqb_bsoftlimit);
36 d->dqb_curblocks = toqb(m->dqb_curspace); 49 d->dqb_curblocks = v1_stoqb(m->dqb_curspace);
37 d->dqb_itime = m->dqb_itime; 50 d->dqb_itime = m->dqb_itime;
38 d->dqb_btime = m->dqb_btime; 51 d->dqb_btime = m->dqb_btime;
39} 52}
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index b53827dc02d9..51c4717f7c6a 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -26,6 +26,19 @@ typedef char *dqbuf_t;
26#define GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff) 26#define GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff)
27#define GETENTRIES(buf) ((struct v2_disk_dqblk *)(((char *)buf)+sizeof(struct v2_disk_dqdbheader))) 27#define GETENTRIES(buf) ((struct v2_disk_dqblk *)(((char *)buf)+sizeof(struct v2_disk_dqdbheader)))
28 28
29#define QUOTABLOCK_BITS 10
30#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
31
32static inline qsize_t v2_stoqb(qsize_t space)
33{
34 return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
35}
36
37static inline qsize_t v2_qbtos(qsize_t blocks)
38{
39 return blocks << QUOTABLOCK_BITS;
40}
41
29/* Check whether given file is really vfsv0 quotafile */ 42/* Check whether given file is really vfsv0 quotafile */
30static int v2_check_quota_file(struct super_block *sb, int type) 43static int v2_check_quota_file(struct super_block *sb, int type)
31{ 44{
@@ -104,8 +117,8 @@ static void disk2memdqb(struct mem_dqblk *m, struct v2_disk_dqblk *d)
104 m->dqb_isoftlimit = le32_to_cpu(d->dqb_isoftlimit); 117 m->dqb_isoftlimit = le32_to_cpu(d->dqb_isoftlimit);
105 m->dqb_curinodes = le32_to_cpu(d->dqb_curinodes); 118 m->dqb_curinodes = le32_to_cpu(d->dqb_curinodes);
106 m->dqb_itime = le64_to_cpu(d->dqb_itime); 119 m->dqb_itime = le64_to_cpu(d->dqb_itime);
107 m->dqb_bhardlimit = le32_to_cpu(d->dqb_bhardlimit); 120 m->dqb_bhardlimit = v2_qbtos(le32_to_cpu(d->dqb_bhardlimit));
108 m->dqb_bsoftlimit = le32_to_cpu(d->dqb_bsoftlimit); 121 m->dqb_bsoftlimit = v2_qbtos(le32_to_cpu(d->dqb_bsoftlimit));
109 m->dqb_curspace = le64_to_cpu(d->dqb_curspace); 122 m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
110 m->dqb_btime = le64_to_cpu(d->dqb_btime); 123 m->dqb_btime = le64_to_cpu(d->dqb_btime);
111} 124}
@@ -116,8 +129,8 @@ static void mem2diskdqb(struct v2_disk_dqblk *d, struct mem_dqblk *m, qid_t id)
116 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit); 129 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit);
117 d->dqb_curinodes = cpu_to_le32(m->dqb_curinodes); 130 d->dqb_curinodes = cpu_to_le32(m->dqb_curinodes);
118 d->dqb_itime = cpu_to_le64(m->dqb_itime); 131 d->dqb_itime = cpu_to_le64(m->dqb_itime);
119 d->dqb_bhardlimit = cpu_to_le32(m->dqb_bhardlimit); 132 d->dqb_bhardlimit = cpu_to_le32(v2_qbtos(m->dqb_bhardlimit));
120 d->dqb_bsoftlimit = cpu_to_le32(m->dqb_bsoftlimit); 133 d->dqb_bsoftlimit = cpu_to_le32(v2_qbtos(m->dqb_bsoftlimit));
121 d->dqb_curspace = cpu_to_le64(m->dqb_curspace); 134 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
122 d->dqb_btime = cpu_to_le64(m->dqb_btime); 135 d->dqb_btime = cpu_to_le64(m->dqb_btime);
123 d->dqb_id = cpu_to_le32(id); 136 d->dqb_id = cpu_to_le32(id);