Blame view
fs/xfs/xfs_qm_bhv.c
4.27 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
932f2c323 [XFS] statvfs com... |
2 |
* Copyright (c) 2000-2006 Silicon Graphics, Inc. |
4ce3121f6 [XFS] Update lice... |
3 |
* All Rights Reserved. |
1da177e4c Linux-2.6.12-rc2 |
4 |
* |
4ce3121f6 [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 Linux-2.6.12-rc2 |
7 8 |
* published by the Free Software Foundation. * |
4ce3121f6 [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 Linux-2.6.12-rc2 |
13 |
* |
4ce3121f6 [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 Linux-2.6.12-rc2 |
17 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
18 19 |
#include "xfs.h" #include "xfs_fs.h" |
6ca1c9063 xfs: separate dqu... |
20 |
#include "xfs_format.h" |
239880ef6 xfs: decouple log... |
21 22 |
#include "xfs_log_format.h" #include "xfs_trans_resv.h" |
1da177e4c Linux-2.6.12-rc2 |
23 24 |
#include "xfs_quota.h" #include "xfs_mount.h" |
1da177e4c Linux-2.6.12-rc2 |
25 |
#include "xfs_inode.h" |
1da177e4c Linux-2.6.12-rc2 |
26 |
#include "xfs_error.h" |
239880ef6 xfs: decouple log... |
27 |
#include "xfs_trans.h" |
1da177e4c Linux-2.6.12-rc2 |
28 |
#include "xfs_qm.h" |
1da177e4c Linux-2.6.12-rc2 |
29 |
|
b09cc7710 [XFS] remove depe... |
30 31 |
STATIC void xfs_fill_statvfs_from_dquot( |
00dd4029e [XFS] remove bhv_... |
32 |
struct kstatfs *statp, |
896050119 xfs: include rese... |
33 |
struct xfs_dquot *dqp) |
932f2c323 [XFS] statvfs com... |
34 |
{ |
932f2c323 [XFS] statvfs com... |
35 |
__uint64_t limit; |
932f2c323 [XFS] statvfs com... |
36 |
|
896050119 xfs: include rese... |
37 38 39 |
limit = dqp->q_core.d_blk_softlimit ? be64_to_cpu(dqp->q_core.d_blk_softlimit) : be64_to_cpu(dqp->q_core.d_blk_hardlimit); |
932f2c323 [XFS] statvfs com... |
40 41 |
if (limit && statp->f_blocks > limit) { statp->f_blocks = limit; |
9b00f3076 xfs: quota limit ... |
42 |
statp->f_bfree = statp->f_bavail = |
896050119 xfs: include rese... |
43 44 |
(statp->f_blocks > dqp->q_res_bcount) ? (statp->f_blocks - dqp->q_res_bcount) : 0; |
932f2c323 [XFS] statvfs com... |
45 |
} |
2a293b7d5 [XFS] All xfs_dis... |
46 |
|
896050119 xfs: include rese... |
47 48 49 |
limit = dqp->q_core.d_ino_softlimit ? be64_to_cpu(dqp->q_core.d_ino_softlimit) : be64_to_cpu(dqp->q_core.d_ino_hardlimit); |
932f2c323 [XFS] statvfs com... |
50 51 |
if (limit && statp->f_files > limit) { statp->f_files = limit; |
2a293b7d5 [XFS] All xfs_dis... |
52 |
statp->f_ffree = |
896050119 xfs: include rese... |
53 54 |
(statp->f_files > dqp->q_res_icount) ? (statp->f_ffree - dqp->q_res_icount) : 0; |
932f2c323 [XFS] statvfs com... |
55 |
} |
932f2c323 [XFS] statvfs com... |
56 |
} |
b09cc7710 [XFS] remove depe... |
57 58 59 60 61 62 63 64 |
/* * Directory tree accounting is implemented using project quotas, where * the project identifier is inherited from parent directories. * A statvfs (df, etc.) of a directory that is using project quota should * return a statvfs of the project, not the entire filesystem. * This makes such trees appear as if they are filesystems in themselves. */ |
7d095257e xfs: kill xfs_qmops |
65 |
void |
b09cc7710 [XFS] remove depe... |
66 67 |
xfs_qm_statvfs( xfs_inode_t *ip, |
00dd4029e [XFS] remove bhv_... |
68 |
struct kstatfs *statp) |
1da177e4c Linux-2.6.12-rc2 |
69 |
{ |
b09cc7710 [XFS] remove depe... |
70 71 |
xfs_mount_t *mp = ip->i_mount; xfs_dquot_t *dqp; |
1da177e4c Linux-2.6.12-rc2 |
72 |
|
6743099ce xfs: Extend proje... |
73 |
if (!xfs_qm_dqget(mp, NULL, xfs_get_projid(ip), XFS_DQ_PROJ, 0, &dqp)) { |
896050119 xfs: include rese... |
74 |
xfs_fill_statvfs_from_dquot(statp, dqp); |
b09cc7710 [XFS] remove depe... |
75 |
xfs_qm_dqput(dqp); |
1da177e4c Linux-2.6.12-rc2 |
76 |
} |
1da177e4c Linux-2.6.12-rc2 |
77 |
} |
7d095257e xfs: kill xfs_qmops |
78 |
int |
1da177e4c Linux-2.6.12-rc2 |
79 80 81 82 83 84 |
xfs_qm_newmount( xfs_mount_t *mp, uint *needquotamount, uint *quotaflags) { uint quotaondisk; |
c8ad20ffe [XFS] Add support... |
85 |
uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0; |
1da177e4c Linux-2.6.12-rc2 |
86 |
|
621187099 [XFS] remove shou... |
87 |
quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) && |
c8ad20ffe [XFS] Add support... |
88 |
(mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); |
1da177e4c Linux-2.6.12-rc2 |
89 90 91 |
if (quotaondisk) { uquotaondisk = mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT; |
c8ad20ffe [XFS] Add support... |
92 |
pquotaondisk = mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT; |
1da177e4c Linux-2.6.12-rc2 |
93 94 95 96 97 98 99 100 101 102 103 104 105 |
gquotaondisk = mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT; } /* * If the device itself is read-only, we can't allow * the user to change the state of quota on the mount - * this would generate a transaction on the ro device, * which would lead to an I/O error and shutdown */ if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) || (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) || (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || |
92f8ff73f xfs: Add pquota f... |
106 107 108 |
(!gquotaondisk && XFS_IS_GQUOTA_ON(mp)) || (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) || (!pquotaondisk && XFS_IS_PQUOTA_ON(mp))) && |
1da177e4c Linux-2.6.12-rc2 |
109 |
xfs_dev_is_read_only(mp, "changing quota state")) { |
0b932cccb xfs: Convert rema... |
110 |
xfs_warn(mp, "please mount with%s%s%s%s.", |
1da177e4c Linux-2.6.12-rc2 |
111 112 |
(!quotaondisk ? "out quota" : ""), (uquotaondisk ? " usrquota" : ""), |
92f8ff73f xfs: Add pquota f... |
113 114 |
(gquotaondisk ? " grpquota" : ""), (pquotaondisk ? " prjquota" : "")); |
2451337dd xfs: global error... |
115 |
return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
116 117 118 119 120 121 122 123 124 |
} if (XFS_IS_QUOTA_ON(mp) || quotaondisk) { /* * Call mount_quotas at this point only if we won't have to do * a quotacheck. */ if (quotaondisk && !XFS_QM_NEED_QUOTACHECK(mp)) { /* |
25985edce Fix common misspe... |
125 |
* If an error occurred, qm_mount_quotas code |
1da177e4c Linux-2.6.12-rc2 |
126 127 128 129 |
* has already disabled quotas. So, just finish * mounting, and get on with the boring life * without disk quotas. */ |
4249023a5 [XFS] cleanup xfs... |
130 |
xfs_qm_mount_quotas(mp); |
1da177e4c Linux-2.6.12-rc2 |
131 132 133 134 135 136 137 138 |
} else { /* * Clear the quota flags, but remember them. This * is so that the quota code doesn't get invoked * before we're ready. This can happen when an * inode goes inactive and wants to free blocks, * or via xfs_log_mount_finish. */ |
667a9291c xfs: Remove boole... |
139 |
*needquotamount = true; |
1da177e4c Linux-2.6.12-rc2 |
140 141 142 143 144 145 146 |
*quotaflags = mp->m_qflags; mp->m_qflags = 0; } } return 0; } |