aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-09-16 06:11:50 -0400
committerEric W. Biederman <ebiederm@xmission.com>2012-09-18 04:01:40 -0400
commitaca645a6a54e001e004f1f1e0eafd94f994bb1b3 (patch)
tree6e143c0077f22d5f3487d67408e7015805f74a69 /fs
parent431f19744d15531825cdbc8e771b43854b0d005b (diff)
userns: Modify dqget to take struct kqid
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/file.c6
-rw-r--r--fs/ocfs2/quota_local.c4
-rw-r--r--fs/quota/dquot.c20
3 files changed, 16 insertions, 14 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 46a1f6d75104..5a4ee77cec51 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1184,8 +1184,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
1184 if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid 1184 if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
1185 && OCFS2_HAS_RO_COMPAT_FEATURE(sb, 1185 && OCFS2_HAS_RO_COMPAT_FEATURE(sb,
1186 OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) { 1186 OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
1187 transfer_to[USRQUOTA] = dqget(sb, attr->ia_uid, 1187 transfer_to[USRQUOTA] = dqget(sb, make_kqid_uid(attr->ia_uid));
1188 USRQUOTA);
1189 if (!transfer_to[USRQUOTA]) { 1188 if (!transfer_to[USRQUOTA]) {
1190 status = -ESRCH; 1189 status = -ESRCH;
1191 goto bail_unlock; 1190 goto bail_unlock;
@@ -1194,8 +1193,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
1194 if (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid 1193 if (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid
1195 && OCFS2_HAS_RO_COMPAT_FEATURE(sb, 1194 && OCFS2_HAS_RO_COMPAT_FEATURE(sb,
1196 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) { 1195 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
1197 transfer_to[GRPQUOTA] = dqget(sb, attr->ia_gid, 1196 transfer_to[GRPQUOTA] = dqget(sb, make_kqid_gid(attr->ia_gid));
1198 GRPQUOTA);
1199 if (!transfer_to[GRPQUOTA]) { 1197 if (!transfer_to[GRPQUOTA]) {
1200 status = -ESRCH; 1198 status = -ESRCH;
1201 goto bail_unlock; 1199 goto bail_unlock;
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index f100bf70a906..020f0ba29ee5 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -501,7 +501,9 @@ static int ocfs2_recover_local_quota_file(struct inode *lqinode,
501 } 501 }
502 dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data + 502 dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data +
503 ol_dqblk_block_off(sb, chunk, bit)); 503 ol_dqblk_block_off(sb, chunk, bit));
504 dquot = dqget(sb, le64_to_cpu(dqblk->dqb_id), type); 504 dquot = dqget(sb,
505 make_kqid(&init_user_ns, type,
506 le64_to_cpu(dqblk->dqb_id)));
505 if (!dquot) { 507 if (!dquot) {
506 status = -EIO; 508 status = -EIO;
507 mlog(ML_ERROR, "Failed to get quota structure " 509 mlog(ML_ERROR, "Failed to get quota structure "
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 80d337822462..53e377a59b05 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -829,8 +829,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
829 * a) checking for quota flags under dq_list_lock and 829 * a) checking for quota flags under dq_list_lock and
830 * b) getting a reference to dquot before we release dq_list_lock 830 * b) getting a reference to dquot before we release dq_list_lock
831 */ 831 */
832struct dquot *dqget(struct super_block *sb, unsigned int id, int type) 832struct dquot *dqget(struct super_block *sb, struct kqid qid)
833{ 833{
834 unsigned int type = qid.type;
835 unsigned int id = from_kqid(&init_user_ns, qid);
834 unsigned int hashent = hashfn(sb, id, type); 836 unsigned int hashent = hashfn(sb, id, type);
835 struct dquot *dquot = NULL, *empty = NULL; 837 struct dquot *dquot = NULL, *empty = NULL;
836 838
@@ -1390,7 +1392,6 @@ static int dquot_active(const struct inode *inode)
1390 */ 1392 */
1391static void __dquot_initialize(struct inode *inode, int type) 1393static void __dquot_initialize(struct inode *inode, int type)
1392{ 1394{
1393 unsigned int id = 0;
1394 int cnt; 1395 int cnt;
1395 struct dquot *got[MAXQUOTAS]; 1396 struct dquot *got[MAXQUOTAS];
1396 struct super_block *sb = inode->i_sb; 1397 struct super_block *sb = inode->i_sb;
@@ -1403,18 +1404,19 @@ static void __dquot_initialize(struct inode *inode, int type)
1403 1404
1404 /* First get references to structures we might need. */ 1405 /* First get references to structures we might need. */
1405 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1406 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1407 struct kqid qid;
1406 got[cnt] = NULL; 1408 got[cnt] = NULL;
1407 if (type != -1 && cnt != type) 1409 if (type != -1 && cnt != type)
1408 continue; 1410 continue;
1409 switch (cnt) { 1411 switch (cnt) {
1410 case USRQUOTA: 1412 case USRQUOTA:
1411 id = inode->i_uid; 1413 qid = make_kqid_uid(inode->i_uid);
1412 break; 1414 break;
1413 case GRPQUOTA: 1415 case GRPQUOTA:
1414 id = inode->i_gid; 1416 qid = make_kqid_gid(inode->i_gid);
1415 break; 1417 break;
1416 } 1418 }
1417 got[cnt] = dqget(sb, id, cnt); 1419 got[cnt] = dqget(sb, qid);
1418 } 1420 }
1419 1421
1420 down_write(&sb_dqopt(sb)->dqptr_sem); 1422 down_write(&sb_dqopt(sb)->dqptr_sem);
@@ -1898,9 +1900,9 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1898 return 0; 1900 return 0;
1899 1901
1900 if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) 1902 if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
1901 transfer_to[USRQUOTA] = dqget(sb, iattr->ia_uid, USRQUOTA); 1903 transfer_to[USRQUOTA] = dqget(sb, make_kqid_uid(iattr->ia_uid));
1902 if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) 1904 if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
1903 transfer_to[GRPQUOTA] = dqget(sb, iattr->ia_gid, GRPQUOTA); 1905 transfer_to[GRPQUOTA] = dqget(sb, make_kqid_gid(iattr->ia_gid));
1904 1906
1905 ret = __dquot_transfer(inode, transfer_to); 1907 ret = __dquot_transfer(inode, transfer_to);
1906 dqput_all(transfer_to); 1908 dqput_all(transfer_to);
@@ -2381,7 +2383,7 @@ int dquot_get_dqblk(struct super_block *sb, struct kqid qid,
2381{ 2383{
2382 struct dquot *dquot; 2384 struct dquot *dquot;
2383 2385
2384 dquot = dqget(sb, qid.type, from_kqid(&init_user_ns, qid)); 2386 dquot = dqget(sb, qid);
2385 if (!dquot) 2387 if (!dquot)
2386 return -ESRCH; 2388 return -ESRCH;
2387 do_get_dqblk(dquot, di); 2389 do_get_dqblk(dquot, di);
@@ -2494,7 +2496,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid qid,
2494 struct dquot *dquot; 2496 struct dquot *dquot;
2495 int rc; 2497 int rc;
2496 2498
2497 dquot = dqget(sb, qid.type, from_kqid(&init_user_ns, qid)); 2499 dquot = dqget(sb, qid);
2498 if (!dquot) { 2500 if (!dquot) {
2499 rc = -ESRCH; 2501 rc = -ESRCH;
2500 goto out; 2502 goto out;