xfs_qmops.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #include "xfs.h"
  33. #include "xfs_macros.h"
  34. #include "xfs_types.h"
  35. #include "xfs_inum.h"
  36. #include "xfs_log.h"
  37. #include "xfs_trans.h"
  38. #include "xfs_sb.h"
  39. #include "xfs_ag.h"
  40. #include "xfs_dir.h"
  41. #include "xfs_dir2.h"
  42. #include "xfs_dmapi.h"
  43. #include "xfs_mount.h"
  44. #include "xfs_quota.h"
  45. #include "xfs_error.h"
  46. STATIC struct xfs_dquot *
  47. xfs_dqvopchown_default(
  48. struct xfs_trans *tp,
  49. struct xfs_inode *ip,
  50. struct xfs_dquot **dqp,
  51. struct xfs_dquot *dq)
  52. {
  53. return NULL;
  54. }
  55. /*
  56. * Clear the quotaflags in memory and in the superblock.
  57. */
  58. int
  59. xfs_mount_reset_sbqflags(xfs_mount_t *mp)
  60. {
  61. int error;
  62. xfs_trans_t *tp;
  63. unsigned long s;
  64. mp->m_qflags = 0;
  65. /*
  66. * It is OK to look at sb_qflags here in mount path,
  67. * without SB_LOCK.
  68. */
  69. if (mp->m_sb.sb_qflags == 0)
  70. return 0;
  71. s = XFS_SB_LOCK(mp);
  72. mp->m_sb.sb_qflags = 0;
  73. XFS_SB_UNLOCK(mp, s);
  74. /*
  75. * if the fs is readonly, let the incore superblock run
  76. * with quotas off but don't flush the update out to disk
  77. */
  78. if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
  79. return 0;
  80. #ifdef QUOTADEBUG
  81. xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
  82. #endif
  83. tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
  84. if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
  85. XFS_DEFAULT_LOG_COUNT))) {
  86. xfs_trans_cancel(tp, 0);
  87. xfs_fs_cmn_err(CE_ALERT, mp,
  88. "xfs_mount_reset_sbqflags: Superblock update failed!");
  89. return error;
  90. }
  91. xfs_mod_sb(tp, XFS_SB_QFLAGS);
  92. error = xfs_trans_commit(tp, 0, NULL);
  93. return error;
  94. }
  95. STATIC int
  96. xfs_noquota_init(
  97. xfs_mount_t *mp,
  98. uint *needquotamount,
  99. uint *quotaflags)
  100. {
  101. int error = 0;
  102. *quotaflags = 0;
  103. *needquotamount = B_FALSE;
  104. ASSERT(!XFS_IS_QUOTA_ON(mp));
  105. /*
  106. * If a file system had quotas running earlier, but decided to
  107. * mount without -o uquota/pquota/gquota options, revoke the
  108. * quotachecked license.
  109. */
  110. if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
  111. cmn_err(CE_NOTE,
  112. "XFS resetting qflags for filesystem %s",
  113. mp->m_fsname);
  114. error = xfs_mount_reset_sbqflags(mp);
  115. }
  116. return error;
  117. }
  118. xfs_qmops_t xfs_qmcore_stub = {
  119. .xfs_qminit = (xfs_qminit_t) xfs_noquota_init,
  120. .xfs_qmdone = (xfs_qmdone_t) fs_noerr,
  121. .xfs_qmmount = (xfs_qmmount_t) fs_noerr,
  122. .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr,
  123. .xfs_dqrele = (xfs_dqrele_t) fs_noerr,
  124. .xfs_dqattach = (xfs_dqattach_t) fs_noerr,
  125. .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr,
  126. .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr,
  127. .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr,
  128. .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr,
  129. .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr,
  130. .xfs_dqvopchown = xfs_dqvopchown_default,
  131. .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr,
  132. };