Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #include "xfs.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 19 | #include "xfs_fs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "xfs_types.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include "xfs_log.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 22 | #include "xfs_inum.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include "xfs_trans.h" |
| 24 | #include "xfs_sb.h" |
| 25 | #include "xfs_ag.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include "xfs_dir2.h" |
| 27 | #include "xfs_dmapi.h" |
| 28 | #include "xfs_mount.h" |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 29 | #include "xfs_quota.h" |
| 30 | #include "xfs_error.h" |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 31 | #include "xfs_clnt.h" |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
| 34 | STATIC struct xfs_dquot * |
| 35 | xfs_dqvopchown_default( |
| 36 | struct xfs_trans *tp, |
| 37 | struct xfs_inode *ip, |
| 38 | struct xfs_dquot **dqp, |
| 39 | struct xfs_dquot *dq) |
| 40 | { |
| 41 | return NULL; |
| 42 | } |
| 43 | |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 44 | /* |
| 45 | * Clear the quotaflags in memory and in the superblock. |
| 46 | */ |
| 47 | int |
| 48 | xfs_mount_reset_sbqflags(xfs_mount_t *mp) |
| 49 | { |
| 50 | int error; |
| 51 | xfs_trans_t *tp; |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 52 | |
| 53 | mp->m_qflags = 0; |
| 54 | /* |
| 55 | * It is OK to look at sb_qflags here in mount path, |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 56 | * without m_sb_lock. |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 57 | */ |
| 58 | if (mp->m_sb.sb_qflags == 0) |
| 59 | return 0; |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 60 | spin_lock(&mp->m_sb_lock); |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 61 | mp->m_sb.sb_qflags = 0; |
Eric Sandeen | 3685c2a | 2007-10-11 17:42:32 +1000 | [diff] [blame] | 62 | spin_unlock(&mp->m_sb_lock); |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * if the fs is readonly, let the incore superblock run |
| 66 | * with quotas off but don't flush the update out to disk |
| 67 | */ |
Christoph Hellwig | bd186aa | 2007-08-30 17:21:12 +1000 | [diff] [blame] | 68 | if (mp->m_flags & XFS_MOUNT_RDONLY) |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 69 | return 0; |
| 70 | #ifdef QUOTADEBUG |
| 71 | xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); |
| 72 | #endif |
| 73 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); |
| 74 | if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, |
| 75 | XFS_DEFAULT_LOG_COUNT))) { |
| 76 | xfs_trans_cancel(tp, 0); |
| 77 | xfs_fs_cmn_err(CE_ALERT, mp, |
| 78 | "xfs_mount_reset_sbqflags: Superblock update failed!"); |
| 79 | return error; |
| 80 | } |
| 81 | xfs_mod_sb(tp, XFS_SB_QFLAGS); |
Eric Sandeen | 1c72bf9 | 2007-05-08 13:48:42 +1000 | [diff] [blame] | 82 | error = xfs_trans_commit(tp, 0); |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 83 | return error; |
| 84 | } |
| 85 | |
| 86 | STATIC int |
| 87 | xfs_noquota_init( |
| 88 | xfs_mount_t *mp, |
| 89 | uint *needquotamount, |
| 90 | uint *quotaflags) |
| 91 | { |
| 92 | int error = 0; |
| 93 | |
| 94 | *quotaflags = 0; |
| 95 | *needquotamount = B_FALSE; |
| 96 | |
| 97 | ASSERT(!XFS_IS_QUOTA_ON(mp)); |
| 98 | |
| 99 | /* |
| 100 | * If a file system had quotas running earlier, but decided to |
| 101 | * mount without -o uquota/pquota/gquota options, revoke the |
| 102 | * quotachecked license. |
| 103 | */ |
| 104 | if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { |
| 105 | cmn_err(CE_NOTE, |
| 106 | "XFS resetting qflags for filesystem %s", |
| 107 | mp->m_fsname); |
| 108 | |
| 109 | error = xfs_mount_reset_sbqflags(mp); |
| 110 | } |
| 111 | return error; |
| 112 | } |
| 113 | |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 114 | static struct xfs_qmops xfs_qmcore_stub = { |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 115 | .xfs_qminit = (xfs_qminit_t) xfs_noquota_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | .xfs_qmdone = (xfs_qmdone_t) fs_noerr, |
| 117 | .xfs_qmmount = (xfs_qmmount_t) fs_noerr, |
| 118 | .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr, |
| 119 | .xfs_dqrele = (xfs_dqrele_t) fs_noerr, |
| 120 | .xfs_dqattach = (xfs_dqattach_t) fs_noerr, |
| 121 | .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr, |
| 122 | .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr, |
| 123 | .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr, |
| 124 | .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr, |
| 125 | .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr, |
| 126 | .xfs_dqvopchown = xfs_dqvopchown_default, |
| 127 | .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr, |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 128 | .xfs_dqstatvfs = (xfs_dqstatvfs_t) fs_noval, |
| 129 | .xfs_dqsync = (xfs_dqsync_t) fs_noerr, |
| 130 | .xfs_quotactl = (xfs_quotactl_t) fs_nosys, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | }; |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 132 | |
| 133 | int |
| 134 | xfs_qmops_get(struct xfs_mount *mp, struct xfs_mount_args *args) |
| 135 | { |
| 136 | if (args->flags & (XFSMNT_UQUOTA | XFSMNT_PQUOTA | XFSMNT_GQUOTA)) { |
Christoph Hellwig | c8fcfac | 2007-10-19 16:57:01 +1000 | [diff] [blame] | 137 | #ifdef CONFIG_XFS_QUOTA |
| 138 | mp->m_qm_ops = &xfs_qmcore_xfs; |
| 139 | #else |
| 140 | cmn_err(CE_WARN, |
| 141 | "XFS: qouta support not available in this kernel."); |
| 142 | return EINVAL; |
| 143 | #endif |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 144 | } else { |
| 145 | mp->m_qm_ops = &xfs_qmcore_stub; |
| 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | void |
| 152 | xfs_qmops_put(struct xfs_mount *mp) |
| 153 | { |
Christoph Hellwig | b09cc77 | 2007-08-30 17:19:57 +1000 | [diff] [blame] | 154 | } |