]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/xfs/linux-2.6/xfs_quotaops.c
drm/i915: fix page flip finish vs. prepare on plane B
[net-next-2.6.git] / fs / xfs / linux-2.6 / xfs_quotaops.c
CommitLineData
fcafb71b
CH
1/*
2 * Copyright (c) 2008, Christoph Hellwig
3 * All Rights Reserved.
4 *
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.
8 *
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.
13 *
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
17 */
18#include "xfs.h"
19#include "xfs_dmapi.h"
20#include "xfs_sb.h"
21#include "xfs_inum.h"
ed3b4d6c 22#include "xfs_log.h"
fcafb71b
CH
23#include "xfs_ag.h"
24#include "xfs_mount.h"
25#include "xfs_quota.h"
26#include "xfs_log.h"
27#include "xfs_trans.h"
28#include "xfs_bmap_btree.h"
29#include "xfs_inode.h"
30#include "quota/xfs_qm.h"
31#include <linux/quota.h>
32
33
34STATIC int
35xfs_quota_type(int type)
36{
37 switch (type) {
38 case USRQUOTA:
39 return XFS_DQ_USER;
40 case GRPQUOTA:
41 return XFS_DQ_GROUP;
42 default:
43 return XFS_DQ_PROJ;
44 }
45}
46
fcafb71b
CH
47STATIC int
48xfs_fs_get_xstate(
49 struct super_block *sb,
50 struct fs_quota_stat *fqs)
51{
52 struct xfs_mount *mp = XFS_M(sb);
53
54 if (!XFS_IS_QUOTA_RUNNING(mp))
55 return -ENOSYS;
56 return -xfs_qm_scall_getqstat(mp, fqs);
57}
58
59STATIC int
60xfs_fs_set_xstate(
61 struct super_block *sb,
62 unsigned int uflags,
63 int op)
64{
65 struct xfs_mount *mp = XFS_M(sb);
66 unsigned int flags = 0;
67
68 if (sb->s_flags & MS_RDONLY)
69 return -EROFS;
c7ff91d7 70 if (op != Q_XQUOTARM && !XFS_IS_QUOTA_RUNNING(mp))
fcafb71b 71 return -ENOSYS;
fcafb71b
CH
72
73 if (uflags & XFS_QUOTA_UDQ_ACCT)
74 flags |= XFS_UQUOTA_ACCT;
75 if (uflags & XFS_QUOTA_PDQ_ACCT)
76 flags |= XFS_PQUOTA_ACCT;
77 if (uflags & XFS_QUOTA_GDQ_ACCT)
78 flags |= XFS_GQUOTA_ACCT;
79 if (uflags & XFS_QUOTA_UDQ_ENFD)
80 flags |= XFS_UQUOTA_ENFD;
81 if (uflags & (XFS_QUOTA_PDQ_ENFD|XFS_QUOTA_GDQ_ENFD))
82 flags |= XFS_OQUOTA_ENFD;
83
84 switch (op) {
85 case Q_XQUOTAON:
86 return -xfs_qm_scall_quotaon(mp, flags);
87 case Q_XQUOTAOFF:
88 if (!XFS_IS_QUOTA_ON(mp))
89 return -EINVAL;
90 return -xfs_qm_scall_quotaoff(mp, flags);
91 case Q_XQUOTARM:
92 if (XFS_IS_QUOTA_ON(mp))
93 return -EINVAL;
94 return -xfs_qm_scall_trunc_qfiles(mp, flags);
95 }
96
97 return -EINVAL;
98}
99
100STATIC int
b9b2dd36 101xfs_fs_get_dqblk(
fcafb71b
CH
102 struct super_block *sb,
103 int type,
104 qid_t id,
105 struct fs_disk_quota *fdq)
106{
107 struct xfs_mount *mp = XFS_M(sb);
108
109 if (!XFS_IS_QUOTA_RUNNING(mp))
110 return -ENOSYS;
111 if (!XFS_IS_QUOTA_ON(mp))
112 return -ESRCH;
113
114 return -xfs_qm_scall_getquota(mp, id, xfs_quota_type(type), fdq);
115}
116
117STATIC int
c472b432 118xfs_fs_set_dqblk(
fcafb71b
CH
119 struct super_block *sb,
120 int type,
121 qid_t id,
122 struct fs_disk_quota *fdq)
123{
124 struct xfs_mount *mp = XFS_M(sb);
125
126 if (sb->s_flags & MS_RDONLY)
127 return -EROFS;
128 if (!XFS_IS_QUOTA_RUNNING(mp))
129 return -ENOSYS;
130 if (!XFS_IS_QUOTA_ON(mp))
131 return -ESRCH;
fcafb71b
CH
132
133 return -xfs_qm_scall_setqlim(mp, id, xfs_quota_type(type), fdq);
134}
135
0d54b217 136const struct quotactl_ops xfs_quotactl_operations = {
fcafb71b
CH
137 .get_xstate = xfs_fs_get_xstate,
138 .set_xstate = xfs_fs_set_xstate,
b9b2dd36 139 .get_dqblk = xfs_fs_get_dqblk,
c472b432 140 .set_dqblk = xfs_fs_set_dqblk,
fcafb71b 141};