xfs: kill xfs_qmops

Kill the quota ops function vector and replace it with direct calls or
stubs in the CONFIG_XFS_QUOTA=n case.

Make sure we check XFS_IS_QUOTA_RUNNING in the right spots. We can remove
the number of those checks because the XFS_TRANS_DQ_DIRTY flag can't be set
otherwise.

This brings us back closer to the way this code worked in IRIX and earlier
Linux versions, but we keep a lot of the more useful factoring of common
code.

Eventually we should also kill xfs_qm_bhv.c, but that's left for a later
patch.

Reduces the size of the source code by about 250 lines and the size of
XFS module by about 1.5 kilobytes with quotas enabled:

text data bss dec hex filename
615957 2960 3848 622765 980ad fs/xfs/xfs.o
617231 3152 3848 624231 98667 fs/xfs/xfs.o.old

Fallout:

- xfs_qm_dqattach is split into xfs_qm_dqattach_locked which expects
the inode locked and xfs_qm_dqattach which does the locking around it,
thus removing XFS_QMOPT_ILOCKED.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>

authored by

Christoph Hellwig and committed by
Christoph Hellwig
7d095257 0c5e1ce8

+377 -625
+1 -2
fs/xfs/Makefile
··· 88 xfs_utils.o \ 89 xfs_vnodeops.o \ 90 xfs_rw.o \ 91 - xfs_dmops.o \ 92 - xfs_qmops.o 93 94 xfs-$(CONFIG_XFS_TRACE) += xfs_btree_trace.o \ 95 xfs_dir2_trace.o
··· 88 xfs_utils.o \ 89 xfs_vnodeops.o \ 90 xfs_rw.o \ 91 + xfs_dmops.o 92 93 xfs-$(CONFIG_XFS_TRACE) += xfs_btree_trace.o \ 94 xfs_dir2_trace.o
+13 -11
fs/xfs/linux-2.6/xfs_ioctl.c
··· 908 struct xfs_mount *mp = ip->i_mount; 909 struct xfs_trans *tp; 910 unsigned int lock_flags = 0; 911 - struct xfs_dquot *udqp = NULL, *gdqp = NULL; 912 struct xfs_dquot *olddquot = NULL; 913 int code; 914 ··· 929 * because the i_*dquot fields will get updated anyway. 930 */ 931 if (XFS_IS_QUOTA_ON(mp) && (mask & FSX_PROJID)) { 932 - code = XFS_QM_DQVOPALLOC(mp, ip, ip->i_d.di_uid, 933 ip->i_d.di_gid, fa->fsx_projid, 934 XFS_QMOPT_PQUOTA, &udqp, &gdqp); 935 if (code) ··· 964 * Do a quota reservation only if projid is actually going to change. 965 */ 966 if (mask & FSX_PROJID) { 967 - if (XFS_IS_PQUOTA_ON(mp) && 968 ip->i_d.di_projid != fa->fsx_projid) { 969 ASSERT(tp); 970 - code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp, 971 capable(CAP_FOWNER) ? 972 XFS_QMOPT_FORCE_RES : 0); 973 if (code) /* out of quota */ ··· 1070 * in the transaction. 1071 */ 1072 if (ip->i_d.di_projid != fa->fsx_projid) { 1073 - if (XFS_IS_PQUOTA_ON(mp)) { 1074 - olddquot = XFS_QM_DQVOPCHOWN(mp, tp, ip, 1075 &ip->i_gdquot, gdqp); 1076 } 1077 ip->i_d.di_projid = fa->fsx_projid; ··· 1117 /* 1118 * Release any dquot(s) the inode had kept before chown. 1119 */ 1120 - XFS_QM_DQRELE(mp, olddquot); 1121 - XFS_QM_DQRELE(mp, udqp); 1122 - XFS_QM_DQRELE(mp, gdqp); 1123 1124 if (code) 1125 return code; ··· 1133 return 0; 1134 1135 error_return: 1136 - XFS_QM_DQRELE(mp, udqp); 1137 - XFS_QM_DQRELE(mp, gdqp); 1138 xfs_trans_cancel(tp, 0); 1139 if (lock_flags) 1140 xfs_iunlock(ip, lock_flags);
··· 908 struct xfs_mount *mp = ip->i_mount; 909 struct xfs_trans *tp; 910 unsigned int lock_flags = 0; 911 + struct xfs_dquot *udqp = NULL; 912 + struct xfs_dquot *gdqp = NULL; 913 struct xfs_dquot *olddquot = NULL; 914 int code; 915 ··· 928 * because the i_*dquot fields will get updated anyway. 929 */ 930 if (XFS_IS_QUOTA_ON(mp) && (mask & FSX_PROJID)) { 931 + code = xfs_qm_vop_dqalloc(ip, ip->i_d.di_uid, 932 ip->i_d.di_gid, fa->fsx_projid, 933 XFS_QMOPT_PQUOTA, &udqp, &gdqp); 934 if (code) ··· 963 * Do a quota reservation only if projid is actually going to change. 964 */ 965 if (mask & FSX_PROJID) { 966 + if (XFS_IS_QUOTA_RUNNING(mp) && 967 + XFS_IS_PQUOTA_ON(mp) && 968 ip->i_d.di_projid != fa->fsx_projid) { 969 ASSERT(tp); 970 + code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, 971 capable(CAP_FOWNER) ? 972 XFS_QMOPT_FORCE_RES : 0); 973 if (code) /* out of quota */ ··· 1068 * in the transaction. 1069 */ 1070 if (ip->i_d.di_projid != fa->fsx_projid) { 1071 + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) { 1072 + olddquot = xfs_qm_vop_chown(tp, ip, 1073 &ip->i_gdquot, gdqp); 1074 } 1075 ip->i_d.di_projid = fa->fsx_projid; ··· 1115 /* 1116 * Release any dquot(s) the inode had kept before chown. 1117 */ 1118 + xfs_qm_dqrele(olddquot); 1119 + xfs_qm_dqrele(udqp); 1120 + xfs_qm_dqrele(gdqp); 1121 1122 if (code) 1123 return code; ··· 1131 return 0; 1132 1133 error_return: 1134 + xfs_qm_dqrele(udqp); 1135 + xfs_qm_dqrele(gdqp); 1136 xfs_trans_cancel(tp, 0); 1137 if (lock_flags) 1138 xfs_iunlock(ip, lock_flags);
+14 -8
fs/xfs/linux-2.6/xfs_super.c
··· 405 return EINVAL; 406 } 407 408 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && 409 (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { 410 cmn_err(CE_WARN, ··· 1106 xfs_freesb(mp); 1107 xfs_icsb_destroy_counters(mp); 1108 xfs_close_devices(mp); 1109 - xfs_qmops_put(mp); 1110 xfs_dmops_put(mp); 1111 xfs_free_fsname(mp); 1112 kfree(mp); ··· 1175 { 1176 struct xfs_mount *mp = XFS_M(dentry->d_sb); 1177 xfs_sb_t *sbp = &mp->m_sb; 1178 __uint64_t fakeinos, id; 1179 xfs_extlen_t lsize; 1180 ··· 1204 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree); 1205 spin_unlock(&mp->m_sb_lock); 1206 1207 - XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp); 1208 return 0; 1209 } 1210 ··· 1415 error = xfs_dmops_get(mp); 1416 if (error) 1417 goto out_free_fsname; 1418 - error = xfs_qmops_get(mp); 1419 - if (error) 1420 - goto out_put_dmops; 1421 1422 if (silent) 1423 flags |= XFS_MFSI_QUIET; 1424 1425 error = xfs_open_devices(mp); 1426 if (error) 1427 - goto out_put_qmops; 1428 1429 if (xfs_icsb_init_counters(mp)) 1430 mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; ··· 1490 out_destroy_counters: 1491 xfs_icsb_destroy_counters(mp); 1492 xfs_close_devices(mp); 1493 - out_put_qmops: 1494 - xfs_qmops_put(mp); 1495 out_put_dmops: 1496 xfs_dmops_put(mp); 1497 out_free_fsname:
··· 405 return EINVAL; 406 } 407 408 + #ifndef CONFIG_XFS_QUOTA 409 + if (XFS_IS_QUOTA_RUNNING(mp)) { 410 + cmn_err(CE_WARN, 411 + "XFS: quota support not available in this kernel."); 412 + return EINVAL; 413 + } 414 + #endif 415 + 416 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && 417 (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { 418 cmn_err(CE_WARN, ··· 1098 xfs_freesb(mp); 1099 xfs_icsb_destroy_counters(mp); 1100 xfs_close_devices(mp); 1101 xfs_dmops_put(mp); 1102 xfs_free_fsname(mp); 1103 kfree(mp); ··· 1168 { 1169 struct xfs_mount *mp = XFS_M(dentry->d_sb); 1170 xfs_sb_t *sbp = &mp->m_sb; 1171 + struct xfs_inode *ip = XFS_I(dentry->d_inode); 1172 __uint64_t fakeinos, id; 1173 xfs_extlen_t lsize; 1174 ··· 1196 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree); 1197 spin_unlock(&mp->m_sb_lock); 1198 1199 + if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) || 1200 + ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) == 1201 + (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) 1202 + xfs_qm_statvfs(ip, statp); 1203 return 0; 1204 } 1205 ··· 1404 error = xfs_dmops_get(mp); 1405 if (error) 1406 goto out_free_fsname; 1407 1408 if (silent) 1409 flags |= XFS_MFSI_QUIET; 1410 1411 error = xfs_open_devices(mp); 1412 if (error) 1413 + goto out_put_dmops; 1414 1415 if (xfs_icsb_init_counters(mp)) 1416 mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; ··· 1482 out_destroy_counters: 1483 xfs_icsb_destroy_counters(mp); 1484 xfs_close_devices(mp); 1485 out_put_dmops: 1486 xfs_dmops_put(mp); 1487 out_free_fsname:
+4 -3
fs/xfs/linux-2.6/xfs_sync.c
··· 43 #include "xfs_buf_item.h" 44 #include "xfs_inode_item.h" 45 #include "xfs_rw.h" 46 47 #include <linux/kthread.h> 48 #include <linux/freezer.h> ··· 318 319 /* push non-blocking */ 320 xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_BDFLUSH); 321 - XFS_QM_DQSYNC(mp, SYNC_BDFLUSH); 322 xfs_filestream_flush(mp); 323 324 /* push and block */ 325 xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_WAIT|SYNC_IOWAIT); 326 - XFS_QM_DQSYNC(mp, SYNC_WAIT); 327 328 /* write superblock and hoover up shutdown errors */ 329 error = xfs_sync_fsdata(mp, 0); ··· 468 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); 469 xfs_reclaim_inodes(mp, 0, XFS_IFLUSH_DELWRI_ELSE_ASYNC); 470 /* dgc: errors ignored here */ 471 - error = XFS_QM_DQSYNC(mp, SYNC_BDFLUSH); 472 error = xfs_sync_fsdata(mp, SYNC_BDFLUSH); 473 if (xfs_log_need_covered(mp)) 474 error = xfs_commit_dummy_trans(mp, XFS_LOG_FORCE);
··· 43 #include "xfs_buf_item.h" 44 #include "xfs_inode_item.h" 45 #include "xfs_rw.h" 46 + #include "xfs_quota.h" 47 48 #include <linux/kthread.h> 49 #include <linux/freezer.h> ··· 317 318 /* push non-blocking */ 319 xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_BDFLUSH); 320 + xfs_qm_sync(mp, SYNC_BDFLUSH); 321 xfs_filestream_flush(mp); 322 323 /* push and block */ 324 xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_WAIT|SYNC_IOWAIT); 325 + xfs_qm_sync(mp, SYNC_WAIT); 326 327 /* write superblock and hoover up shutdown errors */ 328 error = xfs_sync_fsdata(mp, 0); ··· 467 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); 468 xfs_reclaim_inodes(mp, 0, XFS_IFLUSH_DELWRI_ELSE_ASYNC); 469 /* dgc: errors ignored here */ 470 + error = xfs_qm_sync(mp, SYNC_BDFLUSH); 471 error = xfs_sync_fsdata(mp, SYNC_BDFLUSH); 472 if (xfs_log_need_covered(mp)) 473 error = xfs_commit_dummy_trans(mp, XFS_LOG_FORCE);
+3 -1
fs/xfs/quota/xfs_dquot.c
··· 1194 xfs_qm_dqrele( 1195 xfs_dquot_t *dqp) 1196 { 1197 - ASSERT(dqp); 1198 xfs_dqtrace_entry(dqp, "DQRELE"); 1199 1200 xfs_dqlock(dqp);
··· 1194 xfs_qm_dqrele( 1195 xfs_dquot_t *dqp) 1196 { 1197 + if (!dqp) 1198 + return; 1199 + 1200 xfs_dqtrace_entry(dqp, "DQRELE"); 1201 1202 xfs_dqlock(dqp);
-1
fs/xfs/quota/xfs_dquot.h
··· 181 extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *, 182 xfs_dqid_t, uint, uint, xfs_dquot_t **); 183 extern void xfs_qm_dqput(xfs_dquot_t *); 184 - extern void xfs_qm_dqrele(xfs_dquot_t *); 185 extern void xfs_dqlock(xfs_dquot_t *); 186 extern void xfs_dqlock2(xfs_dquot_t *, xfs_dquot_t *); 187 extern void xfs_dqunlock(xfs_dquot_t *);
··· 181 extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *, 182 xfs_dqid_t, uint, uint, xfs_dquot_t **); 183 extern void xfs_qm_dqput(xfs_dquot_t *); 184 extern void xfs_dqlock(xfs_dquot_t *); 185 extern void xfs_dqlock2(xfs_dquot_t *, xfs_dquot_t *); 186 extern void xfs_dqunlock(xfs_dquot_t *);
+73 -66
fs/xfs/quota/xfs_qm.c
··· 287 * Just destroy the quotainfo structure. 288 */ 289 void 290 - xfs_qm_unmount_quotadestroy( 291 - xfs_mount_t *mp) 292 { 293 - if (mp->m_quotainfo) 294 xfs_qm_destroy_quotainfo(mp); 295 } 296 297 ··· 387 if (error) { 388 xfs_fs_cmn_err(CE_WARN, mp, 389 "Failed to initialize disk quotas."); 390 } 391 - return; 392 } 393 394 /* ··· 781 * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON 782 * into account. 783 * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. 784 - * If XFS_QMOPT_ILOCKED, then inode sent is already locked EXCL. 785 * Inode may get unlocked and relocked in here, and the caller must deal with 786 * the consequences. 787 */ 788 int 789 - xfs_qm_dqattach( 790 xfs_inode_t *ip, 791 uint flags) 792 { ··· 793 uint nquotas = 0; 794 int error = 0; 795 796 - if ((! XFS_IS_QUOTA_ON(mp)) || 797 - (! XFS_NOT_DQATTACHED(mp, ip)) || 798 - (ip->i_ino == mp->m_sb.sb_uquotino) || 799 - (ip->i_ino == mp->m_sb.sb_gquotino)) 800 return 0; 801 802 - ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 || 803 - xfs_isilocked(ip, XFS_ILOCK_EXCL)); 804 - 805 - if (! (flags & XFS_QMOPT_ILOCKED)) 806 - xfs_ilock(ip, XFS_ILOCK_EXCL); 807 808 if (XFS_IS_UQUOTA_ON(mp)) { 809 error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER, ··· 852 xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); 853 } 854 855 - done: 856 - 857 #ifdef QUOTADEBUG 858 if (! error) { 859 if (XFS_IS_UQUOTA_ON(mp)) ··· 860 if (XFS_IS_OQUOTA_ON(mp)) 861 ASSERT(ip->i_gdquot); 862 } 863 #endif 864 865 - if (! (flags & XFS_QMOPT_ILOCKED)) 866 - xfs_iunlock(ip, XFS_ILOCK_EXCL); 867 868 - #ifdef QUOTADEBUG 869 - else 870 - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 871 - #endif 872 return error; 873 } 874 ··· 921 boolean_t nowait; 922 int error; 923 924 - if (! XFS_IS_QUOTA_ON(mp)) 925 return 0; 926 927 restarts = 0; ··· 2328 */ 2329 int 2330 xfs_qm_vop_dqalloc( 2331 - xfs_mount_t *mp, 2332 - xfs_inode_t *ip, 2333 - uid_t uid, 2334 - gid_t gid, 2335 - prid_t prid, 2336 - uint flags, 2337 - xfs_dquot_t **O_udqpp, 2338 - xfs_dquot_t **O_gdqpp) 2339 { 2340 - int error; 2341 - xfs_dquot_t *uq, *gq; 2342 - uint lockflags; 2343 2344 - if (!XFS_IS_QUOTA_ON(mp)) 2345 return 0; 2346 2347 lockflags = XFS_ILOCK_EXCL; ··· 2355 * if necessary. The dquot(s) will not be locked. 2356 */ 2357 if (XFS_NOT_DQATTACHED(mp, ip)) { 2358 - if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC | 2359 - XFS_QMOPT_ILOCKED))) { 2360 xfs_iunlock(ip, lockflags); 2361 return error; 2362 } ··· 2478 uint bfield = XFS_IS_REALTIME_INODE(ip) ? 2479 XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; 2480 2481 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 2482 ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); 2483 ··· 2518 xfs_dquot_t *gdqp, 2519 uint flags) 2520 { 2521 - int error; 2522 - xfs_mount_t *mp; 2523 uint delblks, blkflags, prjflags = 0; 2524 xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; 2525 2526 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); 2527 - mp = ip->i_mount; 2528 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 2529 2530 delblks = ip->i_delayed_blks; ··· 2592 2593 int 2594 xfs_qm_vop_rename_dqattach( 2595 - xfs_inode_t **i_tab) 2596 { 2597 - xfs_inode_t *ip; 2598 - int i; 2599 - int error; 2600 2601 - ip = i_tab[0]; 2602 - 2603 - if (! XFS_IS_QUOTA_ON(ip->i_mount)) 2604 return 0; 2605 2606 - if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2607 - error = xfs_qm_dqattach(ip, 0); 2608 - if (error) 2609 - return error; 2610 - } 2611 - for (i = 1; (i < 4 && i_tab[i]); i++) { 2612 /* 2613 * Watch out for duplicate entries in the table. 2614 */ 2615 - if ((ip = i_tab[i]) != i_tab[i-1]) { 2616 - if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2617 error = xfs_qm_dqattach(ip, 0); 2618 if (error) 2619 return error; ··· 2619 } 2620 2621 void 2622 - xfs_qm_vop_dqattach_and_dqmod_newinode( 2623 - xfs_trans_t *tp, 2624 - xfs_inode_t *ip, 2625 - xfs_dquot_t *udqp, 2626 - xfs_dquot_t *gdqp) 2627 { 2628 - if (!XFS_IS_QUOTA_ON(tp->t_mountp)) 2629 return; 2630 2631 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 2632 - ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); 2633 2634 if (udqp) { 2635 xfs_dqlock(udqp); ··· 2639 xfs_dqunlock(udqp); 2640 ASSERT(ip->i_udquot == NULL); 2641 ip->i_udquot = udqp; 2642 - ASSERT(XFS_IS_UQUOTA_ON(tp->t_mountp)); 2643 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); 2644 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); 2645 } ··· 2649 xfs_dqunlock(gdqp); 2650 ASSERT(ip->i_gdquot == NULL); 2651 ip->i_gdquot = gdqp; 2652 - ASSERT(XFS_IS_OQUOTA_ON(tp->t_mountp)); 2653 - ASSERT((XFS_IS_GQUOTA_ON(tp->t_mountp) ? 2654 ip->i_d.di_gid : ip->i_d.di_projid) == 2655 be32_to_cpu(gdqp->q_core.d_id)); 2656 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
··· 287 * Just destroy the quotainfo structure. 288 */ 289 void 290 + xfs_qm_unmount( 291 + struct xfs_mount *mp) 292 { 293 + if (mp->m_quotainfo) { 294 + xfs_qm_dqpurge_all(mp, XFS_QMOPT_QUOTALL | XFS_QMOPT_UMOUNTING); 295 xfs_qm_destroy_quotainfo(mp); 296 + } 297 } 298 299 ··· 385 if (error) { 386 xfs_fs_cmn_err(CE_WARN, mp, 387 "Failed to initialize disk quotas."); 388 + return; 389 } 390 + 391 + #ifdef QUOTADEBUG 392 + if (XFS_IS_QUOTA_ON(mp)) 393 + xfs_qm_internalqcheck(mp); 394 + #endif 395 } 396 397 /* ··· 774 * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON 775 * into account. 776 * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. 777 * Inode may get unlocked and relocked in here, and the caller must deal with 778 * the consequences. 779 */ 780 int 781 + xfs_qm_dqattach_locked( 782 xfs_inode_t *ip, 783 uint flags) 784 { ··· 787 uint nquotas = 0; 788 int error = 0; 789 790 + if (!XFS_IS_QUOTA_RUNNING(mp) || 791 + !XFS_IS_QUOTA_ON(mp) || 792 + !XFS_NOT_DQATTACHED(mp, ip) || 793 + ip->i_ino == mp->m_sb.sb_uquotino || 794 + ip->i_ino == mp->m_sb.sb_gquotino) 795 return 0; 796 797 + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 798 799 if (XFS_IS_UQUOTA_ON(mp)) { 800 error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER, ··· 849 xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); 850 } 851 852 + done: 853 #ifdef QUOTADEBUG 854 if (! error) { 855 if (XFS_IS_UQUOTA_ON(mp)) ··· 858 if (XFS_IS_OQUOTA_ON(mp)) 859 ASSERT(ip->i_gdquot); 860 } 861 + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 862 #endif 863 + return error; 864 + } 865 866 + int 867 + xfs_qm_dqattach( 868 + struct xfs_inode *ip, 869 + uint flags) 870 + { 871 + int error; 872 873 + xfs_ilock(ip, XFS_ILOCK_EXCL); 874 + error = xfs_qm_dqattach_locked(ip, flags); 875 + xfs_iunlock(ip, XFS_ILOCK_EXCL); 876 + 877 return error; 878 } 879 ··· 912 boolean_t nowait; 913 int error; 914 915 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 916 return 0; 917 918 restarts = 0; ··· 2319 */ 2320 int 2321 xfs_qm_vop_dqalloc( 2322 + struct xfs_inode *ip, 2323 + uid_t uid, 2324 + gid_t gid, 2325 + prid_t prid, 2326 + uint flags, 2327 + struct xfs_dquot **O_udqpp, 2328 + struct xfs_dquot **O_gdqpp) 2329 { 2330 + struct xfs_mount *mp = ip->i_mount; 2331 + struct xfs_dquot *uq, *gq; 2332 + int error; 2333 + uint lockflags; 2334 2335 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 2336 return 0; 2337 2338 lockflags = XFS_ILOCK_EXCL; ··· 2346 * if necessary. The dquot(s) will not be locked. 2347 */ 2348 if (XFS_NOT_DQATTACHED(mp, ip)) { 2349 + error = xfs_qm_dqattach_locked(ip, XFS_QMOPT_DQALLOC); 2350 + if (error) { 2351 xfs_iunlock(ip, lockflags); 2352 return error; 2353 } ··· 2469 uint bfield = XFS_IS_REALTIME_INODE(ip) ? 2470 XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; 2471 2472 + 2473 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 2474 ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); 2475 ··· 2508 xfs_dquot_t *gdqp, 2509 uint flags) 2510 { 2511 + xfs_mount_t *mp = ip->i_mount; 2512 uint delblks, blkflags, prjflags = 0; 2513 xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; 2514 + int error; 2515 + 2516 2517 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); 2518 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 2519 2520 delblks = ip->i_delayed_blks; ··· 2582 2583 int 2584 xfs_qm_vop_rename_dqattach( 2585 + struct xfs_inode **i_tab) 2586 { 2587 + struct xfs_mount *mp = i_tab[0]->i_mount; 2588 + int i; 2589 2590 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 2591 return 0; 2592 2593 + for (i = 0; (i < 4 && i_tab[i]); i++) { 2594 + struct xfs_inode *ip = i_tab[i]; 2595 + int error; 2596 + 2597 /* 2598 * Watch out for duplicate entries in the table. 2599 */ 2600 + if (i == 0 || ip != i_tab[i-1]) { 2601 + if (XFS_NOT_DQATTACHED(mp, ip)) { 2602 error = xfs_qm_dqattach(ip, 0); 2603 if (error) 2604 return error; ··· 2614 } 2615 2616 void 2617 + xfs_qm_vop_create_dqattach( 2618 + struct xfs_trans *tp, 2619 + struct xfs_inode *ip, 2620 + struct xfs_dquot *udqp, 2621 + struct xfs_dquot *gdqp) 2622 { 2623 + struct xfs_mount *mp = tp->t_mountp; 2624 + 2625 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 2626 return; 2627 2628 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 2629 + ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 2630 2631 if (udqp) { 2632 xfs_dqlock(udqp); ··· 2632 xfs_dqunlock(udqp); 2633 ASSERT(ip->i_udquot == NULL); 2634 ip->i_udquot = udqp; 2635 + ASSERT(XFS_IS_UQUOTA_ON(mp)); 2636 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); 2637 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); 2638 } ··· 2642 xfs_dqunlock(gdqp); 2643 ASSERT(ip->i_gdquot == NULL); 2644 ip->i_gdquot = gdqp; 2645 + ASSERT(XFS_IS_OQUOTA_ON(mp)); 2646 + ASSERT((XFS_IS_GQUOTA_ON(mp) ? 2647 ip->i_d.di_gid : ip->i_d.di_projid) == 2648 be32_to_cpu(gdqp->q_core.d_id)); 2649 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
-21
fs/xfs/quota/xfs_qm.h
··· 127 } xfs_quotainfo_t; 128 129 130 - extern xfs_dqtrxops_t xfs_trans_dquot_ops; 131 - 132 extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long); 133 extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *, 134 xfs_dquot_t *, xfs_dquot_t *, long, long, uint); ··· 157 #define XFS_QM_RTBWARNLIMIT 5 158 159 extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); 160 - extern void xfs_qm_mount_quotas(xfs_mount_t *); 161 extern int xfs_qm_quotacheck(xfs_mount_t *); 162 - extern void xfs_qm_unmount_quotadestroy(xfs_mount_t *); 163 - extern void xfs_qm_unmount_quotas(xfs_mount_t *); 164 extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t); 165 - extern int xfs_qm_sync(xfs_mount_t *, int); 166 167 /* dquot stuff */ 168 extern boolean_t xfs_qm_dqalloc_incore(xfs_dquot_t **); 169 - extern int xfs_qm_dqattach(xfs_inode_t *, uint); 170 - extern void xfs_qm_dqdetach(xfs_inode_t *); 171 extern int xfs_qm_dqpurge_all(xfs_mount_t *, uint); 172 extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint); 173 ··· 174 extern int xfs_qm_scall_getqstat(xfs_mount_t *, fs_quota_stat_t *); 175 extern int xfs_qm_scall_quotaon(xfs_mount_t *, uint); 176 extern int xfs_qm_scall_quotaoff(xfs_mount_t *, uint); 177 - 178 - /* vop stuff */ 179 - extern int xfs_qm_vop_dqalloc(xfs_mount_t *, xfs_inode_t *, 180 - uid_t, gid_t, prid_t, uint, 181 - xfs_dquot_t **, xfs_dquot_t **); 182 - extern void xfs_qm_vop_dqattach_and_dqmod_newinode( 183 - xfs_trans_t *, xfs_inode_t *, 184 - xfs_dquot_t *, xfs_dquot_t *); 185 - extern int xfs_qm_vop_rename_dqattach(xfs_inode_t **); 186 - extern xfs_dquot_t * xfs_qm_vop_chown(xfs_trans_t *, xfs_inode_t *, 187 - xfs_dquot_t **, xfs_dquot_t *); 188 - extern int xfs_qm_vop_chown_reserve(xfs_trans_t *, xfs_inode_t *, 189 - xfs_dquot_t *, xfs_dquot_t *, uint); 190 191 /* list stuff */ 192 extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *);
··· 127 } xfs_quotainfo_t; 128 129 130 extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long); 131 extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *, 132 xfs_dquot_t *, xfs_dquot_t *, long, long, uint); ··· 159 #define XFS_QM_RTBWARNLIMIT 5 160 161 extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); 162 extern int xfs_qm_quotacheck(xfs_mount_t *); 163 extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t); 164 165 /* dquot stuff */ 166 extern boolean_t xfs_qm_dqalloc_incore(xfs_dquot_t **); 167 extern int xfs_qm_dqpurge_all(xfs_mount_t *, uint); 168 extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint); 169 ··· 182 extern int xfs_qm_scall_getqstat(xfs_mount_t *, fs_quota_stat_t *); 183 extern int xfs_qm_scall_quotaon(xfs_mount_t *, uint); 184 extern int xfs_qm_scall_quotaoff(xfs_mount_t *, uint); 185 186 /* list stuff */ 187 extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *);
+3 -73
fs/xfs/quota/xfs_qm_bhv.c
··· 84 * return a statvfs of the project, not the entire filesystem. 85 * This makes such trees appear as if they are filesystems in themselves. 86 */ 87 - STATIC void 88 xfs_qm_statvfs( 89 xfs_inode_t *ip, 90 struct kstatfs *statp) ··· 92 xfs_mount_t *mp = ip->i_mount; 93 xfs_dquot_t *dqp; 94 95 - if (!(ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) || 96 - !((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) == 97 - (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) 98 - return; 99 - 100 if (!xfs_qm_dqget(mp, NULL, ip->i_d.di_projid, XFS_DQ_PROJ, 0, &dqp)) { 101 - xfs_disk_dquot_t *dp = &dqp->q_core; 102 - 103 - xfs_fill_statvfs_from_dquot(statp, dp); 104 xfs_qm_dqput(dqp); 105 } 106 } 107 108 - STATIC int 109 xfs_qm_newmount( 110 xfs_mount_t *mp, 111 uint *needquotamount, ··· 106 { 107 uint quotaondisk; 108 uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0; 109 - 110 - *quotaflags = 0; 111 - *needquotamount = B_FALSE; 112 113 quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) && 114 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); ··· 168 169 return 0; 170 } 171 - 172 - STATIC int 173 - xfs_qm_endmount( 174 - xfs_mount_t *mp, 175 - uint needquotamount, 176 - uint quotaflags) 177 - { 178 - if (needquotamount) { 179 - ASSERT(mp->m_qflags == 0); 180 - mp->m_qflags = quotaflags; 181 - xfs_qm_mount_quotas(mp); 182 - } 183 - 184 - #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) 185 - if (! (XFS_IS_QUOTA_ON(mp))) 186 - xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas not turned on"); 187 - else 188 - xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas turned on"); 189 - #endif 190 - 191 - #ifdef QUOTADEBUG 192 - if (XFS_IS_QUOTA_ON(mp) && xfs_qm_internalqcheck(mp)) 193 - cmn_err(CE_WARN, "XFS: mount internalqcheck failed"); 194 - #endif 195 - 196 - return 0; 197 - } 198 - 199 - STATIC void 200 - xfs_qm_dqrele_null( 201 - xfs_dquot_t *dq) 202 - { 203 - /* 204 - * Called from XFS, where we always check first for a NULL dquot. 205 - */ 206 - if (!dq) 207 - return; 208 - xfs_qm_dqrele(dq); 209 - } 210 - 211 - 212 - struct xfs_qmops xfs_qmcore_xfs = { 213 - .xfs_qminit = xfs_qm_newmount, 214 - .xfs_qmdone = xfs_qm_unmount_quotadestroy, 215 - .xfs_qmmount = xfs_qm_endmount, 216 - .xfs_qmunmount = xfs_qm_unmount_quotas, 217 - .xfs_dqrele = xfs_qm_dqrele_null, 218 - .xfs_dqattach = xfs_qm_dqattach, 219 - .xfs_dqdetach = xfs_qm_dqdetach, 220 - .xfs_dqpurgeall = xfs_qm_dqpurge_all, 221 - .xfs_dqvopalloc = xfs_qm_vop_dqalloc, 222 - .xfs_dqvopcreate = xfs_qm_vop_dqattach_and_dqmod_newinode, 223 - .xfs_dqvoprename = xfs_qm_vop_rename_dqattach, 224 - .xfs_dqvopchown = xfs_qm_vop_chown, 225 - .xfs_dqvopchownresv = xfs_qm_vop_chown_reserve, 226 - .xfs_dqstatvfs = xfs_qm_statvfs, 227 - .xfs_dqsync = xfs_qm_sync, 228 - .xfs_dqtrxops = &xfs_trans_dquot_ops, 229 - }; 230 - EXPORT_SYMBOL(xfs_qmcore_xfs); 231 232 void __init 233 xfs_qm_init(void)
··· 84 * return a statvfs of the project, not the entire filesystem. 85 * This makes such trees appear as if they are filesystems in themselves. 86 */ 87 + void 88 xfs_qm_statvfs( 89 xfs_inode_t *ip, 90 struct kstatfs *statp) ··· 92 xfs_mount_t *mp = ip->i_mount; 93 xfs_dquot_t *dqp; 94 95 if (!xfs_qm_dqget(mp, NULL, ip->i_d.di_projid, XFS_DQ_PROJ, 0, &dqp)) { 96 + xfs_fill_statvfs_from_dquot(statp, &dqp->q_core); 97 xfs_qm_dqput(dqp); 98 } 99 } 100 101 + int 102 xfs_qm_newmount( 103 xfs_mount_t *mp, 104 uint *needquotamount, ··· 113 { 114 uint quotaondisk; 115 uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0; 116 117 quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) && 118 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); ··· 178 179 return 0; 180 } 181 182 void __init 183 xfs_qm_init(void)
+25 -40
fs/xfs/quota/xfs_trans_dquot.c
··· 111 * Carry forward whatever is left of the quota blk reservation to 112 * the spanky new transaction 113 */ 114 - STATIC void 115 xfs_trans_dup_dqinfo( 116 xfs_trans_t *otp, 117 xfs_trans_t *ntp) ··· 167 /* 168 * Wrap around mod_dquot to account for both user and group quotas. 169 */ 170 - STATIC void 171 xfs_trans_mod_dquot_byino( 172 xfs_trans_t *tp, 173 xfs_inode_t *ip, 174 uint field, 175 long delta) 176 { 177 - xfs_mount_t *mp; 178 179 - ASSERT(tp); 180 - mp = tp->t_mountp; 181 - 182 - if (!XFS_IS_QUOTA_ON(mp) || 183 ip->i_ino == mp->m_sb.sb_uquotino || 184 ip->i_ino == mp->m_sb.sb_gquotino) 185 return; ··· 227 xfs_dqtrx_t *qtrx; 228 229 ASSERT(tp); 230 qtrx = NULL; 231 232 if (tp->t_dqinfo == NULL) ··· 345 * Unreserve just the reservations done by this transaction. 346 * dquot is still left locked at exit. 347 */ 348 - STATIC void 349 xfs_trans_apply_dquot_deltas( 350 xfs_trans_t *tp) 351 { ··· 356 long totalbdelta; 357 long totalrtbdelta; 358 359 - if (! (tp->t_flags & XFS_TRANS_DQ_DIRTY)) 360 return; 361 362 ASSERT(tp->t_dqinfo); ··· 530 * we simply throw those away, since that's the expected behavior 531 * when a transaction is curtailed without a commit. 532 */ 533 - STATIC void 534 xfs_trans_unreserve_and_mod_dquots( 535 xfs_trans_t *tp) 536 { ··· 767 { 768 int resvd = 0, error; 769 770 - if (!XFS_IS_QUOTA_ON(mp)) 771 return 0; 772 773 if (tp && tp->t_dqinfo == NULL) ··· 810 * This doesn't change the actual usage, just the reservation. 811 * The inode sent in is locked. 812 */ 813 - STATIC int 814 xfs_trans_reserve_quota_nblks( 815 - xfs_trans_t *tp, 816 - xfs_mount_t *mp, 817 - xfs_inode_t *ip, 818 - long nblks, 819 - long ninos, 820 - uint flags) 821 { 822 - int error; 823 824 - if (!XFS_IS_QUOTA_ON(mp)) 825 return 0; 826 if (XFS_IS_PQUOTA_ON(mp)) 827 flags |= XFS_QMOPT_ENOSPC; ··· 829 ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); 830 831 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 832 - ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); 833 ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == 834 XFS_TRANS_DQ_RES_RTBLKS || 835 (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == ··· 837 /* 838 * Reserve nblks against these dquots, with trans as the mediator. 839 */ 840 - error = xfs_trans_reserve_quota_bydquots(tp, mp, 841 - ip->i_udquot, ip->i_gdquot, 842 - nblks, ninos, 843 - flags); 844 - return error; 845 } 846 847 /* ··· 890 xfs_trans_alloc_dqinfo( 891 xfs_trans_t *tp) 892 { 893 - (tp)->t_dqinfo = kmem_zone_zalloc(xfs_Gqm->qm_dqtrxzone, KM_SLEEP); 894 } 895 896 - STATIC void 897 xfs_trans_free_dqinfo( 898 xfs_trans_t *tp) 899 { 900 if (!tp->t_dqinfo) 901 return; 902 - kmem_zone_free(xfs_Gqm->qm_dqtrxzone, (tp)->t_dqinfo); 903 - (tp)->t_dqinfo = NULL; 904 } 905 - 906 - xfs_dqtrxops_t xfs_trans_dquot_ops = { 907 - .qo_dup_dqinfo = xfs_trans_dup_dqinfo, 908 - .qo_free_dqinfo = xfs_trans_free_dqinfo, 909 - .qo_mod_dquot_byino = xfs_trans_mod_dquot_byino, 910 - .qo_apply_dquot_deltas = xfs_trans_apply_dquot_deltas, 911 - .qo_reserve_quota_nblks = xfs_trans_reserve_quota_nblks, 912 - .qo_reserve_quota_bydquots = xfs_trans_reserve_quota_bydquots, 913 - .qo_unreserve_and_mod_dquots = xfs_trans_unreserve_and_mod_dquots, 914 - };
··· 111 * Carry forward whatever is left of the quota blk reservation to 112 * the spanky new transaction 113 */ 114 + void 115 xfs_trans_dup_dqinfo( 116 xfs_trans_t *otp, 117 xfs_trans_t *ntp) ··· 167 /* 168 * Wrap around mod_dquot to account for both user and group quotas. 169 */ 170 + void 171 xfs_trans_mod_dquot_byino( 172 xfs_trans_t *tp, 173 xfs_inode_t *ip, 174 uint field, 175 long delta) 176 { 177 + xfs_mount_t *mp = tp->t_mountp; 178 179 + if (!XFS_IS_QUOTA_RUNNING(mp) || 180 + !XFS_IS_QUOTA_ON(mp) || 181 ip->i_ino == mp->m_sb.sb_uquotino || 182 ip->i_ino == mp->m_sb.sb_gquotino) 183 return; ··· 229 xfs_dqtrx_t *qtrx; 230 231 ASSERT(tp); 232 + ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); 233 qtrx = NULL; 234 235 if (tp->t_dqinfo == NULL) ··· 346 * Unreserve just the reservations done by this transaction. 347 * dquot is still left locked at exit. 348 */ 349 + void 350 xfs_trans_apply_dquot_deltas( 351 xfs_trans_t *tp) 352 { ··· 357 long totalbdelta; 358 long totalrtbdelta; 359 360 + if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY)) 361 return; 362 363 ASSERT(tp->t_dqinfo); ··· 531 * we simply throw those away, since that's the expected behavior 532 * when a transaction is curtailed without a commit. 533 */ 534 + void 535 xfs_trans_unreserve_and_mod_dquots( 536 xfs_trans_t *tp) 537 { ··· 768 { 769 int resvd = 0, error; 770 771 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 772 return 0; 773 774 if (tp && tp->t_dqinfo == NULL) ··· 811 * This doesn't change the actual usage, just the reservation. 812 * The inode sent in is locked. 813 */ 814 + int 815 xfs_trans_reserve_quota_nblks( 816 + struct xfs_trans *tp, 817 + struct xfs_inode *ip, 818 + long nblks, 819 + long ninos, 820 + uint flags) 821 { 822 + struct xfs_mount *mp = ip->i_mount; 823 824 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 825 return 0; 826 if (XFS_IS_PQUOTA_ON(mp)) 827 flags |= XFS_QMOPT_ENOSPC; ··· 831 ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); 832 833 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 834 ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == 835 XFS_TRANS_DQ_RES_RTBLKS || 836 (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == ··· 840 /* 841 * Reserve nblks against these dquots, with trans as the mediator. 842 */ 843 + return xfs_trans_reserve_quota_bydquots(tp, mp, 844 + ip->i_udquot, ip->i_gdquot, 845 + nblks, ninos, flags); 846 } 847 848 /* ··· 895 xfs_trans_alloc_dqinfo( 896 xfs_trans_t *tp) 897 { 898 + tp->t_dqinfo = kmem_zone_zalloc(xfs_Gqm->qm_dqtrxzone, KM_SLEEP); 899 } 900 901 + void 902 xfs_trans_free_dqinfo( 903 xfs_trans_t *tp) 904 { 905 if (!tp->t_dqinfo) 906 return; 907 + kmem_zone_free(xfs_Gqm->qm_dqtrxzone, tp->t_dqinfo); 908 + tp->t_dqinfo = NULL; 909 }
+7 -5
fs/xfs/xfs_attr.c
··· 249 /* 250 * Attach the dquots to the inode. 251 */ 252 - if ((error = XFS_QM_DQATTACH(mp, dp, 0))) 253 - return (error); 254 255 /* 256 * If the inode doesn't have an attribute fork, add one. ··· 312 } 313 xfs_ilock(dp, XFS_ILOCK_EXCL); 314 315 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, args.trans, dp, args.total, 0, 316 rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : 317 XFS_QMOPT_RES_REGBLKS); 318 if (error) { ··· 502 /* 503 * Attach the dquots to the inode. 504 */ 505 - if ((error = XFS_QM_DQATTACH(mp, dp, 0))) 506 - return (error); 507 508 /* 509 * Start our first transaction of the day.
··· 249 /* 250 * Attach the dquots to the inode. 251 */ 252 + error = xfs_qm_dqattach(dp, 0); 253 + if (error) 254 + return error; 255 256 /* 257 * If the inode doesn't have an attribute fork, add one. ··· 311 } 312 xfs_ilock(dp, XFS_ILOCK_EXCL); 313 314 + error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0, 315 rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : 316 XFS_QMOPT_RES_REGBLKS); 317 if (error) { ··· 501 /* 502 * Attach the dquots to the inode. 503 */ 504 + error = xfs_qm_dqattach(dp, 0); 505 + if (error) 506 + return error; 507 508 /* 509 * Start our first transaction of the day.
+17 -16
fs/xfs/xfs_bmap.c
··· 2691 * Adjust the disk quota also. This was reserved 2692 * earlier. 2693 */ 2694 - XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, 2695 ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : 2696 XFS_TRANS_DQ_RTBCOUNT, (long) ralen); 2697 } else { ··· 2995 * Adjust the disk quota also. This was reserved 2996 * earlier. 2997 */ 2998 - XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, 2999 ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : 3000 XFS_TRANS_DQ_BCOUNT, 3001 (long) args.len); ··· 3066 return error; 3067 xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); 3068 ip->i_d.di_nblocks--; 3069 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 3070 xfs_trans_binval(tp, cbp); 3071 if (cur->bc_bufs[0] == cbp) 3072 cur->bc_bufs[0] = NULL; ··· 3386 * Adjust quota data. 3387 */ 3388 if (qfield) 3389 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, qfield, (long)-nblks); 3390 3391 /* 3392 * Account for change in delayed indirect blocks. ··· 3523 *firstblock = cur->bc_private.b.firstblock = args.fsbno; 3524 cur->bc_private.b.allocated++; 3525 ip->i_d.di_nblocks++; 3526 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); 3527 abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0); 3528 /* 3529 * Fill in the child block. ··· 3690 XFS_BMAP_TRACE_POST_UPDATE("new", ip, 0, whichfork); 3691 XFS_IFORK_NEXT_SET(ip, whichfork, 1); 3692 ip->i_d.di_nblocks = 1; 3693 - XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, 3694 XFS_TRANS_DQ_BCOUNT, 1L); 3695 flags |= xfs_ilog_fext(whichfork); 3696 } else { ··· 4048 XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT))) 4049 goto error0; 4050 xfs_ilock(ip, XFS_ILOCK_EXCL); 4051 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, blks, 0, rsvd ? 4052 XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : 4053 XFS_QMOPT_RES_REGBLKS); 4054 if (error) { ··· 4983 * adjusted later. We return if we haven't 4984 * allocated blocks already inside this loop. 4985 */ 4986 - if ((error = XFS_TRANS_RESERVE_QUOTA_NBLKS( 4987 - mp, NULL, ip, (long)alen, 0, 4988 rt ? XFS_QMOPT_RES_RTBLKS : 4989 - XFS_QMOPT_RES_REGBLKS))) { 4990 if (n == 0) { 4991 *nmap = 0; 4992 ASSERT(cur == NULL); ··· 5036 if (XFS_IS_QUOTA_ON(mp)) 5037 /* unreserve the blocks now */ 5038 (void) 5039 - XFS_TRANS_UNRESERVE_QUOTA_NBLKS( 5040 - mp, NULL, ip, 5041 (long)alen, 0, rt ? 5042 XFS_QMOPT_RES_RTBLKS : 5043 XFS_QMOPT_RES_REGBLKS); ··· 5692 do_div(rtexts, mp->m_sb.sb_rextsize); 5693 xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, 5694 (int64_t)rtexts, rsvd); 5695 - (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, 5696 - NULL, ip, -((long)del.br_blockcount), 0, 5697 XFS_QMOPT_RES_RTBLKS); 5698 } else { 5699 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, 5700 (int64_t)del.br_blockcount, rsvd); 5701 - (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, 5702 - NULL, ip, -((long)del.br_blockcount), 0, 5703 XFS_QMOPT_RES_REGBLKS); 5704 } 5705 ip->i_delayed_blks -= del.br_blockcount;
··· 2691 * Adjust the disk quota also. This was reserved 2692 * earlier. 2693 */ 2694 + xfs_trans_mod_dquot_byino(ap->tp, ap->ip, 2695 ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : 2696 XFS_TRANS_DQ_RTBCOUNT, (long) ralen); 2697 } else { ··· 2995 * Adjust the disk quota also. This was reserved 2996 * earlier. 2997 */ 2998 + xfs_trans_mod_dquot_byino(ap->tp, ap->ip, 2999 ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : 3000 XFS_TRANS_DQ_BCOUNT, 3001 (long) args.len); ··· 3066 return error; 3067 xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); 3068 ip->i_d.di_nblocks--; 3069 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 3070 xfs_trans_binval(tp, cbp); 3071 if (cur->bc_bufs[0] == cbp) 3072 cur->bc_bufs[0] = NULL; ··· 3386 * Adjust quota data. 3387 */ 3388 if (qfield) 3389 + xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); 3390 3391 /* 3392 * Account for change in delayed indirect blocks. ··· 3523 *firstblock = cur->bc_private.b.firstblock = args.fsbno; 3524 cur->bc_private.b.allocated++; 3525 ip->i_d.di_nblocks++; 3526 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); 3527 abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0); 3528 /* 3529 * Fill in the child block. ··· 3690 XFS_BMAP_TRACE_POST_UPDATE("new", ip, 0, whichfork); 3691 XFS_IFORK_NEXT_SET(ip, whichfork, 1); 3692 ip->i_d.di_nblocks = 1; 3693 + xfs_trans_mod_dquot_byino(tp, ip, 3694 XFS_TRANS_DQ_BCOUNT, 1L); 3695 flags |= xfs_ilog_fext(whichfork); 3696 } else { ··· 4048 XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT))) 4049 goto error0; 4050 xfs_ilock(ip, XFS_ILOCK_EXCL); 4051 + error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ? 4052 XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : 4053 XFS_QMOPT_RES_REGBLKS); 4054 if (error) { ··· 4983 * adjusted later. We return if we haven't 4984 * allocated blocks already inside this loop. 4985 */ 4986 + error = xfs_trans_reserve_quota_nblks( 4987 + NULL, ip, (long)alen, 0, 4988 rt ? XFS_QMOPT_RES_RTBLKS : 4989 + XFS_QMOPT_RES_REGBLKS); 4990 + if (error) { 4991 if (n == 0) { 4992 *nmap = 0; 4993 ASSERT(cur == NULL); ··· 5035 if (XFS_IS_QUOTA_ON(mp)) 5036 /* unreserve the blocks now */ 5037 (void) 5038 + xfs_trans_unreserve_quota_nblks( 5039 + NULL, ip, 5040 (long)alen, 0, rt ? 5041 XFS_QMOPT_RES_RTBLKS : 5042 XFS_QMOPT_RES_REGBLKS); ··· 5691 do_div(rtexts, mp->m_sb.sb_rextsize); 5692 xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, 5693 (int64_t)rtexts, rsvd); 5694 + (void)xfs_trans_reserve_quota_nblks(NULL, 5695 + ip, -((long)del.br_blockcount), 0, 5696 XFS_QMOPT_RES_RTBLKS); 5697 } else { 5698 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, 5699 (int64_t)del.br_blockcount, rsvd); 5700 + (void)xfs_trans_reserve_quota_nblks(NULL, 5701 + ip, -((long)del.br_blockcount), 0, 5702 XFS_QMOPT_RES_REGBLKS); 5703 } 5704 ip->i_delayed_blks -= del.br_blockcount;
+2 -2
fs/xfs/xfs_bmap_btree.c
··· 590 cur->bc_private.b.allocated++; 591 cur->bc_private.b.ip->i_d.di_nblocks++; 592 xfs_trans_log_inode(args.tp, cur->bc_private.b.ip, XFS_ILOG_CORE); 593 - XFS_TRANS_MOD_DQUOT_BYINO(args.mp, args.tp, cur->bc_private.b.ip, 594 XFS_TRANS_DQ_BCOUNT, 1L); 595 596 new->l = cpu_to_be64(args.fsbno); ··· 618 ip->i_d.di_nblocks--; 619 620 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 621 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 622 xfs_trans_binval(tp, bp); 623 return 0; 624 }
··· 590 cur->bc_private.b.allocated++; 591 cur->bc_private.b.ip->i_d.di_nblocks++; 592 xfs_trans_log_inode(args.tp, cur->bc_private.b.ip, XFS_ILOG_CORE); 593 + xfs_trans_mod_dquot_byino(args.tp, cur->bc_private.b.ip, 594 XFS_TRANS_DQ_BCOUNT, 1L); 595 596 new->l = cpu_to_be64(args.fsbno); ··· 618 ip->i_d.di_nblocks--; 619 620 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 621 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 622 xfs_trans_binval(tp, bp); 623 return 0; 624 }
+1 -4
fs/xfs/xfs_iget.c
··· 500 * ilock one but will still hold the iolock. 501 */ 502 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 503 - /* 504 - * Release dquots (and their references) if any. 505 - */ 506 - XFS_QM_DQDETACH(ip->i_mount, ip); 507 xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 508 509 switch (ip->i_d.di_mode & S_IFMT) {
··· 500 * ilock one but will still hold the iolock. 501 */ 502 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 503 + xfs_qm_dqdetach(ip); 504 xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 505 506 switch (ip->i_d.di_mode & S_IFMT) {
+6 -6
fs/xfs/xfs_iomap.c
··· 385 * Make sure that the dquots are there. This doesn't hold 386 * the ilock across a disk read. 387 */ 388 - error = XFS_QM_DQATTACH(ip->i_mount, ip, XFS_QMOPT_ILOCKED); 389 if (error) 390 return XFS_ERROR(error); 391 ··· 444 if (error) 445 goto error_out; 446 447 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, 448 - qblocks, 0, quota_flag); 449 if (error) 450 goto error1; 451 ··· 494 495 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 496 xfs_bmap_cancel(&free_list); 497 - XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag); 498 499 error1: /* Just cancel transaction */ 500 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); ··· 581 * Make sure that the dquots are there. This doesn't hold 582 * the ilock across a disk read. 583 */ 584 - error = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED); 585 if (error) 586 return XFS_ERROR(error); 587 ··· 683 /* 684 * Make sure that the dquots are there. 685 */ 686 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 687 return XFS_ERROR(error); 688 689 offset_fsb = XFS_B_TO_FSBT(mp, offset);
··· 385 * Make sure that the dquots are there. This doesn't hold 386 * the ilock across a disk read. 387 */ 388 + error = xfs_qm_dqattach_locked(ip, 0); 389 if (error) 390 return XFS_ERROR(error); 391 ··· 444 if (error) 445 goto error_out; 446 447 + error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, 0, quota_flag); 448 if (error) 449 goto error1; 450 ··· 495 496 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 497 xfs_bmap_cancel(&free_list); 498 + xfs_trans_unreserve_quota_nblks(tp, ip, qblocks, 0, quota_flag); 499 500 error1: /* Just cancel transaction */ 501 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); ··· 582 * Make sure that the dquots are there. This doesn't hold 583 * the ilock across a disk read. 584 */ 585 + error = xfs_qm_dqattach_locked(ip, 0); 586 if (error) 587 return XFS_ERROR(error); 588 ··· 684 /* 685 * Make sure that the dquots are there. 686 */ 687 + error = xfs_qm_dqattach(ip, 0); 688 + if (error) 689 return XFS_ERROR(error); 690 691 offset_fsb = XFS_B_TO_FSBT(mp, offset);
+86 -17
fs/xfs/xfs_mount.c
··· 960 } 961 962 /* 963 * This function does the following on an initial mount of a file system: 964 * - reads the superblock from disk and init the mount struct 965 * - if we're a 32-bit kernel, do a size check on the superblock ··· 1023 xfs_sb_t *sbp = &(mp->m_sb); 1024 xfs_inode_t *rip; 1025 __uint64_t resblks; 1026 - uint quotamount, quotaflags; 1027 int error = 0; 1028 1029 xfs_mount_common(mp, sbp); ··· 1258 /* 1259 * Initialise the XFS quota management subsystem for this mount 1260 */ 1261 - error = XFS_QM_INIT(mp, &quotamount, &quotaflags); 1262 - if (error) 1263 - goto out_rtunmount; 1264 1265 /* 1266 * Finish recovering the file system. This part needed to be ··· 1295 /* 1296 * Complete the quota initialisation, post-log-replay component. 1297 */ 1298 - error = XFS_QM_MOUNT(mp, quotamount, quotaflags); 1299 - if (error) 1300 - goto out_rtunmount; 1301 1302 /* 1303 * Now we are mounted, reserve a small amount of unused space for ··· 1356 __uint64_t resblks; 1357 int error; 1358 1359 - /* 1360 - * Release dquot that rootinode, rbmino and rsumino might be holding, 1361 - * and release the quota inodes. 1362 - */ 1363 - XFS_QM_UNMOUNT(mp); 1364 - 1365 xfs_rtunmount_inodes(mp); 1366 IRELE(mp->m_rootip); 1367 ··· 1373 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE | XFS_LOG_SYNC); 1374 xfs_reclaim_inodes(mp, 0, XFS_IFLUSH_ASYNC); 1375 1376 - XFS_QM_DQPURGEALL(mp, XFS_QMOPT_QUOTALL | XFS_QMOPT_UMOUNTING); 1377 - 1378 - if (mp->m_quotainfo) 1379 - XFS_QM_DONE(mp); 1380 1381 /* 1382 * Flush out the log synchronously so that we know for sure
··· 960 } 961 962 /* 963 + * Clear the quotaflags in memory and in the superblock. 964 + */ 965 + int 966 + xfs_mount_reset_sbqflags( 967 + struct xfs_mount *mp) 968 + { 969 + int error; 970 + struct xfs_trans *tp; 971 + 972 + mp->m_qflags = 0; 973 + 974 + /* 975 + * It is OK to look at sb_qflags here in mount path, 976 + * without m_sb_lock. 977 + */ 978 + if (mp->m_sb.sb_qflags == 0) 979 + return 0; 980 + spin_lock(&mp->m_sb_lock); 981 + mp->m_sb.sb_qflags = 0; 982 + spin_unlock(&mp->m_sb_lock); 983 + 984 + /* 985 + * If the fs is readonly, let the incore superblock run 986 + * with quotas off but don't flush the update out to disk 987 + */ 988 + if (mp->m_flags & XFS_MOUNT_RDONLY) 989 + return 0; 990 + 991 + #ifdef QUOTADEBUG 992 + xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); 993 + #endif 994 + 995 + tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); 996 + error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, 997 + XFS_DEFAULT_LOG_COUNT); 998 + if (error) { 999 + xfs_trans_cancel(tp, 0); 1000 + xfs_fs_cmn_err(CE_ALERT, mp, 1001 + "xfs_mount_reset_sbqflags: Superblock update failed!"); 1002 + return error; 1003 + } 1004 + 1005 + xfs_mod_sb(tp, XFS_SB_QFLAGS); 1006 + return xfs_trans_commit(tp, 0); 1007 + } 1008 + 1009 + /* 1010 * This function does the following on an initial mount of a file system: 1011 * - reads the superblock from disk and init the mount struct 1012 * - if we're a 32-bit kernel, do a size check on the superblock ··· 976 xfs_sb_t *sbp = &(mp->m_sb); 977 xfs_inode_t *rip; 978 __uint64_t resblks; 979 + uint quotamount = 0; 980 + uint quotaflags = 0; 981 int error = 0; 982 983 xfs_mount_common(mp, sbp); ··· 1210 /* 1211 * Initialise the XFS quota management subsystem for this mount 1212 */ 1213 + if (XFS_IS_QUOTA_RUNNING(mp)) { 1214 + error = xfs_qm_newmount(mp, &quotamount, &quotaflags); 1215 + if (error) 1216 + goto out_rtunmount; 1217 + } else { 1218 + ASSERT(!XFS_IS_QUOTA_ON(mp)); 1219 + 1220 + /* 1221 + * If a file system had quotas running earlier, but decided to 1222 + * mount without -o uquota/pquota/gquota options, revoke the 1223 + * quotachecked license. 1224 + */ 1225 + if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { 1226 + cmn_err(CE_NOTE, 1227 + "XFS: resetting qflags for filesystem %s", 1228 + mp->m_fsname); 1229 + 1230 + error = xfs_mount_reset_sbqflags(mp); 1231 + if (error) 1232 + return error; 1233 + } 1234 + } 1235 1236 /* 1237 * Finish recovering the file system. This part needed to be ··· 1228 /* 1229 * Complete the quota initialisation, post-log-replay component. 1230 */ 1231 + if (quotamount) { 1232 + ASSERT(mp->m_qflags == 0); 1233 + mp->m_qflags = quotaflags; 1234 + 1235 + xfs_qm_mount_quotas(mp); 1236 + } 1237 + 1238 + #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) 1239 + if (XFS_IS_QUOTA_ON(mp)) 1240 + xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas turned on"); 1241 + else 1242 + xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas not turned on"); 1243 + #endif 1244 1245 /* 1246 * Now we are mounted, reserve a small amount of unused space for ··· 1279 __uint64_t resblks; 1280 int error; 1281 1282 + xfs_qm_unmount_quotas(mp); 1283 xfs_rtunmount_inodes(mp); 1284 IRELE(mp->m_rootip); 1285 ··· 1301 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE | XFS_LOG_SYNC); 1302 xfs_reclaim_inodes(mp, 0, XFS_IFLUSH_ASYNC); 1303 1304 + xfs_qm_unmount(mp); 1305 1306 /* 1307 * Flush out the log synchronously so that we know for sure
+2 -82
fs/xfs/xfs_mount.h
··· 64 struct xfs_mru_cache; 65 struct xfs_nameops; 66 struct xfs_ail; 67 68 /* 69 * Prototypes and functions for the Data Migration subsystem. ··· 108 #define XFS_SEND_UNMOUNT(mp, ip,right,mode,rval,fl) \ 109 (*(mp)->m_dm_ops->xfs_send_unmount)(mp,ip,right,mode,rval,fl) 110 111 - 112 - /* 113 - * Prototypes and functions for the Quota Management subsystem. 114 - */ 115 - 116 - struct xfs_dquot; 117 - struct xfs_dqtrxops; 118 - struct xfs_quotainfo; 119 - 120 - typedef int (*xfs_qminit_t)(struct xfs_mount *, uint *, uint *); 121 - typedef int (*xfs_qmmount_t)(struct xfs_mount *, uint, uint); 122 - typedef void (*xfs_qmunmount_t)(struct xfs_mount *); 123 - typedef void (*xfs_qmdone_t)(struct xfs_mount *); 124 - typedef void (*xfs_dqrele_t)(struct xfs_dquot *); 125 - typedef int (*xfs_dqattach_t)(struct xfs_inode *, uint); 126 - typedef void (*xfs_dqdetach_t)(struct xfs_inode *); 127 - typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint); 128 - typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *, 129 - struct xfs_inode *, uid_t, gid_t, prid_t, uint, 130 - struct xfs_dquot **, struct xfs_dquot **); 131 - typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *, 132 - struct xfs_dquot *, struct xfs_dquot *); 133 - typedef int (*xfs_dqvoprename_t)(struct xfs_inode **); 134 - typedef struct xfs_dquot * (*xfs_dqvopchown_t)( 135 - struct xfs_trans *, struct xfs_inode *, 136 - struct xfs_dquot **, struct xfs_dquot *); 137 - typedef int (*xfs_dqvopchownresv_t)(struct xfs_trans *, struct xfs_inode *, 138 - struct xfs_dquot *, struct xfs_dquot *, uint); 139 - typedef void (*xfs_dqstatvfs_t)(struct xfs_inode *, struct kstatfs *); 140 - typedef int (*xfs_dqsync_t)(struct xfs_mount *, int flags); 141 - 142 - typedef struct xfs_qmops { 143 - xfs_qminit_t xfs_qminit; 144 - xfs_qmdone_t xfs_qmdone; 145 - xfs_qmmount_t xfs_qmmount; 146 - xfs_qmunmount_t xfs_qmunmount; 147 - xfs_dqrele_t xfs_dqrele; 148 - xfs_dqattach_t xfs_dqattach; 149 - xfs_dqdetach_t xfs_dqdetach; 150 - xfs_dqpurgeall_t xfs_dqpurgeall; 151 - xfs_dqvopalloc_t xfs_dqvopalloc; 152 - xfs_dqvopcreate_t xfs_dqvopcreate; 153 - xfs_dqvoprename_t xfs_dqvoprename; 154 - xfs_dqvopchown_t xfs_dqvopchown; 155 - xfs_dqvopchownresv_t xfs_dqvopchownresv; 156 - xfs_dqstatvfs_t xfs_dqstatvfs; 157 - xfs_dqsync_t xfs_dqsync; 158 - struct xfs_dqtrxops *xfs_dqtrxops; 159 - } xfs_qmops_t; 160 - 161 - #define XFS_QM_INIT(mp, mnt, fl) \ 162 - (*(mp)->m_qm_ops->xfs_qminit)(mp, mnt, fl) 163 - #define XFS_QM_MOUNT(mp, mnt, fl) \ 164 - (*(mp)->m_qm_ops->xfs_qmmount)(mp, mnt, fl) 165 - #define XFS_QM_UNMOUNT(mp) \ 166 - (*(mp)->m_qm_ops->xfs_qmunmount)(mp) 167 - #define XFS_QM_DONE(mp) \ 168 - (*(mp)->m_qm_ops->xfs_qmdone)(mp) 169 - #define XFS_QM_DQRELE(mp, dq) \ 170 - (*(mp)->m_qm_ops->xfs_dqrele)(dq) 171 - #define XFS_QM_DQATTACH(mp, ip, fl) \ 172 - (*(mp)->m_qm_ops->xfs_dqattach)(ip, fl) 173 - #define XFS_QM_DQDETACH(mp, ip) \ 174 - (*(mp)->m_qm_ops->xfs_dqdetach)(ip) 175 - #define XFS_QM_DQPURGEALL(mp, fl) \ 176 - (*(mp)->m_qm_ops->xfs_dqpurgeall)(mp, fl) 177 - #define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, prid, fl, dq1, dq2) \ 178 - (*(mp)->m_qm_ops->xfs_dqvopalloc)(mp, ip, uid, gid, prid, fl, dq1, dq2) 179 - #define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \ 180 - (*(mp)->m_qm_ops->xfs_dqvopcreate)(tp, ip, dq1, dq2) 181 - #define XFS_QM_DQVOPRENAME(mp, ip) \ 182 - (*(mp)->m_qm_ops->xfs_dqvoprename)(ip) 183 - #define XFS_QM_DQVOPCHOWN(mp, tp, ip, dqp, dq) \ 184 - (*(mp)->m_qm_ops->xfs_dqvopchown)(tp, ip, dqp, dq) 185 - #define XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, dq1, dq2, fl) \ 186 - (*(mp)->m_qm_ops->xfs_dqvopchownresv)(tp, ip, dq1, dq2, fl) 187 - #define XFS_QM_DQSTATVFS(ip, statp) \ 188 - (*(ip)->i_mount->m_qm_ops->xfs_dqstatvfs)(ip, statp) 189 - #define XFS_QM_DQSYNC(mp, flags) \ 190 - (*(mp)->m_qm_ops->xfs_dqsync)(mp, flags) 191 192 #ifdef HAVE_PERCPU_SB 193 ··· 432 433 extern int xfs_dmops_get(struct xfs_mount *); 434 extern void xfs_dmops_put(struct xfs_mount *); 435 - extern int xfs_qmops_get(struct xfs_mount *); 436 - extern void xfs_qmops_put(struct xfs_mount *); 437 438 extern struct xfs_dmops xfs_dmcore_xfs; 439
··· 64 struct xfs_mru_cache; 65 struct xfs_nameops; 66 struct xfs_ail; 67 + struct xfs_quotainfo; 68 + 69 70 /* 71 * Prototypes and functions for the Data Migration subsystem. ··· 106 #define XFS_SEND_UNMOUNT(mp, ip,right,mode,rval,fl) \ 107 (*(mp)->m_dm_ops->xfs_send_unmount)(mp,ip,right,mode,rval,fl) 108 109 110 #ifdef HAVE_PERCPU_SB 111 ··· 510 511 extern int xfs_dmops_get(struct xfs_mount *); 512 extern void xfs_dmops_put(struct xfs_mount *); 513 514 extern struct xfs_dmops xfs_dmcore_xfs; 515
-152
fs/xfs/xfs_qmops.c
··· 1 - /* 2 - * Copyright (c) 2000-2005 Silicon Graphics, Inc. 3 - * All Rights Reserved. 4 - * 5 - * This program is free software; you can redistribute it and/or 6 - * modify it under the terms of the GNU General Public License as 7 - * published by the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it would be useful, 10 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 - * GNU General Public License for more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program; if not, write the Free Software Foundation, 16 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 - */ 18 - #include "xfs.h" 19 - #include "xfs_fs.h" 20 - #include "xfs_types.h" 21 - #include "xfs_log.h" 22 - #include "xfs_inum.h" 23 - #include "xfs_trans.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 - #include "xfs_dir2.h" 27 - #include "xfs_dmapi.h" 28 - #include "xfs_mount.h" 29 - #include "xfs_quota.h" 30 - #include "xfs_error.h" 31 - 32 - 33 - STATIC struct xfs_dquot * 34 - xfs_dqvopchown_default( 35 - struct xfs_trans *tp, 36 - struct xfs_inode *ip, 37 - struct xfs_dquot **dqp, 38 - struct xfs_dquot *dq) 39 - { 40 - return NULL; 41 - } 42 - 43 - /* 44 - * Clear the quotaflags in memory and in the superblock. 45 - */ 46 - int 47 - xfs_mount_reset_sbqflags(xfs_mount_t *mp) 48 - { 49 - int error; 50 - xfs_trans_t *tp; 51 - 52 - mp->m_qflags = 0; 53 - /* 54 - * It is OK to look at sb_qflags here in mount path, 55 - * without m_sb_lock. 56 - */ 57 - if (mp->m_sb.sb_qflags == 0) 58 - return 0; 59 - spin_lock(&mp->m_sb_lock); 60 - mp->m_sb.sb_qflags = 0; 61 - spin_unlock(&mp->m_sb_lock); 62 - 63 - /* 64 - * if the fs is readonly, let the incore superblock run 65 - * with quotas off but don't flush the update out to disk 66 - */ 67 - if (mp->m_flags & XFS_MOUNT_RDONLY) 68 - return 0; 69 - #ifdef QUOTADEBUG 70 - xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); 71 - #endif 72 - tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); 73 - if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, 74 - XFS_DEFAULT_LOG_COUNT))) { 75 - xfs_trans_cancel(tp, 0); 76 - xfs_fs_cmn_err(CE_ALERT, mp, 77 - "xfs_mount_reset_sbqflags: Superblock update failed!"); 78 - return error; 79 - } 80 - xfs_mod_sb(tp, XFS_SB_QFLAGS); 81 - error = xfs_trans_commit(tp, 0); 82 - return error; 83 - } 84 - 85 - STATIC int 86 - xfs_noquota_init( 87 - xfs_mount_t *mp, 88 - uint *needquotamount, 89 - uint *quotaflags) 90 - { 91 - int error = 0; 92 - 93 - *quotaflags = 0; 94 - *needquotamount = B_FALSE; 95 - 96 - ASSERT(!XFS_IS_QUOTA_ON(mp)); 97 - 98 - /* 99 - * If a file system had quotas running earlier, but decided to 100 - * mount without -o uquota/pquota/gquota options, revoke the 101 - * quotachecked license. 102 - */ 103 - if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { 104 - cmn_err(CE_NOTE, 105 - "XFS resetting qflags for filesystem %s", 106 - mp->m_fsname); 107 - 108 - error = xfs_mount_reset_sbqflags(mp); 109 - } 110 - return error; 111 - } 112 - 113 - static struct xfs_qmops xfs_qmcore_stub = { 114 - .xfs_qminit = (xfs_qminit_t) xfs_noquota_init, 115 - .xfs_qmdone = (xfs_qmdone_t) fs_noerr, 116 - .xfs_qmmount = (xfs_qmmount_t) fs_noerr, 117 - .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr, 118 - .xfs_dqrele = (xfs_dqrele_t) fs_noerr, 119 - .xfs_dqattach = (xfs_dqattach_t) fs_noerr, 120 - .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr, 121 - .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr, 122 - .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr, 123 - .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr, 124 - .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr, 125 - .xfs_dqvopchown = xfs_dqvopchown_default, 126 - .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr, 127 - .xfs_dqstatvfs = (xfs_dqstatvfs_t) fs_noval, 128 - .xfs_dqsync = (xfs_dqsync_t) fs_noerr, 129 - }; 130 - 131 - int 132 - xfs_qmops_get(struct xfs_mount *mp) 133 - { 134 - if (XFS_IS_QUOTA_RUNNING(mp)) { 135 - #ifdef CONFIG_XFS_QUOTA 136 - mp->m_qm_ops = &xfs_qmcore_xfs; 137 - #else 138 - cmn_err(CE_WARN, 139 - "XFS: qouta support not available in this kernel."); 140 - return EINVAL; 141 - #endif 142 - } else { 143 - mp->m_qm_ops = &xfs_qmcore_stub; 144 - } 145 - 146 - return 0; 147 - } 148 - 149 - void 150 - xfs_qmops_put(struct xfs_mount *mp) 151 - { 152 - }
···
+59 -57
fs/xfs/xfs_quota.h
··· 197 #define XFS_QMOPT_UMOUNTING 0x0000100 /* filesys is being unmounted */ 198 #define XFS_QMOPT_DOLOG 0x0000200 /* log buf changes (in quotacheck) */ 199 #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */ 200 - #define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */ 201 #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ 202 #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 203 #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ ··· 301 long qt_delrtb_delta; /* delayed RT blk count changes */ 302 } xfs_dqtrx_t; 303 304 - /* 305 - * Dquot transaction functions, used if quota is enabled. 306 - */ 307 - typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *); 308 - typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *, 309 - struct xfs_inode *, uint, long); 310 - typedef void (*qo_free_dqinfo_t)(struct xfs_trans *); 311 - typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *); 312 - typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *); 313 - typedef int (*qo_reserve_quota_nblks_t)( 314 - struct xfs_trans *, struct xfs_mount *, 315 - struct xfs_inode *, long, long, uint); 316 - typedef int (*qo_reserve_quota_bydquots_t)( 317 - struct xfs_trans *, struct xfs_mount *, 318 - struct xfs_dquot *, struct xfs_dquot *, 319 - long, long, uint); 320 - typedef struct xfs_dqtrxops { 321 - qo_dup_dqinfo_t qo_dup_dqinfo; 322 - qo_free_dqinfo_t qo_free_dqinfo; 323 - qo_mod_dquot_byino_t qo_mod_dquot_byino; 324 - qo_apply_dquot_deltas_t qo_apply_dquot_deltas; 325 - qo_reserve_quota_nblks_t qo_reserve_quota_nblks; 326 - qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots; 327 - qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots; 328 - } xfs_dqtrxops_t; 329 330 - #define XFS_DQTRXOP(mp, tp, op, args...) \ 331 - ((mp)->m_qm_ops->xfs_dqtrxops ? \ 332 - ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : 0) 333 334 - #define XFS_DQTRXOP_VOID(mp, tp, op, args...) \ 335 - ((mp)->m_qm_ops->xfs_dqtrxops ? \ 336 - ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : (void)0) 337 338 - #define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \ 339 - XFS_DQTRXOP_VOID(mp, otp, qo_dup_dqinfo, ntp) 340 - #define XFS_TRANS_FREE_DQINFO(mp, tp) \ 341 - XFS_DQTRXOP_VOID(mp, tp, qo_free_dqinfo) 342 - #define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \ 343 - XFS_DQTRXOP_VOID(mp, tp, qo_mod_dquot_byino, ip, field, delta) 344 - #define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \ 345 - XFS_DQTRXOP_VOID(mp, tp, qo_apply_dquot_deltas) 346 - #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \ 347 - XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl) 348 - #define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \ 349 - XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl) 350 - #define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ 351 - XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots) 352 - 353 - #define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, flags) \ 354 - XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), -(ninos), flags) 355 - #define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 356 - XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 357 - f | XFS_QMOPT_RES_REGBLKS) 358 - #define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 359 - XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ 360 f | XFS_QMOPT_RES_REGBLKS) 361 362 extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 363 extern int xfs_mount_reset_sbqflags(struct xfs_mount *); 364 365 - extern struct xfs_qmops xfs_qmcore_xfs; 366 - 367 #endif /* __KERNEL__ */ 368 - 369 #endif /* __XFS_QUOTA_H__ */
··· 197 #define XFS_QMOPT_UMOUNTING 0x0000100 /* filesys is being unmounted */ 198 #define XFS_QMOPT_DOLOG 0x0000200 /* log buf changes (in quotacheck) */ 199 #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */ 200 #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ 201 #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 202 #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ ··· 302 long qt_delrtb_delta; /* delayed RT blk count changes */ 303 } xfs_dqtrx_t; 304 305 + #ifdef CONFIG_XFS_QUOTA 306 + extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *); 307 + extern void xfs_trans_free_dqinfo(struct xfs_trans *); 308 + extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *, 309 + uint, long); 310 + extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *); 311 + extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *); 312 + extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, 313 + struct xfs_inode *, long, long, uint); 314 + extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, 315 + struct xfs_mount *, struct xfs_dquot *, 316 + struct xfs_dquot *, long, long, uint); 317 318 + extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, 319 + struct xfs_dquot **, struct xfs_dquot **); 320 + extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, 321 + struct xfs_dquot *, struct xfs_dquot *); 322 + extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); 323 + extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, 324 + struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); 325 + extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, 326 + struct xfs_dquot *, struct xfs_dquot *, uint); 327 + extern int xfs_qm_dqattach(struct xfs_inode *, uint); 328 + extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); 329 + extern void xfs_qm_dqdetach(struct xfs_inode *); 330 + extern void xfs_qm_dqrele(struct xfs_dquot *); 331 + extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *); 332 + extern int xfs_qm_sync(struct xfs_mount *, int); 333 + extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *); 334 + extern void xfs_qm_mount_quotas(struct xfs_mount *); 335 + extern void xfs_qm_unmount(struct xfs_mount *); 336 + extern void xfs_qm_unmount_quotas(struct xfs_mount *); 337 338 + #else 339 + #define xfs_trans_dup_dqinfo(tp, tp2) 340 + #define xfs_trans_free_dqinfo(tp) 341 + #define xfs_trans_mod_dquot_byino(tp, ip, fields, delta) 342 + #define xfs_trans_apply_dquot_deltas(tp) 343 + #define xfs_trans_unreserve_and_mod_dquots(tp) 344 + #define xfs_trans_reserve_quota_nblks(tp, ip, nblks, ninos, flags) (0) 345 + #define xfs_trans_reserve_quota_bydquots(tp, mp, u, g, nb, ni, fl) (0) 346 + #define xfs_qm_vop_dqalloc(ip, uid, gid, prid, fl, ou, og) (0) 347 + #define xfs_qm_vop_create_dqattach(tp, ip, u, g) 348 + #define xfs_qm_vop_rename_dqattach(it) (0) 349 + #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) 350 + #define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0) 351 + #define xfs_qm_dqattach(ip, fl) (0) 352 + #define xfs_qm_dqattach_locked(ip, fl) (0) 353 + #define xfs_qm_dqdetach(ip) 354 + #define xfs_qm_dqrele(d) 355 + #define xfs_qm_statvfs(ip, s) 356 + #define xfs_qm_sync(mp, fl) (0) 357 + #define xfs_qm_newmount(mp, a, b) (0) 358 + #define xfs_qm_mount_quotas(mp) 359 + #define xfs_qm_unmount(mp) 360 + #define xfs_qm_unmount_quotas(mp) (0) 361 + #endif /* CONFIG_XFS_QUOTA */ 362 363 + #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ 364 + xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) 365 + #define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \ 366 + xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ 367 f | XFS_QMOPT_RES_REGBLKS) 368 369 extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 370 extern int xfs_mount_reset_sbqflags(struct xfs_mount *); 371 372 #endif /* __KERNEL__ */ 373 #endif /* __XFS_QUOTA_H__ */
+2 -1
fs/xfs/xfs_rename.c
··· 166 /* 167 * Attach the dquots to the inodes 168 */ 169 - if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) { 170 xfs_trans_cancel(tp, cancel_flags); 171 goto std_return; 172 }
··· 166 /* 167 * Attach the dquots to the inodes 168 */ 169 + error = xfs_qm_vop_rename_dqattach(inodes); 170 + if (error) { 171 xfs_trans_cancel(tp, cancel_flags); 172 goto std_return; 173 }
+7 -8
fs/xfs/xfs_trans.c
··· 297 tp->t_rtx_res = tp->t_rtx_res_used; 298 ntp->t_pflags = tp->t_pflags; 299 300 - XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); 301 302 atomic_inc(&tp->t_mountp->m_active_trans); 303 return ntp; ··· 831 * means is that we have some (non-persistent) quota 832 * reservations that need to be unreserved. 833 */ 834 - XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp); 835 if (tp->t_ticket) { 836 commit_lsn = xfs_log_done(mp, tp->t_ticket, 837 NULL, log_flags); ··· 850 /* 851 * If we need to update the superblock, then do it now. 852 */ 853 - if (tp->t_flags & XFS_TRANS_SB_DIRTY) { 854 xfs_trans_apply_sb_deltas(tp); 855 - } 856 - XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp); 857 858 /* 859 * Ask each log item how many log_vector entries it will ··· 1057 } 1058 1059 xfs_trans_unreserve_and_mod_sb(tp); 1060 - XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(tp->t_mountp, tp); 1061 1062 xfs_trans_free_items(tp, flags); 1063 xfs_trans_free_busy(tp); ··· 1182 } 1183 #endif 1184 xfs_trans_unreserve_and_mod_sb(tp); 1185 - XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp); 1186 1187 if (tp->t_ticket) { 1188 if (flags & XFS_TRANS_RELEASE_LOG_RES) { ··· 1212 xfs_trans_t *tp) 1213 { 1214 atomic_dec(&tp->t_mountp->m_active_trans); 1215 - XFS_TRANS_FREE_DQINFO(tp->t_mountp, tp); 1216 kmem_zone_free(xfs_trans_zone, tp); 1217 } 1218
··· 297 tp->t_rtx_res = tp->t_rtx_res_used; 298 ntp->t_pflags = tp->t_pflags; 299 300 + xfs_trans_dup_dqinfo(tp, ntp); 301 302 atomic_inc(&tp->t_mountp->m_active_trans); 303 return ntp; ··· 831 * means is that we have some (non-persistent) quota 832 * reservations that need to be unreserved. 833 */ 834 + xfs_trans_unreserve_and_mod_dquots(tp); 835 if (tp->t_ticket) { 836 commit_lsn = xfs_log_done(mp, tp->t_ticket, 837 NULL, log_flags); ··· 850 /* 851 * If we need to update the superblock, then do it now. 852 */ 853 + if (tp->t_flags & XFS_TRANS_SB_DIRTY) 854 xfs_trans_apply_sb_deltas(tp); 855 + xfs_trans_apply_dquot_deltas(tp); 856 857 /* 858 * Ask each log item how many log_vector entries it will ··· 1058 } 1059 1060 xfs_trans_unreserve_and_mod_sb(tp); 1061 + xfs_trans_unreserve_and_mod_dquots(tp); 1062 1063 xfs_trans_free_items(tp, flags); 1064 xfs_trans_free_busy(tp); ··· 1183 } 1184 #endif 1185 xfs_trans_unreserve_and_mod_sb(tp); 1186 + xfs_trans_unreserve_and_mod_dquots(tp); 1187 1188 if (tp->t_ticket) { 1189 if (flags & XFS_TRANS_RELEASE_LOG_RES) { ··· 1213 xfs_trans_t *tp) 1214 { 1215 atomic_dec(&tp->t_mountp->m_active_trans); 1216 + xfs_trans_free_dqinfo(tp); 1217 kmem_zone_free(xfs_trans_zone, tp); 1218 } 1219
+1 -1
fs/xfs/xfs_utils.c
··· 166 xfs_buf_relse(ialloc_context); 167 if (dqinfo) { 168 tp->t_dqinfo = dqinfo; 169 - XFS_TRANS_FREE_DQINFO(tp->t_mountp, tp); 170 } 171 *tpp = ntp; 172 *ipp = NULL;
··· 166 xfs_buf_relse(ialloc_context); 167 if (dqinfo) { 168 tp->t_dqinfo = dqinfo; 169 + xfs_trans_free_dqinfo(tp); 170 } 171 *tpp = ntp; 172 *ipp = NULL;
+51 -48
fs/xfs/xfs_vnodeops.c
··· 118 */ 119 ASSERT(udqp == NULL); 120 ASSERT(gdqp == NULL); 121 - code = XFS_QM_DQVOPALLOC(mp, ip, uid, gid, ip->i_d.di_projid, 122 qflags, &udqp, &gdqp); 123 if (code) 124 return code; ··· 180 * Do a quota reservation only if uid/gid is actually 181 * going to change. 182 */ 183 - if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || 184 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) { 185 ASSERT(tp); 186 - code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp, 187 capable(CAP_FOWNER) ? 188 XFS_QMOPT_FORCE_RES : 0); 189 if (code) /* out of quota */ ··· 218 /* 219 * Make sure that the dquots are attached to the inode. 220 */ 221 - code = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED); 222 if (code) 223 goto error_return; 224 ··· 352 * in the transaction. 353 */ 354 if (iuid != uid) { 355 - if (XFS_IS_UQUOTA_ON(mp)) { 356 ASSERT(mask & ATTR_UID); 357 ASSERT(udqp); 358 - olddquot1 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 359 &ip->i_udquot, udqp); 360 } 361 ip->i_d.di_uid = uid; 362 inode->i_uid = uid; 363 } 364 if (igid != gid) { 365 - if (XFS_IS_GQUOTA_ON(mp)) { 366 ASSERT(!XFS_IS_PQUOTA_ON(mp)); 367 ASSERT(mask & ATTR_GID); 368 ASSERT(gdqp); 369 - olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 370 &ip->i_gdquot, gdqp); 371 } 372 ip->i_d.di_gid = gid; ··· 462 /* 463 * Release any dquot(s) the inode had kept before chown. 464 */ 465 - XFS_QM_DQRELE(mp, olddquot1); 466 - XFS_QM_DQRELE(mp, olddquot2); 467 - XFS_QM_DQRELE(mp, udqp); 468 - XFS_QM_DQRELE(mp, gdqp); 469 470 if (code) { 471 return code; ··· 483 commit_flags |= XFS_TRANS_ABORT; 484 /* FALLTHROUGH */ 485 error_return: 486 - XFS_QM_DQRELE(mp, udqp); 487 - XFS_QM_DQRELE(mp, gdqp); 488 if (tp) { 489 xfs_trans_cancel(tp, commit_flags); 490 } ··· 740 /* 741 * Attach the dquots to the inode up front. 742 */ 743 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 744 return error; 745 746 /* ··· 1183 1184 ASSERT(ip->i_d.di_nlink == 0); 1185 1186 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 1187 return VN_INACTIVE_CACHE; 1188 1189 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); ··· 1310 /* 1311 * Credit the quota account(s). The inode is gone. 1312 */ 1313 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_ICOUNT, -1); 1314 1315 /* 1316 * Just ignore errors at this point. There is nothing we can ··· 1326 xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: " 1327 "xfs_trans_commit() returned error %d", error); 1328 } 1329 /* 1330 * Release the dquots held by inode, if any. 1331 */ 1332 - XFS_QM_DQDETACH(mp, ip); 1333 - 1334 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1335 1336 out: ··· 1430 /* 1431 * Make sure that we have allocated dquot(s) on disk. 1432 */ 1433 - error = XFS_QM_DQVOPALLOC(mp, dp, 1434 - current_fsuid(), current_fsgid(), prid, 1435 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 1436 if (error) 1437 goto std_return; ··· 1491 /* 1492 * Reserve disk quota and the inode. 1493 */ 1494 - error = XFS_TRANS_RESERVE_QUOTA(mp, tp, udqp, gdqp, resblks, 1, 0); 1495 if (error) 1496 goto out_trans_cancel; 1497 ··· 1563 * These ids of the inode couldn't have changed since the new 1564 * inode has been locked ever since it was created. 1565 */ 1566 - XFS_QM_DQVOPCREATE(mp, tp, ip, udqp, gdqp); 1567 1568 /* 1569 * xfs_trans_commit normally decrements the vnode ref count ··· 1582 goto out_dqrele; 1583 } 1584 1585 - XFS_QM_DQRELE(mp, udqp); 1586 - XFS_QM_DQRELE(mp, gdqp); 1587 1588 *ipp = ip; 1589 ··· 1604 out_trans_cancel: 1605 xfs_trans_cancel(tp, cancel_flags); 1606 out_dqrele: 1607 - XFS_QM_DQRELE(mp, udqp); 1608 - XFS_QM_DQRELE(mp, gdqp); 1609 1610 if (unlock_dp_on_error) 1611 xfs_iunlock(dp, XFS_ILOCK_EXCL); ··· 1839 return error; 1840 } 1841 1842 - error = XFS_QM_DQATTACH(mp, dp, 0); 1843 if (error) 1844 goto std_return; 1845 1846 - error = XFS_QM_DQATTACH(mp, ip, 0); 1847 if (error) 1848 goto std_return; 1849 ··· 2030 2031 /* Return through std_return after this point. */ 2032 2033 - error = XFS_QM_DQATTACH(mp, sip, 0); 2034 if (error) 2035 goto std_return; 2036 2037 - error = XFS_QM_DQATTACH(mp, tdp, 0); 2038 if (error) 2039 goto std_return; 2040 ··· 2207 /* 2208 * Make sure that we have allocated dquot(s) on disk. 2209 */ 2210 - error = XFS_QM_DQVOPALLOC(mp, dp, 2211 - current_fsuid(), current_fsgid(), prid, 2212 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 2213 if (error) 2214 goto std_return; ··· 2249 /* 2250 * Reserve disk quota : blocks and inode. 2251 */ 2252 - error = XFS_TRANS_RESERVE_QUOTA(mp, tp, udqp, gdqp, resblks, 1, 0); 2253 if (error) 2254 goto error_return; 2255 ··· 2289 /* 2290 * Also attach the dquot(s) to it, if applicable. 2291 */ 2292 - XFS_QM_DQVOPCREATE(mp, tp, ip, udqp, gdqp); 2293 2294 if (resblks) 2295 resblks -= XFS_IALLOC_SPACE_RES(mp); ··· 2377 goto error2; 2378 } 2379 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); 2380 - XFS_QM_DQRELE(mp, udqp); 2381 - XFS_QM_DQRELE(mp, gdqp); 2382 2383 /* Fall through to std_return with error = 0 or errno from 2384 * xfs_trans_commit */ ··· 2402 cancel_flags |= XFS_TRANS_ABORT; 2403 error_return: 2404 xfs_trans_cancel(tp, cancel_flags); 2405 - XFS_QM_DQRELE(mp, udqp); 2406 - XFS_QM_DQRELE(mp, gdqp); 2407 2408 if (unlock_dp_on_error) 2409 xfs_iunlock(dp, XFS_ILOCK_EXCL); ··· 2542 if (XFS_FORCED_SHUTDOWN(mp)) 2543 return XFS_ERROR(EIO); 2544 2545 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 2546 return error; 2547 2548 if (len <= 0) ··· 2630 break; 2631 } 2632 xfs_ilock(ip, XFS_ILOCK_EXCL); 2633 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, 2634 - qblocks, 0, quota_flag); 2635 if (error) 2636 goto error1; 2637 ··· 2690 2691 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 2692 xfs_bmap_cancel(&free_list); 2693 - XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag); 2694 2695 error1: /* Just cancel transaction */ 2696 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); ··· 2829 2830 xfs_itrace_entry(ip); 2831 2832 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 2833 return error; 2834 2835 error = 0; ··· 2956 break; 2957 } 2958 xfs_ilock(ip, XFS_ILOCK_EXCL); 2959 - error = XFS_TRANS_RESERVE_QUOTA(mp, tp, 2960 - ip->i_udquot, ip->i_gdquot, resblks, 0, 2961 - XFS_QMOPT_RES_REGBLKS); 2962 if (error) 2963 goto error1; 2964
··· 118 */ 119 ASSERT(udqp == NULL); 120 ASSERT(gdqp == NULL); 121 + code = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_d.di_projid, 122 qflags, &udqp, &gdqp); 123 if (code) 124 return code; ··· 180 * Do a quota reservation only if uid/gid is actually 181 * going to change. 182 */ 183 + if (XFS_IS_QUOTA_RUNNING(mp) && 184 + ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || 185 + (XFS_IS_GQUOTA_ON(mp) && igid != gid))) { 186 ASSERT(tp); 187 + code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, 188 capable(CAP_FOWNER) ? 189 XFS_QMOPT_FORCE_RES : 0); 190 if (code) /* out of quota */ ··· 217 /* 218 * Make sure that the dquots are attached to the inode. 219 */ 220 + code = xfs_qm_dqattach_locked(ip, 0); 221 if (code) 222 goto error_return; 223 ··· 351 * in the transaction. 352 */ 353 if (iuid != uid) { 354 + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) { 355 ASSERT(mask & ATTR_UID); 356 ASSERT(udqp); 357 + olddquot1 = xfs_qm_vop_chown(tp, ip, 358 &ip->i_udquot, udqp); 359 } 360 ip->i_d.di_uid = uid; 361 inode->i_uid = uid; 362 } 363 if (igid != gid) { 364 + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) { 365 ASSERT(!XFS_IS_PQUOTA_ON(mp)); 366 ASSERT(mask & ATTR_GID); 367 ASSERT(gdqp); 368 + olddquot2 = xfs_qm_vop_chown(tp, ip, 369 &ip->i_gdquot, gdqp); 370 } 371 ip->i_d.di_gid = gid; ··· 461 /* 462 * Release any dquot(s) the inode had kept before chown. 463 */ 464 + xfs_qm_dqrele(olddquot1); 465 + xfs_qm_dqrele(olddquot2); 466 + xfs_qm_dqrele(udqp); 467 + xfs_qm_dqrele(gdqp); 468 469 if (code) { 470 return code; ··· 482 commit_flags |= XFS_TRANS_ABORT; 483 /* FALLTHROUGH */ 484 error_return: 485 + xfs_qm_dqrele(udqp); 486 + xfs_qm_dqrele(gdqp); 487 if (tp) { 488 xfs_trans_cancel(tp, commit_flags); 489 } ··· 739 /* 740 * Attach the dquots to the inode up front. 741 */ 742 + error = xfs_qm_dqattach(ip, 0); 743 + if (error) 744 return error; 745 746 /* ··· 1181 1182 ASSERT(ip->i_d.di_nlink == 0); 1183 1184 + error = xfs_qm_dqattach(ip, 0); 1185 + if (error) 1186 return VN_INACTIVE_CACHE; 1187 1188 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); ··· 1307 /* 1308 * Credit the quota account(s). The inode is gone. 1309 */ 1310 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_ICOUNT, -1); 1311 1312 /* 1313 * Just ignore errors at this point. There is nothing we can ··· 1323 xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: " 1324 "xfs_trans_commit() returned error %d", error); 1325 } 1326 + 1327 /* 1328 * Release the dquots held by inode, if any. 1329 */ 1330 + xfs_qm_dqdetach(ip); 1331 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1332 1333 out: ··· 1427 /* 1428 * Make sure that we have allocated dquot(s) on disk. 1429 */ 1430 + error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, 1431 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 1432 if (error) 1433 goto std_return; ··· 1489 /* 1490 * Reserve disk quota and the inode. 1491 */ 1492 + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); 1493 if (error) 1494 goto out_trans_cancel; 1495 ··· 1561 * These ids of the inode couldn't have changed since the new 1562 * inode has been locked ever since it was created. 1563 */ 1564 + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); 1565 1566 /* 1567 * xfs_trans_commit normally decrements the vnode ref count ··· 1580 goto out_dqrele; 1581 } 1582 1583 + xfs_qm_dqrele(udqp); 1584 + xfs_qm_dqrele(gdqp); 1585 1586 *ipp = ip; 1587 ··· 1602 out_trans_cancel: 1603 xfs_trans_cancel(tp, cancel_flags); 1604 out_dqrele: 1605 + xfs_qm_dqrele(udqp); 1606 + xfs_qm_dqrele(gdqp); 1607 1608 if (unlock_dp_on_error) 1609 xfs_iunlock(dp, XFS_ILOCK_EXCL); ··· 1837 return error; 1838 } 1839 1840 + error = xfs_qm_dqattach(dp, 0); 1841 if (error) 1842 goto std_return; 1843 1844 + error = xfs_qm_dqattach(ip, 0); 1845 if (error) 1846 goto std_return; 1847 ··· 2028 2029 /* Return through std_return after this point. */ 2030 2031 + error = xfs_qm_dqattach(sip, 0); 2032 if (error) 2033 goto std_return; 2034 2035 + error = xfs_qm_dqattach(tdp, 0); 2036 if (error) 2037 goto std_return; 2038 ··· 2205 /* 2206 * Make sure that we have allocated dquot(s) on disk. 2207 */ 2208 + error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, 2209 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 2210 if (error) 2211 goto std_return; ··· 2248 /* 2249 * Reserve disk quota : blocks and inode. 2250 */ 2251 + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); 2252 if (error) 2253 goto error_return; 2254 ··· 2288 /* 2289 * Also attach the dquot(s) to it, if applicable. 2290 */ 2291 + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); 2292 2293 if (resblks) 2294 resblks -= XFS_IALLOC_SPACE_RES(mp); ··· 2376 goto error2; 2377 } 2378 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); 2379 + xfs_qm_dqrele(udqp); 2380 + xfs_qm_dqrele(gdqp); 2381 2382 /* Fall through to std_return with error = 0 or errno from 2383 * xfs_trans_commit */ ··· 2401 cancel_flags |= XFS_TRANS_ABORT; 2402 error_return: 2403 xfs_trans_cancel(tp, cancel_flags); 2404 + xfs_qm_dqrele(udqp); 2405 + xfs_qm_dqrele(gdqp); 2406 2407 if (unlock_dp_on_error) 2408 xfs_iunlock(dp, XFS_ILOCK_EXCL); ··· 2541 if (XFS_FORCED_SHUTDOWN(mp)) 2542 return XFS_ERROR(EIO); 2543 2544 + error = xfs_qm_dqattach(ip, 0); 2545 + if (error) 2546 return error; 2547 2548 if (len <= 0) ··· 2628 break; 2629 } 2630 xfs_ilock(ip, XFS_ILOCK_EXCL); 2631 + error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, 2632 + 0, quota_flag); 2633 if (error) 2634 goto error1; 2635 ··· 2688 2689 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 2690 xfs_bmap_cancel(&free_list); 2691 + xfs_trans_unreserve_quota_nblks(tp, ip, qblocks, 0, quota_flag); 2692 2693 error1: /* Just cancel transaction */ 2694 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); ··· 2827 2828 xfs_itrace_entry(ip); 2829 2830 + error = xfs_qm_dqattach(ip, 0); 2831 + if (error) 2832 return error; 2833 2834 error = 0; ··· 2953 break; 2954 } 2955 xfs_ilock(ip, XFS_ILOCK_EXCL); 2956 + error = xfs_trans_reserve_quota(tp, mp, 2957 + ip->i_udquot, ip->i_gdquot, 2958 + resblks, 0, XFS_QMOPT_RES_REGBLKS); 2959 if (error) 2960 goto error1; 2961