blob: ac14d26fa9c4897f3bfe5a90dc7c34326986811c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Tim Shimmin4cd4a032005-09-05 08:24:10 +10002 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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"
Nathan Scotta844f452005-11-02 14:38:42 +110033#include "xfs_fs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include "xfs_types.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include "xfs_log.h"
Nathan Scotta844f452005-11-02 14:38:42 +110036#include "xfs_inum.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#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"
Tim Shimmin4cd4a032005-09-05 08:24:10 +100044#include "xfs_quota.h"
45#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47STATIC struct xfs_dquot *
48xfs_dqvopchown_default(
49 struct xfs_trans *tp,
50 struct xfs_inode *ip,
51 struct xfs_dquot **dqp,
52 struct xfs_dquot *dq)
53{
54 return NULL;
55}
56
Tim Shimmin4cd4a032005-09-05 08:24:10 +100057/*
58 * Clear the quotaflags in memory and in the superblock.
59 */
60int
61xfs_mount_reset_sbqflags(xfs_mount_t *mp)
62{
63 int error;
64 xfs_trans_t *tp;
65 unsigned long s;
66
67 mp->m_qflags = 0;
68 /*
69 * It is OK to look at sb_qflags here in mount path,
70 * without SB_LOCK.
71 */
72 if (mp->m_sb.sb_qflags == 0)
73 return 0;
74 s = XFS_SB_LOCK(mp);
75 mp->m_sb.sb_qflags = 0;
76 XFS_SB_UNLOCK(mp, s);
77
78 /*
79 * if the fs is readonly, let the incore superblock run
80 * with quotas off but don't flush the update out to disk
81 */
82 if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
83 return 0;
84#ifdef QUOTADEBUG
85 xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
86#endif
87 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
88 if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
89 XFS_DEFAULT_LOG_COUNT))) {
90 xfs_trans_cancel(tp, 0);
91 xfs_fs_cmn_err(CE_ALERT, mp,
92 "xfs_mount_reset_sbqflags: Superblock update failed!");
93 return error;
94 }
95 xfs_mod_sb(tp, XFS_SB_QFLAGS);
96 error = xfs_trans_commit(tp, 0, NULL);
97 return error;
98}
99
100STATIC int
101xfs_noquota_init(
102 xfs_mount_t *mp,
103 uint *needquotamount,
104 uint *quotaflags)
105{
106 int error = 0;
107
108 *quotaflags = 0;
109 *needquotamount = B_FALSE;
110
111 ASSERT(!XFS_IS_QUOTA_ON(mp));
112
113 /*
114 * If a file system had quotas running earlier, but decided to
115 * mount without -o uquota/pquota/gquota options, revoke the
116 * quotachecked license.
117 */
118 if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
119 cmn_err(CE_NOTE,
120 "XFS resetting qflags for filesystem %s",
121 mp->m_fsname);
122
123 error = xfs_mount_reset_sbqflags(mp);
124 }
125 return error;
126}
127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128xfs_qmops_t xfs_qmcore_stub = {
Tim Shimmin4cd4a032005-09-05 08:24:10 +1000129 .xfs_qminit = (xfs_qminit_t) xfs_noquota_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .xfs_qmdone = (xfs_qmdone_t) fs_noerr,
131 .xfs_qmmount = (xfs_qmmount_t) fs_noerr,
132 .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr,
133 .xfs_dqrele = (xfs_dqrele_t) fs_noerr,
134 .xfs_dqattach = (xfs_dqattach_t) fs_noerr,
135 .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr,
136 .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr,
137 .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr,
138 .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr,
139 .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr,
140 .xfs_dqvopchown = xfs_dqvopchown_default,
141 .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr,
142};