Blame view

fs/xfs/xfs_qmops.c 3.35 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
7b7187698   Nathan Scott   [XFS] Update lice...
2
3
   * Copyright (c) 2000-2005 Silicon Graphics, Inc.
   * All Rights Reserved.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
   *
7b7187698   Nathan Scott   [XFS] Update lice...
5
6
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
   * published by the Free Software Foundation.
   *
7b7187698   Nathan Scott   [XFS] Update lice...
9
10
11
12
   * This program is distributed in the hope that it would be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
   *
7b7187698   Nathan Scott   [XFS] Update lice...
14
15
16
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write the Free Software Foundation,
   * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
   */
  #include "xfs.h"
a844f4510   Nathan Scott   [XFS] Remove xfs_...
19
  #include "xfs_fs.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
  #include "xfs_types.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
  #include "xfs_log.h"
a844f4510   Nathan Scott   [XFS] Remove xfs_...
22
  #include "xfs_inum.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
25
  #include "xfs_trans.h"
  #include "xfs_sb.h"
  #include "xfs_ag.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
  #include "xfs_dir2.h"
  #include "xfs_dmapi.h"
  #include "xfs_mount.h"
4cd4a034a   Tim Shimmin   [XFS] Need to be ...
29
30
  #include "xfs_quota.h"
  #include "xfs_error.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
36
37
38
39
40
  
  STATIC struct xfs_dquot *
  xfs_dqvopchown_default(
  	struct xfs_trans	*tp,
  	struct xfs_inode	*ip,
  	struct xfs_dquot	**dqp,
  	struct xfs_dquot	*dq)
  {
  	return NULL;
  }
4cd4a034a   Tim Shimmin   [XFS] Need to be ...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  /*
   * Clear the quotaflags in memory and in the superblock.
   */
  int
  xfs_mount_reset_sbqflags(xfs_mount_t *mp)
  {
  	int			error;
  	xfs_trans_t		*tp;
  	unsigned long		s;
  
  	mp->m_qflags = 0;
  	/*
  	 * It is OK to look at sb_qflags here in mount path,
  	 * without SB_LOCK.
  	 */
  	if (mp->m_sb.sb_qflags == 0)
  		return 0;
  	s = XFS_SB_LOCK(mp);
  	mp->m_sb.sb_qflags = 0;
  	XFS_SB_UNLOCK(mp, s);
  
  	/*
  	 * if the fs is readonly, let the incore superblock run
  	 * with quotas off but don't flush the update out to disk
  	 */
  	if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
  		return 0;
  #ifdef QUOTADEBUG
  	xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes");
  #endif
  	tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
  	if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
  				      XFS_DEFAULT_LOG_COUNT))) {
  		xfs_trans_cancel(tp, 0);
  		xfs_fs_cmn_err(CE_ALERT, mp,
  			"xfs_mount_reset_sbqflags: Superblock update failed!");
  		return error;
  	}
  	xfs_mod_sb(tp, XFS_SB_QFLAGS);
1c72bf900   Eric Sandeen   [XFS] The last ar...
80
  	error = xfs_trans_commit(tp, 0);
4cd4a034a   Tim Shimmin   [XFS] Need to be ...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  	return error;
  }
  
  STATIC int
  xfs_noquota_init(
  	xfs_mount_t	*mp,
  	uint		*needquotamount,
  	uint		*quotaflags)
  {
  	int		error = 0;
  
  	*quotaflags = 0;
  	*needquotamount = B_FALSE;
  
  	ASSERT(!XFS_IS_QUOTA_ON(mp));
  
  	/*
  	 * If a file system had quotas running earlier, but decided to
  	 * mount without -o uquota/pquota/gquota options, revoke the
  	 * quotachecked license.
  	 */
  	if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) {
  		cmn_err(CE_NOTE,
                          "XFS resetting qflags for filesystem %s",
                          mp->m_fsname);
  
  		error = xfs_mount_reset_sbqflags(mp);
  	}
  	return error;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111
  xfs_qmops_t	xfs_qmcore_stub = {
4cd4a034a   Tim Shimmin   [XFS] Need to be ...
112
  	.xfs_qminit		= (xfs_qminit_t) xfs_noquota_init,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
114
115
116
117
118
119
120
121
122
123
124
125
  	.xfs_qmdone		= (xfs_qmdone_t) fs_noerr,
  	.xfs_qmmount		= (xfs_qmmount_t) fs_noerr,
  	.xfs_qmunmount		= (xfs_qmunmount_t) fs_noerr,
  	.xfs_dqrele		= (xfs_dqrele_t) fs_noerr,
  	.xfs_dqattach		= (xfs_dqattach_t) fs_noerr,
  	.xfs_dqdetach		= (xfs_dqdetach_t) fs_noerr,
  	.xfs_dqpurgeall		= (xfs_dqpurgeall_t) fs_noerr,
  	.xfs_dqvopalloc		= (xfs_dqvopalloc_t) fs_noerr,
  	.xfs_dqvopcreate	= (xfs_dqvopcreate_t) fs_noerr,
  	.xfs_dqvoprename	= (xfs_dqvoprename_t) fs_noerr,
  	.xfs_dqvopchown		= xfs_dqvopchown_default,
  	.xfs_dqvopchownresv	= (xfs_dqvopchownresv_t) fs_noerr,
  };