1153323Srodrigc/*
2159451Srodrigc * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3159451Srodrigc * All Rights Reserved.
4153323Srodrigc *
5159451Srodrigc * This program is free software; you can redistribute it and/or
6159451Srodrigc * modify it under the terms of the GNU General Public License as
7153323Srodrigc * published by the Free Software Foundation.
8153323Srodrigc *
9159451Srodrigc * This program is distributed in the hope that it would be useful,
10159451Srodrigc * but WITHOUT ANY WARRANTY; without even the implied warranty of
11159451Srodrigc * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12159451Srodrigc * GNU General Public License for more details.
13153323Srodrigc *
14159451Srodrigc * You should have received a copy of the GNU General Public License
15159451Srodrigc * along with this program; if not, write the Free Software Foundation,
16159451Srodrigc * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17153323Srodrigc */
18153323Srodrigc#include "xfs.h"
19159451Srodrigc#include "xfs_fs.h"
20153323Srodrigc#include "xfs_types.h"
21159451Srodrigc#include "xfs_log.h"
22153323Srodrigc#include "xfs_inum.h"
23153323Srodrigc#include "xfs_trans.h"
24153323Srodrigc#include "xfs_sb.h"
25153323Srodrigc#include "xfs_ag.h"
26153323Srodrigc#include "xfs_dir.h"
27153323Srodrigc#include "xfs_dir2.h"
28153323Srodrigc#include "xfs_dmapi.h"
29153323Srodrigc#include "xfs_mount.h"
30159451Srodrigc#include "xfs_quota.h"
31159451Srodrigc#include "xfs_error.h"
32153323Srodrigc
33153323SrodrigcSTATIC struct xfs_dquot *
34153323Srodrigcxfs_dqvopchown_default(
35153323Srodrigc	struct xfs_trans	*tp,
36153323Srodrigc	struct xfs_inode	*ip,
37153323Srodrigc	struct xfs_dquot	**dqp,
38153323Srodrigc	struct xfs_dquot	*dq)
39153323Srodrigc{
40153323Srodrigc	return NULL;
41153323Srodrigc}
42153323Srodrigc
43159451Srodrigc/*
44159451Srodrigc * Clear the quotaflags in memory and in the superblock.
45159451Srodrigc */
46159451Srodrigcint
47159451Srodrigcxfs_mount_reset_sbqflags(xfs_mount_t *mp)
48159451Srodrigc{
49159451Srodrigc	int			error;
50159451Srodrigc	xfs_trans_t		*tp;
51159451Srodrigc	unsigned long		s;
52159451Srodrigc
53159451Srodrigc	mp->m_qflags = 0;
54159451Srodrigc	/*
55159451Srodrigc	 * It is OK to look at sb_qflags here in mount path,
56159451Srodrigc	 * without SB_LOCK.
57159451Srodrigc	 */
58159451Srodrigc	if (mp->m_sb.sb_qflags == 0)
59159451Srodrigc		return 0;
60159451Srodrigc	s = XFS_SB_LOCK(mp);
61159451Srodrigc	mp->m_sb.sb_qflags = 0;
62159451Srodrigc	XFS_SB_UNLOCK(mp, s);
63159451Srodrigc
64159451Srodrigc	/*
65159451Srodrigc	 * if the fs is readonly, let the incore superblock run
66159451Srodrigc	 * with quotas off but don't flush the update out to disk
67159451Srodrigc	 */
68159451Srodrigc	if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
69159451Srodrigc		return 0;
70159451Srodrigc#ifdef QUOTADEBUG
71159451Srodrigc	xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
72159451Srodrigc#endif
73159451Srodrigc	tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
74159451Srodrigc	if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
75159451Srodrigc				      XFS_DEFAULT_LOG_COUNT))) {
76159451Srodrigc		xfs_trans_cancel(tp, 0);
77159451Srodrigc		xfs_fs_cmn_err(CE_ALERT, mp,
78159451Srodrigc			"xfs_mount_reset_sbqflags: Superblock update failed!");
79159451Srodrigc		return error;
80159451Srodrigc	}
81159451Srodrigc	xfs_mod_sb(tp, XFS_SB_QFLAGS);
82159451Srodrigc	error = xfs_trans_commit(tp, 0, NULL);
83159451Srodrigc	return error;
84159451Srodrigc}
85159451Srodrigc
86159451SrodrigcSTATIC int
87159451Srodrigcxfs_noquota_init(
88159451Srodrigc	xfs_mount_t	*mp,
89159451Srodrigc	uint		*needquotamount,
90159451Srodrigc	uint		*quotaflags)
91159451Srodrigc{
92159451Srodrigc	int		error = 0;
93159451Srodrigc
94159451Srodrigc	*quotaflags = 0;
95159451Srodrigc	*needquotamount = B_FALSE;
96159451Srodrigc
97159451Srodrigc	ASSERT(!XFS_IS_QUOTA_ON(mp));
98159451Srodrigc
99159451Srodrigc	/*
100159451Srodrigc	 * If a file system had quotas running earlier, but decided to
101159451Srodrigc	 * mount without -o uquota/pquota/gquota options, revoke the
102159451Srodrigc	 * quotachecked license.
103159451Srodrigc	 */
104159451Srodrigc	if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
105159451Srodrigc		cmn_err(CE_NOTE,
106159451Srodrigc                        "XFS resetting qflags for filesystem %s",
107159451Srodrigc                        mp->m_fsname);
108159451Srodrigc
109159451Srodrigc		error = xfs_mount_reset_sbqflags(mp);
110159451Srodrigc	}
111159451Srodrigc	return error;
112159451Srodrigc}
113159451Srodrigc
114153323Srodrigcxfs_qmops_t	xfs_qmcore_stub = {
115159451Srodrigc	.xfs_qminit		= (xfs_qminit_t) xfs_noquota_init,
116153323Srodrigc	.xfs_qmdone		= (xfs_qmdone_t) fs_noerr,
117153323Srodrigc	.xfs_qmmount		= (xfs_qmmount_t) fs_noerr,
118153323Srodrigc	.xfs_qmunmount		= (xfs_qmunmount_t) fs_noerr,
119153323Srodrigc	.xfs_dqrele		= (xfs_dqrele_t) fs_noerr,
120153323Srodrigc	.xfs_dqattach		= (xfs_dqattach_t) fs_noerr,
121153323Srodrigc	.xfs_dqdetach		= (xfs_dqdetach_t) fs_noerr,
122153323Srodrigc	.xfs_dqpurgeall		= (xfs_dqpurgeall_t) fs_noerr,
123153323Srodrigc	.xfs_dqvopalloc		= (xfs_dqvopalloc_t) fs_noerr,
124153323Srodrigc	.xfs_dqvopcreate	= (xfs_dqvopcreate_t) fs_noerr,
125153323Srodrigc	.xfs_dqvoprename	= (xfs_dqvoprename_t) fs_noerr,
126153323Srodrigc	.xfs_dqvopchown		= xfs_dqvopchown_default,
127153323Srodrigc	.xfs_dqvopchownresv	= (xfs_dqvopchownresv_t) fs_noerr,
128153323Srodrigc};
129