xfs_qmops.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. #include "xfs_fs.h"
  20. #include "xfs_types.h"
  21. #include "xfs_log.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_trans.h"
  24. #include "xfs_sb.h"
  25. #include "xfs_ag.h"
  26. #include "xfs_dir2.h"
  27. #include "xfs_dmapi.h"
  28. #include "xfs_mount.h"
  29. #include "xfs_quota.h"
  30. #include "xfs_error.h"
  31. STATIC struct xfs_dquot *
  32. xfs_dqvopchown_default(
  33. struct xfs_trans *tp,
  34. struct xfs_inode *ip,
  35. struct xfs_dquot **dqp,
  36. struct xfs_dquot *dq)
  37. {
  38. return NULL;
  39. }
  40. /*
  41. * Clear the quotaflags in memory and in the superblock.
  42. */
  43. int
  44. xfs_mount_reset_sbqflags(xfs_mount_t *mp)
  45. {
  46. int error;
  47. xfs_trans_t *tp;
  48. mp->m_qflags = 0;
  49. /*
  50. * It is OK to look at sb_qflags here in mount path,
  51. * without m_sb_lock.
  52. */
  53. if (mp->m_sb.sb_qflags == 0)
  54. return 0;
  55. spin_lock(&mp->m_sb_lock);
  56. mp->m_sb.sb_qflags = 0;
  57. spin_unlock(&mp->m_sb_lock);
  58. /*
  59. * if the fs is readonly, let the incore superblock run
  60. * with quotas off but don't flush the update out to disk
  61. */
  62. if (mp->m_flags & XFS_MOUNT_RDONLY)
  63. return 0;
  64. #ifdef QUOTADEBUG
  65. xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
  66. #endif
  67. tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
  68. if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
  69. XFS_DEFAULT_LOG_COUNT))) {
  70. xfs_trans_cancel(tp, 0);
  71. xfs_fs_cmn_err(CE_ALERT, mp,
  72. "xfs_mount_reset_sbqflags: Superblock update failed!");
  73. return error;
  74. }
  75. xfs_mod_sb(tp, XFS_SB_QFLAGS);
  76. error = xfs_trans_commit(tp, 0);
  77. return error;
  78. }
  79. STATIC int
  80. xfs_noquota_init(
  81. xfs_mount_t *mp,
  82. uint *needquotamount,
  83. uint *quotaflags)
  84. {
  85. int error = 0;
  86. *quotaflags = 0;
  87. *needquotamount = B_FALSE;
  88. ASSERT(!XFS_IS_QUOTA_ON(mp));
  89. /*
  90. * If a file system had quotas running earlier, but decided to
  91. * mount without -o uquota/pquota/gquota options, revoke the
  92. * quotachecked license.
  93. */
  94. if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
  95. cmn_err(CE_NOTE,
  96. "XFS resetting qflags for filesystem %s",
  97. mp->m_fsname);
  98. error = xfs_mount_reset_sbqflags(mp);
  99. }
  100. return error;
  101. }
  102. static struct xfs_qmops xfs_qmcore_stub = {
  103. .xfs_qminit = (xfs_qminit_t) xfs_noquota_init,
  104. .xfs_qmdone = (xfs_qmdone_t) fs_noerr,
  105. .xfs_qmmount = (xfs_qmmount_t) fs_noerr,
  106. .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr,
  107. .xfs_dqrele = (xfs_dqrele_t) fs_noerr,
  108. .xfs_dqattach = (xfs_dqattach_t) fs_noerr,
  109. .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr,
  110. .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr,
  111. .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr,
  112. .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr,
  113. .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr,
  114. .xfs_dqvopchown = xfs_dqvopchown_default,
  115. .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr,
  116. .xfs_dqstatvfs = (xfs_dqstatvfs_t) fs_noval,
  117. .xfs_dqsync = (xfs_dqsync_t) fs_noerr,
  118. };
  119. int
  120. xfs_qmops_get(struct xfs_mount *mp)
  121. {
  122. if (XFS_IS_QUOTA_RUNNING(mp)) {
  123. #ifdef CONFIG_XFS_QUOTA
  124. mp->m_qm_ops = &xfs_qmcore_xfs;
  125. #else
  126. cmn_err(CE_WARN,
  127. "XFS: qouta support not available in this kernel.");
  128. return EINVAL;
  129. #endif
  130. } else {
  131. mp->m_qm_ops = &xfs_qmcore_stub;
  132. }
  133. return 0;
  134. }
  135. void
  136. xfs_qmops_put(struct xfs_mount *mp)
  137. {
  138. }