Blame view

fs/xfs/xfs_quotaops.c 3.43 KB
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  /*
   * Copyright (c) 2008, Christoph Hellwig
   * All Rights Reserved.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
   * published by the Free Software Foundation.
   *
   * 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.
   *
   * 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
   */
  #include "xfs.h"
6ca1c9063   Dave Chinner   xfs: separate dqu...
19
  #include "xfs_format.h"
239880ef6   Dave Chinner   xfs: decouple log...
20
  #include "xfs_log_format.h"
7fd36c441   Dave Chinner   xfs: split out tr...
21
  #include "xfs_trans_resv.h"
7fd36c441   Dave Chinner   xfs: split out tr...
22
  #include "xfs_sb.h"
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
23
24
  #include "xfs_ag.h"
  #include "xfs_mount.h"
a4fbe6ab1   Dave Chinner   xfs: decouple ino...
25
  #include "xfs_inode.h"
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
26
  #include "xfs_quota.h"
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
27
  #include "xfs_trans.h"
06f8e2d67   Alex Elder   xfs: don't expect...
28
  #include "xfs_qm.h"
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  #include <linux/quota.h>
  
  
  STATIC int
  xfs_quota_type(int type)
  {
  	switch (type) {
  	case USRQUOTA:
  		return XFS_DQ_USER;
  	case GRPQUOTA:
  		return XFS_DQ_GROUP;
  	default:
  		return XFS_DQ_PROJ;
  	}
  }
  
  STATIC int
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
46
47
48
49
50
51
52
53
54
55
56
57
  xfs_fs_get_xstate(
  	struct super_block	*sb,
  	struct fs_quota_stat	*fqs)
  {
  	struct xfs_mount	*mp = XFS_M(sb);
  
  	if (!XFS_IS_QUOTA_RUNNING(mp))
  		return -ENOSYS;
  	return -xfs_qm_scall_getqstat(mp, fqs);
  }
  
  STATIC int
5d5e3d576   Chandra Seetharaman   xfs: Add support ...
58
59
60
61
62
63
64
65
66
67
68
69
  xfs_fs_get_xstatev(
  	struct super_block	*sb,
  	struct fs_quota_statv	*fqs)
  {
  	struct xfs_mount	*mp = XFS_M(sb);
  
  	if (!XFS_IS_QUOTA_RUNNING(mp))
  		return -ENOSYS;
  	return -xfs_qm_scall_getqstatv(mp, fqs);
  }
  
  STATIC int
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
70
71
72
73
74
75
76
77
78
79
  xfs_fs_set_xstate(
  	struct super_block	*sb,
  	unsigned int		uflags,
  	int			op)
  {
  	struct xfs_mount	*mp = XFS_M(sb);
  	unsigned int		flags = 0;
  
  	if (sb->s_flags & MS_RDONLY)
  		return -EROFS;
c7ff91d72   Ryota Yamauchi   xfs: fix xfs_quot...
80
  	if (op != Q_XQUOTARM && !XFS_IS_QUOTA_RUNNING(mp))
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
81
  		return -ENOSYS;
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
82

ade7ce31c   Christoph Hellwig   quota: Clean up t...
83
  	if (uflags & FS_QUOTA_UDQ_ACCT)
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
84
  		flags |= XFS_UQUOTA_ACCT;
ade7ce31c   Christoph Hellwig   quota: Clean up t...
85
  	if (uflags & FS_QUOTA_PDQ_ACCT)
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
86
  		flags |= XFS_PQUOTA_ACCT;
ade7ce31c   Christoph Hellwig   quota: Clean up t...
87
  	if (uflags & FS_QUOTA_GDQ_ACCT)
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
88
  		flags |= XFS_GQUOTA_ACCT;
ade7ce31c   Christoph Hellwig   quota: Clean up t...
89
  	if (uflags & FS_QUOTA_UDQ_ENFD)
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
90
  		flags |= XFS_UQUOTA_ENFD;
83e782e1a   Chandra Seetharaman   xfs: Remove incor...
91
92
93
94
  	if (uflags & FS_QUOTA_GDQ_ENFD)
  		flags |= XFS_GQUOTA_ENFD;
  	if (uflags & FS_QUOTA_PDQ_ENFD)
  		flags |= XFS_PQUOTA_ENFD;
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  
  	switch (op) {
  	case Q_XQUOTAON:
  		return -xfs_qm_scall_quotaon(mp, flags);
  	case Q_XQUOTAOFF:
  		if (!XFS_IS_QUOTA_ON(mp))
  			return -EINVAL;
  		return -xfs_qm_scall_quotaoff(mp, flags);
  	case Q_XQUOTARM:
  		if (XFS_IS_QUOTA_ON(mp))
  			return -EINVAL;
  		return -xfs_qm_scall_trunc_qfiles(mp, flags);
  	}
  
  	return -EINVAL;
  }
  
  STATIC int
b9b2dd36c   Christoph Hellwig   quota: unify ->ge...
113
  xfs_fs_get_dqblk(
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
114
  	struct super_block	*sb,
74a8a1037   Eric W. Biederman   userns: Convert q...
115
  	struct kqid		qid,
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
116
117
118
119
120
121
122
123
  	struct fs_disk_quota	*fdq)
  {
  	struct xfs_mount	*mp = XFS_M(sb);
  
  	if (!XFS_IS_QUOTA_RUNNING(mp))
  		return -ENOSYS;
  	if (!XFS_IS_QUOTA_ON(mp))
  		return -ESRCH;
74a8a1037   Eric W. Biederman   userns: Convert q...
124
125
  	return -xfs_qm_scall_getquota(mp, from_kqid(&init_user_ns, qid),
  				      xfs_quota_type(qid.type), fdq);
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
126
127
128
  }
  
  STATIC int
c472b4327   Christoph Hellwig   quota: unify ->se...
129
  xfs_fs_set_dqblk(
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
130
  	struct super_block	*sb,
74a8a1037   Eric W. Biederman   userns: Convert q...
131
  	struct kqid		qid,
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
132
133
134
135
136
137
138
139
140
141
  	struct fs_disk_quota	*fdq)
  {
  	struct xfs_mount	*mp = XFS_M(sb);
  
  	if (sb->s_flags & MS_RDONLY)
  		return -EROFS;
  	if (!XFS_IS_QUOTA_RUNNING(mp))
  		return -ENOSYS;
  	if (!XFS_IS_QUOTA_ON(mp))
  		return -ESRCH;
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
142

74a8a1037   Eric W. Biederman   userns: Convert q...
143
144
  	return -xfs_qm_scall_setqlim(mp, from_kqid(&init_user_ns, qid),
  				     xfs_quota_type(qid.type), fdq);
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
145
  }
0d54b217a   Alexey Dobriyan   const: make struc...
146
  const struct quotactl_ops xfs_quotactl_operations = {
5d5e3d576   Chandra Seetharaman   xfs: Add support ...
147
  	.get_xstatev		= xfs_fs_get_xstatev,
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
148
149
  	.get_xstate		= xfs_fs_get_xstate,
  	.set_xstate		= xfs_fs_set_xstate,
b9b2dd36c   Christoph Hellwig   quota: unify ->ge...
150
  	.get_dqblk		= xfs_fs_get_dqblk,
c472b4327   Christoph Hellwig   quota: unify ->se...
151
  	.set_dqblk		= xfs_fs_set_dqblk,
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
152
  };