aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/dquot.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 14:11:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 14:11:09 -0400
commit437589a74b6a590d175f86cf9f7b2efcee7765e7 (patch)
tree37bf8635b1356d80ef002b00e84f3faf3d555a63 /fs/quota/dquot.c
parent68d47a137c3bef754923bccf73fb639c9b0bbd5e (diff)
parent72235465864d84cedb2d9f26f8e1de824ee20339 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull user namespace changes from Eric Biederman: "This is a mostly modest set of changes to enable basic user namespace support. This allows the code to code to compile with user namespaces enabled and removes the assumption there is only the initial user namespace. Everything is converted except for the most complex of the filesystems: autofs4, 9p, afs, ceph, cifs, coda, fuse, gfs2, ncpfs, nfs, ocfs2 and xfs as those patches need a bit more review. The strategy is to push kuid_t and kgid_t values are far down into subsystems and filesystems as reasonable. Leaving the make_kuid and from_kuid operations to happen at the edge of userspace, as the values come off the disk, and as the values come in from the network. Letting compile type incompatible compile errors (present when user namespaces are enabled) guide me to find the issues. The most tricky areas have been the places where we had an implicit union of uid and gid values and were storing them in an unsigned int. Those places were converted into explicit unions. I made certain to handle those places with simple trivial patches. Out of that work I discovered we have generic interfaces for storing quota by projid. I had never heard of the project identifiers before. Adding full user namespace support for project identifiers accounts for most of the code size growth in my git tree. Ultimately there will be work to relax privlige checks from "capable(FOO)" to "ns_capable(user_ns, FOO)" where it is safe allowing root in a user names to do those things that today we only forbid to non-root users because it will confuse suid root applications. While I was pushing kuid_t and kgid_t changes deep into the audit code I made a few other cleanups. I capitalized on the fact we process netlink messages in the context of the message sender. I removed usage of NETLINK_CRED, and started directly using current->tty. Some of these patches have also made it into maintainer trees, with no problems from identical code from different trees showing up in linux-next. After reading through all of this code I feel like I might be able to win a game of kernel trivial pursuit." Fix up some fairly trivial conflicts in netfilter uid/git logging code. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (107 commits) userns: Convert the ufs filesystem to use kuid/kgid where appropriate userns: Convert the udf filesystem to use kuid/kgid where appropriate userns: Convert ubifs to use kuid/kgid userns: Convert squashfs to use kuid/kgid where appropriate userns: Convert reiserfs to use kuid and kgid where appropriate userns: Convert jfs to use kuid/kgid where appropriate userns: Convert jffs2 to use kuid and kgid where appropriate userns: Convert hpfs to use kuid and kgid where appropriate userns: Convert btrfs to use kuid/kgid where appropriate userns: Convert bfs to use kuid/kgid where appropriate userns: Convert affs to use kuid/kgid wherwe appropriate userns: On alpha modify linux_to_osf_stat to use convert from kuids and kgids userns: On ia64 deal with current_uid and current_gid being kuid and kgid userns: On ppc convert current_uid from a kuid before printing. userns: Convert s390 getting uid and gid system calls to use kuid and kgid userns: Convert s390 hypfs to use kuid and kgid where appropriate userns: Convert binder ipc to use kuids userns: Teach security_path_chown to take kuids and kgids userns: Add user namespace support to IMA userns: Convert EVM to deal with kuids and kgids in it's hmac computation ...
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r--fs/quota/dquot.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index c495a3055e2a..557a9c20a215 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -253,8 +253,10 @@ static qsize_t inode_get_rsv_space(struct inode *inode);
253static void __dquot_initialize(struct inode *inode, int type); 253static void __dquot_initialize(struct inode *inode, int type);
254 254
255static inline unsigned int 255static inline unsigned int
256hashfn(const struct super_block *sb, unsigned int id, int type) 256hashfn(const struct super_block *sb, struct kqid qid)
257{ 257{
258 unsigned int id = from_kqid(&init_user_ns, qid);
259 int type = qid.type;
258 unsigned long tmp; 260 unsigned long tmp;
259 261
260 tmp = (((unsigned long)sb>>L1_CACHE_SHIFT) ^ id) * (MAXQUOTAS - type); 262 tmp = (((unsigned long)sb>>L1_CACHE_SHIFT) ^ id) * (MAXQUOTAS - type);
@@ -267,7 +269,7 @@ hashfn(const struct super_block *sb, unsigned int id, int type)
267static inline void insert_dquot_hash(struct dquot *dquot) 269static inline void insert_dquot_hash(struct dquot *dquot)
268{ 270{
269 struct hlist_head *head; 271 struct hlist_head *head;
270 head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id, dquot->dq_type); 272 head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id);
271 hlist_add_head(&dquot->dq_hash, head); 273 hlist_add_head(&dquot->dq_hash, head);
272} 274}
273 275
@@ -277,15 +279,14 @@ static inline void remove_dquot_hash(struct dquot *dquot)
277} 279}
278 280
279static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb, 281static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb,
280 unsigned int id, int type) 282 struct kqid qid)
281{ 283{
282 struct hlist_node *node; 284 struct hlist_node *node;
283 struct dquot *dquot; 285 struct dquot *dquot;
284 286
285 hlist_for_each (node, dquot_hash+hashent) { 287 hlist_for_each (node, dquot_hash+hashent) {
286 dquot = hlist_entry(node, struct dquot, dq_hash); 288 dquot = hlist_entry(node, struct dquot, dq_hash);
287 if (dquot->dq_sb == sb && dquot->dq_id == id && 289 if (dquot->dq_sb == sb && qid_eq(dquot->dq_id, qid))
288 dquot->dq_type == type)
289 return dquot; 290 return dquot;
290 } 291 }
291 return NULL; 292 return NULL;
@@ -351,7 +352,7 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
351 spin_lock(&dq_list_lock); 352 spin_lock(&dq_list_lock);
352 if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) { 353 if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
353 list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)-> 354 list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)->
354 info[dquot->dq_type].dqi_dirty_list); 355 info[dquot->dq_id.type].dqi_dirty_list);
355 ret = 0; 356 ret = 0;
356 } 357 }
357 spin_unlock(&dq_list_lock); 358 spin_unlock(&dq_list_lock);
@@ -410,17 +411,17 @@ int dquot_acquire(struct dquot *dquot)
410 mutex_lock(&dquot->dq_lock); 411 mutex_lock(&dquot->dq_lock);
411 mutex_lock(&dqopt->dqio_mutex); 412 mutex_lock(&dqopt->dqio_mutex);
412 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) 413 if (!test_bit(DQ_READ_B, &dquot->dq_flags))
413 ret = dqopt->ops[dquot->dq_type]->read_dqblk(dquot); 414 ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
414 if (ret < 0) 415 if (ret < 0)
415 goto out_iolock; 416 goto out_iolock;
416 set_bit(DQ_READ_B, &dquot->dq_flags); 417 set_bit(DQ_READ_B, &dquot->dq_flags);
417 /* Instantiate dquot if needed */ 418 /* Instantiate dquot if needed */
418 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { 419 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
419 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); 420 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
420 /* Write the info if needed */ 421 /* Write the info if needed */
421 if (info_dirty(&dqopt->info[dquot->dq_type])) { 422 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
422 ret2 = dqopt->ops[dquot->dq_type]->write_file_info( 423 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
423 dquot->dq_sb, dquot->dq_type); 424 dquot->dq_sb, dquot->dq_id.type);
424 } 425 }
425 if (ret < 0) 426 if (ret < 0)
426 goto out_iolock; 427 goto out_iolock;
@@ -455,7 +456,7 @@ int dquot_commit(struct dquot *dquot)
455 /* Inactive dquot can be only if there was error during read/init 456 /* Inactive dquot can be only if there was error during read/init
456 * => we have better not writing it */ 457 * => we have better not writing it */
457 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) 458 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
458 ret = dqopt->ops[dquot->dq_type]->commit_dqblk(dquot); 459 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
459 else 460 else
460 ret = -EIO; 461 ret = -EIO;
461out_sem: 462out_sem:
@@ -477,12 +478,12 @@ int dquot_release(struct dquot *dquot)
477 if (atomic_read(&dquot->dq_count) > 1) 478 if (atomic_read(&dquot->dq_count) > 1)
478 goto out_dqlock; 479 goto out_dqlock;
479 mutex_lock(&dqopt->dqio_mutex); 480 mutex_lock(&dqopt->dqio_mutex);
480 if (dqopt->ops[dquot->dq_type]->release_dqblk) { 481 if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
481 ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot); 482 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
482 /* Write the info */ 483 /* Write the info */
483 if (info_dirty(&dqopt->info[dquot->dq_type])) { 484 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
484 ret2 = dqopt->ops[dquot->dq_type]->write_file_info( 485 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
485 dquot->dq_sb, dquot->dq_type); 486 dquot->dq_sb, dquot->dq_id.type);
486 } 487 }
487 if (ret >= 0) 488 if (ret >= 0)
488 ret = ret2; 489 ret = ret2;
@@ -521,7 +522,7 @@ restart:
521 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) { 522 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
522 if (dquot->dq_sb != sb) 523 if (dquot->dq_sb != sb)
523 continue; 524 continue;
524 if (dquot->dq_type != type) 525 if (dquot->dq_id.type != type)
525 continue; 526 continue;
526 /* Wait for dquot users */ 527 /* Wait for dquot users */
527 if (atomic_read(&dquot->dq_count)) { 528 if (atomic_read(&dquot->dq_count)) {
@@ -741,7 +742,8 @@ void dqput(struct dquot *dquot)
741#ifdef CONFIG_QUOTA_DEBUG 742#ifdef CONFIG_QUOTA_DEBUG
742 if (!atomic_read(&dquot->dq_count)) { 743 if (!atomic_read(&dquot->dq_count)) {
743 quota_error(dquot->dq_sb, "trying to free free dquot of %s %d", 744 quota_error(dquot->dq_sb, "trying to free free dquot of %s %d",
744 quotatypes[dquot->dq_type], dquot->dq_id); 745 quotatypes[dquot->dq_id.type],
746 from_kqid(&init_user_ns, dquot->dq_id));
745 BUG(); 747 BUG();
746 } 748 }
747#endif 749#endif
@@ -752,7 +754,7 @@ we_slept:
752 /* We have more than one user... nothing to do */ 754 /* We have more than one user... nothing to do */
753 atomic_dec(&dquot->dq_count); 755 atomic_dec(&dquot->dq_count);
754 /* Releasing dquot during quotaoff phase? */ 756 /* Releasing dquot during quotaoff phase? */
755 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_type) && 757 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_id.type) &&
756 atomic_read(&dquot->dq_count) == 1) 758 atomic_read(&dquot->dq_count) == 1)
757 wake_up(&dquot->dq_wait_unused); 759 wake_up(&dquot->dq_wait_unused);
758 spin_unlock(&dq_list_lock); 760 spin_unlock(&dq_list_lock);
@@ -815,7 +817,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
815 INIT_LIST_HEAD(&dquot->dq_dirty); 817 INIT_LIST_HEAD(&dquot->dq_dirty);
816 init_waitqueue_head(&dquot->dq_wait_unused); 818 init_waitqueue_head(&dquot->dq_wait_unused);
817 dquot->dq_sb = sb; 819 dquot->dq_sb = sb;
818 dquot->dq_type = type; 820 dquot->dq_id = make_kqid_invalid(type);
819 atomic_set(&dquot->dq_count, 1); 821 atomic_set(&dquot->dq_count, 1);
820 822
821 return dquot; 823 return dquot;
@@ -829,35 +831,35 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
829 * a) checking for quota flags under dq_list_lock and 831 * a) checking for quota flags under dq_list_lock and
830 * b) getting a reference to dquot before we release dq_list_lock 832 * b) getting a reference to dquot before we release dq_list_lock
831 */ 833 */
832struct dquot *dqget(struct super_block *sb, unsigned int id, int type) 834struct dquot *dqget(struct super_block *sb, struct kqid qid)
833{ 835{
834 unsigned int hashent = hashfn(sb, id, type); 836 unsigned int hashent = hashfn(sb, qid);
835 struct dquot *dquot = NULL, *empty = NULL; 837 struct dquot *dquot = NULL, *empty = NULL;
836 838
837 if (!sb_has_quota_active(sb, type)) 839 if (!sb_has_quota_active(sb, qid.type))
838 return NULL; 840 return NULL;
839we_slept: 841we_slept:
840 spin_lock(&dq_list_lock); 842 spin_lock(&dq_list_lock);
841 spin_lock(&dq_state_lock); 843 spin_lock(&dq_state_lock);
842 if (!sb_has_quota_active(sb, type)) { 844 if (!sb_has_quota_active(sb, qid.type)) {
843 spin_unlock(&dq_state_lock); 845 spin_unlock(&dq_state_lock);
844 spin_unlock(&dq_list_lock); 846 spin_unlock(&dq_list_lock);
845 goto out; 847 goto out;
846 } 848 }
847 spin_unlock(&dq_state_lock); 849 spin_unlock(&dq_state_lock);
848 850
849 dquot = find_dquot(hashent, sb, id, type); 851 dquot = find_dquot(hashent, sb, qid);
850 if (!dquot) { 852 if (!dquot) {
851 if (!empty) { 853 if (!empty) {
852 spin_unlock(&dq_list_lock); 854 spin_unlock(&dq_list_lock);
853 empty = get_empty_dquot(sb, type); 855 empty = get_empty_dquot(sb, qid.type);
854 if (!empty) 856 if (!empty)
855 schedule(); /* Try to wait for a moment... */ 857 schedule(); /* Try to wait for a moment... */
856 goto we_slept; 858 goto we_slept;
857 } 859 }
858 dquot = empty; 860 dquot = empty;
859 empty = NULL; 861 empty = NULL;
860 dquot->dq_id = id; 862 dquot->dq_id = qid;
861 /* all dquots go on the inuse_list */ 863 /* all dquots go on the inuse_list */
862 put_inuse(dquot); 864 put_inuse(dquot);
863 /* hash it first so it can be found */ 865 /* hash it first so it can be found */
@@ -1129,8 +1131,7 @@ static void dquot_decr_space(struct dquot *dquot, qsize_t number)
1129 1131
1130struct dquot_warn { 1132struct dquot_warn {
1131 struct super_block *w_sb; 1133 struct super_block *w_sb;
1132 qid_t w_dq_id; 1134 struct kqid w_dq_id;
1133 short w_dq_type;
1134 short w_type; 1135 short w_type;
1135}; 1136};
1136 1137
@@ -1154,11 +1155,11 @@ static int need_print_warning(struct dquot_warn *warn)
1154 if (!flag_print_warnings) 1155 if (!flag_print_warnings)
1155 return 0; 1156 return 0;
1156 1157
1157 switch (warn->w_dq_type) { 1158 switch (warn->w_dq_id.type) {
1158 case USRQUOTA: 1159 case USRQUOTA:
1159 return current_fsuid() == warn->w_dq_id; 1160 return uid_eq(current_fsuid(), warn->w_dq_id.uid);
1160 case GRPQUOTA: 1161 case GRPQUOTA:
1161 return in_group_p(warn->w_dq_id); 1162 return in_group_p(warn->w_dq_id.gid);
1162 } 1163 }
1163 return 0; 1164 return 0;
1164} 1165}
@@ -1184,7 +1185,7 @@ static void print_warning(struct dquot_warn *warn)
1184 tty_write_message(tty, ": warning, "); 1185 tty_write_message(tty, ": warning, ");
1185 else 1186 else
1186 tty_write_message(tty, ": write failed, "); 1187 tty_write_message(tty, ": write failed, ");
1187 tty_write_message(tty, quotatypes[warn->w_dq_type]); 1188 tty_write_message(tty, quotatypes[warn->w_dq_id.type]);
1188 switch (warntype) { 1189 switch (warntype) {
1189 case QUOTA_NL_IHARDWARN: 1190 case QUOTA_NL_IHARDWARN:
1190 msg = " file limit reached.\r\n"; 1191 msg = " file limit reached.\r\n";
@@ -1218,7 +1219,6 @@ static void prepare_warning(struct dquot_warn *warn, struct dquot *dquot,
1218 warn->w_type = warntype; 1219 warn->w_type = warntype;
1219 warn->w_sb = dquot->dq_sb; 1220 warn->w_sb = dquot->dq_sb;
1220 warn->w_dq_id = dquot->dq_id; 1221 warn->w_dq_id = dquot->dq_id;
1221 warn->w_dq_type = dquot->dq_type;
1222} 1222}
1223 1223
1224/* 1224/*
@@ -1236,14 +1236,14 @@ static void flush_warnings(struct dquot_warn *warn)
1236#ifdef CONFIG_PRINT_QUOTA_WARNING 1236#ifdef CONFIG_PRINT_QUOTA_WARNING
1237 print_warning(&warn[i]); 1237 print_warning(&warn[i]);
1238#endif 1238#endif
1239 quota_send_warning(warn[i].w_dq_type, warn[i].w_dq_id, 1239 quota_send_warning(warn[i].w_dq_id,
1240 warn[i].w_sb->s_dev, warn[i].w_type); 1240 warn[i].w_sb->s_dev, warn[i].w_type);
1241 } 1241 }
1242} 1242}
1243 1243
1244static int ignore_hardlimit(struct dquot *dquot) 1244static int ignore_hardlimit(struct dquot *dquot)
1245{ 1245{
1246 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; 1246 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
1247 1247
1248 return capable(CAP_SYS_RESOURCE) && 1248 return capable(CAP_SYS_RESOURCE) &&
1249 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD || 1249 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD ||
@@ -1256,7 +1256,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes,
1256{ 1256{
1257 qsize_t newinodes = dquot->dq_dqb.dqb_curinodes + inodes; 1257 qsize_t newinodes = dquot->dq_dqb.dqb_curinodes + inodes;
1258 1258
1259 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || 1259 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type) ||
1260 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1260 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1261 return 0; 1261 return 0;
1262 1262
@@ -1281,7 +1281,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes,
1281 dquot->dq_dqb.dqb_itime == 0) { 1281 dquot->dq_dqb.dqb_itime == 0) {
1282 prepare_warning(warn, dquot, QUOTA_NL_ISOFTWARN); 1282 prepare_warning(warn, dquot, QUOTA_NL_ISOFTWARN);
1283 dquot->dq_dqb.dqb_itime = get_seconds() + 1283 dquot->dq_dqb.dqb_itime = get_seconds() +
1284 sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; 1284 sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type].dqi_igrace;
1285 } 1285 }
1286 1286
1287 return 0; 1287 return 0;
@@ -1294,7 +1294,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc,
1294 qsize_t tspace; 1294 qsize_t tspace;
1295 struct super_block *sb = dquot->dq_sb; 1295 struct super_block *sb = dquot->dq_sb;
1296 1296
1297 if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) || 1297 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) ||
1298 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1298 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1299 return 0; 1299 return 0;
1300 1300
@@ -1325,7 +1325,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc,
1325 if (!prealloc) { 1325 if (!prealloc) {
1326 prepare_warning(warn, dquot, QUOTA_NL_BSOFTWARN); 1326 prepare_warning(warn, dquot, QUOTA_NL_BSOFTWARN);
1327 dquot->dq_dqb.dqb_btime = get_seconds() + 1327 dquot->dq_dqb.dqb_btime = get_seconds() +
1328 sb_dqopt(sb)->info[dquot->dq_type].dqi_bgrace; 1328 sb_dqopt(sb)->info[dquot->dq_id.type].dqi_bgrace;
1329 } 1329 }
1330 else 1330 else
1331 /* 1331 /*
@@ -1344,7 +1344,7 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1344 1344
1345 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1345 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1346 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit || 1346 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit ||
1347 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type)) 1347 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type))
1348 return QUOTA_NL_NOWARN; 1348 return QUOTA_NL_NOWARN;
1349 1349
1350 newinodes = dquot->dq_dqb.dqb_curinodes - inodes; 1350 newinodes = dquot->dq_dqb.dqb_curinodes - inodes;
@@ -1390,7 +1390,6 @@ static int dquot_active(const struct inode *inode)
1390 */ 1390 */
1391static void __dquot_initialize(struct inode *inode, int type) 1391static void __dquot_initialize(struct inode *inode, int type)
1392{ 1392{
1393 unsigned int id = 0;
1394 int cnt; 1393 int cnt;
1395 struct dquot *got[MAXQUOTAS]; 1394 struct dquot *got[MAXQUOTAS];
1396 struct super_block *sb = inode->i_sb; 1395 struct super_block *sb = inode->i_sb;
@@ -1403,18 +1402,19 @@ static void __dquot_initialize(struct inode *inode, int type)
1403 1402
1404 /* First get references to structures we might need. */ 1403 /* First get references to structures we might need. */
1405 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1404 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1405 struct kqid qid;
1406 got[cnt] = NULL; 1406 got[cnt] = NULL;
1407 if (type != -1 && cnt != type) 1407 if (type != -1 && cnt != type)
1408 continue; 1408 continue;
1409 switch (cnt) { 1409 switch (cnt) {
1410 case USRQUOTA: 1410 case USRQUOTA:
1411 id = inode->i_uid; 1411 qid = make_kqid_uid(inode->i_uid);
1412 break; 1412 break;
1413 case GRPQUOTA: 1413 case GRPQUOTA:
1414 id = inode->i_gid; 1414 qid = make_kqid_gid(inode->i_gid);
1415 break; 1415 break;
1416 } 1416 }
1417 got[cnt] = dqget(sb, id, cnt); 1417 got[cnt] = dqget(sb, qid);
1418 } 1418 }
1419 1419
1420 down_write(&sb_dqopt(sb)->dqptr_sem); 1420 down_write(&sb_dqopt(sb)->dqptr_sem);
@@ -1897,10 +1897,10 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1897 if (!dquot_active(inode)) 1897 if (!dquot_active(inode))
1898 return 0; 1898 return 0;
1899 1899
1900 if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) 1900 if (iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid))
1901 transfer_to[USRQUOTA] = dqget(sb, iattr->ia_uid, USRQUOTA); 1901 transfer_to[USRQUOTA] = dqget(sb, make_kqid_uid(iattr->ia_uid));
1902 if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) 1902 if (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))
1903 transfer_to[GRPQUOTA] = dqget(sb, iattr->ia_gid, GRPQUOTA); 1903 transfer_to[GRPQUOTA] = dqget(sb, make_kqid_gid(iattr->ia_gid));
1904 1904
1905 ret = __dquot_transfer(inode, transfer_to); 1905 ret = __dquot_transfer(inode, transfer_to);
1906 dqput_all(transfer_to); 1906 dqput_all(transfer_to);
@@ -2360,9 +2360,9 @@ static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
2360 2360
2361 memset(di, 0, sizeof(*di)); 2361 memset(di, 0, sizeof(*di));
2362 di->d_version = FS_DQUOT_VERSION; 2362 di->d_version = FS_DQUOT_VERSION;
2363 di->d_flags = dquot->dq_type == USRQUOTA ? 2363 di->d_flags = dquot->dq_id.type == USRQUOTA ?
2364 FS_USER_QUOTA : FS_GROUP_QUOTA; 2364 FS_USER_QUOTA : FS_GROUP_QUOTA;
2365 di->d_id = dquot->dq_id; 2365 di->d_id = from_kqid_munged(current_user_ns(), dquot->dq_id);
2366 2366
2367 spin_lock(&dq_data_lock); 2367 spin_lock(&dq_data_lock);
2368 di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit); 2368 di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit);
@@ -2376,12 +2376,12 @@ static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
2376 spin_unlock(&dq_data_lock); 2376 spin_unlock(&dq_data_lock);
2377} 2377}
2378 2378
2379int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, 2379int dquot_get_dqblk(struct super_block *sb, struct kqid qid,
2380 struct fs_disk_quota *di) 2380 struct fs_disk_quota *di)
2381{ 2381{
2382 struct dquot *dquot; 2382 struct dquot *dquot;
2383 2383
2384 dquot = dqget(sb, id, type); 2384 dquot = dqget(sb, qid);
2385 if (!dquot) 2385 if (!dquot)
2386 return -ESRCH; 2386 return -ESRCH;
2387 do_get_dqblk(dquot, di); 2387 do_get_dqblk(dquot, di);
@@ -2401,7 +2401,7 @@ static int do_set_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
2401{ 2401{
2402 struct mem_dqblk *dm = &dquot->dq_dqb; 2402 struct mem_dqblk *dm = &dquot->dq_dqb;
2403 int check_blim = 0, check_ilim = 0; 2403 int check_blim = 0, check_ilim = 0;
2404 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type]; 2404 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
2405 2405
2406 if (di->d_fieldmask & ~VFS_FS_DQ_MASK) 2406 if (di->d_fieldmask & ~VFS_FS_DQ_MASK)
2407 return -EINVAL; 2407 return -EINVAL;
@@ -2488,13 +2488,13 @@ static int do_set_dqblk(struct dquot *dquot, struct fs_disk_quota *di)
2488 return 0; 2488 return 0;
2489} 2489}
2490 2490
2491int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, 2491int dquot_set_dqblk(struct super_block *sb, struct kqid qid,
2492 struct fs_disk_quota *di) 2492 struct fs_disk_quota *di)
2493{ 2493{
2494 struct dquot *dquot; 2494 struct dquot *dquot;
2495 int rc; 2495 int rc;
2496 2496
2497 dquot = dqget(sb, id, type); 2497 dquot = dqget(sb, qid);
2498 if (!dquot) { 2498 if (!dquot) {
2499 rc = -ESRCH; 2499 rc = -ESRCH;
2500 goto out; 2500 goto out;