]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
da23017d NS |
2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
dfc130f3 | 4 | * |
da23017d NS |
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 | |
2bd0ea18 | 7 | * published by the Free Software Foundation. |
dfc130f3 | 8 | * |
da23017d NS |
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. | |
dfc130f3 | 13 | * |
da23017d NS |
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 | |
2bd0ea18 NS |
17 | */ |
18 | ||
19 | #include <libxfs.h> | |
20 | ||
21 | #define EXTERN | |
22 | #include "versions.h" | |
23 | #undef EXTERN | |
24 | #include "err_protos.h" | |
25 | #include "globals.h" | |
26 | ||
27 | void | |
28 | update_sb_version(xfs_mount_t *mp) | |
29 | { | |
30 | xfs_sb_t *sb; | |
31 | __uint16_t vn; | |
32 | ||
33 | sb = &mp->m_sb; | |
34 | ||
5e656dbb BN |
35 | if (fs_attributes && !xfs_sb_version_hasattr(sb)) { |
36 | ASSERT(fs_attributes_allowed); | |
37 | xfs_sb_version_addattr(sb); | |
2bd0ea18 NS |
38 | } |
39 | ||
5e656dbb BN |
40 | if (fs_attributes2 && !xfs_sb_version_hasattr2(sb)) { |
41 | ASSERT(fs_attributes2_allowed); | |
42 | xfs_sb_version_addattr2(sb); | |
9b1d68ec NS |
43 | } |
44 | ||
5e656dbb BN |
45 | if (fs_inode_nlink && !xfs_sb_version_hasnlink(sb)) { |
46 | ASSERT(fs_inode_nlink_allowed); | |
47 | xfs_sb_version_addnlink(sb); | |
2bd0ea18 NS |
48 | } |
49 | ||
50 | /* | |
51 | * fix up the superblock version number and feature bits, | |
52 | * turn off quota bits and flags if the filesystem doesn't | |
53 | * have quotas. | |
54 | */ | |
55 | if (fs_quotas) { | |
5e656dbb | 56 | if (!xfs_sb_version_hasquota(sb)) { |
2bd0ea18 | 57 | ASSERT(fs_quotas_allowed); |
5e656dbb | 58 | xfs_sb_version_addquota(sb); |
2bd0ea18 NS |
59 | } |
60 | ||
61 | /* | |
62 | * protect against stray bits in the quota flag field | |
63 | */ | |
64 | if (sb->sb_qflags & ~(XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD| | |
b36eef04 | 65 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT| |
46eca962 | 66 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD| |
9b27bdbb | 67 | XFS_PQUOTA_ACCT)) { |
2bd0ea18 NS |
68 | /* |
69 | * update the incore superblock, if we're in | |
70 | * no_modify mode, it'll never get flushed out | |
71 | * so this is ok. | |
72 | */ | |
507f4e33 | 73 | do_warn(_("bogus quota flags 0x%x set in superblock"), |
2bd0ea18 NS |
74 | sb->sb_qflags & ~(XFS_UQUOTA_ACCT| |
75 | XFS_UQUOTA_ENFD| | |
b36eef04 | 76 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT| |
46eca962 | 77 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD| |
9b27bdbb | 78 | XFS_PQUOTA_ACCT)); |
2bd0ea18 | 79 | |
9b27bdbb | 80 | sb->sb_qflags &= (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD| |
b36eef04 | 81 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT| |
46eca962 | 82 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD| |
9b27bdbb | 83 | XFS_PQUOTA_ACCT); |
2bd0ea18 NS |
84 | |
85 | if (!no_modify) | |
507f4e33 | 86 | do_warn(_(", bogus flags will be cleared\n")); |
2bd0ea18 | 87 | else |
507f4e33 | 88 | do_warn(_(", bogus flags would be cleared\n")); |
2bd0ea18 NS |
89 | } |
90 | } else { | |
91 | sb->sb_qflags = 0; | |
92 | ||
5e656dbb | 93 | if (xfs_sb_version_hasquota(sb)) { |
2bd0ea18 NS |
94 | lost_quotas = 1; |
95 | vn = sb->sb_versionnum; | |
96 | vn &= ~XFS_SB_VERSION_QUOTABIT; | |
97 | ||
98 | if (!(vn & XFS_SB_VERSION_ALLFBITS)) | |
5e656dbb | 99 | vn = xfs_sb_version_toold(vn); |
dfc130f3 | 100 | |
2bd0ea18 NS |
101 | ASSERT(vn != 0); |
102 | sb->sb_versionnum = vn; | |
103 | } | |
104 | } | |
105 | ||
5e656dbb BN |
106 | if (!fs_aligned_inodes && xfs_sb_version_hasalign(sb)) |
107 | sb->sb_versionnum &= ~XFS_SB_VERSION_ALIGNBIT; | |
2bd0ea18 NS |
108 | } |
109 | ||
110 | /* | |
111 | * returns 0 if things are fine, 1 if we don't understand | |
112 | * this superblock version. Sets superblock geometry-dependent | |
113 | * global variables. | |
114 | */ | |
115 | int | |
116 | parse_sb_version(xfs_sb_t *sb) | |
117 | { | |
118 | int issue_warning; | |
119 | ||
120 | fs_attributes = 0; | |
9b1d68ec | 121 | fs_attributes2 = 0; |
2bd0ea18 NS |
122 | fs_inode_nlink = 0; |
123 | fs_quotas = 0; | |
124 | fs_aligned_inodes = 0; | |
125 | fs_sb_feature_bits = 0; | |
126 | fs_ino_alignment = 0; | |
127 | fs_has_extflgbit = 0; | |
128 | have_uquotino = 0; | |
b36eef04 | 129 | have_gquotino = 0; |
2bd0ea18 NS |
130 | issue_warning = 0; |
131 | ||
132 | /* | |
133 | * ok, check to make sure that the sb isn't newer | |
134 | * than we are | |
135 | */ | |
5e656dbb | 136 | if (xfs_sb_version_hasextflgbit(sb)) { |
2bd0ea18 NS |
137 | fs_has_extflgbit = 1; |
138 | if (!fs_has_extflgbit_allowed) { | |
139 | issue_warning = 1; | |
140 | do_warn( | |
507f4e33 | 141 | _("This filesystem has uninitialized extent flags.\n")); |
2bd0ea18 NS |
142 | } |
143 | } | |
144 | ||
5e656dbb | 145 | if (xfs_sb_version_hasshared(sb)) { |
2bd0ea18 NS |
146 | fs_shared = 1; |
147 | if (!fs_shared_allowed) { | |
148 | issue_warning = 1; | |
507f4e33 | 149 | do_warn(_("This filesystem is marked shared.\n")); |
2bd0ea18 NS |
150 | } |
151 | } | |
152 | ||
153 | if (issue_warning) { | |
154 | do_warn( | |
507f4e33 NS |
155 | _("This filesystem uses feature(s) not yet supported in this release.\n" |
156 | "Please run a more recent version of xfs_repair.\n")); | |
2bd0ea18 NS |
157 | return(1); |
158 | } | |
159 | ||
5e656dbb | 160 | if (!xfs_sb_good_version(sb)) { |
507f4e33 NS |
161 | do_warn(_("WARNING: unknown superblock version %d\n"), |
162 | XFS_SB_VERSION_NUM(sb)); | |
2bd0ea18 | 163 | do_warn( |
507f4e33 | 164 | _("This filesystem contains features not understood by this program.\n")); |
2bd0ea18 NS |
165 | return(1); |
166 | } | |
167 | ||
e0607266 | 168 | if (XFS_SB_VERSION_NUM(sb) >= XFS_SB_VERSION_4) { |
2bd0ea18 | 169 | if (!fs_sb_feature_bits_allowed) { |
2bd0ea18 NS |
170 | if (!no_modify) { |
171 | do_warn( | |
507f4e33 NS |
172 | _("WARNING: you have disallowed superblock-feature-bits-allowed\n" |
173 | "\tbut this superblock has feature bits. The superblock\n" | |
174 | "\twill be downgraded. This may cause loss of filesystem meta-data\n")); | |
2bd0ea18 NS |
175 | } else { |
176 | do_warn( | |
507f4e33 NS |
177 | _("WARNING: you have disallowed superblock-feature-bits-allowed\n" |
178 | "\tbut this superblock has feature bits. The superblock\n" | |
179 | "\twould be downgraded. This might cause loss of filesystem\n" | |
180 | "\tmeta-data.\n")); | |
2bd0ea18 NS |
181 | } |
182 | } else { | |
183 | fs_sb_feature_bits = 1; | |
184 | } | |
185 | } | |
186 | ||
5e656dbb | 187 | if (xfs_sb_version_hasattr(sb)) { |
2bd0ea18 | 188 | if (!fs_attributes_allowed) { |
2bd0ea18 NS |
189 | if (!no_modify) { |
190 | do_warn( | |
507f4e33 NS |
191 | _("WARNING: you have disallowed attributes but this filesystem\n" |
192 | "\thas attributes. The filesystem will be downgraded and\n" | |
193 | "\tall attributes will be removed.\n")); | |
2bd0ea18 NS |
194 | } else { |
195 | do_warn( | |
507f4e33 NS |
196 | _("WARNING: you have disallowed attributes but this filesystem\n" |
197 | "\thas attributes. The filesystem would be downgraded and\n" | |
198 | "\tall attributes would be removed.\n")); | |
2bd0ea18 NS |
199 | } |
200 | } else { | |
201 | fs_attributes = 1; | |
202 | } | |
203 | } | |
204 | ||
5e656dbb | 205 | if (xfs_sb_version_hasattr2(sb)) { |
9b1d68ec NS |
206 | if (!fs_attributes2_allowed) { |
207 | if (!no_modify) { | |
208 | do_warn( | |
209 | _("WARNING: you have disallowed attr2 attributes but this filesystem\n" | |
210 | "\thas attributes. The filesystem will be downgraded and\n" | |
211 | "\tall attr2 attributes will be removed.\n")); | |
212 | } else { | |
213 | do_warn( | |
214 | _("WARNING: you have disallowed attr2 attributes but this filesystem\n" | |
215 | "\thas attributes. The filesystem would be downgraded and\n" | |
216 | "\tall attr2 attributes would be removed.\n")); | |
217 | } | |
218 | } else { | |
219 | fs_attributes2 = 1; | |
220 | } | |
221 | } | |
222 | ||
5e656dbb | 223 | if (xfs_sb_version_hasnlink(sb)) { |
2bd0ea18 | 224 | if (!fs_inode_nlink_allowed) { |
2bd0ea18 NS |
225 | if (!no_modify) { |
226 | do_warn( | |
507f4e33 NS |
227 | _("WARNING: you have disallowed version 2 inodes but this filesystem\n" |
228 | "\thas version 2 inodes. The filesystem will be downgraded and\n" | |
229 | "\tall version 2 inodes will be converted to version 1 inodes.\n" | |
230 | "\tThis may cause some hard links to files to be destroyed\n")); | |
2bd0ea18 NS |
231 | } else { |
232 | do_warn( | |
507f4e33 NS |
233 | _("WARNING: you have disallowed version 2 inodes but this filesystem\n" |
234 | "\thas version 2 inodes. The filesystem would be downgraded and\n" | |
235 | "\tall version 2 inodes would be converted to version 1 inodes.\n" | |
236 | "\tThis might cause some hard links to files to be destroyed\n")); | |
2bd0ea18 NS |
237 | } |
238 | } else { | |
239 | fs_inode_nlink = 1; | |
240 | } | |
241 | } | |
242 | ||
5e656dbb | 243 | if (xfs_sb_version_hasquota(sb)) { |
2bd0ea18 | 244 | if (!fs_quotas_allowed) { |
2bd0ea18 NS |
245 | if (!no_modify) { |
246 | do_warn( | |
507f4e33 NS |
247 | _("WARNING: you have disallowed quotas but this filesystem\n" |
248 | "\thas quotas. The filesystem will be downgraded and\n" | |
249 | "\tall quota information will be removed.\n")); | |
2bd0ea18 NS |
250 | } else { |
251 | do_warn( | |
507f4e33 NS |
252 | _("WARNING: you have disallowed quotas but this filesystem\n" |
253 | "\thas quotas. The filesystem would be downgraded and\n" | |
254 | "\tall quota information would be removed.\n")); | |
2bd0ea18 NS |
255 | } |
256 | } else { | |
257 | fs_quotas = 1; | |
258 | ||
259 | if (sb->sb_uquotino != 0 && | |
260 | sb->sb_uquotino != NULLFSINO) | |
261 | have_uquotino = 1; | |
262 | ||
b36eef04 NS |
263 | if (sb->sb_gquotino != 0 && |
264 | sb->sb_gquotino != NULLFSINO) | |
265 | have_gquotino = 1; | |
2bd0ea18 NS |
266 | } |
267 | } | |
268 | ||
5e656dbb | 269 | if (xfs_sb_version_hasalign(sb)) { |
2bd0ea18 NS |
270 | if (fs_aligned_inodes_allowed) { |
271 | fs_aligned_inodes = 1; | |
272 | fs_ino_alignment = sb->sb_inoalignmt; | |
273 | } else { | |
2bd0ea18 NS |
274 | if (!no_modify) { |
275 | do_warn( | |
507f4e33 NS |
276 | _("WARNING: you have disallowed aligned inodes but this filesystem\n" |
277 | "\thas aligned inodes. The filesystem will be downgraded.\n" | |
278 | "\tThis will permanently degrade the performance of this filesystem.\n")); | |
2bd0ea18 NS |
279 | } else { |
280 | do_warn( | |
507f4e33 NS |
281 | _("WARNING: you have disallowed aligned inodes but this filesystem\n" |
282 | "\thas aligned inodes. The filesystem would be downgraded.\n" | |
283 | "\tThis would permanently degrade the performance of this filesystem.\n")); | |
2bd0ea18 NS |
284 | } |
285 | } | |
286 | } | |
287 | ||
288 | /* | |
289 | * calculate maximum file offset for this geometry | |
290 | */ | |
291 | fs_max_file_offset = 0x7fffffffffffffffLL >> sb->sb_blocklog; | |
292 | ||
293 | return(0); | |
294 | } |