diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-16 06:56:19 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-18 04:01:41 -0400 |
commit | 4c376dcae892e5b5daf8576c864061d076d4e4dc (patch) | |
tree | dbb4dbc9422992a00f7b478e4254b4da922f7158 /fs/quota/quota_v1.c | |
parent | aca645a6a54e001e004f1f1e0eafd94f994bb1b3 (diff) |
userns: Convert struct dquot dq_id to be a struct kqid
Change struct dquot dq_id to a struct kqid and remove the now
unecessary dq_type.
Make minimal changes to dquot, quota_tree, quota_v1, quota_v2, ext3,
ext4, and ocfs2 to deal with the change in quota structures and
signatures. The ocfs2 changes are larger than most because of the
extensive tracing throughout the ocfs2 quota code that prints out
dq_id.
quota_tree.c:get_index is modified to take a struct kqid instead of a
qid_t because all of it's callers pass in dquot->dq_id and it allows
me to introduce only a single conversion.
The rest of the changes are either just replacing dq_type with dq_id.type,
adding conversions to deal with the change in type and occassionally
adding qid_eq to allow quota id comparisons in a user namespace safe way.
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: Theodore Tso <tytso@mit.edu>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/quota/quota_v1.c')
-rw-r--r-- | fs/quota/quota_v1.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c index 34b37a67bb16..469c6848b322 100644 --- a/fs/quota/quota_v1.c +++ b/fs/quota/quota_v1.c | |||
@@ -54,7 +54,7 @@ static void v1_mem2disk_dqblk(struct v1_disk_dqblk *d, struct mem_dqblk *m) | |||
54 | 54 | ||
55 | static int v1_read_dqblk(struct dquot *dquot) | 55 | static int v1_read_dqblk(struct dquot *dquot) |
56 | { | 56 | { |
57 | int type = dquot->dq_type; | 57 | int type = dquot->dq_id.type; |
58 | struct v1_disk_dqblk dqblk; | 58 | struct v1_disk_dqblk dqblk; |
59 | 59 | ||
60 | if (!sb_dqopt(dquot->dq_sb)->files[type]) | 60 | if (!sb_dqopt(dquot->dq_sb)->files[type]) |
@@ -63,7 +63,8 @@ static int v1_read_dqblk(struct dquot *dquot) | |||
63 | /* Set structure to 0s in case read fails/is after end of file */ | 63 | /* Set structure to 0s in case read fails/is after end of file */ |
64 | memset(&dqblk, 0, sizeof(struct v1_disk_dqblk)); | 64 | memset(&dqblk, 0, sizeof(struct v1_disk_dqblk)); |
65 | dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk, | 65 | dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk, |
66 | sizeof(struct v1_disk_dqblk), v1_dqoff(dquot->dq_id)); | 66 | sizeof(struct v1_disk_dqblk), |
67 | v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id))); | ||
67 | 68 | ||
68 | v1_disk2mem_dqblk(&dquot->dq_dqb, &dqblk); | 69 | v1_disk2mem_dqblk(&dquot->dq_dqb, &dqblk); |
69 | if (dquot->dq_dqb.dqb_bhardlimit == 0 && | 70 | if (dquot->dq_dqb.dqb_bhardlimit == 0 && |
@@ -78,12 +79,13 @@ static int v1_read_dqblk(struct dquot *dquot) | |||
78 | 79 | ||
79 | static int v1_commit_dqblk(struct dquot *dquot) | 80 | static int v1_commit_dqblk(struct dquot *dquot) |
80 | { | 81 | { |
81 | short type = dquot->dq_type; | 82 | short type = dquot->dq_id.type; |
82 | ssize_t ret; | 83 | ssize_t ret; |
83 | struct v1_disk_dqblk dqblk; | 84 | struct v1_disk_dqblk dqblk; |
84 | 85 | ||
85 | v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb); | 86 | v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb); |
86 | if (dquot->dq_id == 0) { | 87 | if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) || |
88 | ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) { | ||
87 | dqblk.dqb_btime = | 89 | dqblk.dqb_btime = |
88 | sb_dqopt(dquot->dq_sb)->info[type].dqi_bgrace; | 90 | sb_dqopt(dquot->dq_sb)->info[type].dqi_bgrace; |
89 | dqblk.dqb_itime = | 91 | dqblk.dqb_itime = |
@@ -93,7 +95,7 @@ static int v1_commit_dqblk(struct dquot *dquot) | |||
93 | if (sb_dqopt(dquot->dq_sb)->files[type]) | 95 | if (sb_dqopt(dquot->dq_sb)->files[type]) |
94 | ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type, | 96 | ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type, |
95 | (char *)&dqblk, sizeof(struct v1_disk_dqblk), | 97 | (char *)&dqblk, sizeof(struct v1_disk_dqblk), |
96 | v1_dqoff(dquot->dq_id)); | 98 | v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id))); |
97 | if (ret != sizeof(struct v1_disk_dqblk)) { | 99 | if (ret != sizeof(struct v1_disk_dqblk)) { |
98 | quota_error(dquot->dq_sb, "dquota write failed"); | 100 | quota_error(dquot->dq_sb, "dquota write failed"); |
99 | if (ret >= 0) | 101 | if (ret >= 0) |