Skip to content

Commit ed87dab

Browse files
committed
gfs2: Convert gfs2_quota_refresh to take a kqid
- In quota_refresh_user_store convert the user supplied uid into a kqid and pass it to gfs2_quota_refresh. - In quota_refresh_group_store convert the user supplied gid into a kqid and pass it to gfs2_quota_refresh. Cc: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent b59c8b6 commit ed87dab

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎fs/gfs2/quota.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,13 +1177,14 @@ static int gfs2_quota_sync_timeo(struct super_block *sb, int type)
11771177
return gfs2_quota_sync(sb, type);
11781178
}
11791179

1180-
int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id)
1180+
int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid)
11811181
{
11821182
struct gfs2_quota_data *qd;
11831183
struct gfs2_holder q_gh;
11841184
int error;
11851185

1186-
error = qd_get(sdp, user, id, &qd);
1186+
error = qd_get(sdp, qid.type == USRQUOTA ? QUOTA_USER : QUOTA_GROUP,
1187+
from_kqid(&init_user_ns, qid), &qd);
11871188
if (error)
11881189
return error;
11891190

‎fs/gfs2/quota.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
2828
u32 uid, u32 gid);
2929

3030
extern int gfs2_quota_sync(struct super_block *sb, int type);
31-
extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id);
31+
extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid);
3232

3333
extern int gfs2_quota_init(struct gfs2_sbd *sdp);
3434
extern void gfs2_quota_cleanup(struct gfs2_sbd *sdp);

‎fs/gfs2/sys.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
175175
static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
176176
size_t len)
177177
{
178+
struct kqid qid;
178179
int error;
179180
u32 id;
180181

@@ -183,13 +184,18 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
183184

184185
id = simple_strtoul(buf, NULL, 0);
185186

186-
error = gfs2_quota_refresh(sdp, 1, id);
187+
qid = make_kqid(current_user_ns(), USRQUOTA, id);
188+
if (!qid_valid(qid))
189+
return -EINVAL;
190+
191+
error = gfs2_quota_refresh(sdp, qid);
187192
return error ? error : len;
188193
}
189194

190195
static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
191196
size_t len)
192197
{
198+
struct kqid qid;
193199
int error;
194200
u32 id;
195201

@@ -198,7 +204,11 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
198204

199205
id = simple_strtoul(buf, NULL, 0);
200206

201-
error = gfs2_quota_refresh(sdp, 0, id);
207+
qid = make_kqid(current_user_ns(), GRPQUOTA, id);
208+
if (!qid_valid(qid))
209+
return -EINVAL;
210+
211+
error = gfs2_quota_refresh(sdp, qid);
202212
return error ? error : len;
203213
}
204214

0 commit comments

Comments
 (0)