Linux 2.6.14.1
[linux/fpc-iii.git] / fs / xfs / xfs_qmops.c
bloba6cd6324e946af65d2f1e949606a6e7c25be0f90
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
26 * http://www.sgi.com
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #include "xfs.h"
34 #include "xfs_macros.h"
35 #include "xfs_types.h"
36 #include "xfs_inum.h"
37 #include "xfs_log.h"
38 #include "xfs_trans.h"
39 #include "xfs_sb.h"
40 #include "xfs_ag.h"
41 #include "xfs_dir.h"
42 #include "xfs_dir2.h"
43 #include "xfs_dmapi.h"
44 #include "xfs_mount.h"
45 #include "xfs_quota.h"
46 #include "xfs_error.h"
48 STATIC struct xfs_dquot *
49 xfs_dqvopchown_default(
50 struct xfs_trans *tp,
51 struct xfs_inode *ip,
52 struct xfs_dquot **dqp,
53 struct xfs_dquot *dq)
55 return NULL;
59 * Clear the quotaflags in memory and in the superblock.
61 int
62 xfs_mount_reset_sbqflags(xfs_mount_t *mp)
64 int error;
65 xfs_trans_t *tp;
66 unsigned long s;
68 mp->m_qflags = 0;
70 * It is OK to look at sb_qflags here in mount path,
71 * without SB_LOCK.
73 if (mp->m_sb.sb_qflags == 0)
74 return 0;
75 s = XFS_SB_LOCK(mp);
76 mp->m_sb.sb_qflags = 0;
77 XFS_SB_UNLOCK(mp, s);
80 * if the fs is readonly, let the incore superblock run
81 * with quotas off but don't flush the update out to disk
83 if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
84 return 0;
85 #ifdef QUOTADEBUG
86 xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
87 #endif
88 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
89 if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
90 XFS_DEFAULT_LOG_COUNT))) {
91 xfs_trans_cancel(tp, 0);
92 xfs_fs_cmn_err(CE_ALERT, mp,
93 "xfs_mount_reset_sbqflags: Superblock update failed!");
94 return error;
96 xfs_mod_sb(tp, XFS_SB_QFLAGS);
97 error = xfs_trans_commit(tp, 0, NULL);
98 return error;
101 STATIC int
102 xfs_noquota_init(
103 xfs_mount_t *mp,
104 uint *needquotamount,
105 uint *quotaflags)
107 int error = 0;
109 *quotaflags = 0;
110 *needquotamount = B_FALSE;
112 ASSERT(!XFS_IS_QUOTA_ON(mp));
115 * If a file system had quotas running earlier, but decided to
116 * mount without -o uquota/pquota/gquota options, revoke the
117 * quotachecked license.
119 if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
120 cmn_err(CE_NOTE,
121 "XFS resetting qflags for filesystem %s",
122 mp->m_fsname);
124 error = xfs_mount_reset_sbqflags(mp);
126 return error;
129 xfs_qmops_t xfs_qmcore_stub = {
130 .xfs_qminit = (xfs_qminit_t) xfs_noquota_init,
131 .xfs_qmdone = (xfs_qmdone_t) fs_noerr,
132 .xfs_qmmount = (xfs_qmmount_t) fs_noerr,
133 .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr,
134 .xfs_dqrele = (xfs_dqrele_t) fs_noerr,
135 .xfs_dqattach = (xfs_dqattach_t) fs_noerr,
136 .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr,
137 .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr,
138 .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr,
139 .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr,
140 .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr,
141 .xfs_dqvopchown = xfs_dqvopchown_default,
142 .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr,