xfs_dquot.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. /*
  2. * Copyright (c) 2000-2003 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_format.h"
  21. #include "xfs_log_format.h"
  22. #include "xfs_shared.h"
  23. #include "xfs_trans_resv.h"
  24. #include "xfs_bit.h"
  25. #include "xfs_mount.h"
  26. #include "xfs_defer.h"
  27. #include "xfs_inode.h"
  28. #include "xfs_bmap.h"
  29. #include "xfs_bmap_util.h"
  30. #include "xfs_alloc.h"
  31. #include "xfs_quota.h"
  32. #include "xfs_error.h"
  33. #include "xfs_trans.h"
  34. #include "xfs_buf_item.h"
  35. #include "xfs_trans_space.h"
  36. #include "xfs_trans_priv.h"
  37. #include "xfs_qm.h"
  38. #include "xfs_cksum.h"
  39. #include "xfs_trace.h"
  40. #include "xfs_log.h"
  41. #include "xfs_bmap_btree.h"
  42. /*
  43. * Lock order:
  44. *
  45. * ip->i_lock
  46. * qi->qi_tree_lock
  47. * dquot->q_qlock (xfs_dqlock() and friends)
  48. * dquot->q_flush (xfs_dqflock() and friends)
  49. * qi->qi_lru_lock
  50. *
  51. * If two dquots need to be locked the order is user before group/project,
  52. * otherwise by the lowest id first, see xfs_dqlock2.
  53. */
  54. #ifdef DEBUG
  55. xfs_buftarg_t *xfs_dqerror_target;
  56. int xfs_do_dqerror;
  57. int xfs_dqreq_num;
  58. int xfs_dqerror_mod = 33;
  59. #endif
  60. struct kmem_zone *xfs_qm_dqtrxzone;
  61. static struct kmem_zone *xfs_qm_dqzone;
  62. static struct lock_class_key xfs_dquot_group_class;
  63. static struct lock_class_key xfs_dquot_project_class;
  64. /*
  65. * This is called to free all the memory associated with a dquot
  66. */
  67. void
  68. xfs_qm_dqdestroy(
  69. xfs_dquot_t *dqp)
  70. {
  71. ASSERT(list_empty(&dqp->q_lru));
  72. kmem_free(dqp->q_logitem.qli_item.li_lv_shadow);
  73. mutex_destroy(&dqp->q_qlock);
  74. XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
  75. kmem_zone_free(xfs_qm_dqzone, dqp);
  76. }
  77. /*
  78. * If default limits are in force, push them into the dquot now.
  79. * We overwrite the dquot limits only if they are zero and this
  80. * is not the root dquot.
  81. */
  82. void
  83. xfs_qm_adjust_dqlimits(
  84. struct xfs_mount *mp,
  85. struct xfs_dquot *dq)
  86. {
  87. struct xfs_quotainfo *q = mp->m_quotainfo;
  88. struct xfs_disk_dquot *d = &dq->q_core;
  89. struct xfs_def_quota *defq;
  90. int prealloc = 0;
  91. ASSERT(d->d_id);
  92. defq = xfs_get_defquota(dq, q);
  93. if (defq->bsoftlimit && !d->d_blk_softlimit) {
  94. d->d_blk_softlimit = cpu_to_be64(defq->bsoftlimit);
  95. prealloc = 1;
  96. }
  97. if (defq->bhardlimit && !d->d_blk_hardlimit) {
  98. d->d_blk_hardlimit = cpu_to_be64(defq->bhardlimit);
  99. prealloc = 1;
  100. }
  101. if (defq->isoftlimit && !d->d_ino_softlimit)
  102. d->d_ino_softlimit = cpu_to_be64(defq->isoftlimit);
  103. if (defq->ihardlimit && !d->d_ino_hardlimit)
  104. d->d_ino_hardlimit = cpu_to_be64(defq->ihardlimit);
  105. if (defq->rtbsoftlimit && !d->d_rtb_softlimit)
  106. d->d_rtb_softlimit = cpu_to_be64(defq->rtbsoftlimit);
  107. if (defq->rtbhardlimit && !d->d_rtb_hardlimit)
  108. d->d_rtb_hardlimit = cpu_to_be64(defq->rtbhardlimit);
  109. if (prealloc)
  110. xfs_dquot_set_prealloc_limits(dq);
  111. }
  112. /*
  113. * Check the limits and timers of a dquot and start or reset timers
  114. * if necessary.
  115. * This gets called even when quota enforcement is OFF, which makes our
  116. * life a little less complicated. (We just don't reject any quota
  117. * reservations in that case, when enforcement is off).
  118. * We also return 0 as the values of the timers in Q_GETQUOTA calls, when
  119. * enforcement's off.
  120. * In contrast, warnings are a little different in that they don't
  121. * 'automatically' get started when limits get exceeded. They do
  122. * get reset to zero, however, when we find the count to be under
  123. * the soft limit (they are only ever set non-zero via userspace).
  124. */
  125. void
  126. xfs_qm_adjust_dqtimers(
  127. xfs_mount_t *mp,
  128. xfs_disk_dquot_t *d)
  129. {
  130. ASSERT(d->d_id);
  131. #ifdef DEBUG
  132. if (d->d_blk_hardlimit)
  133. ASSERT(be64_to_cpu(d->d_blk_softlimit) <=
  134. be64_to_cpu(d->d_blk_hardlimit));
  135. if (d->d_ino_hardlimit)
  136. ASSERT(be64_to_cpu(d->d_ino_softlimit) <=
  137. be64_to_cpu(d->d_ino_hardlimit));
  138. if (d->d_rtb_hardlimit)
  139. ASSERT(be64_to_cpu(d->d_rtb_softlimit) <=
  140. be64_to_cpu(d->d_rtb_hardlimit));
  141. #endif
  142. if (!d->d_btimer) {
  143. if ((d->d_blk_softlimit &&
  144. (be64_to_cpu(d->d_bcount) >
  145. be64_to_cpu(d->d_blk_softlimit))) ||
  146. (d->d_blk_hardlimit &&
  147. (be64_to_cpu(d->d_bcount) >
  148. be64_to_cpu(d->d_blk_hardlimit)))) {
  149. d->d_btimer = cpu_to_be32(get_seconds() +
  150. mp->m_quotainfo->qi_btimelimit);
  151. } else {
  152. d->d_bwarns = 0;
  153. }
  154. } else {
  155. if ((!d->d_blk_softlimit ||
  156. (be64_to_cpu(d->d_bcount) <=
  157. be64_to_cpu(d->d_blk_softlimit))) &&
  158. (!d->d_blk_hardlimit ||
  159. (be64_to_cpu(d->d_bcount) <=
  160. be64_to_cpu(d->d_blk_hardlimit)))) {
  161. d->d_btimer = 0;
  162. }
  163. }
  164. if (!d->d_itimer) {
  165. if ((d->d_ino_softlimit &&
  166. (be64_to_cpu(d->d_icount) >
  167. be64_to_cpu(d->d_ino_softlimit))) ||
  168. (d->d_ino_hardlimit &&
  169. (be64_to_cpu(d->d_icount) >
  170. be64_to_cpu(d->d_ino_hardlimit)))) {
  171. d->d_itimer = cpu_to_be32(get_seconds() +
  172. mp->m_quotainfo->qi_itimelimit);
  173. } else {
  174. d->d_iwarns = 0;
  175. }
  176. } else {
  177. if ((!d->d_ino_softlimit ||
  178. (be64_to_cpu(d->d_icount) <=
  179. be64_to_cpu(d->d_ino_softlimit))) &&
  180. (!d->d_ino_hardlimit ||
  181. (be64_to_cpu(d->d_icount) <=
  182. be64_to_cpu(d->d_ino_hardlimit)))) {
  183. d->d_itimer = 0;
  184. }
  185. }
  186. if (!d->d_rtbtimer) {
  187. if ((d->d_rtb_softlimit &&
  188. (be64_to_cpu(d->d_rtbcount) >
  189. be64_to_cpu(d->d_rtb_softlimit))) ||
  190. (d->d_rtb_hardlimit &&
  191. (be64_to_cpu(d->d_rtbcount) >
  192. be64_to_cpu(d->d_rtb_hardlimit)))) {
  193. d->d_rtbtimer = cpu_to_be32(get_seconds() +
  194. mp->m_quotainfo->qi_rtbtimelimit);
  195. } else {
  196. d->d_rtbwarns = 0;
  197. }
  198. } else {
  199. if ((!d->d_rtb_softlimit ||
  200. (be64_to_cpu(d->d_rtbcount) <=
  201. be64_to_cpu(d->d_rtb_softlimit))) &&
  202. (!d->d_rtb_hardlimit ||
  203. (be64_to_cpu(d->d_rtbcount) <=
  204. be64_to_cpu(d->d_rtb_hardlimit)))) {
  205. d->d_rtbtimer = 0;
  206. }
  207. }
  208. }
  209. /*
  210. * initialize a buffer full of dquots and log the whole thing
  211. */
  212. STATIC void
  213. xfs_qm_init_dquot_blk(
  214. xfs_trans_t *tp,
  215. xfs_mount_t *mp,
  216. xfs_dqid_t id,
  217. uint type,
  218. xfs_buf_t *bp)
  219. {
  220. struct xfs_quotainfo *q = mp->m_quotainfo;
  221. xfs_dqblk_t *d;
  222. xfs_dqid_t curid;
  223. int i;
  224. ASSERT(tp);
  225. ASSERT(xfs_buf_islocked(bp));
  226. d = bp->b_addr;
  227. /*
  228. * ID of the first dquot in the block - id's are zero based.
  229. */
  230. curid = id - (id % q->qi_dqperchunk);
  231. memset(d, 0, BBTOB(q->qi_dqchunklen));
  232. for (i = 0; i < q->qi_dqperchunk; i++, d++, curid++) {
  233. d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
  234. d->dd_diskdq.d_version = XFS_DQUOT_VERSION;
  235. d->dd_diskdq.d_id = cpu_to_be32(curid);
  236. d->dd_diskdq.d_flags = type;
  237. if (xfs_sb_version_hascrc(&mp->m_sb)) {
  238. uuid_copy(&d->dd_uuid, &mp->m_sb.sb_meta_uuid);
  239. xfs_update_cksum((char *)d, sizeof(struct xfs_dqblk),
  240. XFS_DQUOT_CRC_OFF);
  241. }
  242. }
  243. xfs_trans_dquot_buf(tp, bp,
  244. (type & XFS_DQ_USER ? XFS_BLF_UDQUOT_BUF :
  245. ((type & XFS_DQ_PROJ) ? XFS_BLF_PDQUOT_BUF :
  246. XFS_BLF_GDQUOT_BUF)));
  247. xfs_trans_log_buf(tp, bp, 0, BBTOB(q->qi_dqchunklen) - 1);
  248. }
  249. /*
  250. * Initialize the dynamic speculative preallocation thresholds. The lo/hi
  251. * watermarks correspond to the soft and hard limits by default. If a soft limit
  252. * is not specified, we use 95% of the hard limit.
  253. */
  254. void
  255. xfs_dquot_set_prealloc_limits(struct xfs_dquot *dqp)
  256. {
  257. __uint64_t space;
  258. dqp->q_prealloc_hi_wmark = be64_to_cpu(dqp->q_core.d_blk_hardlimit);
  259. dqp->q_prealloc_lo_wmark = be64_to_cpu(dqp->q_core.d_blk_softlimit);
  260. if (!dqp->q_prealloc_lo_wmark) {
  261. dqp->q_prealloc_lo_wmark = dqp->q_prealloc_hi_wmark;
  262. do_div(dqp->q_prealloc_lo_wmark, 100);
  263. dqp->q_prealloc_lo_wmark *= 95;
  264. }
  265. space = dqp->q_prealloc_hi_wmark;
  266. do_div(space, 100);
  267. dqp->q_low_space[XFS_QLOWSP_1_PCNT] = space;
  268. dqp->q_low_space[XFS_QLOWSP_3_PCNT] = space * 3;
  269. dqp->q_low_space[XFS_QLOWSP_5_PCNT] = space * 5;
  270. }
  271. /*
  272. * Allocate a block and fill it with dquots.
  273. * This is called when the bmapi finds a hole.
  274. */
  275. STATIC int
  276. xfs_qm_dqalloc(
  277. xfs_trans_t **tpp,
  278. xfs_mount_t *mp,
  279. xfs_dquot_t *dqp,
  280. xfs_inode_t *quotip,
  281. xfs_fileoff_t offset_fsb,
  282. xfs_buf_t **O_bpp)
  283. {
  284. xfs_fsblock_t firstblock;
  285. struct xfs_defer_ops dfops;
  286. xfs_bmbt_irec_t map;
  287. int nmaps, error;
  288. xfs_buf_t *bp;
  289. xfs_trans_t *tp = *tpp;
  290. ASSERT(tp != NULL);
  291. trace_xfs_dqalloc(dqp);
  292. /*
  293. * Initialize the bmap freelist prior to calling bmapi code.
  294. */
  295. xfs_defer_init(&dfops, &firstblock);
  296. xfs_ilock(quotip, XFS_ILOCK_EXCL);
  297. /*
  298. * Return if this type of quotas is turned off while we didn't
  299. * have an inode lock
  300. */
  301. if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
  302. xfs_iunlock(quotip, XFS_ILOCK_EXCL);
  303. return -ESRCH;
  304. }
  305. xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
  306. nmaps = 1;
  307. error = xfs_bmapi_write(tp, quotip, offset_fsb,
  308. XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
  309. &firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
  310. &map, &nmaps, &dfops);
  311. if (error)
  312. goto error0;
  313. ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB);
  314. ASSERT(nmaps == 1);
  315. ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
  316. (map.br_startblock != HOLESTARTBLOCK));
  317. /*
  318. * Keep track of the blkno to save a lookup later
  319. */
  320. dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);
  321. /* now we can just get the buffer (there's nothing to read yet) */
  322. bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
  323. dqp->q_blkno,
  324. mp->m_quotainfo->qi_dqchunklen,
  325. 0);
  326. if (!bp) {
  327. error = -ENOMEM;
  328. goto error1;
  329. }
  330. bp->b_ops = &xfs_dquot_buf_ops;
  331. /*
  332. * Make a chunk of dquots out of this buffer and log
  333. * the entire thing.
  334. */
  335. xfs_qm_init_dquot_blk(tp, mp, be32_to_cpu(dqp->q_core.d_id),
  336. dqp->dq_flags & XFS_DQ_ALLTYPES, bp);
  337. /*
  338. * xfs_defer_finish() may commit the current transaction and
  339. * start a second transaction if the freelist is not empty.
  340. *
  341. * Since we still want to modify this buffer, we need to
  342. * ensure that the buffer is not released on commit of
  343. * the first transaction and ensure the buffer is added to the
  344. * second transaction.
  345. *
  346. * If there is only one transaction then don't stop the buffer
  347. * from being released when it commits later on.
  348. */
  349. xfs_trans_bhold(tp, bp);
  350. error = xfs_defer_finish(tpp, &dfops, NULL);
  351. if (error)
  352. goto error1;
  353. /* Transaction was committed? */
  354. if (*tpp != tp) {
  355. tp = *tpp;
  356. xfs_trans_bjoin(tp, bp);
  357. } else {
  358. xfs_trans_bhold_release(tp, bp);
  359. }
  360. *O_bpp = bp;
  361. return 0;
  362. error1:
  363. xfs_defer_cancel(&dfops);
  364. error0:
  365. xfs_iunlock(quotip, XFS_ILOCK_EXCL);
  366. return error;
  367. }
  368. STATIC int
  369. xfs_qm_dqrepair(
  370. struct xfs_mount *mp,
  371. struct xfs_trans *tp,
  372. struct xfs_dquot *dqp,
  373. xfs_dqid_t firstid,
  374. struct xfs_buf **bpp)
  375. {
  376. int error;
  377. struct xfs_disk_dquot *ddq;
  378. struct xfs_dqblk *d;
  379. int i;
  380. /*
  381. * Read the buffer without verification so we get the corrupted
  382. * buffer returned to us. make sure we verify it on write, though.
  383. */
  384. error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, dqp->q_blkno,
  385. mp->m_quotainfo->qi_dqchunklen,
  386. 0, bpp, NULL);
  387. if (error) {
  388. ASSERT(*bpp == NULL);
  389. return error;
  390. }
  391. (*bpp)->b_ops = &xfs_dquot_buf_ops;
  392. ASSERT(xfs_buf_islocked(*bpp));
  393. d = (struct xfs_dqblk *)(*bpp)->b_addr;
  394. /* Do the actual repair of dquots in this buffer */
  395. for (i = 0; i < mp->m_quotainfo->qi_dqperchunk; i++) {
  396. ddq = &d[i].dd_diskdq;
  397. error = xfs_dqcheck(mp, ddq, firstid + i,
  398. dqp->dq_flags & XFS_DQ_ALLTYPES,
  399. XFS_QMOPT_DQREPAIR, "xfs_qm_dqrepair");
  400. if (error) {
  401. /* repair failed, we're screwed */
  402. xfs_trans_brelse(tp, *bpp);
  403. return -EIO;
  404. }
  405. }
  406. return 0;
  407. }
  408. /*
  409. * Maps a dquot to the buffer containing its on-disk version.
  410. * This returns a ptr to the buffer containing the on-disk dquot
  411. * in the bpp param, and a ptr to the on-disk dquot within that buffer
  412. */
  413. STATIC int
  414. xfs_qm_dqtobp(
  415. xfs_trans_t **tpp,
  416. xfs_dquot_t *dqp,
  417. xfs_disk_dquot_t **O_ddpp,
  418. xfs_buf_t **O_bpp,
  419. uint flags)
  420. {
  421. struct xfs_bmbt_irec map;
  422. int nmaps = 1, error;
  423. struct xfs_buf *bp;
  424. struct xfs_inode *quotip;
  425. struct xfs_mount *mp = dqp->q_mount;
  426. xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id);
  427. struct xfs_trans *tp = (tpp ? *tpp : NULL);
  428. uint lock_mode;
  429. quotip = xfs_quota_inode(dqp->q_mount, dqp->dq_flags);
  430. dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk;
  431. lock_mode = xfs_ilock_data_map_shared(quotip);
  432. if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
  433. /*
  434. * Return if this type of quotas is turned off while we
  435. * didn't have the quota inode lock.
  436. */
  437. xfs_iunlock(quotip, lock_mode);
  438. return -ESRCH;
  439. }
  440. /*
  441. * Find the block map; no allocations yet
  442. */
  443. error = xfs_bmapi_read(quotip, dqp->q_fileoffset,
  444. XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0);
  445. xfs_iunlock(quotip, lock_mode);
  446. if (error)
  447. return error;
  448. ASSERT(nmaps == 1);
  449. ASSERT(map.br_blockcount == 1);
  450. /*
  451. * Offset of dquot in the (fixed sized) dquot chunk.
  452. */
  453. dqp->q_bufoffset = (id % mp->m_quotainfo->qi_dqperchunk) *
  454. sizeof(xfs_dqblk_t);
  455. ASSERT(map.br_startblock != DELAYSTARTBLOCK);
  456. if (map.br_startblock == HOLESTARTBLOCK) {
  457. /*
  458. * We don't allocate unless we're asked to
  459. */
  460. if (!(flags & XFS_QMOPT_DQALLOC))
  461. return -ENOENT;
  462. ASSERT(tp);
  463. error = xfs_qm_dqalloc(tpp, mp, dqp, quotip,
  464. dqp->q_fileoffset, &bp);
  465. if (error)
  466. return error;
  467. tp = *tpp;
  468. } else {
  469. trace_xfs_dqtobp_read(dqp);
  470. /*
  471. * store the blkno etc so that we don't have to do the
  472. * mapping all the time
  473. */
  474. dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);
  475. error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
  476. dqp->q_blkno,
  477. mp->m_quotainfo->qi_dqchunklen,
  478. 0, &bp, &xfs_dquot_buf_ops);
  479. if (error == -EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {
  480. xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *
  481. mp->m_quotainfo->qi_dqperchunk;
  482. ASSERT(bp == NULL);
  483. error = xfs_qm_dqrepair(mp, tp, dqp, firstid, &bp);
  484. }
  485. if (error) {
  486. ASSERT(bp == NULL);
  487. return error;
  488. }
  489. }
  490. ASSERT(xfs_buf_islocked(bp));
  491. *O_bpp = bp;
  492. *O_ddpp = bp->b_addr + dqp->q_bufoffset;
  493. return 0;
  494. }
  495. /*
  496. * Read in the ondisk dquot using dqtobp() then copy it to an incore version,
  497. * and release the buffer immediately.
  498. *
  499. * If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
  500. */
  501. int
  502. xfs_qm_dqread(
  503. struct xfs_mount *mp,
  504. xfs_dqid_t id,
  505. uint type,
  506. uint flags,
  507. struct xfs_dquot **O_dqpp)
  508. {
  509. struct xfs_dquot *dqp;
  510. struct xfs_disk_dquot *ddqp;
  511. struct xfs_buf *bp;
  512. struct xfs_trans *tp = NULL;
  513. int error;
  514. dqp = kmem_zone_zalloc(xfs_qm_dqzone, KM_SLEEP);
  515. dqp->dq_flags = type;
  516. dqp->q_core.d_id = cpu_to_be32(id);
  517. dqp->q_mount = mp;
  518. INIT_LIST_HEAD(&dqp->q_lru);
  519. mutex_init(&dqp->q_qlock);
  520. init_waitqueue_head(&dqp->q_pinwait);
  521. /*
  522. * Because we want to use a counting completion, complete
  523. * the flush completion once to allow a single access to
  524. * the flush completion without blocking.
  525. */
  526. init_completion(&dqp->q_flush);
  527. complete(&dqp->q_flush);
  528. /*
  529. * Make sure group quotas have a different lock class than user
  530. * quotas.
  531. */
  532. switch (type) {
  533. case XFS_DQ_USER:
  534. /* uses the default lock class */
  535. break;
  536. case XFS_DQ_GROUP:
  537. lockdep_set_class(&dqp->q_qlock, &xfs_dquot_group_class);
  538. break;
  539. case XFS_DQ_PROJ:
  540. lockdep_set_class(&dqp->q_qlock, &xfs_dquot_project_class);
  541. break;
  542. default:
  543. ASSERT(0);
  544. break;
  545. }
  546. XFS_STATS_INC(mp, xs_qm_dquot);
  547. trace_xfs_dqread(dqp);
  548. if (flags & XFS_QMOPT_DQALLOC) {
  549. error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_dqalloc,
  550. XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
  551. if (error)
  552. goto error0;
  553. }
  554. /*
  555. * get a pointer to the on-disk dquot and the buffer containing it
  556. * dqp already knows its own type (GROUP/USER).
  557. */
  558. error = xfs_qm_dqtobp(&tp, dqp, &ddqp, &bp, flags);
  559. if (error) {
  560. /*
  561. * This can happen if quotas got turned off (ESRCH),
  562. * or if the dquot didn't exist on disk and we ask to
  563. * allocate (ENOENT).
  564. */
  565. trace_xfs_dqread_fail(dqp);
  566. goto error1;
  567. }
  568. /* copy everything from disk dquot to the incore dquot */
  569. memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
  570. xfs_qm_dquot_logitem_init(dqp);
  571. /*
  572. * Reservation counters are defined as reservation plus current usage
  573. * to avoid having to add every time.
  574. */
  575. dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
  576. dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
  577. dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
  578. /* initialize the dquot speculative prealloc thresholds */
  579. xfs_dquot_set_prealloc_limits(dqp);
  580. /* Mark the buf so that this will stay incore a little longer */
  581. xfs_buf_set_ref(bp, XFS_DQUOT_REF);
  582. /*
  583. * We got the buffer with a xfs_trans_read_buf() (in dqtobp())
  584. * So we need to release with xfs_trans_brelse().
  585. * The strategy here is identical to that of inodes; we lock
  586. * the dquot in xfs_qm_dqget() before making it accessible to
  587. * others. This is because dquots, like inodes, need a good level of
  588. * concurrency, and we don't want to take locks on the entire buffers
  589. * for dquot accesses.
  590. * Note also that the dquot buffer may even be dirty at this point, if
  591. * this particular dquot was repaired. We still aren't afraid to
  592. * brelse it because we have the changes incore.
  593. */
  594. ASSERT(xfs_buf_islocked(bp));
  595. xfs_trans_brelse(tp, bp);
  596. if (tp) {
  597. error = xfs_trans_commit(tp);
  598. if (error)
  599. goto error0;
  600. }
  601. *O_dqpp = dqp;
  602. return error;
  603. error1:
  604. if (tp)
  605. xfs_trans_cancel(tp);
  606. error0:
  607. xfs_qm_dqdestroy(dqp);
  608. *O_dqpp = NULL;
  609. return error;
  610. }
  611. /*
  612. * Advance to the next id in the current chunk, or if at the
  613. * end of the chunk, skip ahead to first id in next allocated chunk
  614. * using the SEEK_DATA interface.
  615. */
  616. static int
  617. xfs_dq_get_next_id(
  618. xfs_mount_t *mp,
  619. uint type,
  620. xfs_dqid_t *id,
  621. loff_t eof)
  622. {
  623. struct xfs_inode *quotip;
  624. xfs_fsblock_t start;
  625. loff_t offset;
  626. uint lock;
  627. xfs_dqid_t next_id;
  628. int error = 0;
  629. /* Simple advance */
  630. next_id = *id + 1;
  631. /* If new ID is within the current chunk, advancing it sufficed */
  632. if (next_id % mp->m_quotainfo->qi_dqperchunk) {
  633. *id = next_id;
  634. return 0;
  635. }
  636. /* Nope, next_id is now past the current chunk, so find the next one */
  637. start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;
  638. quotip = xfs_quota_inode(mp, type);
  639. lock = xfs_ilock_data_map_shared(quotip);
  640. offset = __xfs_seek_hole_data(VFS_I(quotip), XFS_FSB_TO_B(mp, start),
  641. eof, SEEK_DATA);
  642. if (offset < 0)
  643. error = offset;
  644. xfs_iunlock(quotip, lock);
  645. /* -ENXIO is essentially "no more data" */
  646. if (error)
  647. return (error == -ENXIO ? -ENOENT: error);
  648. /* Convert next data offset back to a quota id */
  649. *id = XFS_B_TO_FSB(mp, offset) * mp->m_quotainfo->qi_dqperchunk;
  650. return 0;
  651. }
  652. /*
  653. * Given the file system, inode OR id, and type (UDQUOT/GDQUOT), return a
  654. * a locked dquot, doing an allocation (if requested) as needed.
  655. * When both an inode and an id are given, the inode's id takes precedence.
  656. * That is, if the id changes while we don't hold the ilock inside this
  657. * function, the new dquot is returned, not necessarily the one requested
  658. * in the id argument.
  659. */
  660. int
  661. xfs_qm_dqget(
  662. xfs_mount_t *mp,
  663. xfs_inode_t *ip, /* locked inode (optional) */
  664. xfs_dqid_t id, /* uid/projid/gid depending on type */
  665. uint type, /* XFS_DQ_USER/XFS_DQ_PROJ/XFS_DQ_GROUP */
  666. uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */
  667. xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */
  668. {
  669. struct xfs_quotainfo *qi = mp->m_quotainfo;
  670. struct radix_tree_root *tree = xfs_dquot_tree(qi, type);
  671. struct xfs_dquot *dqp;
  672. loff_t eof = 0;
  673. int error;
  674. ASSERT(XFS_IS_QUOTA_RUNNING(mp));
  675. if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) ||
  676. (! XFS_IS_PQUOTA_ON(mp) && type == XFS_DQ_PROJ) ||
  677. (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) {
  678. return -ESRCH;
  679. }
  680. #ifdef DEBUG
  681. if (xfs_do_dqerror) {
  682. if ((xfs_dqerror_target == mp->m_ddev_targp) &&
  683. (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) {
  684. xfs_debug(mp, "Returning error in dqget");
  685. return -EIO;
  686. }
  687. }
  688. ASSERT(type == XFS_DQ_USER ||
  689. type == XFS_DQ_PROJ ||
  690. type == XFS_DQ_GROUP);
  691. if (ip) {
  692. ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
  693. ASSERT(xfs_inode_dquot(ip, type) == NULL);
  694. }
  695. #endif
  696. /* Get the end of the quota file if we need it */
  697. if (flags & XFS_QMOPT_DQNEXT) {
  698. struct xfs_inode *quotip;
  699. xfs_fileoff_t last;
  700. uint lock_mode;
  701. quotip = xfs_quota_inode(mp, type);
  702. lock_mode = xfs_ilock_data_map_shared(quotip);
  703. error = xfs_bmap_last_offset(quotip, &last, XFS_DATA_FORK);
  704. xfs_iunlock(quotip, lock_mode);
  705. if (error)
  706. return error;
  707. eof = XFS_FSB_TO_B(mp, last);
  708. }
  709. restart:
  710. mutex_lock(&qi->qi_tree_lock);
  711. dqp = radix_tree_lookup(tree, id);
  712. if (dqp) {
  713. xfs_dqlock(dqp);
  714. if (dqp->dq_flags & XFS_DQ_FREEING) {
  715. xfs_dqunlock(dqp);
  716. mutex_unlock(&qi->qi_tree_lock);
  717. trace_xfs_dqget_freeing(dqp);
  718. delay(1);
  719. goto restart;
  720. }
  721. /* uninit / unused quota found in radix tree, keep looking */
  722. if (flags & XFS_QMOPT_DQNEXT) {
  723. if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
  724. xfs_dqunlock(dqp);
  725. mutex_unlock(&qi->qi_tree_lock);
  726. error = xfs_dq_get_next_id(mp, type, &id, eof);
  727. if (error)
  728. return error;
  729. goto restart;
  730. }
  731. }
  732. dqp->q_nrefs++;
  733. mutex_unlock(&qi->qi_tree_lock);
  734. trace_xfs_dqget_hit(dqp);
  735. XFS_STATS_INC(mp, xs_qm_dqcachehits);
  736. *O_dqpp = dqp;
  737. return 0;
  738. }
  739. mutex_unlock(&qi->qi_tree_lock);
  740. XFS_STATS_INC(mp, xs_qm_dqcachemisses);
  741. /*
  742. * Dquot cache miss. We don't want to keep the inode lock across
  743. * a (potential) disk read. Also we don't want to deal with the lock
  744. * ordering between quotainode and this inode. OTOH, dropping the inode
  745. * lock here means dealing with a chown that can happen before
  746. * we re-acquire the lock.
  747. */
  748. if (ip)
  749. xfs_iunlock(ip, XFS_ILOCK_EXCL);
  750. error = xfs_qm_dqread(mp, id, type, flags, &dqp);
  751. if (ip)
  752. xfs_ilock(ip, XFS_ILOCK_EXCL);
  753. /* If we are asked to find next active id, keep looking */
  754. if (error == -ENOENT && (flags & XFS_QMOPT_DQNEXT)) {
  755. error = xfs_dq_get_next_id(mp, type, &id, eof);
  756. if (!error)
  757. goto restart;
  758. }
  759. if (error)
  760. return error;
  761. if (ip) {
  762. /*
  763. * A dquot could be attached to this inode by now, since
  764. * we had dropped the ilock.
  765. */
  766. if (xfs_this_quota_on(mp, type)) {
  767. struct xfs_dquot *dqp1;
  768. dqp1 = xfs_inode_dquot(ip, type);
  769. if (dqp1) {
  770. xfs_qm_dqdestroy(dqp);
  771. dqp = dqp1;
  772. xfs_dqlock(dqp);
  773. goto dqret;
  774. }
  775. } else {
  776. /* inode stays locked on return */
  777. xfs_qm_dqdestroy(dqp);
  778. return -ESRCH;
  779. }
  780. }
  781. mutex_lock(&qi->qi_tree_lock);
  782. error = radix_tree_insert(tree, id, dqp);
  783. if (unlikely(error)) {
  784. WARN_ON(error != -EEXIST);
  785. /*
  786. * Duplicate found. Just throw away the new dquot and start
  787. * over.
  788. */
  789. mutex_unlock(&qi->qi_tree_lock);
  790. trace_xfs_dqget_dup(dqp);
  791. xfs_qm_dqdestroy(dqp);
  792. XFS_STATS_INC(mp, xs_qm_dquot_dups);
  793. goto restart;
  794. }
  795. /*
  796. * We return a locked dquot to the caller, with a reference taken
  797. */
  798. xfs_dqlock(dqp);
  799. dqp->q_nrefs = 1;
  800. qi->qi_dquots++;
  801. mutex_unlock(&qi->qi_tree_lock);
  802. /* If we are asked to find next active id, keep looking */
  803. if (flags & XFS_QMOPT_DQNEXT) {
  804. if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
  805. xfs_qm_dqput(dqp);
  806. error = xfs_dq_get_next_id(mp, type, &id, eof);
  807. if (error)
  808. return error;
  809. goto restart;
  810. }
  811. }
  812. dqret:
  813. ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL));
  814. trace_xfs_dqget_miss(dqp);
  815. *O_dqpp = dqp;
  816. return 0;
  817. }
  818. /*
  819. * Release a reference to the dquot (decrement ref-count) and unlock it.
  820. *
  821. * If there is a group quota attached to this dquot, carefully release that
  822. * too without tripping over deadlocks'n'stuff.
  823. */
  824. void
  825. xfs_qm_dqput(
  826. struct xfs_dquot *dqp)
  827. {
  828. ASSERT(dqp->q_nrefs > 0);
  829. ASSERT(XFS_DQ_IS_LOCKED(dqp));
  830. trace_xfs_dqput(dqp);
  831. if (--dqp->q_nrefs == 0) {
  832. struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo;
  833. trace_xfs_dqput_free(dqp);
  834. if (list_lru_add(&qi->qi_lru, &dqp->q_lru))
  835. XFS_STATS_INC(dqp->q_mount, xs_qm_dquot_unused);
  836. }
  837. xfs_dqunlock(dqp);
  838. }
  839. /*
  840. * Release a dquot. Flush it if dirty, then dqput() it.
  841. * dquot must not be locked.
  842. */
  843. void
  844. xfs_qm_dqrele(
  845. xfs_dquot_t *dqp)
  846. {
  847. if (!dqp)
  848. return;
  849. trace_xfs_dqrele(dqp);
  850. xfs_dqlock(dqp);
  851. /*
  852. * We don't care to flush it if the dquot is dirty here.
  853. * That will create stutters that we want to avoid.
  854. * Instead we do a delayed write when we try to reclaim
  855. * a dirty dquot. Also xfs_sync will take part of the burden...
  856. */
  857. xfs_qm_dqput(dqp);
  858. }
  859. /*
  860. * This is the dquot flushing I/O completion routine. It is called
  861. * from interrupt level when the buffer containing the dquot is
  862. * flushed to disk. It is responsible for removing the dquot logitem
  863. * from the AIL if it has not been re-logged, and unlocking the dquot's
  864. * flush lock. This behavior is very similar to that of inodes..
  865. */
  866. STATIC void
  867. xfs_qm_dqflush_done(
  868. struct xfs_buf *bp,
  869. struct xfs_log_item *lip)
  870. {
  871. xfs_dq_logitem_t *qip = (struct xfs_dq_logitem *)lip;
  872. xfs_dquot_t *dqp = qip->qli_dquot;
  873. struct xfs_ail *ailp = lip->li_ailp;
  874. /*
  875. * We only want to pull the item from the AIL if its
  876. * location in the log has not changed since we started the flush.
  877. * Thus, we only bother if the dquot's lsn has
  878. * not changed. First we check the lsn outside the lock
  879. * since it's cheaper, and then we recheck while
  880. * holding the lock before removing the dquot from the AIL.
  881. */
  882. if ((lip->li_flags & XFS_LI_IN_AIL) &&
  883. lip->li_lsn == qip->qli_flush_lsn) {
  884. /* xfs_trans_ail_delete() drops the AIL lock. */
  885. spin_lock(&ailp->xa_lock);
  886. if (lip->li_lsn == qip->qli_flush_lsn)
  887. xfs_trans_ail_delete(ailp, lip, SHUTDOWN_CORRUPT_INCORE);
  888. else
  889. spin_unlock(&ailp->xa_lock);
  890. }
  891. /*
  892. * Release the dq's flush lock since we're done with it.
  893. */
  894. xfs_dqfunlock(dqp);
  895. }
  896. /*
  897. * Write a modified dquot to disk.
  898. * The dquot must be locked and the flush lock too taken by caller.
  899. * The flush lock will not be unlocked until the dquot reaches the disk,
  900. * but the dquot is free to be unlocked and modified by the caller
  901. * in the interim. Dquot is still locked on return. This behavior is
  902. * identical to that of inodes.
  903. */
  904. int
  905. xfs_qm_dqflush(
  906. struct xfs_dquot *dqp,
  907. struct xfs_buf **bpp)
  908. {
  909. struct xfs_mount *mp = dqp->q_mount;
  910. struct xfs_buf *bp;
  911. struct xfs_disk_dquot *ddqp;
  912. int error;
  913. ASSERT(XFS_DQ_IS_LOCKED(dqp));
  914. ASSERT(!completion_done(&dqp->q_flush));
  915. trace_xfs_dqflush(dqp);
  916. *bpp = NULL;
  917. xfs_qm_dqunpin_wait(dqp);
  918. /*
  919. * This may have been unpinned because the filesystem is shutting
  920. * down forcibly. If that's the case we must not write this dquot
  921. * to disk, because the log record didn't make it to disk.
  922. *
  923. * We also have to remove the log item from the AIL in this case,
  924. * as we wait for an emptry AIL as part of the unmount process.
  925. */
  926. if (XFS_FORCED_SHUTDOWN(mp)) {
  927. struct xfs_log_item *lip = &dqp->q_logitem.qli_item;
  928. dqp->dq_flags &= ~XFS_DQ_DIRTY;
  929. xfs_trans_ail_remove(lip, SHUTDOWN_CORRUPT_INCORE);
  930. error = -EIO;
  931. goto out_unlock;
  932. }
  933. /*
  934. * Get the buffer containing the on-disk dquot
  935. */
  936. error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
  937. mp->m_quotainfo->qi_dqchunklen, 0, &bp,
  938. &xfs_dquot_buf_ops);
  939. if (error)
  940. goto out_unlock;
  941. /*
  942. * Calculate the location of the dquot inside the buffer.
  943. */
  944. ddqp = bp->b_addr + dqp->q_bufoffset;
  945. /*
  946. * A simple sanity check in case we got a corrupted dquot..
  947. */
  948. error = xfs_dqcheck(mp, &dqp->q_core, be32_to_cpu(ddqp->d_id), 0,
  949. XFS_QMOPT_DOWARN, "dqflush (incore copy)");
  950. if (error) {
  951. xfs_buf_relse(bp);
  952. xfs_dqfunlock(dqp);
  953. xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
  954. return -EIO;
  955. }
  956. /* This is the only portion of data that needs to persist */
  957. memcpy(ddqp, &dqp->q_core, sizeof(xfs_disk_dquot_t));
  958. /*
  959. * Clear the dirty field and remember the flush lsn for later use.
  960. */
  961. dqp->dq_flags &= ~XFS_DQ_DIRTY;
  962. xfs_trans_ail_copy_lsn(mp->m_ail, &dqp->q_logitem.qli_flush_lsn,
  963. &dqp->q_logitem.qli_item.li_lsn);
  964. /*
  965. * copy the lsn into the on-disk dquot now while we have the in memory
  966. * dquot here. This can't be done later in the write verifier as we
  967. * can't get access to the log item at that point in time.
  968. *
  969. * We also calculate the CRC here so that the on-disk dquot in the
  970. * buffer always has a valid CRC. This ensures there is no possibility
  971. * of a dquot without an up-to-date CRC getting to disk.
  972. */
  973. if (xfs_sb_version_hascrc(&mp->m_sb)) {
  974. struct xfs_dqblk *dqb = (struct xfs_dqblk *)ddqp;
  975. dqb->dd_lsn = cpu_to_be64(dqp->q_logitem.qli_item.li_lsn);
  976. xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
  977. XFS_DQUOT_CRC_OFF);
  978. }
  979. /*
  980. * Attach an iodone routine so that we can remove this dquot from the
  981. * AIL and release the flush lock once the dquot is synced to disk.
  982. */
  983. xfs_buf_attach_iodone(bp, xfs_qm_dqflush_done,
  984. &dqp->q_logitem.qli_item);
  985. /*
  986. * If the buffer is pinned then push on the log so we won't
  987. * get stuck waiting in the write for too long.
  988. */
  989. if (xfs_buf_ispinned(bp)) {
  990. trace_xfs_dqflush_force(dqp);
  991. xfs_log_force(mp, 0);
  992. }
  993. trace_xfs_dqflush_done(dqp);
  994. *bpp = bp;
  995. return 0;
  996. out_unlock:
  997. xfs_dqfunlock(dqp);
  998. return -EIO;
  999. }
  1000. /*
  1001. * Lock two xfs_dquot structures.
  1002. *
  1003. * To avoid deadlocks we always lock the quota structure with
  1004. * the lowerd id first.
  1005. */
  1006. void
  1007. xfs_dqlock2(
  1008. xfs_dquot_t *d1,
  1009. xfs_dquot_t *d2)
  1010. {
  1011. if (d1 && d2) {
  1012. ASSERT(d1 != d2);
  1013. if (be32_to_cpu(d1->q_core.d_id) >
  1014. be32_to_cpu(d2->q_core.d_id)) {
  1015. mutex_lock(&d2->q_qlock);
  1016. mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
  1017. } else {
  1018. mutex_lock(&d1->q_qlock);
  1019. mutex_lock_nested(&d2->q_qlock, XFS_QLOCK_NESTED);
  1020. }
  1021. } else if (d1) {
  1022. mutex_lock(&d1->q_qlock);
  1023. } else if (d2) {
  1024. mutex_lock(&d2->q_qlock);
  1025. }
  1026. }
  1027. int __init
  1028. xfs_qm_init(void)
  1029. {
  1030. xfs_qm_dqzone =
  1031. kmem_zone_init(sizeof(struct xfs_dquot), "xfs_dquot");
  1032. if (!xfs_qm_dqzone)
  1033. goto out;
  1034. xfs_qm_dqtrxzone =
  1035. kmem_zone_init(sizeof(struct xfs_dquot_acct), "xfs_dqtrx");
  1036. if (!xfs_qm_dqtrxzone)
  1037. goto out_free_dqzone;
  1038. return 0;
  1039. out_free_dqzone:
  1040. kmem_zone_destroy(xfs_qm_dqzone);
  1041. out:
  1042. return -ENOMEM;
  1043. }
  1044. void
  1045. xfs_qm_exit(void)
  1046. {
  1047. kmem_zone_destroy(xfs_qm_dqtrxzone);
  1048. kmem_zone_destroy(xfs_qm_dqzone);
  1049. }