Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
Randy Dunlap | 16f7e0f | 2006-01-11 12:17:46 -0800 | [diff] [blame] | 18 | |
| 19 | #include <linux/capability.h> |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include "xfs.h" |
| 22 | #include "xfs_fs.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 23 | #include "xfs_bit.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include "xfs_log.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 25 | #include "xfs_inum.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include "xfs_trans.h" |
| 27 | #include "xfs_sb.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 28 | #include "xfs_ag.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include "xfs_dir2.h" |
| 30 | #include "xfs_alloc.h" |
| 31 | #include "xfs_dmapi.h" |
| 32 | #include "xfs_quota.h" |
| 33 | #include "xfs_mount.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "xfs_bmap_btree.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 35 | #include "xfs_alloc_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include "xfs_ialloc_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include "xfs_dir2_sf.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 38 | #include "xfs_attr_sf.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include "xfs_dinode.h" |
| 40 | #include "xfs_inode.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 41 | #include "xfs_ialloc.h" |
| 42 | #include "xfs_itable.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include "xfs_bmap.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 44 | #include "xfs_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include "xfs_rtalloc.h" |
| 46 | #include "xfs_error.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include "xfs_rw.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include "xfs_attr.h" |
| 49 | #include "xfs_buf_item.h" |
| 50 | #include "xfs_utils.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include "xfs_qm.h" |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 52 | #include "xfs_trace.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | #ifdef DEBUG |
| 55 | # define qdprintk(s, args...) cmn_err(CE_DEBUG, s, ## args) |
| 56 | #else |
| 57 | # define qdprintk(s, args...) do { } while (0) |
| 58 | #endif |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | STATIC int xfs_qm_log_quotaoff(xfs_mount_t *, xfs_qoff_logitem_t **, uint); |
| 61 | STATIC int xfs_qm_log_quotaoff_end(xfs_mount_t *, xfs_qoff_logitem_t *, |
| 62 | uint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | STATIC uint xfs_qm_export_flags(uint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | STATIC uint xfs_qm_export_qtype_flags(uint); |
| 65 | STATIC void xfs_qm_export_dquot(xfs_mount_t *, xfs_disk_dquot_t *, |
| 66 | fs_disk_quota_t *); |
| 67 | |
| 68 | |
| 69 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | * Turn off quota accounting and/or enforcement for all udquots and/or |
| 71 | * gdquots. Called only at unmount time. |
| 72 | * |
| 73 | * This assumes that there are no dquots of this file system cached |
| 74 | * incore, and modifies the ondisk dquot directly. Therefore, for example, |
| 75 | * it is an error to call this twice, without purging the cache. |
| 76 | */ |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 77 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | xfs_qm_scall_quotaoff( |
| 79 | xfs_mount_t *mp, |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 80 | uint flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 82 | struct xfs_quotainfo *q = mp->m_quotainfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | uint dqtype; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | int error; |
| 85 | uint inactivate_flags; |
| 86 | xfs_qoff_logitem_t *qoffstart; |
| 87 | int nculprits; |
| 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | /* |
| 90 | * No file system can have quotas enabled on disk but not in core. |
| 91 | * Note that quota utilities (like quotaoff) _expect_ |
| 92 | * errno == EEXIST here. |
| 93 | */ |
| 94 | if ((mp->m_qflags & flags) == 0) |
| 95 | return XFS_ERROR(EEXIST); |
| 96 | error = 0; |
| 97 | |
| 98 | flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD); |
| 99 | |
| 100 | /* |
| 101 | * We don't want to deal with two quotaoffs messing up each other, |
| 102 | * so we're going to serialize it. quotaoff isn't exactly a performance |
| 103 | * critical thing. |
| 104 | * If quotaoff, then we must be dealing with the root filesystem. |
| 105 | */ |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 106 | ASSERT(q); |
| 107 | mutex_lock(&q->qi_quotaofflock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | /* |
| 110 | * If we're just turning off quota enforcement, change mp and go. |
| 111 | */ |
| 112 | if ((flags & XFS_ALL_QUOTA_ACCT) == 0) { |
| 113 | mp->m_qflags &= ~(flags); |
| 114 | |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 115 | spin_lock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | mp->m_sb.sb_qflags = mp->m_qflags; |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 117 | spin_unlock(&mp->m_sb_lock); |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 118 | mutex_unlock(&q->qi_quotaofflock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
| 120 | /* XXX what to do if error ? Revert back to old vals incore ? */ |
| 121 | error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS); |
| 122 | return (error); |
| 123 | } |
| 124 | |
| 125 | dqtype = 0; |
| 126 | inactivate_flags = 0; |
| 127 | /* |
| 128 | * If accounting is off, we must turn enforcement off, clear the |
| 129 | * quota 'CHKD' certificate to make it known that we have to |
| 130 | * do a quotacheck the next time this quota is turned on. |
| 131 | */ |
| 132 | if (flags & XFS_UQUOTA_ACCT) { |
| 133 | dqtype |= XFS_QMOPT_UQUOTA; |
| 134 | flags |= (XFS_UQUOTA_CHKD | XFS_UQUOTA_ENFD); |
| 135 | inactivate_flags |= XFS_UQUOTA_ACTIVE; |
| 136 | } |
| 137 | if (flags & XFS_GQUOTA_ACCT) { |
| 138 | dqtype |= XFS_QMOPT_GQUOTA; |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 139 | flags |= (XFS_OQUOTA_CHKD | XFS_OQUOTA_ENFD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | inactivate_flags |= XFS_GQUOTA_ACTIVE; |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 141 | } else if (flags & XFS_PQUOTA_ACCT) { |
| 142 | dqtype |= XFS_QMOPT_PQUOTA; |
| 143 | flags |= (XFS_OQUOTA_CHKD | XFS_OQUOTA_ENFD); |
| 144 | inactivate_flags |= XFS_PQUOTA_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Nothing to do? Don't complain. This happens when we're just |
| 149 | * turning off quota enforcement. |
| 150 | */ |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 151 | if ((mp->m_qflags & flags) == 0) |
| 152 | goto out_unlock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * Write the LI_QUOTAOFF log record, and do SB changes atomically, |
David Chinner | cb6edc2 | 2008-04-10 12:20:45 +1000 | [diff] [blame] | 156 | * and synchronously. If we fail to write, we should abort the |
| 157 | * operation as it cannot be recovered safely if we crash. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | */ |
David Chinner | cb6edc2 | 2008-04-10 12:20:45 +1000 | [diff] [blame] | 159 | error = xfs_qm_log_quotaoff(mp, &qoffstart, flags); |
| 160 | if (error) |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 161 | goto out_unlock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
| 163 | /* |
| 164 | * Next we clear the XFS_MOUNT_*DQ_ACTIVE bit(s) in the mount struct |
| 165 | * to take care of the race between dqget and quotaoff. We don't take |
| 166 | * any special locks to reset these bits. All processes need to check |
| 167 | * these bits *after* taking inode lock(s) to see if the particular |
| 168 | * quota type is in the process of being turned off. If *ACTIVE, it is |
| 169 | * guaranteed that all dquot structures and all quotainode ptrs will all |
| 170 | * stay valid as long as that inode is kept locked. |
| 171 | * |
| 172 | * There is no turning back after this. |
| 173 | */ |
| 174 | mp->m_qflags &= ~inactivate_flags; |
| 175 | |
| 176 | /* |
| 177 | * Give back all the dquot reference(s) held by inodes. |
| 178 | * Here we go thru every single incore inode in this file system, and |
| 179 | * do a dqrele on the i_udquot/i_gdquot that it may have. |
| 180 | * Essentially, as long as somebody has an inode locked, this guarantees |
| 181 | * that quotas will not be turned off. This is handy because in a |
| 182 | * transaction once we lock the inode(s) and check for quotaon, we can |
| 183 | * depend on the quota inodes (and other things) being valid as long as |
| 184 | * we keep the lock(s). |
| 185 | */ |
| 186 | xfs_qm_dqrele_all_inodes(mp, flags); |
| 187 | |
| 188 | /* |
| 189 | * Next we make the changes in the quota flag in the mount struct. |
| 190 | * This isn't protected by a particular lock directly, because we |
| 191 | * don't want to take a mrlock everytime we depend on quotas being on. |
| 192 | */ |
| 193 | mp->m_qflags &= ~(flags); |
| 194 | |
| 195 | /* |
| 196 | * Go through all the dquots of this file system and purge them, |
| 197 | * according to what was turned off. We may not be able to get rid |
| 198 | * of all dquots, because dquots can have temporary references that |
| 199 | * are not attached to inodes. eg. xfs_setattr, xfs_create. |
| 200 | * So, if we couldn't purge all the dquots from the filesystem, |
| 201 | * we can't get rid of the incore data structures. |
| 202 | */ |
Christoph Hellwig | 8112e9d | 2010-04-20 17:02:29 +1000 | [diff] [blame] | 203 | while ((nculprits = xfs_qm_dqpurge_all(mp, dqtype))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | delay(10 * nculprits); |
| 205 | |
| 206 | /* |
| 207 | * Transactions that had started before ACTIVE state bit was cleared |
| 208 | * could have logged many dquots, so they'd have higher LSNs than |
| 209 | * the first QUOTAOFF log record does. If we happen to crash when |
| 210 | * the tail of the log has gone past the QUOTAOFF record, but |
| 211 | * before the last dquot modification, those dquots __will__ |
| 212 | * recover, and that's not good. |
| 213 | * |
| 214 | * So, we have QUOTAOFF start and end logitems; the start |
| 215 | * logitem won't get overwritten until the end logitem appears... |
| 216 | */ |
David Chinner | cb6edc2 | 2008-04-10 12:20:45 +1000 | [diff] [blame] | 217 | error = xfs_qm_log_quotaoff_end(mp, qoffstart, flags); |
| 218 | if (error) { |
| 219 | /* We're screwed now. Shutdown is the only option. */ |
| 220 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 221 | goto out_unlock; |
David Chinner | cb6edc2 | 2008-04-10 12:20:45 +1000 | [diff] [blame] | 222 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
| 224 | /* |
| 225 | * If quotas is completely disabled, close shop. |
| 226 | */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 227 | if (((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET1) || |
| 228 | ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET2)) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 229 | mutex_unlock(&q->qi_quotaofflock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | xfs_qm_destroy_quotainfo(mp); |
| 231 | return (0); |
| 232 | } |
| 233 | |
| 234 | /* |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 235 | * Release our quotainode references if we don't need them anymore. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | */ |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 237 | if ((dqtype & XFS_QMOPT_UQUOTA) && q->qi_uquotaip) { |
| 238 | IRELE(q->qi_uquotaip); |
| 239 | q->qi_uquotaip = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | } |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 241 | if ((dqtype & (XFS_QMOPT_GQUOTA|XFS_QMOPT_PQUOTA)) && q->qi_gquotaip) { |
| 242 | IRELE(q->qi_gquotaip); |
| 243 | q->qi_gquotaip = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 246 | out_unlock: |
| 247 | mutex_unlock(&q->qi_quotaofflock); |
| 248 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 251 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | xfs_qm_scall_trunc_qfiles( |
| 253 | xfs_mount_t *mp, |
| 254 | uint flags) |
| 255 | { |
David Chinner | 88ab020 | 2008-04-10 12:20:51 +1000 | [diff] [blame] | 256 | int error = 0, error2 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | xfs_inode_t *qip; |
| 258 | |
Eric Sandeen | 6211870 | 2008-03-06 13:44:28 +1100 | [diff] [blame] | 259 | if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | qdprintk("qtrunc flags=%x m_qflags=%x\n", flags, mp->m_qflags); |
| 261 | return XFS_ERROR(EINVAL); |
| 262 | } |
| 263 | |
| 264 | if ((flags & XFS_DQ_USER) && mp->m_sb.sb_uquotino != NULLFSINO) { |
Dave Chinner | 7b6259e | 2010-06-24 11:35:17 +1000 | [diff] [blame^] | 265 | error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip); |
David Chinner | 88ab020 | 2008-04-10 12:20:51 +1000 | [diff] [blame] | 266 | if (!error) { |
| 267 | error = xfs_truncate_file(mp, qip); |
Christoph Hellwig | 4335509 | 2008-03-27 18:01:08 +1100 | [diff] [blame] | 268 | IRELE(qip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 272 | if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) && |
| 273 | mp->m_sb.sb_gquotino != NULLFSINO) { |
Dave Chinner | 7b6259e | 2010-06-24 11:35:17 +1000 | [diff] [blame^] | 274 | error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip); |
David Chinner | 88ab020 | 2008-04-10 12:20:51 +1000 | [diff] [blame] | 275 | if (!error2) { |
| 276 | error2 = xfs_truncate_file(mp, qip); |
Christoph Hellwig | 4335509 | 2008-03-27 18:01:08 +1100 | [diff] [blame] | 277 | IRELE(qip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | } |
| 279 | } |
| 280 | |
David Chinner | 88ab020 | 2008-04-10 12:20:51 +1000 | [diff] [blame] | 281 | return error ? error : error2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | |
| 285 | /* |
| 286 | * Switch on (a given) quota enforcement for a filesystem. This takes |
| 287 | * effect immediately. |
| 288 | * (Switching on quota accounting must be done at mount time.) |
| 289 | */ |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 290 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | xfs_qm_scall_quotaon( |
| 292 | xfs_mount_t *mp, |
| 293 | uint flags) |
| 294 | { |
| 295 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | uint qf; |
| 297 | uint accflags; |
| 298 | __int64_t sbflags; |
| 299 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | flags &= (XFS_ALL_QUOTA_ACCT | XFS_ALL_QUOTA_ENFD); |
| 301 | /* |
| 302 | * Switching on quota accounting must be done at mount time. |
| 303 | */ |
| 304 | accflags = flags & XFS_ALL_QUOTA_ACCT; |
| 305 | flags &= ~(XFS_ALL_QUOTA_ACCT); |
| 306 | |
| 307 | sbflags = 0; |
| 308 | |
| 309 | if (flags == 0) { |
| 310 | qdprintk("quotaon: zero flags, m_qflags=%x\n", mp->m_qflags); |
| 311 | return XFS_ERROR(EINVAL); |
| 312 | } |
| 313 | |
| 314 | /* No fs can turn on quotas with a delayed effect */ |
| 315 | ASSERT((flags & XFS_ALL_QUOTA_ACCT) == 0); |
| 316 | |
| 317 | /* |
| 318 | * Can't enforce without accounting. We check the superblock |
| 319 | * qflags here instead of m_qflags because rootfs can have |
| 320 | * quota acct on ondisk without m_qflags' knowing. |
| 321 | */ |
| 322 | if (((flags & XFS_UQUOTA_ACCT) == 0 && |
| 323 | (mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) == 0 && |
| 324 | (flags & XFS_UQUOTA_ENFD)) |
| 325 | || |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 326 | ((flags & XFS_PQUOTA_ACCT) == 0 && |
| 327 | (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && |
Donald Douwsma | 424ea91 | 2007-05-08 13:49:15 +1000 | [diff] [blame] | 328 | (flags & XFS_GQUOTA_ACCT) == 0 && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 330 | (flags & XFS_OQUOTA_ENFD))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | qdprintk("Can't enforce without acct, flags=%x sbflags=%x\n", |
| 332 | flags, mp->m_sb.sb_qflags); |
| 333 | return XFS_ERROR(EINVAL); |
| 334 | } |
| 335 | /* |
| 336 | * If everything's upto-date incore, then don't waste time. |
| 337 | */ |
| 338 | if ((mp->m_qflags & flags) == flags) |
| 339 | return XFS_ERROR(EEXIST); |
| 340 | |
| 341 | /* |
| 342 | * Change sb_qflags on disk but not incore mp->qflags |
| 343 | * if this is the root filesystem. |
| 344 | */ |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 345 | spin_lock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | qf = mp->m_sb.sb_qflags; |
| 347 | mp->m_sb.sb_qflags = qf | flags; |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 348 | spin_unlock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
| 350 | /* |
| 351 | * There's nothing to change if it's the same. |
| 352 | */ |
| 353 | if ((qf & flags) == flags && sbflags == 0) |
| 354 | return XFS_ERROR(EEXIST); |
| 355 | sbflags |= XFS_SB_QFLAGS; |
| 356 | |
| 357 | if ((error = xfs_qm_write_sb_changes(mp, sbflags))) |
| 358 | return (error); |
| 359 | /* |
| 360 | * If we aren't trying to switch on quota enforcement, we are done. |
| 361 | */ |
| 362 | if (((mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) != |
| 363 | (mp->m_qflags & XFS_UQUOTA_ACCT)) || |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 364 | ((mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) != |
| 365 | (mp->m_qflags & XFS_PQUOTA_ACCT)) || |
| 366 | ((mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) != |
| 367 | (mp->m_qflags & XFS_GQUOTA_ACCT)) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | (flags & XFS_ALL_QUOTA_ENFD) == 0) |
| 369 | return (0); |
| 370 | |
| 371 | if (! XFS_IS_QUOTA_RUNNING(mp)) |
| 372 | return XFS_ERROR(ESRCH); |
| 373 | |
| 374 | /* |
| 375 | * Switch on quota enforcement in core. |
| 376 | */ |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 377 | mutex_lock(&mp->m_quotainfo->qi_quotaofflock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD); |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 379 | mutex_unlock(&mp->m_quotainfo->qi_quotaofflock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
| 381 | return (0); |
| 382 | } |
| 383 | |
| 384 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | /* |
| 386 | * Return quota status information, such as uquota-off, enforcements, etc. |
| 387 | */ |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 388 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | xfs_qm_scall_getqstat( |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 390 | struct xfs_mount *mp, |
| 391 | struct fs_quota_stat *out) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 393 | struct xfs_quotainfo *q = mp->m_quotainfo; |
| 394 | struct xfs_inode *uip, *gip; |
| 395 | boolean_t tempuqip, tempgqip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
| 397 | uip = gip = NULL; |
| 398 | tempuqip = tempgqip = B_FALSE; |
| 399 | memset(out, 0, sizeof(fs_quota_stat_t)); |
| 400 | |
| 401 | out->qs_version = FS_QSTAT_VERSION; |
Eric Sandeen | 6211870 | 2008-03-06 13:44:28 +1100 | [diff] [blame] | 402 | if (!xfs_sb_version_hasquota(&mp->m_sb)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | out->qs_uquota.qfs_ino = NULLFSINO; |
| 404 | out->qs_gquota.qfs_ino = NULLFSINO; |
| 405 | return (0); |
| 406 | } |
| 407 | out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags & |
| 408 | (XFS_ALL_QUOTA_ACCT| |
| 409 | XFS_ALL_QUOTA_ENFD)); |
| 410 | out->qs_pad = 0; |
| 411 | out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; |
| 412 | out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; |
| 413 | |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 414 | if (q) { |
| 415 | uip = q->qi_uquotaip; |
| 416 | gip = q->qi_gquotaip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | } |
| 418 | if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) { |
| 419 | if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, |
Dave Chinner | 7b6259e | 2010-06-24 11:35:17 +1000 | [diff] [blame^] | 420 | 0, 0, &uip) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | tempuqip = B_TRUE; |
| 422 | } |
| 423 | if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) { |
| 424 | if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, |
Dave Chinner | 7b6259e | 2010-06-24 11:35:17 +1000 | [diff] [blame^] | 425 | 0, 0, &gip) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | tempgqip = B_TRUE; |
| 427 | } |
| 428 | if (uip) { |
| 429 | out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; |
| 430 | out->qs_uquota.qfs_nextents = uip->i_d.di_nextents; |
| 431 | if (tempuqip) |
Christoph Hellwig | 4335509 | 2008-03-27 18:01:08 +1100 | [diff] [blame] | 432 | IRELE(uip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | } |
| 434 | if (gip) { |
| 435 | out->qs_gquota.qfs_nblks = gip->i_d.di_nblocks; |
| 436 | out->qs_gquota.qfs_nextents = gip->i_d.di_nextents; |
| 437 | if (tempgqip) |
Christoph Hellwig | 4335509 | 2008-03-27 18:01:08 +1100 | [diff] [blame] | 438 | IRELE(gip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | } |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 440 | if (q) { |
| 441 | out->qs_incoredqs = q->qi_dquots; |
| 442 | out->qs_btimelimit = q->qi_btimelimit; |
| 443 | out->qs_itimelimit = q->qi_itimelimit; |
| 444 | out->qs_rtbtimelimit = q->qi_rtbtimelimit; |
| 445 | out->qs_bwarnlimit = q->qi_bwarnlimit; |
| 446 | out->qs_iwarnlimit = q->qi_iwarnlimit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | } |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 448 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 451 | #define XFS_DQ_MASK \ |
| 452 | (FS_DQ_LIMIT_MASK | FS_DQ_TIMER_MASK | FS_DQ_WARNS_MASK) |
| 453 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | /* |
| 455 | * Adjust quota limits, and start/stop timers accordingly. |
| 456 | */ |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 457 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | xfs_qm_scall_setqlim( |
| 459 | xfs_mount_t *mp, |
| 460 | xfs_dqid_t id, |
| 461 | uint type, |
| 462 | fs_disk_quota_t *newlim) |
| 463 | { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 464 | struct xfs_quotainfo *q = mp->m_quotainfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | xfs_disk_dquot_t *ddq; |
| 466 | xfs_dquot_t *dqp; |
| 467 | xfs_trans_t *tp; |
| 468 | int error; |
| 469 | xfs_qcnt_t hard, soft; |
| 470 | |
Christoph Hellwig | c472b43 | 2010-05-06 17:05:17 -0400 | [diff] [blame] | 471 | if (newlim->d_fieldmask & ~XFS_DQ_MASK) |
| 472 | return EINVAL; |
| 473 | if ((newlim->d_fieldmask & XFS_DQ_MASK) == 0) |
| 474 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
| 476 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM); |
| 477 | if ((error = xfs_trans_reserve(tp, 0, sizeof(xfs_disk_dquot_t) + 128, |
| 478 | 0, 0, XFS_DEFAULT_LOG_COUNT))) { |
| 479 | xfs_trans_cancel(tp, 0); |
| 480 | return (error); |
| 481 | } |
| 482 | |
| 483 | /* |
| 484 | * We don't want to race with a quotaoff so take the quotaoff lock. |
| 485 | * (We don't hold an inode lock, so there's nothing else to stop |
| 486 | * a quotaoff from happening). (XXXThis doesn't currently happen |
| 487 | * because we take the vfslock before calling xfs_qm_sysent). |
| 488 | */ |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 489 | mutex_lock(&q->qi_quotaofflock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
| 491 | /* |
| 492 | * Get the dquot (locked), and join it to the transaction. |
| 493 | * Allocate the dquot if this doesn't exist. |
| 494 | */ |
| 495 | if ((error = xfs_qm_dqget(mp, NULL, id, type, XFS_QMOPT_DQALLOC, &dqp))) { |
| 496 | xfs_trans_cancel(tp, XFS_TRANS_ABORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | ASSERT(error != ENOENT); |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 498 | goto out_unlock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | xfs_trans_dqjoin(tp, dqp); |
| 501 | ddq = &dqp->q_core; |
| 502 | |
| 503 | /* |
| 504 | * Make sure that hardlimits are >= soft limits before changing. |
| 505 | */ |
| 506 | hard = (newlim->d_fieldmask & FS_DQ_BHARD) ? |
| 507 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) : |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 508 | be64_to_cpu(ddq->d_blk_hardlimit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ? |
| 510 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) : |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 511 | be64_to_cpu(ddq->d_blk_softlimit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | if (hard == 0 || hard >= soft) { |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 513 | ddq->d_blk_hardlimit = cpu_to_be64(hard); |
| 514 | ddq->d_blk_softlimit = cpu_to_be64(soft); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | if (id == 0) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 516 | q->qi_bhardlimit = hard; |
| 517 | q->qi_bsoftlimit = soft; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | } |
| 519 | } else { |
| 520 | qdprintk("blkhard %Ld < blksoft %Ld\n", hard, soft); |
| 521 | } |
| 522 | hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? |
| 523 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 524 | be64_to_cpu(ddq->d_rtb_hardlimit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ? |
| 526 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) : |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 527 | be64_to_cpu(ddq->d_rtb_softlimit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | if (hard == 0 || hard >= soft) { |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 529 | ddq->d_rtb_hardlimit = cpu_to_be64(hard); |
| 530 | ddq->d_rtb_softlimit = cpu_to_be64(soft); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | if (id == 0) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 532 | q->qi_rtbhardlimit = hard; |
| 533 | q->qi_rtbsoftlimit = soft; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | } |
| 535 | } else { |
| 536 | qdprintk("rtbhard %Ld < rtbsoft %Ld\n", hard, soft); |
| 537 | } |
| 538 | |
| 539 | hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? |
| 540 | (xfs_qcnt_t) newlim->d_ino_hardlimit : |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 541 | be64_to_cpu(ddq->d_ino_hardlimit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ? |
| 543 | (xfs_qcnt_t) newlim->d_ino_softlimit : |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 544 | be64_to_cpu(ddq->d_ino_softlimit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | if (hard == 0 || hard >= soft) { |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 546 | ddq->d_ino_hardlimit = cpu_to_be64(hard); |
| 547 | ddq->d_ino_softlimit = cpu_to_be64(soft); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | if (id == 0) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 549 | q->qi_ihardlimit = hard; |
| 550 | q->qi_isoftlimit = soft; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | } |
| 552 | } else { |
| 553 | qdprintk("ihard %Ld < isoft %Ld\n", hard, soft); |
| 554 | } |
| 555 | |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 556 | /* |
| 557 | * Update warnings counter(s) if requested |
| 558 | */ |
| 559 | if (newlim->d_fieldmask & FS_DQ_BWARNS) |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 560 | ddq->d_bwarns = cpu_to_be16(newlim->d_bwarns); |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 561 | if (newlim->d_fieldmask & FS_DQ_IWARNS) |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 562 | ddq->d_iwarns = cpu_to_be16(newlim->d_iwarns); |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 563 | if (newlim->d_fieldmask & FS_DQ_RTBWARNS) |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 564 | ddq->d_rtbwarns = cpu_to_be16(newlim->d_rtbwarns); |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 565 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | if (id == 0) { |
| 567 | /* |
| 568 | * Timelimits for the super user set the relative time |
| 569 | * the other users can be over quota for this file system. |
| 570 | * If it is zero a default is used. Ditto for the default |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 571 | * soft and hard limit values (already done, above), and |
| 572 | * for warnings. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | */ |
| 574 | if (newlim->d_fieldmask & FS_DQ_BTIMER) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 575 | q->qi_btimelimit = newlim->d_btimer; |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 576 | ddq->d_btimer = cpu_to_be32(newlim->d_btimer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | } |
| 578 | if (newlim->d_fieldmask & FS_DQ_ITIMER) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 579 | q->qi_itimelimit = newlim->d_itimer; |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 580 | ddq->d_itimer = cpu_to_be32(newlim->d_itimer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | } |
| 582 | if (newlim->d_fieldmask & FS_DQ_RTBTIMER) { |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 583 | q->qi_rtbtimelimit = newlim->d_rtbtimer; |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 584 | ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | } |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 586 | if (newlim->d_fieldmask & FS_DQ_BWARNS) |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 587 | q->qi_bwarnlimit = newlim->d_bwarns; |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 588 | if (newlim->d_fieldmask & FS_DQ_IWARNS) |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 589 | q->qi_iwarnlimit = newlim->d_iwarns; |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 590 | if (newlim->d_fieldmask & FS_DQ_RTBWARNS) |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 591 | q->qi_rtbwarnlimit = newlim->d_rtbwarns; |
Nathan Scott | 754002b | 2005-06-21 15:49:06 +1000 | [diff] [blame] | 592 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | /* |
| 594 | * If the user is now over quota, start the timelimit. |
| 595 | * The user will not be 'warned'. |
| 596 | * Note that we keep the timers ticking, whether enforcement |
| 597 | * is on or off. We don't really want to bother with iterating |
| 598 | * over all ondisk dquots and turning the timers on/off. |
| 599 | */ |
| 600 | xfs_qm_adjust_dqtimers(mp, ddq); |
| 601 | } |
| 602 | dqp->dq_flags |= XFS_DQ_DIRTY; |
| 603 | xfs_trans_log_dquot(tp, dqp); |
| 604 | |
David Chinner | e5720ee | 2008-04-10 12:21:18 +1000 | [diff] [blame] | 605 | error = xfs_trans_commit(tp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | xfs_qm_dqprint(dqp); |
| 607 | xfs_qm_dqrele(dqp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 609 | out_unlock: |
| 610 | mutex_unlock(&q->qi_quotaofflock); |
David Chinner | e5720ee | 2008-04-10 12:21:18 +1000 | [diff] [blame] | 611 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | } |
| 613 | |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 614 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | xfs_qm_scall_getquota( |
| 616 | xfs_mount_t *mp, |
| 617 | xfs_dqid_t id, |
| 618 | uint type, |
| 619 | fs_disk_quota_t *out) |
| 620 | { |
| 621 | xfs_dquot_t *dqp; |
| 622 | int error; |
| 623 | |
| 624 | /* |
| 625 | * Try to get the dquot. We don't want it allocated on disk, so |
| 626 | * we aren't passing the XFS_QMOPT_DOALLOC flag. If it doesn't |
| 627 | * exist, we'll get ENOENT back. |
| 628 | */ |
| 629 | if ((error = xfs_qm_dqget(mp, NULL, id, type, 0, &dqp))) { |
| 630 | return (error); |
| 631 | } |
| 632 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | /* |
| 634 | * If everything's NULL, this dquot doesn't quite exist as far as |
| 635 | * our utility programs are concerned. |
| 636 | */ |
| 637 | if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) { |
| 638 | xfs_qm_dqput(dqp); |
| 639 | return XFS_ERROR(ENOENT); |
| 640 | } |
| 641 | /* xfs_qm_dqprint(dqp); */ |
| 642 | /* |
| 643 | * Convert the disk dquot to the exportable format |
| 644 | */ |
| 645 | xfs_qm_export_dquot(mp, &dqp->q_core, out); |
| 646 | xfs_qm_dqput(dqp); |
| 647 | return (error ? XFS_ERROR(EFAULT) : 0); |
| 648 | } |
| 649 | |
| 650 | |
| 651 | STATIC int |
| 652 | xfs_qm_log_quotaoff_end( |
| 653 | xfs_mount_t *mp, |
| 654 | xfs_qoff_logitem_t *startqoff, |
| 655 | uint flags) |
| 656 | { |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 657 | xfs_trans_t *tp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | int error; |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 659 | xfs_qoff_logitem_t *qoffi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
| 661 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF_END); |
| 662 | |
| 663 | if ((error = xfs_trans_reserve(tp, 0, sizeof(xfs_qoff_logitem_t) * 2, |
| 664 | 0, 0, XFS_DEFAULT_LOG_COUNT))) { |
| 665 | xfs_trans_cancel(tp, 0); |
| 666 | return (error); |
| 667 | } |
| 668 | |
| 669 | qoffi = xfs_trans_get_qoff_item(tp, startqoff, |
| 670 | flags & XFS_ALL_QUOTA_ACCT); |
| 671 | xfs_trans_log_quotaoff_item(tp, qoffi); |
| 672 | |
| 673 | /* |
| 674 | * We have to make sure that the transaction is secure on disk before we |
| 675 | * return and actually stop quota accounting. So, make it synchronous. |
| 676 | * We don't care about quotoff's performance. |
| 677 | */ |
| 678 | xfs_trans_set_sync(tp); |
Eric Sandeen | 1c72bf9 | 2007-05-08 13:48:42 +1000 | [diff] [blame] | 679 | error = xfs_trans_commit(tp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | return (error); |
| 681 | } |
| 682 | |
| 683 | |
| 684 | STATIC int |
| 685 | xfs_qm_log_quotaoff( |
| 686 | xfs_mount_t *mp, |
| 687 | xfs_qoff_logitem_t **qoffstartp, |
| 688 | uint flags) |
| 689 | { |
| 690 | xfs_trans_t *tp; |
| 691 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | xfs_qoff_logitem_t *qoffi=NULL; |
| 693 | uint oldsbqflag=0; |
| 694 | |
| 695 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); |
| 696 | if ((error = xfs_trans_reserve(tp, 0, |
| 697 | sizeof(xfs_qoff_logitem_t) * 2 + |
| 698 | mp->m_sb.sb_sectsize + 128, |
| 699 | 0, |
| 700 | 0, |
| 701 | XFS_DEFAULT_LOG_COUNT))) { |
| 702 | goto error0; |
| 703 | } |
| 704 | |
| 705 | qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); |
| 706 | xfs_trans_log_quotaoff_item(tp, qoffi); |
| 707 | |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 708 | spin_lock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | oldsbqflag = mp->m_sb.sb_qflags; |
| 710 | mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 711 | spin_unlock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | |
| 713 | xfs_mod_sb(tp, XFS_SB_QFLAGS); |
| 714 | |
| 715 | /* |
| 716 | * We have to make sure that the transaction is secure on disk before we |
| 717 | * return and actually stop quota accounting. So, make it synchronous. |
| 718 | * We don't care about quotoff's performance. |
| 719 | */ |
| 720 | xfs_trans_set_sync(tp); |
Eric Sandeen | 1c72bf9 | 2007-05-08 13:48:42 +1000 | [diff] [blame] | 721 | error = xfs_trans_commit(tp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | |
| 723 | error0: |
| 724 | if (error) { |
| 725 | xfs_trans_cancel(tp, 0); |
| 726 | /* |
| 727 | * No one else is modifying sb_qflags, so this is OK. |
| 728 | * We still hold the quotaofflock. |
| 729 | */ |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 730 | spin_lock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | mp->m_sb.sb_qflags = oldsbqflag; |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 732 | spin_unlock(&mp->m_sb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | } |
| 734 | *qoffstartp = qoffi; |
| 735 | return (error); |
| 736 | } |
| 737 | |
| 738 | |
| 739 | /* |
| 740 | * Translate an internal style on-disk-dquot to the exportable format. |
| 741 | * The main differences are that the counters/limits are all in Basic |
| 742 | * Blocks (BBs) instead of the internal FSBs, and all on-disk data has |
| 743 | * to be converted to the native endianness. |
| 744 | */ |
| 745 | STATIC void |
| 746 | xfs_qm_export_dquot( |
| 747 | xfs_mount_t *mp, |
| 748 | xfs_disk_dquot_t *src, |
| 749 | struct fs_disk_quota *dst) |
| 750 | { |
| 751 | memset(dst, 0, sizeof(*dst)); |
| 752 | dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */ |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 753 | dst->d_flags = xfs_qm_export_qtype_flags(src->d_flags); |
| 754 | dst->d_id = be32_to_cpu(src->d_id); |
| 755 | dst->d_blk_hardlimit = |
| 756 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_hardlimit)); |
| 757 | dst->d_blk_softlimit = |
| 758 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_softlimit)); |
| 759 | dst->d_ino_hardlimit = be64_to_cpu(src->d_ino_hardlimit); |
| 760 | dst->d_ino_softlimit = be64_to_cpu(src->d_ino_softlimit); |
| 761 | dst->d_bcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_bcount)); |
| 762 | dst->d_icount = be64_to_cpu(src->d_icount); |
| 763 | dst->d_btimer = be32_to_cpu(src->d_btimer); |
| 764 | dst->d_itimer = be32_to_cpu(src->d_itimer); |
| 765 | dst->d_iwarns = be16_to_cpu(src->d_iwarns); |
| 766 | dst->d_bwarns = be16_to_cpu(src->d_bwarns); |
| 767 | dst->d_rtb_hardlimit = |
| 768 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_hardlimit)); |
| 769 | dst->d_rtb_softlimit = |
| 770 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_softlimit)); |
| 771 | dst->d_rtbcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtbcount)); |
| 772 | dst->d_rtbtimer = be32_to_cpu(src->d_rtbtimer); |
| 773 | dst->d_rtbwarns = be16_to_cpu(src->d_rtbwarns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | |
| 775 | /* |
| 776 | * Internally, we don't reset all the timers when quota enforcement |
Nathan Scott | c41564b | 2006-03-29 08:55:14 +1000 | [diff] [blame] | 777 | * gets turned off. No need to confuse the user level code, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | * so return zeroes in that case. |
| 779 | */ |
Kouta Ooizumi | e6d2942 | 2007-05-08 13:49:33 +1000 | [diff] [blame] | 780 | if ((!XFS_IS_UQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_USER) || |
| 781 | (!XFS_IS_OQUOTA_ENFORCED(mp) && |
| 782 | (src->d_flags & (XFS_DQ_PROJ | XFS_DQ_GROUP)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | dst->d_btimer = 0; |
| 784 | dst->d_itimer = 0; |
| 785 | dst->d_rtbtimer = 0; |
| 786 | } |
| 787 | |
| 788 | #ifdef DEBUG |
Kouta Ooizumi | e6d2942 | 2007-05-08 13:49:33 +1000 | [diff] [blame] | 789 | if (((XFS_IS_UQUOTA_ENFORCED(mp) && dst->d_flags == XFS_USER_QUOTA) || |
| 790 | (XFS_IS_OQUOTA_ENFORCED(mp) && |
| 791 | (dst->d_flags & (XFS_PROJ_QUOTA | XFS_GROUP_QUOTA)))) && |
| 792 | dst->d_id != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | if (((int) dst->d_bcount >= (int) dst->d_blk_softlimit) && |
| 794 | (dst->d_blk_softlimit > 0)) { |
| 795 | ASSERT(dst->d_btimer != 0); |
| 796 | } |
| 797 | if (((int) dst->d_icount >= (int) dst->d_ino_softlimit) && |
| 798 | (dst->d_ino_softlimit > 0)) { |
| 799 | ASSERT(dst->d_itimer != 0); |
| 800 | } |
| 801 | } |
| 802 | #endif |
| 803 | } |
| 804 | |
| 805 | STATIC uint |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | xfs_qm_export_qtype_flags( |
| 807 | uint flags) |
| 808 | { |
| 809 | /* |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 810 | * Can't be more than one, or none. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 812 | ASSERT((flags & (XFS_PROJ_QUOTA | XFS_USER_QUOTA)) != |
| 813 | (XFS_PROJ_QUOTA | XFS_USER_QUOTA)); |
| 814 | ASSERT((flags & (XFS_PROJ_QUOTA | XFS_GROUP_QUOTA)) != |
| 815 | (XFS_PROJ_QUOTA | XFS_GROUP_QUOTA)); |
| 816 | ASSERT((flags & (XFS_USER_QUOTA | XFS_GROUP_QUOTA)) != |
| 817 | (XFS_USER_QUOTA | XFS_GROUP_QUOTA)); |
| 818 | ASSERT((flags & (XFS_PROJ_QUOTA|XFS_USER_QUOTA|XFS_GROUP_QUOTA)) != 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
| 820 | return (flags & XFS_DQ_USER) ? |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 821 | XFS_USER_QUOTA : (flags & XFS_DQ_PROJ) ? |
| 822 | XFS_PROJ_QUOTA : XFS_GROUP_QUOTA; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | } |
| 824 | |
| 825 | STATIC uint |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | xfs_qm_export_flags( |
| 827 | uint flags) |
| 828 | { |
| 829 | uint uflags; |
| 830 | |
| 831 | uflags = 0; |
| 832 | if (flags & XFS_UQUOTA_ACCT) |
| 833 | uflags |= XFS_QUOTA_UDQ_ACCT; |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 834 | if (flags & XFS_PQUOTA_ACCT) |
| 835 | uflags |= XFS_QUOTA_PDQ_ACCT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | if (flags & XFS_GQUOTA_ACCT) |
| 837 | uflags |= XFS_QUOTA_GDQ_ACCT; |
| 838 | if (flags & XFS_UQUOTA_ENFD) |
| 839 | uflags |= XFS_QUOTA_UDQ_ENFD; |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 840 | if (flags & (XFS_OQUOTA_ENFD)) { |
| 841 | uflags |= (flags & XFS_GQUOTA_ACCT) ? |
| 842 | XFS_QUOTA_GDQ_ENFD : XFS_QUOTA_PDQ_ENFD; |
| 843 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | return (uflags); |
| 845 | } |
| 846 | |
| 847 | |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 848 | STATIC int |
| 849 | xfs_dqrele_inode( |
| 850 | struct xfs_inode *ip, |
| 851 | struct xfs_perag *pag, |
| 852 | int flags) |
David Chinner | 5b4d89a | 2008-10-30 17:08:03 +1100 | [diff] [blame] | 853 | { |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 854 | int error; |
David Chinner | 5b4d89a | 2008-10-30 17:08:03 +1100 | [diff] [blame] | 855 | |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 856 | /* skip quota inodes */ |
Christoph Hellwig | 8a7b8a8 | 2010-04-20 17:01:30 +1000 | [diff] [blame] | 857 | if (ip == ip->i_mount->m_quotainfo->qi_uquotaip || |
| 858 | ip == ip->i_mount->m_quotainfo->qi_gquotaip) { |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 859 | ASSERT(ip->i_udquot == NULL); |
| 860 | ASSERT(ip->i_gdquot == NULL); |
Dave Chinner | cb4f0d1 | 2008-11-10 17:11:18 +1100 | [diff] [blame] | 861 | read_unlock(&pag->pag_ici_lock); |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 862 | return 0; |
| 863 | } |
Dave Chinner | cb4f0d1 | 2008-11-10 17:11:18 +1100 | [diff] [blame] | 864 | |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 865 | error = xfs_sync_inode_valid(ip, pag); |
| 866 | if (error) |
| 867 | return error; |
Dave Chinner | 6307091 | 2008-11-10 17:13:23 +1100 | [diff] [blame] | 868 | |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 869 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 870 | if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) { |
| 871 | xfs_qm_dqrele(ip->i_udquot); |
| 872 | ip->i_udquot = NULL; |
| 873 | } |
| 874 | if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) && ip->i_gdquot) { |
| 875 | xfs_qm_dqrele(ip->i_gdquot); |
| 876 | ip->i_gdquot = NULL; |
| 877 | } |
| 878 | xfs_iput(ip, XFS_ILOCK_EXCL); |
Dave Chinner | cb4f0d1 | 2008-11-10 17:11:18 +1100 | [diff] [blame] | 879 | |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 880 | return 0; |
David Chinner | 5b4d89a | 2008-10-30 17:08:03 +1100 | [diff] [blame] | 881 | } |
| 882 | |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 883 | |
David Chinner | 5b4d89a | 2008-10-30 17:08:03 +1100 | [diff] [blame] | 884 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | * Go thru all the inodes in the file system, releasing their dquots. |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 886 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | * Note that the mount structure gets modified to indicate that quotas are off |
Christoph Hellwig | fe588ed | 2009-06-08 15:35:27 +0200 | [diff] [blame] | 888 | * AFTER this, in the case of quotaoff. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | */ |
| 890 | void |
| 891 | xfs_qm_dqrele_all_inodes( |
| 892 | struct xfs_mount *mp, |
| 893 | uint flags) |
| 894 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | ASSERT(mp->m_quotainfo); |
Dave Chinner | 9bf729c | 2010-04-29 09:55:50 +1000 | [diff] [blame] | 896 | xfs_inode_ag_iterator(mp, xfs_dqrele_inode, flags, |
| 897 | XFS_ICI_NO_TAG, 0, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | /*------------------------------------------------------------------------*/ |
| 901 | #ifdef DEBUG |
| 902 | /* |
| 903 | * This contains all the test functions for XFS disk quotas. |
| 904 | * Currently it does a quota accounting check. ie. it walks through |
| 905 | * all inodes in the file system, calculating the dquot accounting fields, |
| 906 | * and prints out any inconsistencies. |
| 907 | */ |
| 908 | xfs_dqhash_t *qmtest_udqtab; |
| 909 | xfs_dqhash_t *qmtest_gdqtab; |
| 910 | int qmtest_hashmask; |
| 911 | int qmtest_nfails; |
Christoph Hellwig | a0b0b8a | 2009-03-29 09:51:00 +0200 | [diff] [blame] | 912 | struct mutex qcheck_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | |
| 914 | #define DQTEST_HASHVAL(mp, id) (((__psunsigned_t)(mp) + \ |
| 915 | (__psunsigned_t)(id)) & \ |
| 916 | (qmtest_hashmask - 1)) |
| 917 | |
| 918 | #define DQTEST_HASH(mp, id, type) ((type & XFS_DQ_USER) ? \ |
| 919 | (qmtest_udqtab + \ |
| 920 | DQTEST_HASHVAL(mp, id)) : \ |
| 921 | (qmtest_gdqtab + \ |
| 922 | DQTEST_HASHVAL(mp, id))) |
| 923 | |
| 924 | #define DQTEST_LIST_PRINT(l, NXT, title) \ |
| 925 | { \ |
| 926 | xfs_dqtest_t *dqp; int i = 0;\ |
| 927 | cmn_err(CE_DEBUG, "%s (#%d)", title, (int) (l)->qh_nelems); \ |
| 928 | for (dqp = (xfs_dqtest_t *)(l)->qh_next; dqp != NULL; \ |
| 929 | dqp = (xfs_dqtest_t *)dqp->NXT) { \ |
| 930 | cmn_err(CE_DEBUG, " %d. \"%d (%s)\" bcnt = %d, icnt = %d", \ |
| 931 | ++i, dqp->d_id, DQFLAGTO_TYPESTR(dqp), \ |
| 932 | dqp->d_bcount, dqp->d_icount); } \ |
| 933 | } |
| 934 | |
| 935 | typedef struct dqtest { |
Christoph Hellwig | 74457cf | 2010-04-13 15:06:53 +1000 | [diff] [blame] | 936 | uint dq_flags; /* various flags (XFS_DQ_*) */ |
Dave Chinner | e6a81f1 | 2010-04-13 15:06:51 +1000 | [diff] [blame] | 937 | struct list_head q_hashlist; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | xfs_dqhash_t *q_hash; /* the hashchain header */ |
| 939 | xfs_mount_t *q_mount; /* filesystem this relates to */ |
| 940 | xfs_dqid_t d_id; /* user id or group id */ |
| 941 | xfs_qcnt_t d_bcount; /* # disk blocks owned by the user */ |
| 942 | xfs_qcnt_t d_icount; /* # inodes owned by the user */ |
| 943 | } xfs_dqtest_t; |
| 944 | |
| 945 | STATIC void |
| 946 | xfs_qm_hashinsert(xfs_dqhash_t *h, xfs_dqtest_t *dqp) |
| 947 | { |
Dave Chinner | e6a81f1 | 2010-04-13 15:06:51 +1000 | [diff] [blame] | 948 | list_add(&dqp->q_hashlist, &h->qh_list); |
| 949 | h->qh_version++; |
| 950 | h->qh_nelems++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | } |
| 952 | STATIC void |
| 953 | xfs_qm_dqtest_print( |
| 954 | xfs_dqtest_t *d) |
| 955 | { |
| 956 | cmn_err(CE_DEBUG, "-----------DQTEST DQUOT----------------"); |
| 957 | cmn_err(CE_DEBUG, "---- dquot ID = %d", d->d_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | cmn_err(CE_DEBUG, "---- fs = 0x%p", d->q_mount); |
| 959 | cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", |
| 960 | d->d_bcount, (int)d->d_bcount); |
| 961 | cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", |
| 962 | d->d_icount, (int)d->d_icount); |
| 963 | cmn_err(CE_DEBUG, "---------------------------"); |
| 964 | } |
| 965 | |
| 966 | STATIC void |
| 967 | xfs_qm_dqtest_failed( |
| 968 | xfs_dqtest_t *d, |
| 969 | xfs_dquot_t *dqp, |
| 970 | char *reason, |
| 971 | xfs_qcnt_t a, |
| 972 | xfs_qcnt_t b, |
| 973 | int error) |
| 974 | { |
| 975 | qmtest_nfails++; |
| 976 | if (error) |
| 977 | cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s", |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 978 | d->d_id, error, reason); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | else |
| 980 | cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]", |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 981 | d->d_id, reason, (int)a, (int)b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | xfs_qm_dqtest_print(d); |
| 983 | if (dqp) |
| 984 | xfs_qm_dqprint(dqp); |
| 985 | } |
| 986 | |
| 987 | STATIC int |
| 988 | xfs_dqtest_cmp2( |
| 989 | xfs_dqtest_t *d, |
| 990 | xfs_dquot_t *dqp) |
| 991 | { |
| 992 | int err = 0; |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 993 | if (be64_to_cpu(dqp->q_core.d_icount) != d->d_icount) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | xfs_qm_dqtest_failed(d, dqp, "icount mismatch", |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 995 | be64_to_cpu(dqp->q_core.d_icount), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | d->d_icount, 0); |
| 997 | err++; |
| 998 | } |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 999 | if (be64_to_cpu(dqp->q_core.d_bcount) != d->d_bcount) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | xfs_qm_dqtest_failed(d, dqp, "bcount mismatch", |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 1001 | be64_to_cpu(dqp->q_core.d_bcount), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | d->d_bcount, 0); |
| 1003 | err++; |
| 1004 | } |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 1005 | if (dqp->q_core.d_blk_softlimit && |
| 1006 | be64_to_cpu(dqp->q_core.d_bcount) >= |
| 1007 | be64_to_cpu(dqp->q_core.d_blk_softlimit)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { |
| 1009 | cmn_err(CE_DEBUG, |
| 1010 | "%d [%s] [0x%p] BLK TIMER NOT STARTED", |
| 1011 | d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount); |
| 1012 | err++; |
| 1013 | } |
| 1014 | } |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 1015 | if (dqp->q_core.d_ino_softlimit && |
| 1016 | be64_to_cpu(dqp->q_core.d_icount) >= |
| 1017 | be64_to_cpu(dqp->q_core.d_ino_softlimit)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { |
| 1019 | cmn_err(CE_DEBUG, |
| 1020 | "%d [%s] [0x%p] INO TIMER NOT STARTED", |
| 1021 | d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount); |
| 1022 | err++; |
| 1023 | } |
| 1024 | } |
| 1025 | #ifdef QUOTADEBUG |
| 1026 | if (!err) { |
| 1027 | cmn_err(CE_DEBUG, "%d [%s] [0x%p] qchecked", |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 1028 | d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | } |
| 1030 | #endif |
| 1031 | return (err); |
| 1032 | } |
| 1033 | |
| 1034 | STATIC void |
| 1035 | xfs_dqtest_cmp( |
| 1036 | xfs_dqtest_t *d) |
| 1037 | { |
| 1038 | xfs_dquot_t *dqp; |
| 1039 | int error; |
| 1040 | |
| 1041 | /* xfs_qm_dqtest_print(d); */ |
| 1042 | if ((error = xfs_qm_dqget(d->q_mount, NULL, d->d_id, d->dq_flags, 0, |
| 1043 | &dqp))) { |
| 1044 | xfs_qm_dqtest_failed(d, NULL, "dqget failed", 0, 0, error); |
| 1045 | return; |
| 1046 | } |
| 1047 | xfs_dqtest_cmp2(d, dqp); |
| 1048 | xfs_qm_dqput(dqp); |
| 1049 | } |
| 1050 | |
| 1051 | STATIC int |
| 1052 | xfs_qm_internalqcheck_dqget( |
| 1053 | xfs_mount_t *mp, |
| 1054 | xfs_dqid_t id, |
| 1055 | uint type, |
| 1056 | xfs_dqtest_t **O_dq) |
| 1057 | { |
| 1058 | xfs_dqtest_t *d; |
| 1059 | xfs_dqhash_t *h; |
| 1060 | |
| 1061 | h = DQTEST_HASH(mp, id, type); |
Dave Chinner | e6a81f1 | 2010-04-13 15:06:51 +1000 | [diff] [blame] | 1062 | list_for_each_entry(d, &h->qh_list, q_hashlist) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | if (d->d_id == id && mp == d->q_mount) { |
| 1064 | *O_dq = d; |
| 1065 | return (0); |
| 1066 | } |
| 1067 | } |
| 1068 | d = kmem_zalloc(sizeof(xfs_dqtest_t), KM_SLEEP); |
| 1069 | d->dq_flags = type; |
| 1070 | d->d_id = id; |
| 1071 | d->q_mount = mp; |
| 1072 | d->q_hash = h; |
Dave Chinner | e6a81f1 | 2010-04-13 15:06:51 +1000 | [diff] [blame] | 1073 | INIT_LIST_HEAD(&d->q_hashlist); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | xfs_qm_hashinsert(h, d); |
| 1075 | *O_dq = d; |
| 1076 | return (0); |
| 1077 | } |
| 1078 | |
| 1079 | STATIC void |
| 1080 | xfs_qm_internalqcheck_get_dquots( |
| 1081 | xfs_mount_t *mp, |
| 1082 | xfs_dqid_t uid, |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 1083 | xfs_dqid_t projid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | xfs_dqid_t gid, |
| 1085 | xfs_dqtest_t **ud, |
| 1086 | xfs_dqtest_t **gd) |
| 1087 | { |
| 1088 | if (XFS_IS_UQUOTA_ON(mp)) |
| 1089 | xfs_qm_internalqcheck_dqget(mp, uid, XFS_DQ_USER, ud); |
| 1090 | if (XFS_IS_GQUOTA_ON(mp)) |
| 1091 | xfs_qm_internalqcheck_dqget(mp, gid, XFS_DQ_GROUP, gd); |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 1092 | else if (XFS_IS_PQUOTA_ON(mp)) |
| 1093 | xfs_qm_internalqcheck_dqget(mp, projid, XFS_DQ_PROJ, gd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | |
| 1097 | STATIC void |
| 1098 | xfs_qm_internalqcheck_dqadjust( |
| 1099 | xfs_inode_t *ip, |
| 1100 | xfs_dqtest_t *d) |
| 1101 | { |
| 1102 | d->d_icount++; |
| 1103 | d->d_bcount += (xfs_qcnt_t)ip->i_d.di_nblocks; |
| 1104 | } |
| 1105 | |
| 1106 | STATIC int |
| 1107 | xfs_qm_internalqcheck_adjust( |
| 1108 | xfs_mount_t *mp, /* mount point for filesystem */ |
| 1109 | xfs_ino_t ino, /* inode number to get data for */ |
| 1110 | void __user *buffer, /* not used */ |
| 1111 | int ubsize, /* not used */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | int *ubused, /* not used */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | int *res) /* bulkstat result code */ |
| 1114 | { |
| 1115 | xfs_inode_t *ip; |
| 1116 | xfs_dqtest_t *ud, *gd; |
| 1117 | uint lock_flags; |
| 1118 | boolean_t ipreleased; |
| 1119 | int error; |
| 1120 | |
| 1121 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
| 1122 | |
| 1123 | if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) { |
| 1124 | *res = BULKSTAT_RV_NOTHING; |
| 1125 | qdprintk("internalqcheck: ino=%llu, uqino=%llu, gqino=%llu\n", |
| 1126 | (unsigned long long) ino, |
| 1127 | (unsigned long long) mp->m_sb.sb_uquotino, |
| 1128 | (unsigned long long) mp->m_sb.sb_gquotino); |
| 1129 | return XFS_ERROR(EINVAL); |
| 1130 | } |
| 1131 | ipreleased = B_FALSE; |
| 1132 | again: |
| 1133 | lock_flags = XFS_ILOCK_SHARED; |
Dave Chinner | 7b6259e | 2010-06-24 11:35:17 +1000 | [diff] [blame^] | 1134 | if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | *res = BULKSTAT_RV_NOTHING; |
| 1136 | return (error); |
| 1137 | } |
| 1138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | /* |
| 1140 | * This inode can have blocks after eof which can get released |
| 1141 | * when we send it to inactive. Since we don't check the dquot |
| 1142 | * until the after all our calculations are done, we must get rid |
| 1143 | * of those now. |
| 1144 | */ |
| 1145 | if (! ipreleased) { |
| 1146 | xfs_iput(ip, lock_flags); |
| 1147 | ipreleased = B_TRUE; |
| 1148 | goto again; |
| 1149 | } |
| 1150 | xfs_qm_internalqcheck_get_dquots(mp, |
| 1151 | (xfs_dqid_t) ip->i_d.di_uid, |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 1152 | (xfs_dqid_t) ip->i_d.di_projid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | (xfs_dqid_t) ip->i_d.di_gid, |
| 1154 | &ud, &gd); |
| 1155 | if (XFS_IS_UQUOTA_ON(mp)) { |
| 1156 | ASSERT(ud); |
| 1157 | xfs_qm_internalqcheck_dqadjust(ip, ud); |
| 1158 | } |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 1159 | if (XFS_IS_OQUOTA_ON(mp)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | ASSERT(gd); |
| 1161 | xfs_qm_internalqcheck_dqadjust(ip, gd); |
| 1162 | } |
| 1163 | xfs_iput(ip, lock_flags); |
| 1164 | *res = BULKSTAT_RV_DIDONE; |
| 1165 | return (0); |
| 1166 | } |
| 1167 | |
| 1168 | |
| 1169 | /* PRIVATE, debugging */ |
| 1170 | int |
| 1171 | xfs_qm_internalqcheck( |
| 1172 | xfs_mount_t *mp) |
| 1173 | { |
| 1174 | xfs_ino_t lastino; |
| 1175 | int done, count; |
| 1176 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | int error; |
| 1178 | |
| 1179 | lastino = 0; |
| 1180 | qmtest_hashmask = 32; |
| 1181 | count = 5; |
| 1182 | done = 0; |
| 1183 | qmtest_nfails = 0; |
| 1184 | |
| 1185 | if (! XFS_IS_QUOTA_ON(mp)) |
| 1186 | return XFS_ERROR(ESRCH); |
| 1187 | |
Christoph Hellwig | a14a348 | 2010-01-19 09:56:46 +0000 | [diff] [blame] | 1188 | xfs_log_force(mp, XFS_LOG_SYNC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | XFS_bflush(mp->m_ddev_targp); |
Christoph Hellwig | a14a348 | 2010-01-19 09:56:46 +0000 | [diff] [blame] | 1190 | xfs_log_force(mp, XFS_LOG_SYNC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | XFS_bflush(mp->m_ddev_targp); |
| 1192 | |
Jes Sorensen | 794ee1b | 2006-01-09 15:59:21 -0800 | [diff] [blame] | 1193 | mutex_lock(&qcheck_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | /* There should be absolutely no quota activity while this |
| 1195 | is going on. */ |
| 1196 | qmtest_udqtab = kmem_zalloc(qmtest_hashmask * |
| 1197 | sizeof(xfs_dqhash_t), KM_SLEEP); |
| 1198 | qmtest_gdqtab = kmem_zalloc(qmtest_hashmask * |
| 1199 | sizeof(xfs_dqhash_t), KM_SLEEP); |
| 1200 | do { |
| 1201 | /* |
| 1202 | * Iterate thru all the inodes in the file system, |
| 1203 | * adjusting the corresponding dquot counters |
| 1204 | */ |
Christoph Hellwig | 7dce11d | 2010-06-23 18:11:11 +1000 | [diff] [blame] | 1205 | error = xfs_bulkstat(mp, &lastino, &count, |
| 1206 | xfs_qm_internalqcheck_adjust, |
| 1207 | 0, NULL, &done); |
| 1208 | if (error) { |
| 1209 | cmn_err(CE_DEBUG, "Bulkstat returned error 0x%x", error); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | break; |
| 1211 | } |
Christoph Hellwig | 7dce11d | 2010-06-23 18:11:11 +1000 | [diff] [blame] | 1212 | } while (!done); |
| 1213 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | cmn_err(CE_DEBUG, "Checking results against system dquots"); |
| 1215 | for (i = 0; i < qmtest_hashmask; i++) { |
Dave Chinner | e6a81f1 | 2010-04-13 15:06:51 +1000 | [diff] [blame] | 1216 | xfs_dqtest_t *d, *n; |
| 1217 | xfs_dqhash_t *h; |
| 1218 | |
| 1219 | h = &qmtest_udqtab[i]; |
| 1220 | list_for_each_entry_safe(d, n, &h->qh_list, q_hashlist) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | xfs_dqtest_cmp(d); |
Denys Vlasenko | f0e2d93 | 2008-05-19 16:31:57 +1000 | [diff] [blame] | 1222 | kmem_free(d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | } |
Dave Chinner | e6a81f1 | 2010-04-13 15:06:51 +1000 | [diff] [blame] | 1224 | h = &qmtest_gdqtab[i]; |
| 1225 | list_for_each_entry_safe(d, n, &h->qh_list, q_hashlist) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | xfs_dqtest_cmp(d); |
Denys Vlasenko | f0e2d93 | 2008-05-19 16:31:57 +1000 | [diff] [blame] | 1227 | kmem_free(d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | if (qmtest_nfails) { |
| 1232 | cmn_err(CE_DEBUG, "******** quotacheck failed ********"); |
| 1233 | cmn_err(CE_DEBUG, "failures = %d", qmtest_nfails); |
| 1234 | } else { |
| 1235 | cmn_err(CE_DEBUG, "******** quotacheck successful! ********"); |
| 1236 | } |
Denys Vlasenko | f0e2d93 | 2008-05-19 16:31:57 +1000 | [diff] [blame] | 1237 | kmem_free(qmtest_udqtab); |
| 1238 | kmem_free(qmtest_gdqtab); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | mutex_unlock(&qcheck_lock); |
| 1240 | return (qmtest_nfails); |
| 1241 | } |
| 1242 | |
| 1243 | #endif /* DEBUG */ |