]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
a805bad5 | 2 | * Copyright (c) 2000-2006 Silicon Graphics, Inc. |
7b718769 | 3 | * All Rights Reserved. |
1da177e4 | 4 | * |
7b718769 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 | |
1da177e4 LT |
7 | * published by the Free Software Foundation. |
8 | * | |
7b718769 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. | |
1da177e4 | 13 | * |
7b718769 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 | |
1da177e4 | 17 | */ |
0b1b213f | 18 | |
1da177e4 | 19 | #include "xfs.h" |
a844f451 | 20 | #include "xfs_bit.h" |
1da177e4 | 21 | #include "xfs_log.h" |
a844f451 | 22 | #include "xfs_inum.h" |
1da177e4 LT |
23 | #include "xfs_trans.h" |
24 | #include "xfs_sb.h" | |
a844f451 | 25 | #include "xfs_ag.h" |
1da177e4 LT |
26 | #include "xfs_dir2.h" |
27 | #include "xfs_alloc.h" | |
28 | #include "xfs_dmapi.h" | |
29 | #include "xfs_quota.h" | |
30 | #include "xfs_mount.h" | |
1da177e4 | 31 | #include "xfs_bmap_btree.h" |
a844f451 | 32 | #include "xfs_alloc_btree.h" |
1da177e4 | 33 | #include "xfs_ialloc_btree.h" |
1da177e4 | 34 | #include "xfs_dir2_sf.h" |
a844f451 | 35 | #include "xfs_attr_sf.h" |
1da177e4 LT |
36 | #include "xfs_dinode.h" |
37 | #include "xfs_inode.h" | |
a844f451 | 38 | #include "xfs_btree.h" |
8c4ed633 | 39 | #include "xfs_btree_trace.h" |
a844f451 | 40 | #include "xfs_ialloc.h" |
1da177e4 | 41 | #include "xfs_bmap.h" |
1da177e4 LT |
42 | #include "xfs_rtalloc.h" |
43 | #include "xfs_error.h" | |
44 | #include "xfs_itable.h" | |
9909c4aa | 45 | #include "xfs_fsops.h" |
1da177e4 | 46 | #include "xfs_rw.h" |
1da177e4 LT |
47 | #include "xfs_attr.h" |
48 | #include "xfs_buf_item.h" | |
49 | #include "xfs_utils.h" | |
739bfb2a | 50 | #include "xfs_vnodeops.h" |
1da177e4 | 51 | #include "xfs_version.h" |
a67d7c5f | 52 | #include "xfs_log_priv.h" |
249a8c11 | 53 | #include "xfs_trans_priv.h" |
48b62a1a | 54 | #include "xfs_filestream.h" |
9f8868ff | 55 | #include "xfs_da_btree.h" |
9f8868ff CH |
56 | #include "xfs_extfree_item.h" |
57 | #include "xfs_mru_cache.h" | |
58 | #include "xfs_inode_item.h" | |
fe4fa4b8 | 59 | #include "xfs_sync.h" |
0b1b213f | 60 | #include "xfs_trace.h" |
1da177e4 LT |
61 | |
62 | #include <linux/namei.h> | |
63 | #include <linux/init.h> | |
5a0e3ad6 | 64 | #include <linux/slab.h> |
1da177e4 | 65 | #include <linux/mount.h> |
0829c360 | 66 | #include <linux/mempool.h> |
1da177e4 | 67 | #include <linux/writeback.h> |
4df08c52 | 68 | #include <linux/kthread.h> |
7dfb7103 | 69 | #include <linux/freezer.h> |
62a877e3 | 70 | #include <linux/parser.h> |
1da177e4 | 71 | |
b87221de | 72 | static const struct super_operations xfs_super_operations; |
7989cb8e | 73 | static kmem_zone_t *xfs_ioend_zone; |
0829c360 | 74 | mempool_t *xfs_ioend_pool; |
1da177e4 | 75 | |
a67d7c5f DC |
76 | #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ |
77 | #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ | |
78 | #define MNTOPT_LOGDEV "logdev" /* log device */ | |
79 | #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */ | |
80 | #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */ | |
81 | #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */ | |
a67d7c5f DC |
82 | #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */ |
83 | #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */ | |
84 | #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */ | |
85 | #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */ | |
86 | #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */ | |
87 | #define MNTOPT_MTPT "mtpt" /* filesystem mount point */ | |
88 | #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */ | |
89 | #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */ | |
90 | #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */ | |
91 | #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */ | |
92 | #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */ | |
93 | #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ | |
94 | #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and | |
95 | * unwritten extent conversion */ | |
96 | #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */ | |
97 | #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */ | |
98 | #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */ | |
99 | #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ | |
100 | #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ | |
101 | #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */ | |
102 | #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes | |
103 | * in stat(). */ | |
104 | #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */ | |
105 | #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */ | |
106 | #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */ | |
107 | #define MNTOPT_QUOTA "quota" /* disk quotas (user) */ | |
108 | #define MNTOPT_NOQUOTA "noquota" /* no quotas */ | |
109 | #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */ | |
110 | #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */ | |
111 | #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */ | |
112 | #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */ | |
113 | #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */ | |
114 | #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */ | |
115 | #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */ | |
116 | #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */ | |
117 | #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */ | |
118 | #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */ | |
119 | #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */ | |
120 | #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */ | |
121 | #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */ | |
71e330b5 DC |
122 | #define MNTOPT_DELAYLOG "delaylog" /* Delayed loging enabled */ |
123 | #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */ | |
a67d7c5f | 124 | |
62a877e3 CH |
125 | /* |
126 | * Table driven mount option parser. | |
127 | * | |
128 | * Currently only used for remount, but it will be used for mount | |
129 | * in the future, too. | |
130 | */ | |
131 | enum { | |
132 | Opt_barrier, Opt_nobarrier, Opt_err | |
133 | }; | |
134 | ||
a447c093 | 135 | static const match_table_t tokens = { |
62a877e3 CH |
136 | {Opt_barrier, "barrier"}, |
137 | {Opt_nobarrier, "nobarrier"}, | |
138 | {Opt_err, NULL} | |
139 | }; | |
140 | ||
141 | ||
a67d7c5f DC |
142 | STATIC unsigned long |
143 | suffix_strtoul(char *s, char **endp, unsigned int base) | |
144 | { | |
145 | int last, shift_left_factor = 0; | |
146 | char *value = s; | |
147 | ||
148 | last = strlen(value) - 1; | |
149 | if (value[last] == 'K' || value[last] == 'k') { | |
150 | shift_left_factor = 10; | |
151 | value[last] = '\0'; | |
152 | } | |
153 | if (value[last] == 'M' || value[last] == 'm') { | |
154 | shift_left_factor = 20; | |
155 | value[last] = '\0'; | |
156 | } | |
157 | if (value[last] == 'G' || value[last] == 'g') { | |
158 | shift_left_factor = 30; | |
159 | value[last] = '\0'; | |
160 | } | |
161 | ||
162 | return simple_strtoul((const char *)s, endp, base) << shift_left_factor; | |
163 | } | |
164 | ||
9d565ffa CH |
165 | /* |
166 | * This function fills in xfs_mount_t fields based on mount args. | |
167 | * Note: the superblock has _not_ yet been read in. | |
168 | * | |
169 | * Note that this function leaks the various device name allocations on | |
170 | * failure. The caller takes care of them. | |
171 | */ | |
a67d7c5f DC |
172 | STATIC int |
173 | xfs_parseargs( | |
174 | struct xfs_mount *mp, | |
175 | char *options, | |
9d565ffa | 176 | char **mtpt) |
a67d7c5f | 177 | { |
9d565ffa | 178 | struct super_block *sb = mp->m_super; |
a67d7c5f | 179 | char *this_char, *value, *eov; |
9d565ffa CH |
180 | int dsunit = 0; |
181 | int dswidth = 0; | |
182 | int iosize = 0; | |
1bd960ee | 183 | int dmapi_implies_ikeep = 1; |
a5687787 | 184 | __uint8_t iosizelog = 0; |
9d565ffa CH |
185 | |
186 | /* | |
187 | * Copy binary VFS mount flags we are interested in. | |
188 | */ | |
189 | if (sb->s_flags & MS_RDONLY) | |
190 | mp->m_flags |= XFS_MOUNT_RDONLY; | |
191 | if (sb->s_flags & MS_DIRSYNC) | |
192 | mp->m_flags |= XFS_MOUNT_DIRSYNC; | |
193 | if (sb->s_flags & MS_SYNCHRONOUS) | |
194 | mp->m_flags |= XFS_MOUNT_WSYNC; | |
195 | ||
196 | /* | |
197 | * Set some default flags that could be cleared by the mount option | |
198 | * parsing. | |
199 | */ | |
200 | mp->m_flags |= XFS_MOUNT_BARRIER; | |
201 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; | |
202 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; | |
a67d7c5f | 203 | |
9d565ffa CH |
204 | /* |
205 | * These can be overridden by the mount option parsing. | |
206 | */ | |
207 | mp->m_logbufs = -1; | |
208 | mp->m_logbsize = -1; | |
a67d7c5f DC |
209 | |
210 | if (!options) | |
211 | goto done; | |
212 | ||
a67d7c5f DC |
213 | while ((this_char = strsep(&options, ",")) != NULL) { |
214 | if (!*this_char) | |
215 | continue; | |
216 | if ((value = strchr(this_char, '=')) != NULL) | |
217 | *value++ = 0; | |
218 | ||
219 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { | |
220 | if (!value || !*value) { | |
221 | cmn_err(CE_WARN, | |
222 | "XFS: %s option requires an argument", | |
223 | this_char); | |
224 | return EINVAL; | |
225 | } | |
9d565ffa | 226 | mp->m_logbufs = simple_strtoul(value, &eov, 10); |
a67d7c5f DC |
227 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { |
228 | if (!value || !*value) { | |
229 | cmn_err(CE_WARN, | |
230 | "XFS: %s option requires an argument", | |
231 | this_char); | |
232 | return EINVAL; | |
233 | } | |
9d565ffa | 234 | mp->m_logbsize = suffix_strtoul(value, &eov, 10); |
a67d7c5f DC |
235 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { |
236 | if (!value || !*value) { | |
237 | cmn_err(CE_WARN, | |
238 | "XFS: %s option requires an argument", | |
239 | this_char); | |
240 | return EINVAL; | |
241 | } | |
9d565ffa CH |
242 | mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); |
243 | if (!mp->m_logname) | |
244 | return ENOMEM; | |
a67d7c5f DC |
245 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { |
246 | if (!value || !*value) { | |
247 | cmn_err(CE_WARN, | |
248 | "XFS: %s option requires an argument", | |
249 | this_char); | |
250 | return EINVAL; | |
251 | } | |
9d565ffa CH |
252 | *mtpt = kstrndup(value, MAXNAMELEN, GFP_KERNEL); |
253 | if (!*mtpt) | |
254 | return ENOMEM; | |
a67d7c5f DC |
255 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { |
256 | if (!value || !*value) { | |
257 | cmn_err(CE_WARN, | |
258 | "XFS: %s option requires an argument", | |
259 | this_char); | |
260 | return EINVAL; | |
261 | } | |
9d565ffa CH |
262 | mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL); |
263 | if (!mp->m_rtname) | |
264 | return ENOMEM; | |
a67d7c5f DC |
265 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { |
266 | if (!value || !*value) { | |
267 | cmn_err(CE_WARN, | |
268 | "XFS: %s option requires an argument", | |
269 | this_char); | |
270 | return EINVAL; | |
271 | } | |
272 | iosize = simple_strtoul(value, &eov, 10); | |
1ec7944b | 273 | iosizelog = ffs(iosize) - 1; |
a67d7c5f DC |
274 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { |
275 | if (!value || !*value) { | |
276 | cmn_err(CE_WARN, | |
277 | "XFS: %s option requires an argument", | |
278 | this_char); | |
279 | return EINVAL; | |
280 | } | |
281 | iosize = suffix_strtoul(value, &eov, 10); | |
9d565ffa | 282 | iosizelog = ffs(iosize) - 1; |
a67d7c5f DC |
283 | } else if (!strcmp(this_char, MNTOPT_GRPID) || |
284 | !strcmp(this_char, MNTOPT_BSDGROUPS)) { | |
285 | mp->m_flags |= XFS_MOUNT_GRPID; | |
286 | } else if (!strcmp(this_char, MNTOPT_NOGRPID) || | |
287 | !strcmp(this_char, MNTOPT_SYSVGROUPS)) { | |
288 | mp->m_flags &= ~XFS_MOUNT_GRPID; | |
289 | } else if (!strcmp(this_char, MNTOPT_WSYNC)) { | |
9d565ffa | 290 | mp->m_flags |= XFS_MOUNT_WSYNC; |
a67d7c5f | 291 | } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) { |
9d565ffa | 292 | mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC; |
a67d7c5f | 293 | } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) { |
9d565ffa | 294 | mp->m_flags |= XFS_MOUNT_NORECOVERY; |
a67d7c5f | 295 | } else if (!strcmp(this_char, MNTOPT_NOALIGN)) { |
9d565ffa | 296 | mp->m_flags |= XFS_MOUNT_NOALIGN; |
a67d7c5f | 297 | } else if (!strcmp(this_char, MNTOPT_SWALLOC)) { |
9d565ffa | 298 | mp->m_flags |= XFS_MOUNT_SWALLOC; |
a67d7c5f DC |
299 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { |
300 | if (!value || !*value) { | |
301 | cmn_err(CE_WARN, | |
302 | "XFS: %s option requires an argument", | |
303 | this_char); | |
304 | return EINVAL; | |
305 | } | |
306 | dsunit = simple_strtoul(value, &eov, 10); | |
307 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { | |
308 | if (!value || !*value) { | |
309 | cmn_err(CE_WARN, | |
310 | "XFS: %s option requires an argument", | |
311 | this_char); | |
312 | return EINVAL; | |
313 | } | |
314 | dswidth = simple_strtoul(value, &eov, 10); | |
315 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { | |
9d565ffa | 316 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; |
a67d7c5f DC |
317 | #if !XFS_BIG_INUMS |
318 | cmn_err(CE_WARN, | |
319 | "XFS: %s option not allowed on this system", | |
320 | this_char); | |
321 | return EINVAL; | |
322 | #endif | |
323 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { | |
9d565ffa | 324 | mp->m_flags |= XFS_MOUNT_NOUUID; |
a67d7c5f | 325 | } else if (!strcmp(this_char, MNTOPT_BARRIER)) { |
9d565ffa | 326 | mp->m_flags |= XFS_MOUNT_BARRIER; |
a67d7c5f | 327 | } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) { |
9d565ffa | 328 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
a67d7c5f | 329 | } else if (!strcmp(this_char, MNTOPT_IKEEP)) { |
9d565ffa | 330 | mp->m_flags |= XFS_MOUNT_IKEEP; |
a67d7c5f | 331 | } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { |
1bd960ee | 332 | dmapi_implies_ikeep = 0; |
9d565ffa | 333 | mp->m_flags &= ~XFS_MOUNT_IKEEP; |
a67d7c5f | 334 | } else if (!strcmp(this_char, MNTOPT_LARGEIO)) { |
9d565ffa | 335 | mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE; |
a67d7c5f | 336 | } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) { |
9d565ffa | 337 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; |
a67d7c5f | 338 | } else if (!strcmp(this_char, MNTOPT_ATTR2)) { |
9d565ffa | 339 | mp->m_flags |= XFS_MOUNT_ATTR2; |
a67d7c5f | 340 | } else if (!strcmp(this_char, MNTOPT_NOATTR2)) { |
9d565ffa CH |
341 | mp->m_flags &= ~XFS_MOUNT_ATTR2; |
342 | mp->m_flags |= XFS_MOUNT_NOATTR2; | |
a67d7c5f | 343 | } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) { |
9d565ffa | 344 | mp->m_flags |= XFS_MOUNT_FILESTREAMS; |
a67d7c5f | 345 | } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) { |
9d565ffa CH |
346 | mp->m_qflags &= ~(XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE | |
347 | XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | | |
469fc23d | 348 | XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | |
9d565ffa | 349 | XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD); |
a67d7c5f DC |
350 | } else if (!strcmp(this_char, MNTOPT_QUOTA) || |
351 | !strcmp(this_char, MNTOPT_UQUOTA) || | |
352 | !strcmp(this_char, MNTOPT_USRQUOTA)) { | |
9d565ffa CH |
353 | mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE | |
354 | XFS_UQUOTA_ENFD); | |
a67d7c5f DC |
355 | } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) || |
356 | !strcmp(this_char, MNTOPT_UQUOTANOENF)) { | |
9d565ffa CH |
357 | mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE); |
358 | mp->m_qflags &= ~XFS_UQUOTA_ENFD; | |
a67d7c5f DC |
359 | } else if (!strcmp(this_char, MNTOPT_PQUOTA) || |
360 | !strcmp(this_char, MNTOPT_PRJQUOTA)) { | |
9d565ffa CH |
361 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | |
362 | XFS_OQUOTA_ENFD); | |
a67d7c5f | 363 | } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) { |
9d565ffa CH |
364 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); |
365 | mp->m_qflags &= ~XFS_OQUOTA_ENFD; | |
a67d7c5f DC |
366 | } else if (!strcmp(this_char, MNTOPT_GQUOTA) || |
367 | !strcmp(this_char, MNTOPT_GRPQUOTA)) { | |
9d565ffa CH |
368 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | |
369 | XFS_OQUOTA_ENFD); | |
a67d7c5f | 370 | } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) { |
9d565ffa CH |
371 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); |
372 | mp->m_qflags &= ~XFS_OQUOTA_ENFD; | |
a67d7c5f | 373 | } else if (!strcmp(this_char, MNTOPT_DMAPI)) { |
9d565ffa | 374 | mp->m_flags |= XFS_MOUNT_DMAPI; |
a67d7c5f | 375 | } else if (!strcmp(this_char, MNTOPT_XDSM)) { |
9d565ffa | 376 | mp->m_flags |= XFS_MOUNT_DMAPI; |
a67d7c5f | 377 | } else if (!strcmp(this_char, MNTOPT_DMI)) { |
9d565ffa | 378 | mp->m_flags |= XFS_MOUNT_DMAPI; |
71e330b5 DC |
379 | } else if (!strcmp(this_char, MNTOPT_DELAYLOG)) { |
380 | mp->m_flags |= XFS_MOUNT_DELAYLOG; | |
381 | cmn_err(CE_WARN, | |
382 | "Enabling EXPERIMENTAL delayed logging feature " | |
383 | "- use at your own risk.\n"); | |
384 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { | |
385 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; | |
a67d7c5f DC |
386 | } else if (!strcmp(this_char, "ihashsize")) { |
387 | cmn_err(CE_WARN, | |
388 | "XFS: ihashsize no longer used, option is deprecated."); | |
389 | } else if (!strcmp(this_char, "osyncisdsync")) { | |
390 | /* no-op, this is now the default */ | |
391 | cmn_err(CE_WARN, | |
392 | "XFS: osyncisdsync is now the default, option is deprecated."); | |
393 | } else if (!strcmp(this_char, "irixsgid")) { | |
394 | cmn_err(CE_WARN, | |
395 | "XFS: irixsgid is now a sysctl(2) variable, option is deprecated."); | |
396 | } else { | |
397 | cmn_err(CE_WARN, | |
398 | "XFS: unknown mount option [%s].", this_char); | |
399 | return EINVAL; | |
400 | } | |
401 | } | |
402 | ||
9d565ffa CH |
403 | /* |
404 | * no recovery flag requires a read-only mount | |
405 | */ | |
406 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && | |
407 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { | |
408 | cmn_err(CE_WARN, "XFS: no-recovery mounts must be read-only."); | |
409 | return EINVAL; | |
a67d7c5f DC |
410 | } |
411 | ||
9d565ffa | 412 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { |
a67d7c5f DC |
413 | cmn_err(CE_WARN, |
414 | "XFS: sunit and swidth options incompatible with the noalign option"); | |
415 | return EINVAL; | |
416 | } | |
417 | ||
7d095257 CH |
418 | #ifndef CONFIG_XFS_QUOTA |
419 | if (XFS_IS_QUOTA_RUNNING(mp)) { | |
420 | cmn_err(CE_WARN, | |
421 | "XFS: quota support not available in this kernel."); | |
422 | return EINVAL; | |
423 | } | |
424 | #endif | |
425 | ||
9d565ffa CH |
426 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && |
427 | (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { | |
a67d7c5f DC |
428 | cmn_err(CE_WARN, |
429 | "XFS: cannot mount with both project and group quota"); | |
430 | return EINVAL; | |
431 | } | |
432 | ||
9d565ffa | 433 | if ((mp->m_flags & XFS_MOUNT_DMAPI) && (!*mtpt || *mtpt[0] == '\0')) { |
a67d7c5f DC |
434 | printk("XFS: %s option needs the mount point option as well\n", |
435 | MNTOPT_DMAPI); | |
436 | return EINVAL; | |
437 | } | |
438 | ||
439 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { | |
440 | cmn_err(CE_WARN, | |
441 | "XFS: sunit and swidth must be specified together"); | |
442 | return EINVAL; | |
443 | } | |
444 | ||
445 | if (dsunit && (dswidth % dsunit != 0)) { | |
446 | cmn_err(CE_WARN, | |
447 | "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)", | |
448 | dswidth, dsunit); | |
449 | return EINVAL; | |
450 | } | |
451 | ||
452 | /* | |
453 | * Applications using DMI filesystems often expect the | |
454 | * inode generation number to be monotonically increasing. | |
455 | * If we delete inode chunks we break this assumption, so | |
456 | * keep unused inode chunks on disk for DMI filesystems | |
457 | * until we come up with a better solution. | |
458 | * Note that if "ikeep" or "noikeep" mount options are | |
459 | * supplied, then they are honored. | |
460 | */ | |
9d565ffa CH |
461 | if ((mp->m_flags & XFS_MOUNT_DMAPI) && dmapi_implies_ikeep) |
462 | mp->m_flags |= XFS_MOUNT_IKEEP; | |
a67d7c5f | 463 | |
9d565ffa CH |
464 | done: |
465 | if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) { | |
466 | /* | |
467 | * At this point the superblock has not been read | |
468 | * in, therefore we do not know the block size. | |
469 | * Before the mount call ends we will convert | |
470 | * these to FSBs. | |
471 | */ | |
a67d7c5f | 472 | if (dsunit) { |
9d565ffa CH |
473 | mp->m_dalign = dsunit; |
474 | mp->m_flags |= XFS_MOUNT_RETERR; | |
a67d7c5f | 475 | } |
9d565ffa CH |
476 | |
477 | if (dswidth) | |
478 | mp->m_swidth = dswidth; | |
479 | } | |
480 | ||
481 | if (mp->m_logbufs != -1 && | |
482 | mp->m_logbufs != 0 && | |
483 | (mp->m_logbufs < XLOG_MIN_ICLOGS || | |
484 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { | |
485 | cmn_err(CE_WARN, | |
486 | "XFS: invalid logbufs value: %d [not %d-%d]", | |
487 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); | |
488 | return XFS_ERROR(EINVAL); | |
489 | } | |
490 | if (mp->m_logbsize != -1 && | |
491 | mp->m_logbsize != 0 && | |
492 | (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || | |
493 | mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || | |
494 | !is_power_of_2(mp->m_logbsize))) { | |
495 | cmn_err(CE_WARN, | |
496 | "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", | |
497 | mp->m_logbsize); | |
498 | return XFS_ERROR(EINVAL); | |
499 | } | |
500 | ||
501 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); | |
502 | if (!mp->m_fsname) | |
503 | return ENOMEM; | |
504 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; | |
505 | ||
506 | if (iosizelog) { | |
507 | if (iosizelog > XFS_MAX_IO_LOG || | |
508 | iosizelog < XFS_MIN_IO_LOG) { | |
509 | cmn_err(CE_WARN, | |
510 | "XFS: invalid log iosize: %d [not %d-%d]", | |
511 | iosizelog, XFS_MIN_IO_LOG, | |
512 | XFS_MAX_IO_LOG); | |
513 | return XFS_ERROR(EINVAL); | |
514 | } | |
515 | ||
516 | mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; | |
517 | mp->m_readio_log = iosizelog; | |
518 | mp->m_writeio_log = iosizelog; | |
a67d7c5f DC |
519 | } |
520 | ||
a67d7c5f DC |
521 | return 0; |
522 | } | |
523 | ||
524 | struct proc_xfs_info { | |
525 | int flag; | |
526 | char *str; | |
527 | }; | |
528 | ||
529 | STATIC int | |
530 | xfs_showargs( | |
531 | struct xfs_mount *mp, | |
532 | struct seq_file *m) | |
533 | { | |
534 | static struct proc_xfs_info xfs_info_set[] = { | |
535 | /* the few simple ones we can get from the mount struct */ | |
1bd960ee | 536 | { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP }, |
a67d7c5f | 537 | { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC }, |
a67d7c5f DC |
538 | { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN }, |
539 | { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC }, | |
540 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, | |
541 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, | |
542 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, | |
543 | { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 }, | |
544 | { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM }, | |
545 | { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI }, | |
546 | { XFS_MOUNT_GRPID, "," MNTOPT_GRPID }, | |
71e330b5 | 547 | { XFS_MOUNT_DELAYLOG, "," MNTOPT_DELAYLOG }, |
a67d7c5f DC |
548 | { 0, NULL } |
549 | }; | |
550 | static struct proc_xfs_info xfs_info_unset[] = { | |
551 | /* the few simple ones we can get from the mount struct */ | |
a67d7c5f DC |
552 | { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO }, |
553 | { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER }, | |
554 | { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE }, | |
555 | { 0, NULL } | |
556 | }; | |
557 | struct proc_xfs_info *xfs_infop; | |
558 | ||
559 | for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) { | |
560 | if (mp->m_flags & xfs_infop->flag) | |
561 | seq_puts(m, xfs_infop->str); | |
562 | } | |
563 | for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) { | |
564 | if (!(mp->m_flags & xfs_infop->flag)) | |
565 | seq_puts(m, xfs_infop->str); | |
566 | } | |
567 | ||
568 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) | |
569 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk", | |
570 | (int)(1 << mp->m_writeio_log) >> 10); | |
571 | ||
572 | if (mp->m_logbufs > 0) | |
573 | seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); | |
574 | if (mp->m_logbsize > 0) | |
575 | seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10); | |
576 | ||
577 | if (mp->m_logname) | |
578 | seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname); | |
579 | if (mp->m_rtname) | |
580 | seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname); | |
581 | ||
582 | if (mp->m_dalign > 0) | |
583 | seq_printf(m, "," MNTOPT_SUNIT "=%d", | |
584 | (int)XFS_FSB_TO_BB(mp, mp->m_dalign)); | |
585 | if (mp->m_swidth > 0) | |
586 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", | |
587 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); | |
588 | ||
589 | if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD)) | |
590 | seq_puts(m, "," MNTOPT_USRQUOTA); | |
591 | else if (mp->m_qflags & XFS_UQUOTA_ACCT) | |
592 | seq_puts(m, "," MNTOPT_UQUOTANOENF); | |
593 | ||
988abe40 AE |
594 | /* Either project or group quotas can be active, not both */ |
595 | ||
596 | if (mp->m_qflags & XFS_PQUOTA_ACCT) { | |
597 | if (mp->m_qflags & XFS_OQUOTA_ENFD) | |
598 | seq_puts(m, "," MNTOPT_PRJQUOTA); | |
599 | else | |
600 | seq_puts(m, "," MNTOPT_PQUOTANOENF); | |
601 | } else if (mp->m_qflags & XFS_GQUOTA_ACCT) { | |
602 | if (mp->m_qflags & XFS_OQUOTA_ENFD) | |
603 | seq_puts(m, "," MNTOPT_GRPQUOTA); | |
604 | else | |
605 | seq_puts(m, "," MNTOPT_GQUOTANOENF); | |
606 | } | |
a67d7c5f DC |
607 | |
608 | if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) | |
609 | seq_puts(m, "," MNTOPT_NOQUOTA); | |
610 | ||
611 | return 0; | |
612 | } | |
1da177e4 LT |
613 | __uint64_t |
614 | xfs_max_file_offset( | |
615 | unsigned int blockshift) | |
616 | { | |
617 | unsigned int pagefactor = 1; | |
618 | unsigned int bitshift = BITS_PER_LONG - 1; | |
619 | ||
620 | /* Figure out maximum filesize, on Linux this can depend on | |
621 | * the filesystem blocksize (on 32 bit platforms). | |
622 | * __block_prepare_write does this in an [unsigned] long... | |
623 | * page->index << (PAGE_CACHE_SHIFT - bbits) | |
624 | * So, for page sized blocks (4K on 32 bit platforms), | |
625 | * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is | |
626 | * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) | |
627 | * but for smaller blocksizes it is less (bbits = log2 bsize). | |
628 | * Note1: get_block_t takes a long (implicit cast from above) | |
629 | * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch | |
630 | * can optionally convert the [unsigned] long from above into | |
631 | * an [unsigned] long long. | |
632 | */ | |
633 | ||
634 | #if BITS_PER_LONG == 32 | |
90c699a9 | 635 | # if defined(CONFIG_LBDAF) |
1da177e4 LT |
636 | ASSERT(sizeof(sector_t) == 8); |
637 | pagefactor = PAGE_CACHE_SIZE; | |
638 | bitshift = BITS_PER_LONG; | |
639 | # else | |
640 | pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift); | |
641 | # endif | |
642 | #endif | |
643 | ||
644 | return (((__uint64_t)pagefactor) << bitshift) - 1; | |
645 | } | |
646 | ||
3180e66d | 647 | STATIC int |
1da177e4 LT |
648 | xfs_blkdev_get( |
649 | xfs_mount_t *mp, | |
650 | const char *name, | |
651 | struct block_device **bdevp) | |
652 | { | |
653 | int error = 0; | |
654 | ||
30c40d2c | 655 | *bdevp = open_bdev_exclusive(name, FMODE_READ|FMODE_WRITE, mp); |
1da177e4 LT |
656 | if (IS_ERR(*bdevp)) { |
657 | error = PTR_ERR(*bdevp); | |
658 | printk("XFS: Invalid device [%s], error=%d\n", name, error); | |
659 | } | |
660 | ||
661 | return -error; | |
662 | } | |
663 | ||
3180e66d | 664 | STATIC void |
1da177e4 LT |
665 | xfs_blkdev_put( |
666 | struct block_device *bdev) | |
667 | { | |
668 | if (bdev) | |
30c40d2c | 669 | close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE); |
1da177e4 LT |
670 | } |
671 | ||
f538d4da CH |
672 | /* |
673 | * Try to write out the superblock using barriers. | |
674 | */ | |
675 | STATIC int | |
676 | xfs_barrier_test( | |
677 | xfs_mount_t *mp) | |
678 | { | |
679 | xfs_buf_t *sbp = xfs_getsb(mp, 0); | |
680 | int error; | |
681 | ||
682 | XFS_BUF_UNDONE(sbp); | |
683 | XFS_BUF_UNREAD(sbp); | |
684 | XFS_BUF_UNDELAYWRITE(sbp); | |
685 | XFS_BUF_WRITE(sbp); | |
686 | XFS_BUF_UNASYNC(sbp); | |
687 | XFS_BUF_ORDERED(sbp); | |
688 | ||
689 | xfsbdstrat(mp, sbp); | |
690 | error = xfs_iowait(sbp); | |
691 | ||
692 | /* | |
693 | * Clear all the flags we set and possible error state in the | |
694 | * buffer. We only did the write to try out whether barriers | |
695 | * worked and shouldn't leave any traces in the superblock | |
696 | * buffer. | |
697 | */ | |
698 | XFS_BUF_DONE(sbp); | |
699 | XFS_BUF_ERROR(sbp, 0); | |
700 | XFS_BUF_UNORDERED(sbp); | |
701 | ||
702 | xfs_buf_relse(sbp); | |
703 | return error; | |
704 | } | |
705 | ||
d96f8f89 | 706 | STATIC void |
f538d4da CH |
707 | xfs_mountfs_check_barriers(xfs_mount_t *mp) |
708 | { | |
709 | int error; | |
710 | ||
711 | if (mp->m_logdev_targp != mp->m_ddev_targp) { | |
712 | xfs_fs_cmn_err(CE_NOTE, mp, | |
713 | "Disabling barriers, not supported with external log device"); | |
714 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | |
4ef19ddd | 715 | return; |
f538d4da CH |
716 | } |
717 | ||
b2ea401b NS |
718 | if (xfs_readonly_buftarg(mp->m_ddev_targp)) { |
719 | xfs_fs_cmn_err(CE_NOTE, mp, | |
720 | "Disabling barriers, underlying device is readonly"); | |
721 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | |
722 | return; | |
723 | } | |
724 | ||
f538d4da CH |
725 | error = xfs_barrier_test(mp); |
726 | if (error) { | |
727 | xfs_fs_cmn_err(CE_NOTE, mp, | |
728 | "Disabling barriers, trial barrier write failed"); | |
729 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | |
4ef19ddd | 730 | return; |
f538d4da CH |
731 | } |
732 | } | |
733 | ||
734 | void | |
735 | xfs_blkdev_issue_flush( | |
736 | xfs_buftarg_t *buftarg) | |
737 | { | |
ce8e922c | 738 | blkdev_issue_flush(buftarg->bt_bdev, NULL); |
f538d4da | 739 | } |
1da177e4 | 740 | |
19f354d4 CH |
741 | STATIC void |
742 | xfs_close_devices( | |
743 | struct xfs_mount *mp) | |
744 | { | |
745 | if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { | |
c032bfcf | 746 | struct block_device *logdev = mp->m_logdev_targp->bt_bdev; |
b7963133 | 747 | xfs_free_buftarg(mp, mp->m_logdev_targp); |
c032bfcf | 748 | xfs_blkdev_put(logdev); |
19f354d4 CH |
749 | } |
750 | if (mp->m_rtdev_targp) { | |
c032bfcf | 751 | struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev; |
b7963133 | 752 | xfs_free_buftarg(mp, mp->m_rtdev_targp); |
c032bfcf | 753 | xfs_blkdev_put(rtdev); |
19f354d4 | 754 | } |
b7963133 | 755 | xfs_free_buftarg(mp, mp->m_ddev_targp); |
19f354d4 CH |
756 | } |
757 | ||
758 | /* | |
759 | * The file system configurations are: | |
760 | * (1) device (partition) with data and internal log | |
761 | * (2) logical volume with data and log subvolumes. | |
762 | * (3) logical volume with data, log, and realtime subvolumes. | |
763 | * | |
764 | * We only have to handle opening the log and realtime volumes here if | |
765 | * they are present. The data subvolume has already been opened by | |
766 | * get_sb_bdev() and is stored in sb->s_bdev. | |
767 | */ | |
768 | STATIC int | |
769 | xfs_open_devices( | |
9d565ffa | 770 | struct xfs_mount *mp) |
19f354d4 CH |
771 | { |
772 | struct block_device *ddev = mp->m_super->s_bdev; | |
773 | struct block_device *logdev = NULL, *rtdev = NULL; | |
774 | int error; | |
775 | ||
776 | /* | |
777 | * Open real time and log devices - order is important. | |
778 | */ | |
9d565ffa CH |
779 | if (mp->m_logname) { |
780 | error = xfs_blkdev_get(mp, mp->m_logname, &logdev); | |
19f354d4 CH |
781 | if (error) |
782 | goto out; | |
783 | } | |
784 | ||
9d565ffa CH |
785 | if (mp->m_rtname) { |
786 | error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev); | |
19f354d4 CH |
787 | if (error) |
788 | goto out_close_logdev; | |
789 | ||
790 | if (rtdev == ddev || rtdev == logdev) { | |
791 | cmn_err(CE_WARN, | |
792 | "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev."); | |
793 | error = EINVAL; | |
794 | goto out_close_rtdev; | |
795 | } | |
796 | } | |
797 | ||
798 | /* | |
799 | * Setup xfs_mount buffer target pointers | |
800 | */ | |
801 | error = ENOMEM; | |
e2a07812 | 802 | mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0, mp->m_fsname); |
19f354d4 CH |
803 | if (!mp->m_ddev_targp) |
804 | goto out_close_rtdev; | |
805 | ||
806 | if (rtdev) { | |
e2a07812 | 807 | mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1, mp->m_fsname); |
19f354d4 CH |
808 | if (!mp->m_rtdev_targp) |
809 | goto out_free_ddev_targ; | |
810 | } | |
811 | ||
812 | if (logdev && logdev != ddev) { | |
e2a07812 | 813 | mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1, mp->m_fsname); |
19f354d4 CH |
814 | if (!mp->m_logdev_targp) |
815 | goto out_free_rtdev_targ; | |
816 | } else { | |
817 | mp->m_logdev_targp = mp->m_ddev_targp; | |
818 | } | |
819 | ||
820 | return 0; | |
821 | ||
822 | out_free_rtdev_targ: | |
823 | if (mp->m_rtdev_targp) | |
b7963133 | 824 | xfs_free_buftarg(mp, mp->m_rtdev_targp); |
19f354d4 | 825 | out_free_ddev_targ: |
b7963133 | 826 | xfs_free_buftarg(mp, mp->m_ddev_targp); |
19f354d4 CH |
827 | out_close_rtdev: |
828 | if (rtdev) | |
829 | xfs_blkdev_put(rtdev); | |
830 | out_close_logdev: | |
831 | if (logdev && logdev != ddev) | |
832 | xfs_blkdev_put(logdev); | |
833 | out: | |
834 | return error; | |
835 | } | |
836 | ||
e34b562c CH |
837 | /* |
838 | * Setup xfs_mount buffer target pointers based on superblock | |
839 | */ | |
840 | STATIC int | |
841 | xfs_setup_devices( | |
842 | struct xfs_mount *mp) | |
843 | { | |
844 | int error; | |
19f354d4 | 845 | |
e34b562c CH |
846 | error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize, |
847 | mp->m_sb.sb_sectsize); | |
848 | if (error) | |
849 | return error; | |
850 | ||
851 | if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { | |
852 | unsigned int log_sector_size = BBSIZE; | |
853 | ||
854 | if (xfs_sb_version_hassector(&mp->m_sb)) | |
855 | log_sector_size = mp->m_sb.sb_logsectsize; | |
856 | error = xfs_setsize_buftarg(mp->m_logdev_targp, | |
857 | mp->m_sb.sb_blocksize, | |
858 | log_sector_size); | |
859 | if (error) | |
860 | return error; | |
861 | } | |
862 | if (mp->m_rtdev_targp) { | |
863 | error = xfs_setsize_buftarg(mp->m_rtdev_targp, | |
864 | mp->m_sb.sb_blocksize, | |
865 | mp->m_sb.sb_sectsize); | |
866 | if (error) | |
867 | return error; | |
868 | } | |
869 | ||
870 | return 0; | |
871 | } | |
19f354d4 | 872 | |
249a8c11 DC |
873 | /* |
874 | * XFS AIL push thread support | |
875 | */ | |
876 | void | |
877 | xfsaild_wakeup( | |
82fa9012 | 878 | struct xfs_ail *ailp, |
249a8c11 DC |
879 | xfs_lsn_t threshold_lsn) |
880 | { | |
82fa9012 DC |
881 | ailp->xa_target = threshold_lsn; |
882 | wake_up_process(ailp->xa_task); | |
249a8c11 DC |
883 | } |
884 | ||
3180e66d | 885 | STATIC int |
249a8c11 DC |
886 | xfsaild( |
887 | void *data) | |
888 | { | |
82fa9012 | 889 | struct xfs_ail *ailp = data; |
249a8c11 | 890 | xfs_lsn_t last_pushed_lsn = 0; |
453eac8a | 891 | long tout = 0; /* milliseconds */ |
249a8c11 DC |
892 | |
893 | while (!kthread_should_stop()) { | |
453eac8a DC |
894 | schedule_timeout_interruptible(tout ? |
895 | msecs_to_jiffies(tout) : MAX_SCHEDULE_TIMEOUT); | |
249a8c11 DC |
896 | |
897 | /* swsusp */ | |
898 | try_to_freeze(); | |
899 | ||
82fa9012 DC |
900 | ASSERT(ailp->xa_mount->m_log); |
901 | if (XFS_FORCED_SHUTDOWN(ailp->xa_mount)) | |
249a8c11 DC |
902 | continue; |
903 | ||
82fa9012 | 904 | tout = xfsaild_push(ailp, &last_pushed_lsn); |
249a8c11 DC |
905 | } |
906 | ||
907 | return 0; | |
908 | } /* xfsaild */ | |
909 | ||
910 | int | |
911 | xfsaild_start( | |
82fa9012 | 912 | struct xfs_ail *ailp) |
249a8c11 | 913 | { |
82fa9012 | 914 | ailp->xa_target = 0; |
e2a07812 JE |
915 | ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild/%s", |
916 | ailp->xa_mount->m_fsname); | |
82fa9012 DC |
917 | if (IS_ERR(ailp->xa_task)) |
918 | return -PTR_ERR(ailp->xa_task); | |
249a8c11 DC |
919 | return 0; |
920 | } | |
921 | ||
922 | void | |
923 | xfsaild_stop( | |
82fa9012 | 924 | struct xfs_ail *ailp) |
249a8c11 | 925 | { |
82fa9012 | 926 | kthread_stop(ailp->xa_task); |
249a8c11 DC |
927 | } |
928 | ||
929 | ||
bf904248 | 930 | /* Catch misguided souls that try to use this interface on XFS */ |
1da177e4 | 931 | STATIC struct inode * |
a50cd269 | 932 | xfs_fs_alloc_inode( |
1da177e4 LT |
933 | struct super_block *sb) |
934 | { | |
bf904248 | 935 | BUG(); |
493dca61 | 936 | return NULL; |
1da177e4 LT |
937 | } |
938 | ||
bf904248 | 939 | /* |
99fa8cb3 DC |
940 | * Now that the generic code is guaranteed not to be accessing |
941 | * the linux inode, we can reclaim the inode. | |
bf904248 | 942 | */ |
1da177e4 | 943 | STATIC void |
a50cd269 | 944 | xfs_fs_destroy_inode( |
848ce8f7 | 945 | struct inode *inode) |
1da177e4 | 946 | { |
848ce8f7 CH |
947 | struct xfs_inode *ip = XFS_I(inode); |
948 | ||
949 | xfs_itrace_entry(ip); | |
99fa8cb3 DC |
950 | |
951 | XFS_STATS_INC(vn_reclaim); | |
848ce8f7 CH |
952 | |
953 | /* bad inode, get out here ASAP */ | |
954 | if (is_bad_inode(inode)) | |
955 | goto out_reclaim; | |
956 | ||
957 | xfs_ioend_wait(ip); | |
958 | ||
959 | ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0); | |
960 | ||
961 | /* | |
962 | * We should never get here with one of the reclaim flags already set. | |
963 | */ | |
964 | ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIMABLE)); | |
965 | ASSERT_ALWAYS(!xfs_iflags_test(ip, XFS_IRECLAIM)); | |
966 | ||
967 | /* | |
57817c68 DC |
968 | * We always use background reclaim here because even if the |
969 | * inode is clean, it still may be under IO and hence we have | |
970 | * to take the flush lock. The background reclaim path handles | |
971 | * this more efficiently than we can here, so simply let background | |
972 | * reclaim tear down all inodes. | |
848ce8f7 | 973 | */ |
848ce8f7 | 974 | out_reclaim: |
57817c68 | 975 | xfs_inode_set_reclaim_tag(ip); |
1da177e4 LT |
976 | } |
977 | ||
07c8f675 DC |
978 | /* |
979 | * Slab object creation initialisation for the XFS inode. | |
980 | * This covers only the idempotent fields in the XFS inode; | |
981 | * all other fields need to be initialised on allocation | |
982 | * from the slab. This avoids the need to repeatedly intialise | |
983 | * fields in the xfs inode that left in the initialise state | |
984 | * when freeing the inode. | |
985 | */ | |
bf904248 DC |
986 | STATIC void |
987 | xfs_fs_inode_init_once( | |
07c8f675 DC |
988 | void *inode) |
989 | { | |
990 | struct xfs_inode *ip = inode; | |
991 | ||
992 | memset(ip, 0, sizeof(struct xfs_inode)); | |
bf904248 DC |
993 | |
994 | /* vfs inode */ | |
995 | inode_init_once(VFS_I(ip)); | |
996 | ||
997 | /* xfs inode */ | |
07c8f675 DC |
998 | atomic_set(&ip->i_iocount, 0); |
999 | atomic_set(&ip->i_pincount, 0); | |
1000 | spin_lock_init(&ip->i_flags_lock); | |
07c8f675 DC |
1001 | init_waitqueue_head(&ip->i_ipin_wait); |
1002 | /* | |
1003 | * Because we want to use a counting completion, complete | |
1004 | * the flush completion once to allow a single access to | |
1005 | * the flush completion without blocking. | |
1006 | */ | |
1007 | init_completion(&ip->i_flush); | |
1008 | complete(&ip->i_flush); | |
1009 | ||
1010 | mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, | |
1011 | "xfsino", ip->i_ino); | |
07c8f675 DC |
1012 | } |
1013 | ||
f9581b14 CH |
1014 | /* |
1015 | * Dirty the XFS inode when mark_inode_dirty_sync() is called so that | |
1016 | * we catch unlogged VFS level updates to the inode. Care must be taken | |
1017 | * here - the transaction code calls mark_inode_dirty_sync() to mark the | |
1018 | * VFS inode dirty in a transaction and clears the i_update_core field; | |
1019 | * it must clear the field after calling mark_inode_dirty_sync() to | |
1020 | * correctly indicate that the dirty state has been propagated into the | |
1021 | * inode log item. | |
1022 | * | |
1023 | * We need the barrier() to maintain correct ordering between unlogged | |
1024 | * updates and the transaction commit code that clears the i_update_core | |
1025 | * field. This requires all updates to be completed before marking the | |
1026 | * inode dirty. | |
1027 | */ | |
1028 | STATIC void | |
1029 | xfs_fs_dirty_inode( | |
1030 | struct inode *inode) | |
1031 | { | |
1032 | barrier(); | |
1033 | XFS_I(inode)->i_update_core = 1; | |
1034 | } | |
1035 | ||
07fec736 CH |
1036 | STATIC int |
1037 | xfs_log_inode( | |
1038 | struct xfs_inode *ip) | |
1039 | { | |
1040 | struct xfs_mount *mp = ip->i_mount; | |
1041 | struct xfs_trans *tp; | |
1042 | int error; | |
1043 | ||
1044 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | |
1045 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); | |
1046 | error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); | |
1047 | ||
1048 | if (error) { | |
1049 | xfs_trans_cancel(tp, 0); | |
1050 | /* we need to return with the lock hold shared */ | |
1051 | xfs_ilock(ip, XFS_ILOCK_SHARED); | |
1052 | return error; | |
1053 | } | |
1054 | ||
1055 | xfs_ilock(ip, XFS_ILOCK_EXCL); | |
1056 | ||
1057 | /* | |
1058 | * Note - it's possible that we might have pushed ourselves out of the | |
1059 | * way during trans_reserve which would flush the inode. But there's | |
1060 | * no guarantee that the inode buffer has actually gone out yet (it's | |
1061 | * delwri). Plus the buffer could be pinned anyway if it's part of | |
1062 | * an inode in another recent transaction. So we play it safe and | |
1063 | * fire off the transaction anyway. | |
1064 | */ | |
1065 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | |
1066 | xfs_trans_ihold(tp, ip); | |
1067 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | |
1068 | xfs_trans_set_sync(tp); | |
1069 | error = xfs_trans_commit(tp, 0); | |
1070 | xfs_ilock_demote(ip, XFS_ILOCK_EXCL); | |
1071 | ||
1072 | return error; | |
1073 | } | |
1074 | ||
1da177e4 | 1075 | STATIC int |
a50cd269 | 1076 | xfs_fs_write_inode( |
1da177e4 | 1077 | struct inode *inode, |
a9185b41 | 1078 | struct writeback_control *wbc) |
1da177e4 | 1079 | { |
2e656092 | 1080 | struct xfs_inode *ip = XFS_I(inode); |
d4bb6d06 | 1081 | struct xfs_mount *mp = ip->i_mount; |
07fec736 | 1082 | int error = EAGAIN; |
1da177e4 | 1083 | |
2e656092 | 1084 | xfs_itrace_entry(ip); |
d4bb6d06 CH |
1085 | |
1086 | if (XFS_FORCED_SHUTDOWN(mp)) | |
1087 | return XFS_ERROR(EIO); | |
1088 | ||
a9185b41 | 1089 | if (wbc->sync_mode == WB_SYNC_ALL) { |
07fec736 CH |
1090 | /* |
1091 | * Make sure the inode has hit stable storage. By using the | |
1092 | * log and the fsync transactions we reduce the IOs we have | |
1093 | * to do here from two (log and inode) to just the log. | |
1094 | * | |
1095 | * Note: We still need to do a delwri write of the inode after | |
1096 | * this to flush it to the backing buffer so that bulkstat | |
1097 | * works properly if this is the first time the inode has been | |
1098 | * written. Because we hold the ilock atomically over the | |
1099 | * transaction commit and the inode flush we are guaranteed | |
1100 | * that the inode is not pinned when it returns. If the flush | |
1101 | * lock is already held, then the inode has already been | |
1102 | * flushed once and we don't need to flush it again. Hence | |
1103 | * the code will only flush the inode if it isn't already | |
1104 | * being flushed. | |
1105 | */ | |
37bc5743 | 1106 | xfs_ioend_wait(ip); |
d4bb6d06 | 1107 | xfs_ilock(ip, XFS_ILOCK_SHARED); |
07fec736 CH |
1108 | if (ip->i_update_core) { |
1109 | error = xfs_log_inode(ip); | |
1110 | if (error) | |
1111 | goto out_unlock; | |
1112 | } | |
d4bb6d06 | 1113 | } else { |
07fec736 CH |
1114 | /* |
1115 | * We make this non-blocking if the inode is contended, return | |
1116 | * EAGAIN to indicate to the caller that they did not succeed. | |
1117 | * This prevents the flush path from blocking on inodes inside | |
1118 | * another operation right now, they get caught later by xfs_sync. | |
1119 | */ | |
d4bb6d06 CH |
1120 | if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) |
1121 | goto out; | |
07fec736 CH |
1122 | } |
1123 | ||
1124 | if (xfs_ipincount(ip) || !xfs_iflock_nowait(ip)) | |
1125 | goto out_unlock; | |
d4bb6d06 | 1126 | |
07fec736 CH |
1127 | /* |
1128 | * Now we have the flush lock and the inode is not pinned, we can check | |
1129 | * if the inode is really clean as we know that there are no pending | |
1130 | * transaction completions, it is not waiting on the delayed write | |
1131 | * queue and there is no IO in progress. | |
1132 | */ | |
1133 | if (xfs_inode_clean(ip)) { | |
1134 | xfs_ifunlock(ip); | |
1135 | error = 0; | |
1136 | goto out_unlock; | |
d4bb6d06 | 1137 | } |
07fec736 | 1138 | error = xfs_iflush(ip, 0); |
d4bb6d06 CH |
1139 | |
1140 | out_unlock: | |
1141 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | |
1142 | out: | |
e893bffd LM |
1143 | /* |
1144 | * if we failed to write out the inode then mark | |
1145 | * it dirty again so we'll try again later. | |
1146 | */ | |
1147 | if (error) | |
2e656092 | 1148 | xfs_mark_inode_dirty_sync(ip); |
1da177e4 LT |
1149 | return -error; |
1150 | } | |
1151 | ||
1152 | STATIC void | |
a50cd269 | 1153 | xfs_fs_clear_inode( |
1da177e4 LT |
1154 | struct inode *inode) |
1155 | { | |
1543d79c | 1156 | xfs_inode_t *ip = XFS_I(inode); |
56d433e4 | 1157 | |
99fa8cb3 DC |
1158 | xfs_itrace_entry(ip); |
1159 | XFS_STATS_INC(vn_rele); | |
1160 | XFS_STATS_INC(vn_remove); | |
1161 | XFS_STATS_DEC(vn_active); | |
1162 | ||
033da48f CH |
1163 | /* |
1164 | * The iolock is used by the file system to coordinate reads, | |
1165 | * writes, and block truncates. Up to this point the lock | |
1166 | * protected concurrent accesses by users of the inode. But | |
1167 | * from here forward we're doing some final processing of the | |
1168 | * inode because we're done with it, and although we reuse the | |
1169 | * iolock for protection it is really a distinct lock class | |
1170 | * (in the lockdep sense) from before. To keep lockdep happy | |
1171 | * (and basically indicate what we are doing), we explicitly | |
1172 | * re-init the iolock here. | |
1173 | */ | |
1174 | ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock)); | |
1175 | mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); | |
1176 | ||
99fa8cb3 | 1177 | xfs_inactive(ip); |
56d433e4 | 1178 | } |
1da177e4 | 1179 | |
a738159d CH |
1180 | STATIC void |
1181 | xfs_free_fsname( | |
1182 | struct xfs_mount *mp) | |
1183 | { | |
1184 | kfree(mp->m_fsname); | |
1185 | kfree(mp->m_rtname); | |
1186 | kfree(mp->m_logname); | |
1187 | } | |
1188 | ||
1da177e4 | 1189 | STATIC void |
a50cd269 | 1190 | xfs_fs_put_super( |
1da177e4 LT |
1191 | struct super_block *sb) |
1192 | { | |
745f6919 | 1193 | struct xfs_mount *mp = XFS_M(sb); |
1da177e4 | 1194 | |
a167b17e | 1195 | xfs_syncd_stop(mp); |
075fe102 CH |
1196 | |
1197 | if (!(sb->s_flags & MS_RDONLY)) { | |
1198 | /* | |
1199 | * XXX(hch): this should be SYNC_WAIT. | |
1200 | * | |
1201 | * Or more likely not needed at all because the VFS is already | |
1202 | * calling ->sync_fs after shutting down all filestem | |
1203 | * operations and just before calling ->put_super. | |
1204 | */ | |
1205 | xfs_sync_data(mp, 0); | |
1206 | xfs_sync_attr(mp, 0); | |
1207 | } | |
e48ad316 | 1208 | |
30ac0683 | 1209 | XFS_SEND_PREUNMOUNT(mp); |
e48ad316 CH |
1210 | |
1211 | /* | |
1212 | * Blow away any referenced inode in the filestreams cache. | |
1213 | * This can and will cause log traffic as inodes go inactive | |
1214 | * here. | |
1215 | */ | |
1216 | xfs_filestream_unmount(mp); | |
1217 | ||
1218 | XFS_bflush(mp->m_ddev_targp); | |
e48ad316 | 1219 | |
30ac0683 | 1220 | XFS_SEND_UNMOUNT(mp); |
e48ad316 | 1221 | |
19f354d4 | 1222 | xfs_unmountfs(mp); |
6203300e | 1223 | xfs_freesb(mp); |
9bf729c0 | 1224 | xfs_inode_shrinker_unregister(mp); |
c962fb79 | 1225 | xfs_icsb_destroy_counters(mp); |
19f354d4 | 1226 | xfs_close_devices(mp); |
e48ad316 | 1227 | xfs_dmops_put(mp); |
a738159d | 1228 | xfs_free_fsname(mp); |
c962fb79 | 1229 | kfree(mp); |
1da177e4 LT |
1230 | } |
1231 | ||
1da177e4 | 1232 | STATIC int |
69961a26 | 1233 | xfs_fs_sync_fs( |
1da177e4 LT |
1234 | struct super_block *sb, |
1235 | int wait) | |
1236 | { | |
745f6919 | 1237 | struct xfs_mount *mp = XFS_M(sb); |
b83bd138 | 1238 | int error; |
1da177e4 | 1239 | |
e893bffd | 1240 | /* |
69961a26 CH |
1241 | * Not much we can do for the first async pass. Writing out the |
1242 | * superblock would be counter-productive as we are going to redirty | |
1243 | * when writing out other data and metadata (and writing out a single | |
1244 | * block is quite fast anyway). | |
1245 | * | |
1246 | * Try to asynchronously kick off quota syncing at least. | |
e893bffd | 1247 | */ |
69961a26 CH |
1248 | if (!wait) { |
1249 | xfs_qm_sync(mp, SYNC_TRYLOCK); | |
1250 | return 0; | |
1251 | } | |
1252 | ||
1253 | error = xfs_quiesce_data(mp); | |
1254 | if (error) | |
1255 | return -error; | |
1da177e4 | 1256 | |
69961a26 | 1257 | if (laptop_mode) { |
74394496 | 1258 | int prev_sync_seq = mp->m_sync_seq; |
1da177e4 LT |
1259 | |
1260 | /* | |
1261 | * The disk must be active because we're syncing. | |
1262 | * We schedule xfssyncd now (now that the disk is | |
1263 | * active) instead of later (when it might not be). | |
1264 | */ | |
74394496 | 1265 | wake_up_process(mp->m_sync_task); |
1da177e4 LT |
1266 | /* |
1267 | * We have to wait for the sync iteration to complete. | |
1268 | * If we don't, the disk activity caused by the sync | |
1269 | * will come after the sync is completed, and that | |
1270 | * triggers another sync from laptop mode. | |
1271 | */ | |
74394496 CH |
1272 | wait_event(mp->m_wait_single_sync_task, |
1273 | mp->m_sync_seq != prev_sync_seq); | |
1da177e4 LT |
1274 | } |
1275 | ||
69961a26 | 1276 | return 0; |
1da177e4 LT |
1277 | } |
1278 | ||
1279 | STATIC int | |
a50cd269 | 1280 | xfs_fs_statfs( |
726c3342 | 1281 | struct dentry *dentry, |
1da177e4 LT |
1282 | struct kstatfs *statp) |
1283 | { | |
4ca488eb CH |
1284 | struct xfs_mount *mp = XFS_M(dentry->d_sb); |
1285 | xfs_sb_t *sbp = &mp->m_sb; | |
7d095257 | 1286 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
4ca488eb CH |
1287 | __uint64_t fakeinos, id; |
1288 | xfs_extlen_t lsize; | |
1289 | ||
1290 | statp->f_type = XFS_SB_MAGIC; | |
1291 | statp->f_namelen = MAXNAMELEN - 1; | |
1292 | ||
1293 | id = huge_encode_dev(mp->m_ddev_targp->bt_dev); | |
1294 | statp->f_fsid.val[0] = (u32)id; | |
1295 | statp->f_fsid.val[1] = (u32)(id >> 32); | |
1296 | ||
d4d90b57 | 1297 | xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT); |
4ca488eb CH |
1298 | |
1299 | spin_lock(&mp->m_sb_lock); | |
1300 | statp->f_bsize = sbp->sb_blocksize; | |
1301 | lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; | |
1302 | statp->f_blocks = sbp->sb_dblocks - lsize; | |
1303 | statp->f_bfree = statp->f_bavail = | |
1304 | sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp); | |
1305 | fakeinos = statp->f_bfree << sbp->sb_inopblog; | |
4ca488eb CH |
1306 | statp->f_files = |
1307 | MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER); | |
1308 | if (mp->m_maxicount) | |
a19d9f88 CH |
1309 | statp->f_files = min_t(typeof(statp->f_files), |
1310 | statp->f_files, | |
1311 | mp->m_maxicount); | |
4ca488eb CH |
1312 | statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree); |
1313 | spin_unlock(&mp->m_sb_lock); | |
1314 | ||
7d095257 CH |
1315 | if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) || |
1316 | ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) == | |
1317 | (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) | |
1318 | xfs_qm_statvfs(ip, statp); | |
4ca488eb | 1319 | return 0; |
1da177e4 LT |
1320 | } |
1321 | ||
d5db0f97 ES |
1322 | STATIC void |
1323 | xfs_save_resvblks(struct xfs_mount *mp) | |
1324 | { | |
1325 | __uint64_t resblks = 0; | |
1326 | ||
1327 | mp->m_resblks_save = mp->m_resblks; | |
1328 | xfs_reserve_blocks(mp, &resblks, NULL); | |
1329 | } | |
1330 | ||
1331 | STATIC void | |
1332 | xfs_restore_resvblks(struct xfs_mount *mp) | |
1333 | { | |
1334 | __uint64_t resblks; | |
1335 | ||
1336 | if (mp->m_resblks_save) { | |
1337 | resblks = mp->m_resblks_save; | |
1338 | mp->m_resblks_save = 0; | |
1339 | } else | |
1340 | resblks = xfs_default_resblks(mp); | |
1341 | ||
1342 | xfs_reserve_blocks(mp, &resblks, NULL); | |
1343 | } | |
1344 | ||
1da177e4 | 1345 | STATIC int |
a50cd269 | 1346 | xfs_fs_remount( |
1da177e4 LT |
1347 | struct super_block *sb, |
1348 | int *flags, | |
1349 | char *options) | |
1350 | { | |
745f6919 | 1351 | struct xfs_mount *mp = XFS_M(sb); |
62a877e3 CH |
1352 | substring_t args[MAX_OPT_ARGS]; |
1353 | char *p; | |
7884bc86 | 1354 | int error; |
1da177e4 | 1355 | |
62a877e3 CH |
1356 | while ((p = strsep(&options, ",")) != NULL) { |
1357 | int token; | |
bdd907ba | 1358 | |
62a877e3 CH |
1359 | if (!*p) |
1360 | continue; | |
48b62a1a | 1361 | |
62a877e3 CH |
1362 | token = match_token(p, tokens, args); |
1363 | switch (token) { | |
1364 | case Opt_barrier: | |
48b62a1a | 1365 | mp->m_flags |= XFS_MOUNT_BARRIER; |
62a877e3 CH |
1366 | |
1367 | /* | |
1368 | * Test if barriers are actually working if we can, | |
1369 | * else delay this check until the filesystem is | |
1370 | * marked writeable. | |
1371 | */ | |
1372 | if (!(mp->m_flags & XFS_MOUNT_RDONLY)) | |
1373 | xfs_mountfs_check_barriers(mp); | |
1374 | break; | |
1375 | case Opt_nobarrier: | |
48b62a1a | 1376 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
62a877e3 CH |
1377 | break; |
1378 | default: | |
6efdf281 CH |
1379 | /* |
1380 | * Logically we would return an error here to prevent | |
1381 | * users from believing they might have changed | |
1382 | * mount options using remount which can't be changed. | |
1383 | * | |
1384 | * But unfortunately mount(8) adds all options from | |
1385 | * mtab and fstab to the mount arguments in some cases | |
1386 | * so we can't blindly reject options, but have to | |
1387 | * check for each specified option if it actually | |
1388 | * differs from the currently set option and only | |
1389 | * reject it if that's the case. | |
1390 | * | |
1391 | * Until that is implemented we return success for | |
1392 | * every remount request, and silently ignore all | |
1393 | * options that we can't actually change. | |
1394 | */ | |
1395 | #if 0 | |
62a877e3 CH |
1396 | printk(KERN_INFO |
1397 | "XFS: mount option \"%s\" not supported for remount\n", p); | |
1398 | return -EINVAL; | |
6efdf281 | 1399 | #else |
6c5e51da | 1400 | break; |
6efdf281 | 1401 | #endif |
48b62a1a | 1402 | } |
62a877e3 CH |
1403 | } |
1404 | ||
7884bc86 | 1405 | /* ro -> rw */ |
62a877e3 CH |
1406 | if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) { |
1407 | mp->m_flags &= ~XFS_MOUNT_RDONLY; | |
1408 | if (mp->m_flags & XFS_MOUNT_BARRIER) | |
1409 | xfs_mountfs_check_barriers(mp); | |
7884bc86 CH |
1410 | |
1411 | /* | |
1412 | * If this is the first remount to writeable state we | |
1413 | * might have some superblock changes to update. | |
1414 | */ | |
1415 | if (mp->m_update_flags) { | |
1416 | error = xfs_mount_log_sb(mp, mp->m_update_flags); | |
1417 | if (error) { | |
1418 | cmn_err(CE_WARN, | |
1419 | "XFS: failed to write sb changes"); | |
1420 | return error; | |
1421 | } | |
1422 | mp->m_update_flags = 0; | |
1423 | } | |
cbe132a8 DC |
1424 | |
1425 | /* | |
1426 | * Fill out the reserve pool if it is empty. Use the stashed | |
1427 | * value if it is non-zero, otherwise go with the default. | |
1428 | */ | |
d5db0f97 | 1429 | xfs_restore_resvblks(mp); |
62a877e3 CH |
1430 | } |
1431 | ||
1432 | /* rw -> ro */ | |
1433 | if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { | |
cbe132a8 DC |
1434 | /* |
1435 | * After we have synced the data but before we sync the | |
1436 | * metadata, we need to free up the reserve block pool so that | |
1437 | * the used block count in the superblock on disk is correct at | |
1438 | * the end of the remount. Stash the current reserve pool size | |
1439 | * so that if we get remounted rw, we can return it to the same | |
1440 | * size. | |
1441 | */ | |
cbe132a8 | 1442 | |
e9f1c6ee | 1443 | xfs_quiesce_data(mp); |
d5db0f97 | 1444 | xfs_save_resvblks(mp); |
76bf105c | 1445 | xfs_quiesce_attr(mp); |
48b62a1a CH |
1446 | mp->m_flags |= XFS_MOUNT_RDONLY; |
1447 | } | |
1448 | ||
62a877e3 | 1449 | return 0; |
1da177e4 LT |
1450 | } |
1451 | ||
9909c4aa CH |
1452 | /* |
1453 | * Second stage of a freeze. The data is already frozen so we only | |
76bf105c | 1454 | * need to take care of the metadata. Once that's done write a dummy |
9909c4aa CH |
1455 | * record to dirty the log in case of a crash while frozen. |
1456 | */ | |
c4be0c1d TS |
1457 | STATIC int |
1458 | xfs_fs_freeze( | |
1da177e4 LT |
1459 | struct super_block *sb) |
1460 | { | |
9909c4aa CH |
1461 | struct xfs_mount *mp = XFS_M(sb); |
1462 | ||
d5db0f97 | 1463 | xfs_save_resvblks(mp); |
76bf105c | 1464 | xfs_quiesce_attr(mp); |
c4be0c1d | 1465 | return -xfs_fs_log_dummy(mp); |
1da177e4 LT |
1466 | } |
1467 | ||
d5db0f97 ES |
1468 | STATIC int |
1469 | xfs_fs_unfreeze( | |
1470 | struct super_block *sb) | |
1471 | { | |
1472 | struct xfs_mount *mp = XFS_M(sb); | |
1473 | ||
1474 | xfs_restore_resvblks(mp); | |
1475 | return 0; | |
1476 | } | |
1477 | ||
1da177e4 | 1478 | STATIC int |
a50cd269 | 1479 | xfs_fs_show_options( |
1da177e4 LT |
1480 | struct seq_file *m, |
1481 | struct vfsmount *mnt) | |
1482 | { | |
745f6919 | 1483 | return -xfs_showargs(XFS_M(mnt->mnt_sb), m); |
1da177e4 LT |
1484 | } |
1485 | ||
f8f15e42 CH |
1486 | /* |
1487 | * This function fills in xfs_mount_t fields based on mount args. | |
1488 | * Note: the superblock _has_ now been read in. | |
1489 | */ | |
1490 | STATIC int | |
1491 | xfs_finish_flags( | |
f8f15e42 CH |
1492 | struct xfs_mount *mp) |
1493 | { | |
1494 | int ronly = (mp->m_flags & XFS_MOUNT_RDONLY); | |
1495 | ||
025dfdaf | 1496 | /* Fail a mount where the logbuf is smaller than the log stripe */ |
f8f15e42 | 1497 | if (xfs_sb_version_haslogv2(&mp->m_sb)) { |
9d565ffa CH |
1498 | if (mp->m_logbsize <= 0 && |
1499 | mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) { | |
f8f15e42 | 1500 | mp->m_logbsize = mp->m_sb.sb_logsunit; |
9d565ffa CH |
1501 | } else if (mp->m_logbsize > 0 && |
1502 | mp->m_logbsize < mp->m_sb.sb_logsunit) { | |
f8f15e42 CH |
1503 | cmn_err(CE_WARN, |
1504 | "XFS: logbuf size must be greater than or equal to log stripe size"); | |
1505 | return XFS_ERROR(EINVAL); | |
1506 | } | |
1507 | } else { | |
1508 | /* Fail a mount if the logbuf is larger than 32K */ | |
9d565ffa | 1509 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { |
f8f15e42 CH |
1510 | cmn_err(CE_WARN, |
1511 | "XFS: logbuf size for version 1 logs must be 16K or 32K"); | |
1512 | return XFS_ERROR(EINVAL); | |
1513 | } | |
1514 | } | |
1515 | ||
1516 | /* | |
1517 | * mkfs'ed attr2 will turn on attr2 mount unless explicitly | |
1518 | * told by noattr2 to turn it off | |
1519 | */ | |
1520 | if (xfs_sb_version_hasattr2(&mp->m_sb) && | |
9d565ffa | 1521 | !(mp->m_flags & XFS_MOUNT_NOATTR2)) |
f8f15e42 CH |
1522 | mp->m_flags |= XFS_MOUNT_ATTR2; |
1523 | ||
1524 | /* | |
1525 | * prohibit r/w mounts of read-only filesystems | |
1526 | */ | |
1527 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { | |
1528 | cmn_err(CE_WARN, | |
1529 | "XFS: cannot mount a read-only filesystem as read-write"); | |
1530 | return XFS_ERROR(EROFS); | |
1531 | } | |
1532 | ||
f8f15e42 CH |
1533 | return 0; |
1534 | } | |
1535 | ||
1da177e4 | 1536 | STATIC int |
a50cd269 | 1537 | xfs_fs_fill_super( |
1da177e4 LT |
1538 | struct super_block *sb, |
1539 | void *data, | |
1540 | int silent) | |
1541 | { | |
f3dcc13f | 1542 | struct inode *root; |
745f6919 | 1543 | struct xfs_mount *mp = NULL; |
c962fb79 | 1544 | int flags = 0, error = ENOMEM; |
9d565ffa | 1545 | char *mtpt = NULL; |
bdd907ba | 1546 | |
c962fb79 CH |
1547 | mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL); |
1548 | if (!mp) | |
9d565ffa | 1549 | goto out; |
1da177e4 | 1550 | |
c962fb79 | 1551 | spin_lock_init(&mp->m_sb_lock); |
c962fb79 CH |
1552 | mutex_init(&mp->m_growlock); |
1553 | atomic_set(&mp->m_active_trans, 0); | |
74394496 CH |
1554 | INIT_LIST_HEAD(&mp->m_sync_list); |
1555 | spin_lock_init(&mp->m_sync_lock); | |
1556 | init_waitqueue_head(&mp->m_wait_single_sync_task); | |
1557 | ||
b267ce99 CH |
1558 | mp->m_super = sb; |
1559 | sb->s_fs_info = mp; | |
1da177e4 | 1560 | |
9d565ffa | 1561 | error = xfs_parseargs(mp, (char *)data, &mtpt); |
745f6919 | 1562 | if (error) |
9d565ffa | 1563 | goto out_free_fsname; |
1da177e4 LT |
1564 | |
1565 | sb_min_blocksize(sb, BBSIZE); | |
0ec58516 | 1566 | sb->s_xattr = xfs_xattr_handlers; |
a50cd269 | 1567 | sb->s_export_op = &xfs_export_operations; |
fcafb71b | 1568 | #ifdef CONFIG_XFS_QUOTA |
a50cd269 | 1569 | sb->s_qcop = &xfs_quotactl_operations; |
fcafb71b | 1570 | #endif |
a50cd269 | 1571 | sb->s_op = &xfs_super_operations; |
1da177e4 | 1572 | |
9d565ffa | 1573 | error = xfs_dmops_get(mp); |
f8f15e42 | 1574 | if (error) |
9d565ffa | 1575 | goto out_free_fsname; |
1da177e4 | 1576 | |
9d565ffa | 1577 | if (silent) |
f8f15e42 CH |
1578 | flags |= XFS_MFSI_QUIET; |
1579 | ||
9d565ffa | 1580 | error = xfs_open_devices(mp); |
19f354d4 | 1581 | if (error) |
7d095257 | 1582 | goto out_put_dmops; |
f8f15e42 | 1583 | |
c962fb79 CH |
1584 | if (xfs_icsb_init_counters(mp)) |
1585 | mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; | |
1586 | ||
f8f15e42 CH |
1587 | error = xfs_readsb(mp, flags); |
1588 | if (error) | |
9d565ffa CH |
1589 | goto out_destroy_counters; |
1590 | ||
1591 | error = xfs_finish_flags(mp); | |
f8f15e42 | 1592 | if (error) |
effa2eda | 1593 | goto out_free_sb; |
f8f15e42 | 1594 | |
e34b562c | 1595 | error = xfs_setup_devices(mp); |
19f354d4 | 1596 | if (error) |
effa2eda | 1597 | goto out_free_sb; |
f8f15e42 CH |
1598 | |
1599 | if (mp->m_flags & XFS_MOUNT_BARRIER) | |
1600 | xfs_mountfs_check_barriers(mp); | |
1601 | ||
1602 | error = xfs_filestream_mount(mp); | |
1603 | if (error) | |
effa2eda | 1604 | goto out_free_sb; |
f8f15e42 | 1605 | |
4249023a | 1606 | error = xfs_mountfs(mp); |
f8f15e42 | 1607 | if (error) |
120226c1 | 1608 | goto out_filestream_unmount; |
f8f15e42 | 1609 | |
9d565ffa | 1610 | XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname); |
f8f15e42 | 1611 | |
4ca488eb CH |
1612 | sb->s_magic = XFS_SB_MAGIC; |
1613 | sb->s_blocksize = mp->m_sb.sb_blocksize; | |
1614 | sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; | |
1da177e4 LT |
1615 | sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits); |
1616 | sb->s_time_gran = 1; | |
1617 | set_posix_acl_flag(sb); | |
1618 | ||
01651646 | 1619 | root = igrab(VFS_I(mp->m_rootip)); |
f3dcc13f | 1620 | if (!root) { |
cbc89dcf | 1621 | error = ENOENT; |
1da177e4 | 1622 | goto fail_unmount; |
cbc89dcf | 1623 | } |
f3dcc13f CH |
1624 | if (is_bad_inode(root)) { |
1625 | error = EINVAL; | |
1da177e4 LT |
1626 | goto fail_vnrele; |
1627 | } | |
f3dcc13f CH |
1628 | sb->s_root = d_alloc_root(root); |
1629 | if (!sb->s_root) { | |
1630 | error = ENOMEM; | |
1da177e4 LT |
1631 | goto fail_vnrele; |
1632 | } | |
74394496 | 1633 | |
a167b17e DC |
1634 | error = xfs_syncd_init(mp); |
1635 | if (error) | |
1da177e4 | 1636 | goto fail_vnrele; |
74394496 | 1637 | |
9bf729c0 DC |
1638 | xfs_inode_shrinker_register(mp); |
1639 | ||
9d565ffa | 1640 | kfree(mtpt); |
1da177e4 LT |
1641 | return 0; |
1642 | ||
120226c1 CH |
1643 | out_filestream_unmount: |
1644 | xfs_filestream_unmount(mp); | |
effa2eda CH |
1645 | out_free_sb: |
1646 | xfs_freesb(mp); | |
9d565ffa | 1647 | out_destroy_counters: |
c962fb79 | 1648 | xfs_icsb_destroy_counters(mp); |
19f354d4 | 1649 | xfs_close_devices(mp); |
19f354d4 | 1650 | out_put_dmops: |
f8f15e42 | 1651 | xfs_dmops_put(mp); |
9d565ffa CH |
1652 | out_free_fsname: |
1653 | xfs_free_fsname(mp); | |
1654 | kfree(mtpt); | |
c962fb79 | 1655 | kfree(mp); |
9d565ffa | 1656 | out: |
c962fb79 | 1657 | return -error; |
f8f15e42 CH |
1658 | |
1659 | fail_vnrele: | |
1da177e4 LT |
1660 | if (sb->s_root) { |
1661 | dput(sb->s_root); | |
1662 | sb->s_root = NULL; | |
1663 | } else { | |
f3dcc13f | 1664 | iput(root); |
1da177e4 LT |
1665 | } |
1666 | ||
f8f15e42 | 1667 | fail_unmount: |
e48ad316 CH |
1668 | /* |
1669 | * Blow away any referenced inode in the filestreams cache. | |
1670 | * This can and will cause log traffic as inodes go inactive | |
1671 | * here. | |
1672 | */ | |
1673 | xfs_filestream_unmount(mp); | |
1674 | ||
1675 | XFS_bflush(mp->m_ddev_targp); | |
e48ad316 | 1676 | |
19f354d4 | 1677 | xfs_unmountfs(mp); |
6203300e | 1678 | goto out_free_sb; |
1da177e4 LT |
1679 | } |
1680 | ||
454e2398 | 1681 | STATIC int |
a50cd269 | 1682 | xfs_fs_get_sb( |
1da177e4 LT |
1683 | struct file_system_type *fs_type, |
1684 | int flags, | |
1685 | const char *dev_name, | |
454e2398 DH |
1686 | void *data, |
1687 | struct vfsmount *mnt) | |
1da177e4 | 1688 | { |
454e2398 DH |
1689 | return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super, |
1690 | mnt); | |
a50cd269 NS |
1691 | } |
1692 | ||
b87221de | 1693 | static const struct super_operations xfs_super_operations = { |
a50cd269 NS |
1694 | .alloc_inode = xfs_fs_alloc_inode, |
1695 | .destroy_inode = xfs_fs_destroy_inode, | |
f9581b14 | 1696 | .dirty_inode = xfs_fs_dirty_inode, |
a50cd269 NS |
1697 | .write_inode = xfs_fs_write_inode, |
1698 | .clear_inode = xfs_fs_clear_inode, | |
1699 | .put_super = xfs_fs_put_super, | |
69961a26 | 1700 | .sync_fs = xfs_fs_sync_fs, |
c4be0c1d | 1701 | .freeze_fs = xfs_fs_freeze, |
d5db0f97 | 1702 | .unfreeze_fs = xfs_fs_unfreeze, |
a50cd269 NS |
1703 | .statfs = xfs_fs_statfs, |
1704 | .remount_fs = xfs_fs_remount, | |
1705 | .show_options = xfs_fs_show_options, | |
1da177e4 LT |
1706 | }; |
1707 | ||
5085b607 | 1708 | static struct file_system_type xfs_fs_type = { |
1da177e4 LT |
1709 | .owner = THIS_MODULE, |
1710 | .name = "xfs", | |
a50cd269 | 1711 | .get_sb = xfs_fs_get_sb, |
1da177e4 LT |
1712 | .kill_sb = kill_block_super, |
1713 | .fs_flags = FS_REQUIRES_DEV, | |
1714 | }; | |
1715 | ||
9f8868ff CH |
1716 | STATIC int __init |
1717 | xfs_init_zones(void) | |
1718 | { | |
9f8868ff CH |
1719 | |
1720 | xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend"); | |
1721 | if (!xfs_ioend_zone) | |
bf904248 | 1722 | goto out; |
9f8868ff CH |
1723 | |
1724 | xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE, | |
1725 | xfs_ioend_zone); | |
1726 | if (!xfs_ioend_pool) | |
1727 | goto out_destroy_ioend_zone; | |
1728 | ||
1729 | xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t), | |
1730 | "xfs_log_ticket"); | |
1731 | if (!xfs_log_ticket_zone) | |
1732 | goto out_destroy_ioend_pool; | |
1733 | ||
1734 | xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t), | |
1735 | "xfs_bmap_free_item"); | |
1736 | if (!xfs_bmap_free_item_zone) | |
1737 | goto out_destroy_log_ticket_zone; | |
bf904248 | 1738 | |
9f8868ff CH |
1739 | xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t), |
1740 | "xfs_btree_cur"); | |
1741 | if (!xfs_btree_cur_zone) | |
1742 | goto out_destroy_bmap_free_item_zone; | |
1743 | ||
1744 | xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t), | |
1745 | "xfs_da_state"); | |
1746 | if (!xfs_da_state_zone) | |
1747 | goto out_destroy_btree_cur_zone; | |
1748 | ||
1749 | xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf"); | |
1750 | if (!xfs_dabuf_zone) | |
1751 | goto out_destroy_da_state_zone; | |
1752 | ||
1753 | xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); | |
1754 | if (!xfs_ifork_zone) | |
1755 | goto out_destroy_dabuf_zone; | |
1756 | ||
1757 | xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); | |
1758 | if (!xfs_trans_zone) | |
1759 | goto out_destroy_ifork_zone; | |
1760 | ||
1761 | /* | |
1762 | * The size of the zone allocated buf log item is the maximum | |
1763 | * size possible under XFS. This wastes a little bit of memory, | |
1764 | * but it is much faster. | |
1765 | */ | |
1766 | xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) + | |
c1155410 | 1767 | (((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / |
9f8868ff CH |
1768 | NBWORD) * sizeof(int))), "xfs_buf_item"); |
1769 | if (!xfs_buf_item_zone) | |
1770 | goto out_destroy_trans_zone; | |
1771 | ||
1772 | xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) + | |
1773 | ((XFS_EFD_MAX_FAST_EXTENTS - 1) * | |
1774 | sizeof(xfs_extent_t))), "xfs_efd_item"); | |
1775 | if (!xfs_efd_zone) | |
1776 | goto out_destroy_buf_item_zone; | |
1777 | ||
1778 | xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) + | |
1779 | ((XFS_EFI_MAX_FAST_EXTENTS - 1) * | |
1780 | sizeof(xfs_extent_t))), "xfs_efi_item"); | |
1781 | if (!xfs_efi_zone) | |
1782 | goto out_destroy_efd_zone; | |
1783 | ||
1784 | xfs_inode_zone = | |
1785 | kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode", | |
bf904248 DC |
1786 | KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD, |
1787 | xfs_fs_inode_init_once); | |
9f8868ff CH |
1788 | if (!xfs_inode_zone) |
1789 | goto out_destroy_efi_zone; | |
1790 | ||
1791 | xfs_ili_zone = | |
1792 | kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili", | |
1793 | KM_ZONE_SPREAD, NULL); | |
1794 | if (!xfs_ili_zone) | |
1795 | goto out_destroy_inode_zone; | |
1796 | ||
9f8868ff CH |
1797 | return 0; |
1798 | ||
9f8868ff CH |
1799 | out_destroy_inode_zone: |
1800 | kmem_zone_destroy(xfs_inode_zone); | |
1801 | out_destroy_efi_zone: | |
1802 | kmem_zone_destroy(xfs_efi_zone); | |
1803 | out_destroy_efd_zone: | |
1804 | kmem_zone_destroy(xfs_efd_zone); | |
1805 | out_destroy_buf_item_zone: | |
1806 | kmem_zone_destroy(xfs_buf_item_zone); | |
1807 | out_destroy_trans_zone: | |
1808 | kmem_zone_destroy(xfs_trans_zone); | |
1809 | out_destroy_ifork_zone: | |
1810 | kmem_zone_destroy(xfs_ifork_zone); | |
1811 | out_destroy_dabuf_zone: | |
1812 | kmem_zone_destroy(xfs_dabuf_zone); | |
1813 | out_destroy_da_state_zone: | |
1814 | kmem_zone_destroy(xfs_da_state_zone); | |
1815 | out_destroy_btree_cur_zone: | |
1816 | kmem_zone_destroy(xfs_btree_cur_zone); | |
1817 | out_destroy_bmap_free_item_zone: | |
1818 | kmem_zone_destroy(xfs_bmap_free_item_zone); | |
1819 | out_destroy_log_ticket_zone: | |
1820 | kmem_zone_destroy(xfs_log_ticket_zone); | |
1821 | out_destroy_ioend_pool: | |
1822 | mempool_destroy(xfs_ioend_pool); | |
1823 | out_destroy_ioend_zone: | |
1824 | kmem_zone_destroy(xfs_ioend_zone); | |
9f8868ff CH |
1825 | out: |
1826 | return -ENOMEM; | |
1827 | } | |
1828 | ||
1829 | STATIC void | |
1830 | xfs_destroy_zones(void) | |
1831 | { | |
9f8868ff CH |
1832 | kmem_zone_destroy(xfs_ili_zone); |
1833 | kmem_zone_destroy(xfs_inode_zone); | |
1834 | kmem_zone_destroy(xfs_efi_zone); | |
1835 | kmem_zone_destroy(xfs_efd_zone); | |
1836 | kmem_zone_destroy(xfs_buf_item_zone); | |
1837 | kmem_zone_destroy(xfs_trans_zone); | |
1838 | kmem_zone_destroy(xfs_ifork_zone); | |
1839 | kmem_zone_destroy(xfs_dabuf_zone); | |
1840 | kmem_zone_destroy(xfs_da_state_zone); | |
1841 | kmem_zone_destroy(xfs_btree_cur_zone); | |
1842 | kmem_zone_destroy(xfs_bmap_free_item_zone); | |
1843 | kmem_zone_destroy(xfs_log_ticket_zone); | |
1844 | mempool_destroy(xfs_ioend_pool); | |
1845 | kmem_zone_destroy(xfs_ioend_zone); | |
9f8868ff CH |
1846 | |
1847 | } | |
1da177e4 LT |
1848 | |
1849 | STATIC int __init | |
9f8868ff | 1850 | init_xfs_fs(void) |
1da177e4 LT |
1851 | { |
1852 | int error; | |
1da177e4 | 1853 | |
65795910 CH |
1854 | printk(KERN_INFO XFS_VERSION_STRING " with " |
1855 | XFS_BUILD_OPTIONS " enabled\n"); | |
1da177e4 | 1856 | |
25e41b3d | 1857 | xfs_ioend_init(); |
9f8868ff | 1858 | xfs_dir_startup(); |
1da177e4 | 1859 | |
8758280f | 1860 | error = xfs_init_zones(); |
9f8868ff CH |
1861 | if (error) |
1862 | goto out; | |
1863 | ||
9f8868ff CH |
1864 | error = xfs_mru_cache_init(); |
1865 | if (error) | |
0b1b213f | 1866 | goto out_destroy_zones; |
9f8868ff CH |
1867 | |
1868 | error = xfs_filestream_init(); | |
1869 | if (error) | |
1870 | goto out_mru_cache_uninit; | |
1da177e4 | 1871 | |
ce8e922c | 1872 | error = xfs_buf_init(); |
9f8868ff CH |
1873 | if (error) |
1874 | goto out_filestream_uninit; | |
1875 | ||
1876 | error = xfs_init_procfs(); | |
1877 | if (error) | |
1878 | goto out_buf_terminate; | |
1879 | ||
1880 | error = xfs_sysctl_register(); | |
1881 | if (error) | |
1882 | goto out_cleanup_procfs; | |
1da177e4 | 1883 | |
1da177e4 | 1884 | vfs_initquota(); |
9bf729c0 | 1885 | xfs_inode_shrinker_init(); |
1da177e4 LT |
1886 | |
1887 | error = register_filesystem(&xfs_fs_type); | |
1888 | if (error) | |
9f8868ff | 1889 | goto out_sysctl_unregister; |
1da177e4 LT |
1890 | return 0; |
1891 | ||
9f8868ff CH |
1892 | out_sysctl_unregister: |
1893 | xfs_sysctl_unregister(); | |
1894 | out_cleanup_procfs: | |
1895 | xfs_cleanup_procfs(); | |
1896 | out_buf_terminate: | |
ce8e922c | 1897 | xfs_buf_terminate(); |
9f8868ff CH |
1898 | out_filestream_uninit: |
1899 | xfs_filestream_uninit(); | |
1900 | out_mru_cache_uninit: | |
1901 | xfs_mru_cache_uninit(); | |
9f8868ff | 1902 | out_destroy_zones: |
8758280f | 1903 | xfs_destroy_zones(); |
9f8868ff | 1904 | out: |
1da177e4 LT |
1905 | return error; |
1906 | } | |
1907 | ||
1908 | STATIC void __exit | |
9f8868ff | 1909 | exit_xfs_fs(void) |
1da177e4 LT |
1910 | { |
1911 | vfs_exitquota(); | |
1da177e4 | 1912 | unregister_filesystem(&xfs_fs_type); |
9bf729c0 | 1913 | xfs_inode_shrinker_destroy(); |
9f8868ff CH |
1914 | xfs_sysctl_unregister(); |
1915 | xfs_cleanup_procfs(); | |
ce8e922c | 1916 | xfs_buf_terminate(); |
9f8868ff CH |
1917 | xfs_filestream_uninit(); |
1918 | xfs_mru_cache_uninit(); | |
8758280f | 1919 | xfs_destroy_zones(); |
1da177e4 LT |
1920 | } |
1921 | ||
1922 | module_init(init_xfs_fs); | |
1923 | module_exit(exit_xfs_fs); | |
1924 | ||
1925 | MODULE_AUTHOR("Silicon Graphics, Inc."); | |
1926 | MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled"); | |
1927 | MODULE_LICENSE("GPL"); |