2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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.
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.
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
20 #include "xfs_types.h"
23 #include "xfs_trans.h"
27 #include "xfs_dmapi.h"
28 #include "xfs_mount.h"
29 #include "xfs_quota.h"
30 #include "xfs_error.h"
34 STATIC struct xfs_dquot *
35 xfs_dqvopchown_default(
38 struct xfs_dquot **dqp,
45 * Clear the quotaflags in memory and in the superblock.
48 xfs_mount_reset_sbqflags(xfs_mount_t *mp)
56 * It is OK to look at sb_qflags here in mount path,
59 if (mp->m_sb.sb_qflags == 0)
62 mp->m_sb.sb_qflags = 0;
66 * if the fs is readonly, let the incore superblock run
67 * with quotas off but don't flush the update out to disk
69 if (mp->m_flags & XFS_MOUNT_RDONLY)
72 xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
74 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
75 if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
76 XFS_DEFAULT_LOG_COUNT))) {
77 xfs_trans_cancel(tp, 0);
78 xfs_fs_cmn_err(CE_ALERT, mp,
79 "xfs_mount_reset_sbqflags: Superblock update failed!");
82 xfs_mod_sb(tp, XFS_SB_QFLAGS);
83 error = xfs_trans_commit(tp, 0);
96 *needquotamount = B_FALSE;
98 ASSERT(!XFS_IS_QUOTA_ON(mp));
101 * If a file system had quotas running earlier, but decided to
102 * mount without -o uquota/pquota/gquota options, revoke the
103 * quotachecked license.
105 if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
107 "XFS resetting qflags for filesystem %s",
110 error = xfs_mount_reset_sbqflags(mp);
115 static struct xfs_qmops xfs_qmcore_stub = {
116 .xfs_qminit = (xfs_qminit_t) xfs_noquota_init,
117 .xfs_qmdone = (xfs_qmdone_t) fs_noerr,
118 .xfs_qmmount = (xfs_qmmount_t) fs_noerr,
119 .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr,
120 .xfs_dqrele = (xfs_dqrele_t) fs_noerr,
121 .xfs_dqattach = (xfs_dqattach_t) fs_noerr,
122 .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr,
123 .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr,
124 .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr,
125 .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr,
126 .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr,
127 .xfs_dqvopchown = xfs_dqvopchown_default,
128 .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr,
129 .xfs_dqstatvfs = (xfs_dqstatvfs_t) fs_noval,
130 .xfs_dqsync = (xfs_dqsync_t) fs_noerr,
131 .xfs_quotactl = (xfs_quotactl_t) fs_nosys,
135 xfs_qmops_get(struct xfs_mount *mp, struct xfs_mount_args *args)
137 if (args->flags & (XFSMNT_UQUOTA | XFSMNT_PQUOTA | XFSMNT_GQUOTA)) {
138 struct xfs_qmops *ops;
140 ops = symbol_get(xfs_qmcore_xfs);
142 request_module("xfs_quota");
143 ops = symbol_get(xfs_qmcore_xfs);
147 cmn_err(CE_WARN, "XFS: no quota support available.");
152 mp->m_qm_ops = &xfs_qmcore_stub;
159 xfs_qmops_put(struct xfs_mount *mp)
161 if (mp->m_qm_ops != &xfs_qmcore_stub)
162 symbol_put(xfs_qmcore_xfs);