Commit 4cd4a034a3ef020d9de48fe0a3f5f976e5134669
Committed by
Nathan Scott
1 parent
56d433e430
Exists in
master
and in
7 other branches
[XFS] Need to be able to reset sb_qflags if not mounting with quotas
having previously mounted with quotas. SGI-PV: 940491 SGI-Modid: xfs-linux:xfs-kern:23388a Signed-off-by: Tim Shimmin <tes@sgi.com> Signed-off-by: Nathan Scott <nathans@sgi.com>
Showing 6 changed files with 95 additions and 76 deletions Side-by-side Diff
fs/xfs/quota/xfs_dquot.h
1 | 1 | /* |
2 | - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | |
2 | + * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | 5 | * under the terms of version 2 of the GNU General Public License as |
... | ... | @@ -112,20 +112,6 @@ |
112 | 112 | #define dq_flags q_lists.dqm_flags |
113 | 113 | |
114 | 114 | #define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++) |
115 | - | |
116 | -/* | |
117 | - * Quota Accounting/Enforcement flags | |
118 | - */ | |
119 | -#define XFS_ALL_QUOTA_ACCT \ | |
120 | - (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) | |
121 | -#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) | |
122 | -#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) | |
123 | - | |
124 | -#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) | |
125 | -#define XFS_IS_QUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ENFD) | |
126 | -#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) | |
127 | -#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) | |
128 | -#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) | |
129 | 115 | |
130 | 116 | #ifdef DEBUG |
131 | 117 | static inline int |
fs/xfs/quota/xfs_qm.c
1 | 1 | /* |
2 | - * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | |
2 | + * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | 5 | * under the terms of version 2 of the GNU General Public License as |
... | ... | @@ -365,16 +365,6 @@ |
365 | 365 | int error = 0; |
366 | 366 | uint sbf; |
367 | 367 | |
368 | - /* | |
369 | - * If a file system had quotas running earlier, but decided to | |
370 | - * mount without -o uquota/pquota/gquota options, revoke the | |
371 | - * quotachecked license, and bail out. | |
372 | - */ | |
373 | - if (! XFS_IS_QUOTA_ON(mp) && | |
374 | - (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT)) { | |
375 | - mp->m_qflags = 0; | |
376 | - goto write_changes; | |
377 | - } | |
378 | 368 | |
379 | 369 | /* |
380 | 370 | * If quotas on realtime volumes is not supported, we disable |
... | ... | @@ -2002,7 +1992,7 @@ |
2002 | 1992 | ASSERT(mp->m_quotainfo != NULL); |
2003 | 1993 | ASSERT(xfs_Gqm != NULL); |
2004 | 1994 | xfs_qm_destroy_quotainfo(mp); |
2005 | - xfs_mount_reset_sbqflags(mp); | |
1995 | + (void)xfs_mount_reset_sbqflags(mp); | |
2006 | 1996 | } else { |
2007 | 1997 | cmn_err(CE_NOTE, "XFS quotacheck %s: Done.", mp->m_fsname); |
2008 | 1998 | } |
fs/xfs/quota/xfs_qm.h
... | ... | @@ -184,8 +184,6 @@ |
184 | 184 | #define XFS_QM_HOLD(xqm) ((xqm)->qm_nrefs++) |
185 | 185 | #define XFS_QM_RELE(xqm) ((xqm)->qm_nrefs--) |
186 | 186 | |
187 | -extern void xfs_mount_reset_sbqflags(xfs_mount_t *); | |
188 | - | |
189 | 187 | extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); |
190 | 188 | extern int xfs_qm_mount_quotas(xfs_mount_t *, int); |
191 | 189 | extern void xfs_qm_mount_quotainit(xfs_mount_t *, uint); |
fs/xfs/quota/xfs_qm_bhv.c
1 | 1 | /* |
2 | - * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | |
2 | + * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | 5 | * under the terms of version 2 of the GNU General Public License as |
... | ... | @@ -227,48 +227,6 @@ |
227 | 227 | } |
228 | 228 | PVFS_SYNC(BHV_NEXT(bhv), flags, credp, error); |
229 | 229 | return error; |
230 | -} | |
231 | - | |
232 | -/* | |
233 | - * Clear the quotaflags in memory and in the superblock. | |
234 | - */ | |
235 | -void | |
236 | -xfs_mount_reset_sbqflags( | |
237 | - xfs_mount_t *mp) | |
238 | -{ | |
239 | - xfs_trans_t *tp; | |
240 | - unsigned long s; | |
241 | - | |
242 | - mp->m_qflags = 0; | |
243 | - /* | |
244 | - * It is OK to look at sb_qflags here in mount path, | |
245 | - * without SB_LOCK. | |
246 | - */ | |
247 | - if (mp->m_sb.sb_qflags == 0) | |
248 | - return; | |
249 | - s = XFS_SB_LOCK(mp); | |
250 | - mp->m_sb.sb_qflags = 0; | |
251 | - XFS_SB_UNLOCK(mp, s); | |
252 | - | |
253 | - /* | |
254 | - * if the fs is readonly, let the incore superblock run | |
255 | - * with quotas off but don't flush the update out to disk | |
256 | - */ | |
257 | - if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY) | |
258 | - return; | |
259 | -#ifdef QUOTADEBUG | |
260 | - xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); | |
261 | -#endif | |
262 | - tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); | |
263 | - if (xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, | |
264 | - XFS_DEFAULT_LOG_COUNT)) { | |
265 | - xfs_trans_cancel(tp, 0); | |
266 | - xfs_fs_cmn_err(CE_ALERT, mp, | |
267 | - "xfs_mount_reset_sbqflags: Superblock update failed!"); | |
268 | - return; | |
269 | - } | |
270 | - xfs_mod_sb(tp, XFS_SB_QFLAGS); | |
271 | - xfs_trans_commit(tp, 0, NULL); | |
272 | 230 | } |
273 | 231 | |
274 | 232 | STATIC int |
fs/xfs/xfs_qmops.c
1 | 1 | /* |
2 | - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | |
2 | + * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | 5 | * under the terms of version 2 of the GNU General Public License as |
6 | 6 | |
... | ... | @@ -42,8 +42,9 @@ |
42 | 42 | #include "xfs_dir2.h" |
43 | 43 | #include "xfs_dmapi.h" |
44 | 44 | #include "xfs_mount.h" |
45 | +#include "xfs_quota.h" | |
46 | +#include "xfs_error.h" | |
45 | 47 | |
46 | - | |
47 | 48 | STATIC struct xfs_dquot * |
48 | 49 | xfs_dqvopchown_default( |
49 | 50 | struct xfs_trans *tp, |
50 | 51 | |
... | ... | @@ -54,8 +55,79 @@ |
54 | 55 | return NULL; |
55 | 56 | } |
56 | 57 | |
58 | +/* | |
59 | + * Clear the quotaflags in memory and in the superblock. | |
60 | + */ | |
61 | +int | |
62 | +xfs_mount_reset_sbqflags(xfs_mount_t *mp) | |
63 | +{ | |
64 | + int error; | |
65 | + xfs_trans_t *tp; | |
66 | + unsigned long s; | |
67 | + | |
68 | + mp->m_qflags = 0; | |
69 | + /* | |
70 | + * It is OK to look at sb_qflags here in mount path, | |
71 | + * without SB_LOCK. | |
72 | + */ | |
73 | + if (mp->m_sb.sb_qflags == 0) | |
74 | + return 0; | |
75 | + s = XFS_SB_LOCK(mp); | |
76 | + mp->m_sb.sb_qflags = 0; | |
77 | + XFS_SB_UNLOCK(mp, s); | |
78 | + | |
79 | + /* | |
80 | + * if the fs is readonly, let the incore superblock run | |
81 | + * with quotas off but don't flush the update out to disk | |
82 | + */ | |
83 | + if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY) | |
84 | + return 0; | |
85 | +#ifdef QUOTADEBUG | |
86 | + xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); | |
87 | +#endif | |
88 | + tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); | |
89 | + if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, | |
90 | + XFS_DEFAULT_LOG_COUNT))) { | |
91 | + xfs_trans_cancel(tp, 0); | |
92 | + xfs_fs_cmn_err(CE_ALERT, mp, | |
93 | + "xfs_mount_reset_sbqflags: Superblock update failed!"); | |
94 | + return error; | |
95 | + } | |
96 | + xfs_mod_sb(tp, XFS_SB_QFLAGS); | |
97 | + error = xfs_trans_commit(tp, 0, NULL); | |
98 | + return error; | |
99 | +} | |
100 | + | |
101 | +STATIC int | |
102 | +xfs_noquota_init( | |
103 | + xfs_mount_t *mp, | |
104 | + uint *needquotamount, | |
105 | + uint *quotaflags) | |
106 | +{ | |
107 | + int error = 0; | |
108 | + | |
109 | + *quotaflags = 0; | |
110 | + *needquotamount = B_FALSE; | |
111 | + | |
112 | + ASSERT(!XFS_IS_QUOTA_ON(mp)); | |
113 | + | |
114 | + /* | |
115 | + * If a file system had quotas running earlier, but decided to | |
116 | + * mount without -o uquota/pquota/gquota options, revoke the | |
117 | + * quotachecked license. | |
118 | + */ | |
119 | + if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { | |
120 | + cmn_err(CE_NOTE, | |
121 | + "XFS resetting qflags for filesystem %s", | |
122 | + mp->m_fsname); | |
123 | + | |
124 | + error = xfs_mount_reset_sbqflags(mp); | |
125 | + } | |
126 | + return error; | |
127 | +} | |
128 | + | |
57 | 129 | xfs_qmops_t xfs_qmcore_stub = { |
58 | - .xfs_qminit = (xfs_qminit_t) fs_noerr, | |
130 | + .xfs_qminit = (xfs_qminit_t) xfs_noquota_init, | |
59 | 131 | .xfs_qmdone = (xfs_qmdone_t) fs_noerr, |
60 | 132 | .xfs_qmmount = (xfs_qmmount_t) fs_noerr, |
61 | 133 | .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr, |
fs/xfs/xfs_quota.h
1 | 1 | /* |
2 | - * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | |
2 | + * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | |
3 | 3 | * |
4 | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | 5 | * under the terms of version 2 of the GNU General Public License as |
... | ... | @@ -160,6 +160,20 @@ |
160 | 160 | #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ |
161 | 161 | |
162 | 162 | /* |
163 | + * Quota Accounting/Enforcement flags | |
164 | + */ | |
165 | +#define XFS_ALL_QUOTA_ACCT \ | |
166 | + (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) | |
167 | +#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) | |
168 | +#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) | |
169 | + | |
170 | +#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) | |
171 | +#define XFS_IS_QUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ENFD) | |
172 | +#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) | |
173 | +#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) | |
174 | +#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) | |
175 | + | |
176 | +/* | |
163 | 177 | * Incore only flags for quotaoff - these bits get cleared when quota(s) |
164 | 178 | * are in the process of getting turned off. These flags are in m_qflags but |
165 | 179 | * never in sb_qflags. |
... | ... | @@ -362,6 +376,7 @@ |
362 | 376 | f | XFS_QMOPT_RES_REGBLKS) |
363 | 377 | |
364 | 378 | extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); |
379 | +extern int xfs_mount_reset_sbqflags(struct xfs_mount *); | |
365 | 380 | |
366 | 381 | extern struct bhv_vfsops xfs_qmops; |
367 | 382 |