diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-01-31 22:52:08 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:07 -0500 |
commit | 05e0a60d8025e280e56b3fa36ea8facc7c1c65c2 (patch) | |
tree | 4d7d6cc9303a35ba910359d779b0977aa16d15f0 /fs/gfs2 | |
parent | ed87dabcc3fc0a5040f95dd3f7206cffebca5c79 (diff) |
gfs2: Store qd_id in struct gfs2_quota_data as a struct kqid
- Change qd_id in struct gfs2_qutoa_data to struct kqid.
- Remove the now unnecessary QDF_USER bit field in qd_flags.
- Propopoage this change through the code generally making
things simpler along the way.
Cc: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/incore.h | 3 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 69 |
2 files changed, 26 insertions, 46 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index c373a24fedd9..5b298bdab90c 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -391,7 +391,6 @@ struct gfs2_revoke_replay { | |||
391 | }; | 391 | }; |
392 | 392 | ||
393 | enum { | 393 | enum { |
394 | QDF_USER = 0, | ||
395 | QDF_CHANGE = 1, | 394 | QDF_CHANGE = 1, |
396 | QDF_LOCKED = 2, | 395 | QDF_LOCKED = 2, |
397 | QDF_REFRESH = 3, | 396 | QDF_REFRESH = 3, |
@@ -403,7 +402,7 @@ struct gfs2_quota_data { | |||
403 | 402 | ||
404 | atomic_t qd_count; | 403 | atomic_t qd_count; |
405 | 404 | ||
406 | u32 qd_id; | 405 | struct kqid qd_id; |
407 | unsigned long qd_flags; /* QDF_... */ | 406 | unsigned long qd_flags; /* QDF_... */ |
408 | 407 | ||
409 | s64 qd_change; | 408 | s64 qd_change; |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 47315c091a09..8cb4d10cb16a 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -122,8 +122,9 @@ out: | |||
122 | 122 | ||
123 | static u64 qd2index(struct gfs2_quota_data *qd) | 123 | static u64 qd2index(struct gfs2_quota_data *qd) |
124 | { | 124 | { |
125 | return (2 * (u64)qd->qd_id) + | 125 | struct kqid qid = qd->qd_id; |
126 | test_bit(QDF_USER, &qd->qd_flags) ? 0 : 1; | 126 | return (2 * (u64)from_kqid(&init_user_ns, qid)) + |
127 | (qid.type == USRQUOTA) ? 0 : 1; | ||
127 | } | 128 | } |
128 | 129 | ||
129 | static u64 qd2offset(struct gfs2_quota_data *qd) | 130 | static u64 qd2offset(struct gfs2_quota_data *qd) |
@@ -136,7 +137,7 @@ static u64 qd2offset(struct gfs2_quota_data *qd) | |||
136 | return offset; | 137 | return offset; |
137 | } | 138 | } |
138 | 139 | ||
139 | static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id, | 140 | static int qd_alloc(struct gfs2_sbd *sdp, struct kqid qid, |
140 | struct gfs2_quota_data **qdp) | 141 | struct gfs2_quota_data **qdp) |
141 | { | 142 | { |
142 | struct gfs2_quota_data *qd; | 143 | struct gfs2_quota_data *qd; |
@@ -147,9 +148,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id, | |||
147 | return -ENOMEM; | 148 | return -ENOMEM; |
148 | 149 | ||
149 | atomic_set(&qd->qd_count, 1); | 150 | atomic_set(&qd->qd_count, 1); |
150 | qd->qd_id = id; | 151 | qd->qd_id = qid; |
151 | if (user) | ||
152 | set_bit(QDF_USER, &qd->qd_flags); | ||
153 | qd->qd_slot = -1; | 152 | qd->qd_slot = -1; |
154 | INIT_LIST_HEAD(&qd->qd_reclaim); | 153 | INIT_LIST_HEAD(&qd->qd_reclaim); |
155 | 154 | ||
@@ -167,7 +166,7 @@ fail: | |||
167 | return error; | 166 | return error; |
168 | } | 167 | } |
169 | 168 | ||
170 | static int qd_get(struct gfs2_sbd *sdp, int user, u32 id, | 169 | static int qd_get(struct gfs2_sbd *sdp, struct kqid qid, |
171 | struct gfs2_quota_data **qdp) | 170 | struct gfs2_quota_data **qdp) |
172 | { | 171 | { |
173 | struct gfs2_quota_data *qd = NULL, *new_qd = NULL; | 172 | struct gfs2_quota_data *qd = NULL, *new_qd = NULL; |
@@ -179,8 +178,7 @@ static int qd_get(struct gfs2_sbd *sdp, int user, u32 id, | |||
179 | found = 0; | 178 | found = 0; |
180 | spin_lock(&qd_lru_lock); | 179 | spin_lock(&qd_lru_lock); |
181 | list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { | 180 | list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { |
182 | if (qd->qd_id == id && | 181 | if (qid_eq(qd->qd_id, qid)) { |
183 | !test_bit(QDF_USER, &qd->qd_flags) == !user) { | ||
184 | if (!atomic_read(&qd->qd_count) && | 182 | if (!atomic_read(&qd->qd_count) && |
185 | !list_empty(&qd->qd_reclaim)) { | 183 | !list_empty(&qd->qd_reclaim)) { |
186 | /* Remove it from reclaim list */ | 184 | /* Remove it from reclaim list */ |
@@ -214,7 +212,7 @@ static int qd_get(struct gfs2_sbd *sdp, int user, u32 id, | |||
214 | return 0; | 212 | return 0; |
215 | } | 213 | } |
216 | 214 | ||
217 | error = qd_alloc(sdp, user, id, &new_qd); | 215 | error = qd_alloc(sdp, qid, &new_qd); |
218 | if (error) | 216 | if (error) |
219 | return error; | 217 | return error; |
220 | } | 218 | } |
@@ -469,8 +467,7 @@ static int qdsb_get(struct gfs2_sbd *sdp, struct kqid qid, | |||
469 | { | 467 | { |
470 | int error; | 468 | int error; |
471 | 469 | ||
472 | error = qd_get(sdp, qid.type == USRQUOTA ? QUOTA_USER : QUOTA_GROUP, | 470 | error = qd_get(sdp, qid, qdp); |
473 | from_kqid(&init_user_ns, qid), qdp); | ||
474 | if (error) | 471 | if (error) |
475 | return error; | 472 | return error; |
476 | 473 | ||
@@ -574,18 +571,10 @@ static int sort_qd(const void *a, const void *b) | |||
574 | const struct gfs2_quota_data *qd_a = *(const struct gfs2_quota_data **)a; | 571 | const struct gfs2_quota_data *qd_a = *(const struct gfs2_quota_data **)a; |
575 | const struct gfs2_quota_data *qd_b = *(const struct gfs2_quota_data **)b; | 572 | const struct gfs2_quota_data *qd_b = *(const struct gfs2_quota_data **)b; |
576 | 573 | ||
577 | if (!test_bit(QDF_USER, &qd_a->qd_flags) != | 574 | if (qid_lt(qd_a->qd_id, qd_b->qd_id)) |
578 | !test_bit(QDF_USER, &qd_b->qd_flags)) { | ||
579 | if (test_bit(QDF_USER, &qd_a->qd_flags)) | ||
580 | return -1; | ||
581 | else | ||
582 | return 1; | ||
583 | } | ||
584 | if (qd_a->qd_id < qd_b->qd_id) | ||
585 | return -1; | 575 | return -1; |
586 | if (qd_a->qd_id > qd_b->qd_id) | 576 | if (qid_lt(qd_b->qd_id, qd_a->qd_id)) |
587 | return 1; | 577 | return 1; |
588 | |||
589 | return 0; | 578 | return 0; |
590 | } | 579 | } |
591 | 580 | ||
@@ -602,9 +591,9 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change) | |||
602 | if (!test_bit(QDF_CHANGE, &qd->qd_flags)) { | 591 | if (!test_bit(QDF_CHANGE, &qd->qd_flags)) { |
603 | qc->qc_change = 0; | 592 | qc->qc_change = 0; |
604 | qc->qc_flags = 0; | 593 | qc->qc_flags = 0; |
605 | if (test_bit(QDF_USER, &qd->qd_flags)) | 594 | if (qd->qd_id.type == USRQUOTA) |
606 | qc->qc_flags = cpu_to_be32(GFS2_QCF_USER); | 595 | qc->qc_flags = cpu_to_be32(GFS2_QCF_USER); |
607 | qc->qc_id = cpu_to_be32(qd->qd_id); | 596 | qc->qc_id = cpu_to_be32(from_kqid(&init_user_ns, qd->qd_id)); |
608 | } | 597 | } |
609 | 598 | ||
610 | x = be64_to_cpu(qc->qc_change) + change; | 599 | x = be64_to_cpu(qc->qc_change) + change; |
@@ -1047,8 +1036,8 @@ static int print_message(struct gfs2_quota_data *qd, char *type) | |||
1047 | 1036 | ||
1048 | printk(KERN_INFO "GFS2: fsid=%s: quota %s for %s %u\n", | 1037 | printk(KERN_INFO "GFS2: fsid=%s: quota %s for %s %u\n", |
1049 | sdp->sd_fsname, type, | 1038 | sdp->sd_fsname, type, |
1050 | (test_bit(QDF_USER, &qd->qd_flags)) ? "user" : "group", | 1039 | (qd->qd_id.type == USRQUOTA) ? "user" : "group", |
1051 | qd->qd_id); | 1040 | from_kqid(&init_user_ns, qd->qd_id)); |
1052 | 1041 | ||
1053 | return 0; | 1042 | return 0; |
1054 | } | 1043 | } |
@@ -1070,8 +1059,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
1070 | for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) { | 1059 | for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) { |
1071 | qd = ip->i_res->rs_qa_qd[x]; | 1060 | qd = ip->i_res->rs_qa_qd[x]; |
1072 | 1061 | ||
1073 | if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || | 1062 | if (!(qid_eq(qd->qd_id, make_kqid_uid(uid)) || |
1074 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) | 1063 | qid_eq(qd->qd_id, make_kqid_gid(gid)))) |
1075 | continue; | 1064 | continue; |
1076 | 1065 | ||
1077 | value = (s64)be64_to_cpu(qd->qd_qb.qb_value); | 1066 | value = (s64)be64_to_cpu(qd->qd_qb.qb_value); |
@@ -1081,10 +1070,7 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
1081 | 1070 | ||
1082 | if (be64_to_cpu(qd->qd_qb.qb_limit) && (s64)be64_to_cpu(qd->qd_qb.qb_limit) < value) { | 1071 | if (be64_to_cpu(qd->qd_qb.qb_limit) && (s64)be64_to_cpu(qd->qd_qb.qb_limit) < value) { |
1083 | print_message(qd, "exceeded"); | 1072 | print_message(qd, "exceeded"); |
1084 | quota_send_warning(make_kqid(&init_user_ns, | 1073 | quota_send_warning(qd->qd_id, |
1085 | test_bit(QDF_USER, &qd->qd_flags) ? | ||
1086 | USRQUOTA : GRPQUOTA, | ||
1087 | qd->qd_id), | ||
1088 | sdp->sd_vfs->s_dev, QUOTA_NL_BHARDWARN); | 1074 | sdp->sd_vfs->s_dev, QUOTA_NL_BHARDWARN); |
1089 | 1075 | ||
1090 | error = -EDQUOT; | 1076 | error = -EDQUOT; |
@@ -1094,10 +1080,7 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
1094 | time_after_eq(jiffies, qd->qd_last_warn + | 1080 | time_after_eq(jiffies, qd->qd_last_warn + |
1095 | gfs2_tune_get(sdp, | 1081 | gfs2_tune_get(sdp, |
1096 | gt_quota_warn_period) * HZ)) { | 1082 | gt_quota_warn_period) * HZ)) { |
1097 | quota_send_warning(make_kqid(&init_user_ns, | 1083 | quota_send_warning(qd->qd_id, |
1098 | test_bit(QDF_USER, &qd->qd_flags) ? | ||
1099 | USRQUOTA : GRPQUOTA, | ||
1100 | qd->qd_id), | ||
1101 | sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN); | 1084 | sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN); |
1102 | error = print_message(qd, "warning"); | 1085 | error = print_message(qd, "warning"); |
1103 | qd->qd_last_warn = jiffies; | 1086 | qd->qd_last_warn = jiffies; |
@@ -1121,8 +1104,8 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | |||
1121 | for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) { | 1104 | for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) { |
1122 | qd = ip->i_res->rs_qa_qd[x]; | 1105 | qd = ip->i_res->rs_qa_qd[x]; |
1123 | 1106 | ||
1124 | if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || | 1107 | if (qid_eq(qd->qd_id, make_kqid_uid(uid)) || |
1125 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) { | 1108 | qid_eq(qd->qd_id, make_kqid_gid(gid))) { |
1126 | do_qc(qd, change); | 1109 | do_qc(qd, change); |
1127 | } | 1110 | } |
1128 | } | 1111 | } |
@@ -1183,8 +1166,7 @@ int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid) | |||
1183 | struct gfs2_holder q_gh; | 1166 | struct gfs2_holder q_gh; |
1184 | int error; | 1167 | int error; |
1185 | 1168 | ||
1186 | error = qd_get(sdp, qid.type == USRQUOTA ? QUOTA_USER : QUOTA_GROUP, | 1169 | error = qd_get(sdp, qid, &qd); |
1187 | from_kqid(&init_user_ns, qid), &qd); | ||
1188 | if (error) | 1170 | if (error) |
1189 | return error; | 1171 | return error; |
1190 | 1172 | ||
@@ -1267,8 +1249,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) | |||
1267 | if (!qc.qc_change) | 1249 | if (!qc.qc_change) |
1268 | continue; | 1250 | continue; |
1269 | 1251 | ||
1270 | error = qd_alloc(sdp, (qc.qc_flags & GFS2_QCF_USER), | 1252 | error = qd_alloc(sdp, qc.qc_id, &qd); |
1271 | from_kqid(&init_user_ns, qc.qc_id), &qd); | ||
1272 | if (error) { | 1253 | if (error) { |
1273 | brelse(bh); | 1254 | brelse(bh); |
1274 | goto fail; | 1255 | goto fail; |
@@ -1509,7 +1490,7 @@ static int gfs2_get_dqblk(struct super_block *sb, struct kqid qid, | |||
1509 | else | 1490 | else |
1510 | return -EINVAL; | 1491 | return -EINVAL; |
1511 | 1492 | ||
1512 | error = qd_get(sdp, type, from_kqid(&init_user_ns, qid), &qd); | 1493 | error = qd_get(sdp, qid, &qd); |
1513 | if (error) | 1494 | if (error) |
1514 | return error; | 1495 | return error; |
1515 | error = do_glock(qd, FORCE, &q_gh); | 1496 | error = do_glock(qd, FORCE, &q_gh); |
@@ -1564,7 +1545,7 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, | |||
1564 | if (fdq->d_fieldmask & ~GFS2_FIELDMASK) | 1545 | if (fdq->d_fieldmask & ~GFS2_FIELDMASK) |
1565 | return -EINVAL; | 1546 | return -EINVAL; |
1566 | 1547 | ||
1567 | error = qd_get(sdp, type, from_kqid(&init_user_ns, qid), &qd); | 1548 | error = qd_get(sdp, qid, &qd); |
1568 | if (error) | 1549 | if (error) |
1569 | return error; | 1550 | return error; |
1570 | 1551 | ||