aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-09-16 06:56:19 -0400
committerEric W. Biederman <ebiederm@xmission.com>2012-09-18 04:01:41 -0400
commit4c376dcae892e5b5daf8576c864061d076d4e4dc (patch)
treedbb4dbc9422992a00f7b478e4254b4da922f7158
parentaca645a6a54e001e004f1f1e0eafd94f994bb1b3 (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>
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/ocfs2/quota_global.c43
-rw-r--r--fs/ocfs2/quota_local.c11
-rw-r--r--fs/quota/dquot.c63
-rw-r--r--fs/quota/quota_tree.c22
-rw-r--r--fs/quota/quota_v1.c12
-rw-r--r--fs/quota/quota_v2.c26
-rw-r--r--include/linux/quota.h3
9 files changed, 102 insertions, 82 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index ff9bcdc5b0d5..73e42f5c7009 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2814,7 +2814,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2814 2814
2815static inline struct inode *dquot_to_inode(struct dquot *dquot) 2815static inline struct inode *dquot_to_inode(struct dquot *dquot)
2816{ 2816{
2817 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; 2817 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_id.type];
2818} 2818}
2819 2819
2820static int ext3_write_dquot(struct dquot *dquot) 2820static int ext3_write_dquot(struct dquot *dquot)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d76ec8277d3f..78e6036ff244 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4796,7 +4796,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
4796 4796
4797static inline struct inode *dquot_to_inode(struct dquot *dquot) 4797static inline struct inode *dquot_to_inode(struct dquot *dquot)
4798{ 4798{
4799 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type]; 4799 return sb_dqopt(dquot->dq_sb)->files[dquot->dq_id.type];
4800} 4800}
4801 4801
4802static int ext4_write_dquot(struct dquot *dquot) 4802static int ext4_write_dquot(struct dquot *dquot)
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index 0a86e302655f..332a281f217e 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -95,7 +95,7 @@ static void ocfs2_global_mem2diskdqb(void *dp, struct dquot *dquot)
95 struct ocfs2_global_disk_dqblk *d = dp; 95 struct ocfs2_global_disk_dqblk *d = dp;
96 struct mem_dqblk *m = &dquot->dq_dqb; 96 struct mem_dqblk *m = &dquot->dq_dqb;
97 97
98 d->dqb_id = cpu_to_le32(dquot->dq_id); 98 d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id));
99 d->dqb_use_count = cpu_to_le32(OCFS2_DQUOT(dquot)->dq_use_count); 99 d->dqb_use_count = cpu_to_le32(OCFS2_DQUOT(dquot)->dq_use_count);
100 d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit); 100 d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
101 d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit); 101 d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
@@ -112,11 +112,14 @@ static int ocfs2_global_is_id(void *dp, struct dquot *dquot)
112{ 112{
113 struct ocfs2_global_disk_dqblk *d = dp; 113 struct ocfs2_global_disk_dqblk *d = dp;
114 struct ocfs2_mem_dqinfo *oinfo = 114 struct ocfs2_mem_dqinfo *oinfo =
115 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 115 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
116 116
117 if (qtree_entry_unused(&oinfo->dqi_gi, dp)) 117 if (qtree_entry_unused(&oinfo->dqi_gi, dp))
118 return 0; 118 return 0;
119 return le32_to_cpu(d->dqb_id) == dquot->dq_id; 119
120 return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type,
121 le32_to_cpu(d->dqb_id)),
122 dquot->dq_id);
120} 123}
121 124
122struct qtree_fmt_operations ocfs2_global_ops = { 125struct qtree_fmt_operations ocfs2_global_ops = {
@@ -475,7 +478,7 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
475{ 478{
476 int err, err2; 479 int err, err2;
477 struct super_block *sb = dquot->dq_sb; 480 struct super_block *sb = dquot->dq_sb;
478 int type = dquot->dq_type; 481 int type = dquot->dq_id.type;
479 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv; 482 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
480 struct ocfs2_global_disk_dqblk dqblk; 483 struct ocfs2_global_disk_dqblk dqblk;
481 s64 spacechange, inodechange; 484 s64 spacechange, inodechange;
@@ -504,7 +507,8 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
504 olditime = dquot->dq_dqb.dqb_itime; 507 olditime = dquot->dq_dqb.dqb_itime;
505 oldbtime = dquot->dq_dqb.dqb_btime; 508 oldbtime = dquot->dq_dqb.dqb_btime;
506 ocfs2_global_disk2memdqb(dquot, &dqblk); 509 ocfs2_global_disk2memdqb(dquot, &dqblk);
507 trace_ocfs2_sync_dquot(dquot->dq_id, dquot->dq_dqb.dqb_curspace, 510 trace_ocfs2_sync_dquot(from_kqid(&init_user_ns, dquot->dq_id),
511 dquot->dq_dqb.dqb_curspace,
508 (long long)spacechange, 512 (long long)spacechange,
509 dquot->dq_dqb.dqb_curinodes, 513 dquot->dq_dqb.dqb_curinodes,
510 (long long)inodechange); 514 (long long)inodechange);
@@ -555,8 +559,8 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
555 err = ocfs2_qinfo_lock(info, freeing); 559 err = ocfs2_qinfo_lock(info, freeing);
556 if (err < 0) { 560 if (err < 0) {
557 mlog(ML_ERROR, "Failed to lock quota info, losing quota write" 561 mlog(ML_ERROR, "Failed to lock quota info, losing quota write"
558 " (type=%d, id=%u)\n", dquot->dq_type, 562 " (type=%d, id=%u)\n", dquot->dq_id.type,
559 (unsigned)dquot->dq_id); 563 (unsigned)from_kqid(&init_user_ns, dquot->dq_id));
560 goto out; 564 goto out;
561 } 565 }
562 if (freeing) 566 if (freeing)
@@ -591,9 +595,10 @@ static int ocfs2_sync_dquot_helper(struct dquot *dquot, unsigned long type)
591 struct ocfs2_super *osb = OCFS2_SB(sb); 595 struct ocfs2_super *osb = OCFS2_SB(sb);
592 int status = 0; 596 int status = 0;
593 597
594 trace_ocfs2_sync_dquot_helper(dquot->dq_id, dquot->dq_type, 598 trace_ocfs2_sync_dquot_helper(from_kqid(&init_user_ns, dquot->dq_id),
599 dquot->dq_id.type,
595 type, sb->s_id); 600 type, sb->s_id);
596 if (type != dquot->dq_type) 601 if (type != dquot->dq_id.type)
597 goto out; 602 goto out;
598 status = ocfs2_lock_global_qf(oinfo, 1); 603 status = ocfs2_lock_global_qf(oinfo, 1);
599 if (status < 0) 604 if (status < 0)
@@ -643,7 +648,8 @@ static int ocfs2_write_dquot(struct dquot *dquot)
643 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); 648 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
644 int status = 0; 649 int status = 0;
645 650
646 trace_ocfs2_write_dquot(dquot->dq_id, dquot->dq_type); 651 trace_ocfs2_write_dquot(from_kqid(&init_user_ns, dquot->dq_id),
652 dquot->dq_id.type);
647 653
648 handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS); 654 handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS);
649 if (IS_ERR(handle)) { 655 if (IS_ERR(handle)) {
@@ -677,11 +683,12 @@ static int ocfs2_release_dquot(struct dquot *dquot)
677{ 683{
678 handle_t *handle; 684 handle_t *handle;
679 struct ocfs2_mem_dqinfo *oinfo = 685 struct ocfs2_mem_dqinfo *oinfo =
680 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 686 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
681 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); 687 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
682 int status = 0; 688 int status = 0;
683 689
684 trace_ocfs2_release_dquot(dquot->dq_id, dquot->dq_type); 690 trace_ocfs2_release_dquot(from_kqid(&init_user_ns, dquot->dq_id),
691 dquot->dq_id.type);
685 692
686 mutex_lock(&dquot->dq_lock); 693 mutex_lock(&dquot->dq_lock);
687 /* Check whether we are not racing with some other dqget() */ 694 /* Check whether we are not racing with some other dqget() */
@@ -691,7 +698,7 @@ static int ocfs2_release_dquot(struct dquot *dquot)
691 if (status < 0) 698 if (status < 0)
692 goto out; 699 goto out;
693 handle = ocfs2_start_trans(osb, 700 handle = ocfs2_start_trans(osb,
694 ocfs2_calc_qdel_credits(dquot->dq_sb, dquot->dq_type)); 701 ocfs2_calc_qdel_credits(dquot->dq_sb, dquot->dq_id.type));
695 if (IS_ERR(handle)) { 702 if (IS_ERR(handle)) {
696 status = PTR_ERR(handle); 703 status = PTR_ERR(handle);
697 mlog_errno(status); 704 mlog_errno(status);
@@ -733,13 +740,14 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
733 int ex = 0; 740 int ex = 0;
734 struct super_block *sb = dquot->dq_sb; 741 struct super_block *sb = dquot->dq_sb;
735 struct ocfs2_super *osb = OCFS2_SB(sb); 742 struct ocfs2_super *osb = OCFS2_SB(sb);
736 int type = dquot->dq_type; 743 int type = dquot->dq_id.type;
737 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv; 744 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
738 struct inode *gqinode = info->dqi_gqinode; 745 struct inode *gqinode = info->dqi_gqinode;
739 int need_alloc = ocfs2_global_qinit_alloc(sb, type); 746 int need_alloc = ocfs2_global_qinit_alloc(sb, type);
740 handle_t *handle; 747 handle_t *handle;
741 748
742 trace_ocfs2_acquire_dquot(dquot->dq_id, type); 749 trace_ocfs2_acquire_dquot(from_kqid(&init_user_ns, dquot->dq_id),
750 type);
743 mutex_lock(&dquot->dq_lock); 751 mutex_lock(&dquot->dq_lock);
744 /* 752 /*
745 * We need an exclusive lock, because we're going to update use count 753 * We need an exclusive lock, because we're going to update use count
@@ -821,12 +829,13 @@ static int ocfs2_mark_dquot_dirty(struct dquot *dquot)
821 int sync = 0; 829 int sync = 0;
822 int status; 830 int status;
823 struct super_block *sb = dquot->dq_sb; 831 struct super_block *sb = dquot->dq_sb;
824 int type = dquot->dq_type; 832 int type = dquot->dq_id.type;
825 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv; 833 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
826 handle_t *handle; 834 handle_t *handle;
827 struct ocfs2_super *osb = OCFS2_SB(sb); 835 struct ocfs2_super *osb = OCFS2_SB(sb);
828 836
829 trace_ocfs2_mark_dquot_dirty(dquot->dq_id, type); 837 trace_ocfs2_mark_dquot_dirty(from_kqid(&init_user_ns, dquot->dq_id),
838 type);
830 839
831 /* In case user set some limits, sync dquot immediately to global 840 /* In case user set some limits, sync dquot immediately to global
832 * quota file so that information propagates quicker */ 841 * quota file so that information propagates quicker */
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 020f0ba29ee5..27fe7ee4874c 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -883,7 +883,8 @@ static void olq_set_dquot(struct buffer_head *bh, void *private)
883 dqblk = (struct ocfs2_local_disk_dqblk *)(bh->b_data 883 dqblk = (struct ocfs2_local_disk_dqblk *)(bh->b_data
884 + ol_dqblk_block_offset(sb, od->dq_local_off)); 884 + ol_dqblk_block_offset(sb, od->dq_local_off));
885 885
886 dqblk->dqb_id = cpu_to_le64(od->dq_dquot.dq_id); 886 dqblk->dqb_id = cpu_to_le64(from_kqid(&init_user_ns,
887 od->dq_dquot.dq_id));
887 spin_lock(&dq_data_lock); 888 spin_lock(&dq_data_lock);
888 dqblk->dqb_spacemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curspace - 889 dqblk->dqb_spacemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curspace -
889 od->dq_origspace); 890 od->dq_origspace);
@@ -893,7 +894,7 @@ static void olq_set_dquot(struct buffer_head *bh, void *private)
893 trace_olq_set_dquot( 894 trace_olq_set_dquot(
894 (unsigned long long)le64_to_cpu(dqblk->dqb_spacemod), 895 (unsigned long long)le64_to_cpu(dqblk->dqb_spacemod),
895 (unsigned long long)le64_to_cpu(dqblk->dqb_inodemod), 896 (unsigned long long)le64_to_cpu(dqblk->dqb_inodemod),
896 od->dq_dquot.dq_id); 897 from_kqid(&init_user_ns, od->dq_dquot.dq_id));
897} 898}
898 899
899/* Write dquot to local quota file */ 900/* Write dquot to local quota file */
@@ -902,7 +903,7 @@ int ocfs2_local_write_dquot(struct dquot *dquot)
902 struct super_block *sb = dquot->dq_sb; 903 struct super_block *sb = dquot->dq_sb;
903 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot); 904 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
904 struct buffer_head *bh; 905 struct buffer_head *bh;
905 struct inode *lqinode = sb_dqopt(sb)->files[dquot->dq_type]; 906 struct inode *lqinode = sb_dqopt(sb)->files[dquot->dq_id.type];
906 int status; 907 int status;
907 908
908 status = ocfs2_read_quota_phys_block(lqinode, od->dq_local_phys_blk, 909 status = ocfs2_read_quota_phys_block(lqinode, od->dq_local_phys_blk,
@@ -1223,7 +1224,7 @@ static void olq_alloc_dquot(struct buffer_head *bh, void *private)
1223int ocfs2_create_local_dquot(struct dquot *dquot) 1224int ocfs2_create_local_dquot(struct dquot *dquot)
1224{ 1225{
1225 struct super_block *sb = dquot->dq_sb; 1226 struct super_block *sb = dquot->dq_sb;
1226 int type = dquot->dq_type; 1227 int type = dquot->dq_id.type;
1227 struct inode *lqinode = sb_dqopt(sb)->files[type]; 1228 struct inode *lqinode = sb_dqopt(sb)->files[type];
1228 struct ocfs2_quota_chunk *chunk; 1229 struct ocfs2_quota_chunk *chunk;
1229 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot); 1230 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
@@ -1277,7 +1278,7 @@ out:
1277int ocfs2_local_release_dquot(handle_t *handle, struct dquot *dquot) 1278int ocfs2_local_release_dquot(handle_t *handle, struct dquot *dquot)
1278{ 1279{
1279 int status; 1280 int status;
1280 int type = dquot->dq_type; 1281 int type = dquot->dq_id.type;
1281 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot); 1282 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
1282 struct super_block *sb = dquot->dq_sb; 1283 struct super_block *sb = dquot->dq_sb;
1283 struct ocfs2_local_disk_chunk *dchunk; 1284 struct ocfs2_local_disk_chunk *dchunk;
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 53e377a59b05..efaeed35476f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -267,7 +267,7 @@ hashfn(const struct super_block *sb, unsigned int id, int type)
267static inline void insert_dquot_hash(struct dquot *dquot) 267static inline void insert_dquot_hash(struct dquot *dquot)
268{ 268{
269 struct hlist_head *head; 269 struct hlist_head *head;
270 head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type); 270 head = dquot_hash + hashfn(dquot->dq_sb, from_kqid(&init_user_ns, dquot->dq_id), dquot->dq_id.type);
271 hlist_add_head(&dquot->dq_hash, head); 271 hlist_add_head(&dquot->dq_hash, head);
272} 272}
273 273
@@ -279,13 +279,13 @@ static inline void remove_dquot_hash(struct dquot *dquot)
279static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb, 279static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb,
280 unsigned int id, int type) 280 unsigned int id, int type)
281{ 281{
282 struct kqid qid = make_kqid(&init_user_ns, type, id);
282 struct hlist_node *node; 283 struct hlist_node *node;
283 struct dquot *dquot; 284 struct dquot *dquot;
284 285
285 hlist_for_each (node, dquot_hash+hashent) { 286 hlist_for_each (node, dquot_hash+hashent) {
286 dquot = hlist_entry(node, struct dquot, dq_hash); 287 dquot = hlist_entry(node, struct dquot, dq_hash);
287 if (dquot->dq_sb == sb && dquot->dq_id == id && 288 if (dquot->dq_sb == sb && qid_eq(dquot->dq_id, qid))
288 dquot->dq_type == type)
289 return dquot; 289 return dquot;
290 } 290 }
291 return NULL; 291 return NULL;
@@ -351,7 +351,7 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
351 spin_lock(&dq_list_lock); 351 spin_lock(&dq_list_lock);
352 if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) { 352 if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
353 list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)-> 353 list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)->
354 info[dquot->dq_type].dqi_dirty_list); 354 info[dquot->dq_id.type].dqi_dirty_list);
355 ret = 0; 355 ret = 0;
356 } 356 }
357 spin_unlock(&dq_list_lock); 357 spin_unlock(&dq_list_lock);
@@ -410,17 +410,17 @@ int dquot_acquire(struct dquot *dquot)
410 mutex_lock(&dquot->dq_lock); 410 mutex_lock(&dquot->dq_lock);
411 mutex_lock(&dqopt->dqio_mutex); 411 mutex_lock(&dqopt->dqio_mutex);
412 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) 412 if (!test_bit(DQ_READ_B, &dquot->dq_flags))
413 ret = dqopt->ops[dquot->dq_type]->read_dqblk(dquot); 413 ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
414 if (ret < 0) 414 if (ret < 0)
415 goto out_iolock; 415 goto out_iolock;
416 set_bit(DQ_READ_B, &dquot->dq_flags); 416 set_bit(DQ_READ_B, &dquot->dq_flags);
417 /* Instantiate dquot if needed */ 417 /* Instantiate dquot if needed */
418 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { 418 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
419 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); 419 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
420 /* Write the info if needed */ 420 /* Write the info if needed */
421 if (info_dirty(&dqopt->info[dquot->dq_type])) { 421 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
422 ret2 = dqopt->ops[dquot->dq_type]->write_file_info( 422 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
423 dquot->dq_sb, dquot->dq_type); 423 dquot->dq_sb, dquot->dq_id.type);
424 } 424 }
425 if (ret < 0) 425 if (ret < 0)
426 goto out_iolock; 426 goto out_iolock;
@@ -455,7 +455,7 @@ int dquot_commit(struct dquot *dquot)
455 /* Inactive dquot can be only if there was error during read/init 455 /* Inactive dquot can be only if there was error during read/init
456 * => we have better not writing it */ 456 * => we have better not writing it */
457 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) 457 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
458 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); 458 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
459 else 459 else
460 ret = -EIO; 460 ret = -EIO;
461out_sem: 461out_sem:
@@ -477,12 +477,12 @@ int dquot_release(struct dquot *dquot)
477 if (atomic_read(&dquot->dq_count) > 1) 477 if (atomic_read(&dquot->dq_count) > 1)
478 goto out_dqlock; 478 goto out_dqlock;
479 mutex_lock(&dqopt->dqio_mutex); 479 mutex_lock(&dqopt->dqio_mutex);
480 if (dqopt->ops[dquot->dq_type]->release_dqblk) { 480 if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
481 ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot); 481 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
482 /* Write the info */ 482 /* Write the info */
483 if (info_dirty(&dqopt->info[dquot->dq_type])) { 483 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
484 ret2 = dqopt->ops[dquot->dq_type]->write_file_info( 484 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
485 dquot->dq_sb, dquot->dq_type); 485 dquot->dq_sb, dquot->dq_id.type);
486 } 486 }
487 if (ret >= 0) 487 if (ret >= 0)
488 ret = ret2; 488 ret = ret2;
@@ -521,7 +521,7 @@ restart:
521 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) { 521 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
522 if (dquot->dq_sb != sb) 522 if (dquot->dq_sb != sb)
523 continue; 523 continue;
524 if (dquot->dq_type != type) 524 if (dquot->dq_id.type != type)
525 continue; 525 continue;
526 /* Wait for dquot users */ 526 /* Wait for dquot users */
527 if (atomic_read(&dquot->dq_count)) { 527 if (atomic_read(&dquot->dq_count)) {
@@ -741,7 +741,8 @@ void dqput(struct dquot *dquot)
741#ifdef CONFIG_QUOTA_DEBUG 741#ifdef CONFIG_QUOTA_DEBUG
742 if (!atomic_read(&dquot->dq_count)) { 742 if (!atomic_read(&dquot->dq_count)) {
743 quota_error(dquot->dq_sb, "trying to free free dquot of %s %d", 743 quota_error(dquot->dq_sb, "trying to free free dquot of %s %d",
744 quotatypes[dquot->dq_type], dquot->dq_id); 744 quotatypes[dquot->dq_id.type],
745 from_kqid(&init_user_ns, dquot->dq_id));
745 BUG(); 746 BUG();
746 } 747 }
747#endif 748#endif
@@ -752,7 +753,7 @@ we_slept:
752 /* We have more than one user... nothing to do */ 753 /* We have more than one user... nothing to do */
753 atomic_dec(&dquot->dq_count); 754 atomic_dec(&dquot->dq_count);
754 /* Releasing dquot during quotaoff phase? */ 755 /* Releasing dquot during quotaoff phase? */
755 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_type) && 756 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_id.type) &&
756 atomic_read(&dquot->dq_count) == 1) 757 atomic_read(&dquot->dq_count) == 1)
757 wake_up(&dquot->dq_wait_unused); 758 wake_up(&dquot->dq_wait_unused);
758 spin_unlock(&dq_list_lock); 759 spin_unlock(&dq_list_lock);
@@ -815,7 +816,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
815 INIT_LIST_HEAD(&dquot->dq_dirty); 816 INIT_LIST_HEAD(&dquot->dq_dirty);
816 init_waitqueue_head(&dquot->dq_wait_unused); 817 init_waitqueue_head(&dquot->dq_wait_unused);
817 dquot->dq_sb = sb; 818 dquot->dq_sb = sb;
818 dquot->dq_type = type; 819 dquot->dq_id.type = type;
819 atomic_set(&dquot->dq_count, 1); 820 atomic_set(&dquot->dq_count, 1);
820 821
821 return dquot; 822 return dquot;
@@ -859,7 +860,7 @@ we_slept:
859 } 860 }
860 dquot = empty; 861 dquot = empty;
861 empty = NULL; 862 empty = NULL;
862 dquot->dq_id = id; 863 dquot->dq_id = qid;
863 /* all dquots go on the inuse_list */ 864 /* all dquots go on the inuse_list */
864 put_inuse(dquot); 865 put_inuse(dquot);
865 /* hash it first so it can be found */ 866 /* hash it first so it can be found */
@@ -1219,8 +1220,8 @@ static void prepare_warning(struct dquot_warn *warn, struct dquot *dquot,
1219 return; 1220 return;
1220 warn->w_type = warntype; 1221 warn->w_type = warntype;
1221 warn->w_sb = dquot->dq_sb; 1222 warn->w_sb = dquot->dq_sb;
1222 warn->w_dq_id = dquot->dq_id; 1223 warn->w_dq_id = from_kqid(&init_user_ns, dquot->dq_id);
1223 warn->w_dq_type = dquot->dq_type; 1224 warn->w_dq_type = dquot->dq_id.type;
1224} 1225}
1225 1226
1226/* 1227/*
@@ -1245,7 +1246,7 @@ static void flush_warnings(struct dquot_warn *warn)
1245 1246
1246static int ignore_hardlimit(struct dquot *dquot) 1247static int ignore_hardlimit(struct dquot *dquot)
1247{ 1248{
1248 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; 1249 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
1249 1250
1250 return capable(CAP_SYS_RESOURCE) && 1251 return capable(CAP_SYS_RESOURCE) &&
1251 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD || 1252 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD ||
@@ -1258,7 +1259,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes,
1258{ 1259{
1259 qsize_t newinodes = dquot->dq_dqb.dqb_curinodes + inodes; 1260 qsize_t newinodes = dquot->dq_dqb.dqb_curinodes + inodes;
1260 1261
1261 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || 1262 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type) ||
1262 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1263 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1263 return 0; 1264 return 0;
1264 1265
@@ -1283,7 +1284,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes,
1283 dquot->dq_dqb.dqb_itime == 0) { 1284 dquot->dq_dqb.dqb_itime == 0) {
1284 prepare_warning(warn, dquot, QUOTA_NL_ISOFTWARN); 1285 prepare_warning(warn, dquot, QUOTA_NL_ISOFTWARN);
1285 dquot->dq_dqb.dqb_itime = get_seconds() + 1286 dquot->dq_dqb.dqb_itime = get_seconds() +
1286 sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; 1287 sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type].dqi_igrace;
1287 } 1288 }
1288 1289
1289 return 0; 1290 return 0;
@@ -1296,7 +1297,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc,
1296 qsize_t tspace; 1297 qsize_t tspace;
1297 struct super_block *sb = dquot->dq_sb; 1298 struct super_block *sb = dquot->dq_sb;
1298 1299
1299 if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) || 1300 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) ||
1300 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1301 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1301 return 0; 1302 return 0;
1302 1303
@@ -1327,7 +1328,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc,
1327 if (!prealloc) { 1328 if (!prealloc) {
1328 prepare_warning(warn, dquot, QUOTA_NL_BSOFTWARN); 1329 prepare_warning(warn, dquot, QUOTA_NL_BSOFTWARN);
1329 dquot->dq_dqb.dqb_btime = get_seconds() + 1330 dquot->dq_dqb.dqb_btime = get_seconds() +
1330 sb_dqopt(sb)->info[dquot->dq_type].dqi_bgrace; 1331 sb_dqopt(sb)->info[dquot->dq_id.type].dqi_bgrace;
1331 } 1332 }
1332 else 1333 else
1333 /* 1334 /*
@@ -1346,7 +1347,7 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1346 1347
1347 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1348 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1348 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit || 1349 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit ||
1349 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type)) 1350 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type))
1350 return QUOTA_NL_NOWARN; 1351 return QUOTA_NL_NOWARN;
1351 1352
1352 newinodes = dquot->dq_dqb.dqb_curinodes - inodes; 1353 newinodes = dquot->dq_dqb.dqb_curinodes - inodes;
@@ -2362,9 +2363,9 @@ static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
2362 2363
2363 memset(di, 0, sizeof(*di)); 2364 memset(di, 0, sizeof(*di));
2364 di->d_version = FS_DQUOT_VERSION; 2365 di->d_version = FS_DQUOT_VERSION;
2365 di->d_flags = dquot->dq_type == USRQUOTA ? 2366 di->d_flags = dquot->dq_id.type == USRQUOTA ?
2366 FS_USER_QUOTA : FS_GROUP_QUOTA; 2367 FS_USER_QUOTA : FS_GROUP_QUOTA;
2367 di->d_id = dquot->dq_id; 2368 di->d_id = from_kqid_munged(current_user_ns(), dquot->dq_id);
2368 2369
2369 spin_lock(&dq_data_lock); 2370 spin_lock(&dq_data_lock);
2370 di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit); 2371 di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit);
@@ -2403,7 +2404,7 @@ static int do_set_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
2403{ 2404{
2404 struct mem_dqblk *dm = &dquot->dq_dqb; 2405 struct mem_dqblk *dm = &dquot->dq_dqb;
2405 int check_blim = 0, check_ilim = 0; 2406 int check_blim = 0, check_ilim = 0;
2406 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; 2407 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
2407 2408
2408 if (di->d_fieldmask & ~VFS_FS_DQ_MASK) 2409 if (di->d_fieldmask & ~VFS_FS_DQ_MASK)
2409 return -EINVAL; 2410 return -EINVAL;
diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
index e41c1becf096..d65877fbe8f4 100644
--- a/fs/quota/quota_tree.c
+++ b/fs/quota/quota_tree.c
@@ -22,9 +22,10 @@ MODULE_LICENSE("GPL");
22 22
23#define __QUOTA_QT_PARANOIA 23#define __QUOTA_QT_PARANOIA
24 24
25static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth) 25static int get_index(struct qtree_mem_dqinfo *info, struct kqid qid, int depth)
26{ 26{
27 unsigned int epb = info->dqi_usable_bs >> 2; 27 unsigned int epb = info->dqi_usable_bs >> 2;
28 qid_t id = from_kqid(&init_user_ns, qid);
28 29
29 depth = info->dqi_qtree_depth - depth - 1; 30 depth = info->dqi_qtree_depth - depth - 1;
30 while (depth--) 31 while (depth--)
@@ -244,7 +245,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
244 /* This is enough as the block is already zeroed and the entry 245 /* This is enough as the block is already zeroed and the entry
245 * list is empty... */ 246 * list is empty... */
246 info->dqi_free_entry = blk; 247 info->dqi_free_entry = blk;
247 mark_info_dirty(dquot->dq_sb, dquot->dq_type); 248 mark_info_dirty(dquot->dq_sb, dquot->dq_id.type);
248 } 249 }
249 /* Block will be full? */ 250 /* Block will be full? */
250 if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) { 251 if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) {
@@ -357,7 +358,7 @@ static inline int dq_insert_tree(struct qtree_mem_dqinfo *info,
357 */ 358 */
358int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) 359int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
359{ 360{
360 int type = dquot->dq_type; 361 int type = dquot->dq_id.type;
361 struct super_block *sb = dquot->dq_sb; 362 struct super_block *sb = dquot->dq_sb;
362 ssize_t ret; 363 ssize_t ret;
363 char *ddquot = getdqbuf(info->dqi_entry_size); 364 char *ddquot = getdqbuf(info->dqi_entry_size);
@@ -538,8 +539,9 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
538 ddquot += info->dqi_entry_size; 539 ddquot += info->dqi_entry_size;
539 } 540 }
540 if (i == qtree_dqstr_in_blk(info)) { 541 if (i == qtree_dqstr_in_blk(info)) {
541 quota_error(dquot->dq_sb, "Quota for id %u referenced " 542 quota_error(dquot->dq_sb,
542 "but not present", dquot->dq_id); 543 "Quota for id %u referenced but not present",
544 from_kqid(&init_user_ns, dquot->dq_id));
543 ret = -EIO; 545 ret = -EIO;
544 goto out_buf; 546 goto out_buf;
545 } else { 547 } else {
@@ -589,7 +591,7 @@ static inline loff_t find_dqentry(struct qtree_mem_dqinfo *info,
589 591
590int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) 592int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
591{ 593{
592 int type = dquot->dq_type; 594 int type = dquot->dq_id.type;
593 struct super_block *sb = dquot->dq_sb; 595 struct super_block *sb = dquot->dq_sb;
594 loff_t offset; 596 loff_t offset;
595 char *ddquot; 597 char *ddquot;
@@ -607,8 +609,10 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
607 offset = find_dqentry(info, dquot); 609 offset = find_dqentry(info, dquot);
608 if (offset <= 0) { /* Entry not present? */ 610 if (offset <= 0) { /* Entry not present? */
609 if (offset < 0) 611 if (offset < 0)
610 quota_error(sb, "Can't read quota structure " 612 quota_error(sb,"Can't read quota structure "
611 "for id %u", dquot->dq_id); 613 "for id %u",
614 from_kqid(&init_user_ns,
615 dquot->dq_id));
612 dquot->dq_off = 0; 616 dquot->dq_off = 0;
613 set_bit(DQ_FAKE_B, &dquot->dq_flags); 617 set_bit(DQ_FAKE_B, &dquot->dq_flags);
614 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); 618 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk));
@@ -626,7 +630,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
626 if (ret >= 0) 630 if (ret >= 0)
627 ret = -EIO; 631 ret = -EIO;
628 quota_error(sb, "Error while reading quota structure for id %u", 632 quota_error(sb, "Error while reading quota structure for id %u",
629 dquot->dq_id); 633 from_kqid(&init_user_ns, dquot->dq_id));
630 set_bit(DQ_FAKE_B, &dquot->dq_flags); 634 set_bit(DQ_FAKE_B, &dquot->dq_flags);
631 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); 635 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk));
632 kfree(ddquot); 636 kfree(ddquot);
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
55static int v1_read_dqblk(struct dquot *dquot) 55static 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
79static int v1_commit_dqblk(struct dquot *dquot) 80static 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)
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index f1ab3604db5a..02751ec695c5 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -196,7 +196,7 @@ static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot)
196 struct v2r0_disk_dqblk *d = dp; 196 struct v2r0_disk_dqblk *d = dp;
197 struct mem_dqblk *m = &dquot->dq_dqb; 197 struct mem_dqblk *m = &dquot->dq_dqb;
198 struct qtree_mem_dqinfo *info = 198 struct qtree_mem_dqinfo *info =
199 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 199 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
200 200
201 d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit); 201 d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit);
202 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit); 202 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit);
@@ -206,7 +206,7 @@ static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot)
206 d->dqb_bsoftlimit = cpu_to_le32(v2_stoqb(m->dqb_bsoftlimit)); 206 d->dqb_bsoftlimit = cpu_to_le32(v2_stoqb(m->dqb_bsoftlimit));
207 d->dqb_curspace = cpu_to_le64(m->dqb_curspace); 207 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
208 d->dqb_btime = cpu_to_le64(m->dqb_btime); 208 d->dqb_btime = cpu_to_le64(m->dqb_btime);
209 d->dqb_id = cpu_to_le32(dquot->dq_id); 209 d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id));
210 if (qtree_entry_unused(info, dp)) 210 if (qtree_entry_unused(info, dp))
211 d->dqb_itime = cpu_to_le64(1); 211 d->dqb_itime = cpu_to_le64(1);
212} 212}
@@ -215,11 +215,13 @@ static int v2r0_is_id(void *dp, struct dquot *dquot)
215{ 215{
216 struct v2r0_disk_dqblk *d = dp; 216 struct v2r0_disk_dqblk *d = dp;
217 struct qtree_mem_dqinfo *info = 217 struct qtree_mem_dqinfo *info =
218 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 218 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
219 219
220 if (qtree_entry_unused(info, dp)) 220 if (qtree_entry_unused(info, dp))
221 return 0; 221 return 0;
222 return le32_to_cpu(d->dqb_id) == dquot->dq_id; 222 return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type,
223 le32_to_cpu(d->dqb_id)),
224 dquot->dq_id);
223} 225}
224 226
225static void v2r1_disk2memdqb(struct dquot *dquot, void *dp) 227static void v2r1_disk2memdqb(struct dquot *dquot, void *dp)
@@ -247,7 +249,7 @@ static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot)
247 struct v2r1_disk_dqblk *d = dp; 249 struct v2r1_disk_dqblk *d = dp;
248 struct mem_dqblk *m = &dquot->dq_dqb; 250 struct mem_dqblk *m = &dquot->dq_dqb;
249 struct qtree_mem_dqinfo *info = 251 struct qtree_mem_dqinfo *info =
250 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 252 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
251 253
252 d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit); 254 d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
253 d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit); 255 d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
@@ -257,7 +259,7 @@ static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot)
257 d->dqb_bsoftlimit = cpu_to_le64(v2_stoqb(m->dqb_bsoftlimit)); 259 d->dqb_bsoftlimit = cpu_to_le64(v2_stoqb(m->dqb_bsoftlimit));
258 d->dqb_curspace = cpu_to_le64(m->dqb_curspace); 260 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
259 d->dqb_btime = cpu_to_le64(m->dqb_btime); 261 d->dqb_btime = cpu_to_le64(m->dqb_btime);
260 d->dqb_id = cpu_to_le32(dquot->dq_id); 262 d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id));
261 if (qtree_entry_unused(info, dp)) 263 if (qtree_entry_unused(info, dp))
262 d->dqb_itime = cpu_to_le64(1); 264 d->dqb_itime = cpu_to_le64(1);
263} 265}
@@ -266,26 +268,28 @@ static int v2r1_is_id(void *dp, struct dquot *dquot)
266{ 268{
267 struct v2r1_disk_dqblk *d = dp; 269 struct v2r1_disk_dqblk *d = dp;
268 struct qtree_mem_dqinfo *info = 270 struct qtree_mem_dqinfo *info =
269 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 271 sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv;
270 272
271 if (qtree_entry_unused(info, dp)) 273 if (qtree_entry_unused(info, dp))
272 return 0; 274 return 0;
273 return le32_to_cpu(d->dqb_id) == dquot->dq_id; 275 return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type,
276 le32_to_cpu(d->dqb_id)),
277 dquot->dq_id);
274} 278}
275 279
276static int v2_read_dquot(struct dquot *dquot) 280static int v2_read_dquot(struct dquot *dquot)
277{ 281{
278 return qtree_read_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot); 282 return qtree_read_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
279} 283}
280 284
281static int v2_write_dquot(struct dquot *dquot) 285static int v2_write_dquot(struct dquot *dquot)
282{ 286{
283 return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot); 287 return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
284} 288}
285 289
286static int v2_release_dquot(struct dquot *dquot) 290static int v2_release_dquot(struct dquot *dquot)
287{ 291{
288 return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot); 292 return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
289} 293}
290 294
291static int v2_free_file_info(struct super_block *sb, int type) 295static int v2_free_file_info(struct super_block *sb, int type)
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 8b2760427252..dcd5721e626d 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -419,10 +419,9 @@ struct dquot {
419 atomic_t dq_count; /* Use count */ 419 atomic_t dq_count; /* Use count */
420 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */ 420 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */
421 struct super_block *dq_sb; /* superblock this applies to */ 421 struct super_block *dq_sb; /* superblock this applies to */
422 unsigned int dq_id; /* ID this applies to (uid, gid) */ 422 struct kqid dq_id; /* ID this applies to (uid, gid, projid) */
423 loff_t dq_off; /* Offset of dquot on disk */ 423 loff_t dq_off; /* Offset of dquot on disk */
424 unsigned long dq_flags; /* See DQ_* */ 424 unsigned long dq_flags; /* See DQ_* */
425 short dq_type; /* Type of quota */
426 struct mem_dqblk dq_dqb; /* Diskquota usage */ 425 struct mem_dqblk dq_dqb; /* Diskquota usage */
427}; 426};
428 427