1 From: Jan Kara <jack@suse.cz>
2 References: fate#302681
3 Subject: [PATCH 13/28] quota: Convert union in mem_dqinfo to a pointer
4 Patch-mainline: 2.6.29?
6 Coming quota support for OCFS2 is going to need quite a bit
7 of additional per-sb quota information. Moreover having fs.h
8 include all the types needed for this structure would be a
9 pain in the a**. So remove the union from mem_dqinfo and add
10 a private pointer for filesystem's use.
12 Signed-off-by: Jan Kara <jack@suse.cz>
14 fs/quota_v2.c | 53 +++++++++++++++++++++++++++++----------------
15 include/linux/dqblk_v1.h | 4 ---
16 include/linux/dqblk_v2.h | 4 ---
17 include/linux/quota.h | 5 +---
18 4 files changed, 35 insertions(+), 31 deletions(-)
20 diff --git a/fs/quota_v2.c b/fs/quota_v2.c
21 index a87f102..a371919 100644
24 @@ -71,6 +71,7 @@ static int v2_read_file_info(struct super_block *sb, int type)
26 struct v2_disk_dqinfo dinfo;
27 struct mem_dqinfo *info = sb_dqinfo(sb, type);
28 + struct qtree_mem_dqinfo *qinfo;
31 size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
32 @@ -80,22 +81,29 @@ static int v2_read_file_info(struct super_block *sb, int type)
36 + info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);
37 + if (!info->dqi_priv) {
38 + printk(KERN_WARNING "Not enough memory for quota information"
42 + qinfo = info->dqi_priv;
43 /* limits are stored as unsigned 32-bit data */
44 info->dqi_maxblimit = 0xffffffff;
45 info->dqi_maxilimit = 0xffffffff;
46 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
47 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
48 info->dqi_flags = le32_to_cpu(dinfo.dqi_flags);
49 - info->u.v2_i.i.dqi_sb = sb;
50 - info->u.v2_i.i.dqi_type = type;
51 - info->u.v2_i.i.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
52 - info->u.v2_i.i.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
53 - info->u.v2_i.i.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
54 - info->u.v2_i.i.dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
55 - info->u.v2_i.i.dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
56 - info->u.v2_i.i.dqi_qtree_depth = qtree_depth(&info->u.v2_i.i);
57 - info->u.v2_i.i.dqi_entry_size = sizeof(struct v2_disk_dqblk);
58 - info->u.v2_i.i.dqi_ops = &v2_qtree_ops;
60 + qinfo->dqi_type = type;
61 + qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
62 + qinfo->dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
63 + qinfo->dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
64 + qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
65 + qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
66 + qinfo->dqi_qtree_depth = qtree_depth(qinfo);
67 + qinfo->dqi_entry_size = sizeof(struct v2_disk_dqblk);
68 + qinfo->dqi_ops = &v2_qtree_ops;
72 @@ -104,6 +112,7 @@ static int v2_write_file_info(struct super_block *sb, int type)
74 struct v2_disk_dqinfo dinfo;
75 struct mem_dqinfo *info = sb_dqinfo(sb, type);
76 + struct qtree_mem_dqinfo *qinfo = info->dqi_priv;
79 spin_lock(&dq_data_lock);
80 @@ -112,9 +121,9 @@ static int v2_write_file_info(struct super_block *sb, int type)
81 dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
82 dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK);
83 spin_unlock(&dq_data_lock);
84 - dinfo.dqi_blocks = cpu_to_le32(info->u.v2_i.i.dqi_blocks);
85 - dinfo.dqi_free_blk = cpu_to_le32(info->u.v2_i.i.dqi_free_blk);
86 - dinfo.dqi_free_entry = cpu_to_le32(info->u.v2_i.i.dqi_free_entry);
87 + dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks);
88 + dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk);
89 + dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry);
90 size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
91 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
92 if (size != sizeof(struct v2_disk_dqinfo)) {
93 @@ -150,7 +159,7 @@ static void v2_mem2diskdqb(void *dp, struct dquot *dquot)
94 struct v2_disk_dqblk *d = dp;
95 struct mem_dqblk *m = &dquot->dq_dqb;
96 struct qtree_mem_dqinfo *info =
97 - &sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i;
98 + sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
100 d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit);
101 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit);
102 @@ -169,7 +178,7 @@ static int v2_is_id(void *dp, struct dquot *dquot)
104 struct v2_disk_dqblk *d = dp;
105 struct qtree_mem_dqinfo *info =
106 - &sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i;
107 + sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
109 if (qtree_entry_unused(info, dp))
111 @@ -178,24 +187,30 @@ static int v2_is_id(void *dp, struct dquot *dquot)
113 static int v2_read_dquot(struct dquot *dquot)
115 - return qtree_read_dquot(&sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i, dquot);
116 + return qtree_read_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
119 static int v2_write_dquot(struct dquot *dquot)
121 - return qtree_write_dquot(&sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i, dquot);
122 + return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
125 static int v2_release_dquot(struct dquot *dquot)
127 - return qtree_release_dquot(&sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i, dquot);
128 + return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
131 +static int v2_free_file_info(struct super_block *sb, int type)
133 + kfree(sb_dqinfo(sb, type)->dqi_priv);
137 static struct quota_format_ops v2_format_ops = {
138 .check_quota_file = v2_check_quota_file,
139 .read_file_info = v2_read_file_info,
140 .write_file_info = v2_write_file_info,
141 - .free_file_info = NULL,
142 + .free_file_info = v2_free_file_info,
143 .read_dqblk = v2_read_dquot,
144 .commit_dqblk = v2_write_dquot,
145 .release_dqblk = v2_release_dquot,
146 diff --git a/include/linux/dqblk_v1.h b/include/linux/dqblk_v1.h
147 index 57f1250..9cea901 100644
148 --- a/include/linux/dqblk_v1.h
149 +++ b/include/linux/dqblk_v1.h
151 #define V1_DEL_ALLOC 0
152 #define V1_DEL_REWRITE 2
154 -/* Special information about quotafile */
155 -struct v1_mem_dqinfo {
158 #endif /* _LINUX_DQBLK_V1_H */
159 diff --git a/include/linux/dqblk_v2.h b/include/linux/dqblk_v2.h
160 index e5e22a7..ff8af1b 100644
161 --- a/include/linux/dqblk_v2.h
162 +++ b/include/linux/dqblk_v2.h
164 #define V2_DEL_ALLOC QTREE_DEL_ALLOC
165 #define V2_DEL_REWRITE QTREE_DEL_REWRITE
167 -struct v2_mem_dqinfo {
168 - struct qtree_mem_dqinfo i;
171 #endif /* _LINUX_DQBLK_V2_H */
172 diff --git a/include/linux/quota.h b/include/linux/quota.h
173 index 8dd5333..e05c30d 100644
174 --- a/include/linux/quota.h
175 +++ b/include/linux/quota.h
176 @@ -210,10 +210,7 @@ struct mem_dqinfo {
177 unsigned int dqi_igrace;
178 qsize_t dqi_maxblimit;
179 qsize_t dqi_maxilimit;
181 - struct v1_mem_dqinfo v1_i;
182 - struct v2_mem_dqinfo v2_i;