Skip to content

Commit

Permalink
userns: Modify dqget to take struct kqid
Browse files Browse the repository at this point in the history
Modify dqget to take struct kqid instead of a type and an identifier
pair.

Modify the callers of dqget in ocfs2 and dquot to take generate
a struct kqid so they can continue to call dqget.  The conversion
to create struct kqid should all be the final conversions that
are needed in those code paths.

Cc: Jan Kara <jack@suse.cz>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
  • Loading branch information
Eric W. Biederman committed Sep 18, 2012
1 parent 431f197 commit aca645a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
6 changes: 2 additions & 4 deletions fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
&& OCFS2_HAS_RO_COMPAT_FEATURE(sb,
OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
transfer_to[USRQUOTA] = dqget(sb, attr->ia_uid,
USRQUOTA);
transfer_to[USRQUOTA] = dqget(sb, make_kqid_uid(attr->ia_uid));
if (!transfer_to[USRQUOTA]) {
status = -ESRCH;
goto bail_unlock;
Expand All @@ -1194,8 +1193,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid
&& OCFS2_HAS_RO_COMPAT_FEATURE(sb,
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
transfer_to[GRPQUOTA] = dqget(sb, attr->ia_gid,
GRPQUOTA);
transfer_to[GRPQUOTA] = dqget(sb, make_kqid_gid(attr->ia_gid));
if (!transfer_to[GRPQUOTA]) {
status = -ESRCH;
goto bail_unlock;
Expand Down
4 changes: 3 additions & 1 deletion fs/ocfs2/quota_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ static int ocfs2_recover_local_quota_file(struct inode *lqinode,
}
dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data +
ol_dqblk_block_off(sb, chunk, bit));
dquot = dqget(sb, le64_to_cpu(dqblk->dqb_id), type);
dquot = dqget(sb,
make_kqid(&init_user_ns, type,
le64_to_cpu(dqblk->dqb_id)));
if (!dquot) {
status = -EIO;
mlog(ML_ERROR, "Failed to get quota structure "
Expand Down
20 changes: 11 additions & 9 deletions fs/quota/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
* a) checking for quota flags under dq_list_lock and
* b) getting a reference to dquot before we release dq_list_lock
*/
struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
struct dquot *dqget(struct super_block *sb, struct kqid qid)
{
unsigned int type = qid.type;
unsigned int id = from_kqid(&init_user_ns, qid);
unsigned int hashent = hashfn(sb, id, type);
struct dquot *dquot = NULL, *empty = NULL;

Expand Down Expand Up @@ -1390,7 +1392,6 @@ static int dquot_active(const struct inode *inode)
*/
static void __dquot_initialize(struct inode *inode, int type)
{
unsigned int id = 0;
int cnt;
struct dquot *got[MAXQUOTAS];
struct super_block *sb = inode->i_sb;
Expand All @@ -1403,18 +1404,19 @@ static void __dquot_initialize(struct inode *inode, int type)

/* First get references to structures we might need. */
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
struct kqid qid;
got[cnt] = NULL;
if (type != -1 && cnt != type)
continue;
switch (cnt) {
case USRQUOTA:
id = inode->i_uid;
qid = make_kqid_uid(inode->i_uid);
break;
case GRPQUOTA:
id = inode->i_gid;
qid = make_kqid_gid(inode->i_gid);
break;
}
got[cnt] = dqget(sb, id, cnt);
got[cnt] = dqget(sb, qid);
}

down_write(&sb_dqopt(sb)->dqptr_sem);
Expand Down Expand Up @@ -1898,9 +1900,9 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
return 0;

if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
transfer_to[USRQUOTA] = dqget(sb, iattr->ia_uid, USRQUOTA);
transfer_to[USRQUOTA] = dqget(sb, make_kqid_uid(iattr->ia_uid));
if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
transfer_to[GRPQUOTA] = dqget(sb, iattr->ia_gid, GRPQUOTA);
transfer_to[GRPQUOTA] = dqget(sb, make_kqid_gid(iattr->ia_gid));

ret = __dquot_transfer(inode, transfer_to);
dqput_all(transfer_to);
Expand Down Expand Up @@ -2381,7 +2383,7 @@ int dquot_get_dqblk(struct super_block *sb, struct kqid qid,
{
struct dquot *dquot;

dquot = dqget(sb, qid.type, from_kqid(&init_user_ns, qid));
dquot = dqget(sb, qid);
if (!dquot)
return -ESRCH;
do_get_dqblk(dquot, di);
Expand Down Expand Up @@ -2494,7 +2496,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid qid,
struct dquot *dquot;
int rc;

dquot = dqget(sb, qid.type, from_kqid(&init_user_ns, qid));
dquot = dqget(sb, qid);
if (!dquot) {
rc = -ESRCH;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/quotaops.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void inode_sub_rsv_space(struct inode *inode, qsize_t number);

void dquot_initialize(struct inode *inode);
void dquot_drop(struct inode *inode);
struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
struct dquot *dqget(struct super_block *sb, struct kqid qid);
void dqput(struct dquot *dquot);
int dquot_scan_active(struct super_block *sb,
int (*fn)(struct dquot *dquot, unsigned long priv),
Expand Down

0 comments on commit aca645a

Please sign in to comment.