blob: 1ca593fb1225d3064c24913d48015f0eea27238d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scotta805bad2006-06-19 08:40:27 +10002 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
Nathan Scott7b718762005-11-02 14:58:39 +11003 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
Nathan Scotta844f452005-11-02 14:38:42 +110019#include "xfs_bit.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "xfs_log.h"
21#include "xfs_clnt.h"
Nathan Scotta844f452005-11-02 14:38:42 +110022#include "xfs_inum.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include "xfs_trans.h"
24#include "xfs_sb.h"
Nathan Scotta844f452005-11-02 14:38:42 +110025#include "xfs_ag.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include "xfs_dir2.h"
27#include "xfs_alloc.h"
28#include "xfs_dmapi.h"
29#include "xfs_quota.h"
30#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include "xfs_bmap_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110032#include "xfs_alloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "xfs_ialloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include "xfs_dir2_sf.h"
Nathan Scotta844f452005-11-02 14:38:42 +110035#include "xfs_attr_sf.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include "xfs_dinode.h"
37#include "xfs_inode.h"
Nathan Scotta844f452005-11-02 14:38:42 +110038#include "xfs_btree.h"
39#include "xfs_ialloc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include "xfs_bmap.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include "xfs_rtalloc.h"
42#include "xfs_error.h"
43#include "xfs_itable.h"
Christoph Hellwig9909c4a2007-10-11 18:11:14 +100044#include "xfs_fsops.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include "xfs_rw.h"
46#include "xfs_acl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include "xfs_attr.h"
48#include "xfs_buf_item.h"
49#include "xfs_utils.h"
Christoph Hellwig739bfb22007-08-29 10:58:01 +100050#include "xfs_vnodeops.h"
Christoph Hellwig745f6912007-08-30 17:20:39 +100051#include "xfs_vfsops.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include "xfs_version.h"
David Chinnera67d7c52007-11-23 16:29:32 +110053#include "xfs_log_priv.h"
David Chinner249a8c12008-02-05 12:13:32 +110054#include "xfs_trans_priv.h"
Christoph Hellwig48b62a12008-05-20 11:30:39 +100055#include "xfs_filestream.h"
Christoph Hellwig9f8868f2008-07-18 17:11:46 +100056#include "xfs_da_btree.h"
57#include "xfs_dir2_trace.h"
58#include "xfs_extfree_item.h"
59#include "xfs_mru_cache.h"
60#include "xfs_inode_item.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#include <linux/namei.h>
63#include <linux/init.h>
64#include <linux/mount.h>
Christoph Hellwig0829c362005-09-02 16:58:49 +100065#include <linux/mempool.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#include <linux/writeback.h>
Christoph Hellwig4df08c52005-09-05 08:34:18 +100067#include <linux/kthread.h>
Nigel Cunningham7dfb7102006-12-06 20:34:23 -080068#include <linux/freezer.h>
Christoph Hellwig62a877e2008-07-18 17:12:36 +100069#include <linux/parser.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
David Chinner7989cb82007-02-10 18:34:56 +110071static struct quotactl_ops xfs_quotactl_operations;
72static struct super_operations xfs_super_operations;
73static kmem_zone_t *xfs_vnode_zone;
74static kmem_zone_t *xfs_ioend_zone;
Christoph Hellwig0829c362005-09-02 16:58:49 +100075mempool_t *xfs_ioend_pool;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77STATIC struct xfs_mount_args *
78xfs_args_allocate(
Nathan Scott764d1f82006-03-31 13:04:17 +100079 struct super_block *sb,
80 int silent)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
82 struct xfs_mount_args *args;
83
Christoph Hellwigbdd907b2008-05-20 15:10:44 +100084 args = kzalloc(sizeof(struct xfs_mount_args), GFP_KERNEL);
85 if (!args)
86 return NULL;
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 args->logbufs = args->logbufsize = -1;
89 strncpy(args->fsname, sb->s_id, MAXNAMELEN);
90
91 /* Copy the already-parsed mount(2) flags we're interested in */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 if (sb->s_flags & MS_DIRSYNC)
93 args->flags |= XFSMNT_DIRSYNC;
94 if (sb->s_flags & MS_SYNCHRONOUS)
95 args->flags |= XFSMNT_WSYNC;
Nathan Scott764d1f82006-03-31 13:04:17 +100096 if (silent)
97 args->flags |= XFSMNT_QUIET;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 args->flags |= XFSMNT_32BITINODES;
99
100 return args;
101}
102
David Chinnera67d7c52007-11-23 16:29:32 +1100103#define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
104#define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
105#define MNTOPT_LOGDEV "logdev" /* log device */
106#define MNTOPT_RTDEV "rtdev" /* realtime I/O device */
107#define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */
108#define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */
109#define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */
110#define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
111#define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
112#define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
113#define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
114#define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
115#define MNTOPT_MTPT "mtpt" /* filesystem mount point */
116#define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
117#define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
118#define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
119#define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
120#define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
121#define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
122#define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
123 * unwritten extent conversion */
124#define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
125#define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
126#define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
127#define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
128#define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
129#define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
130#define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
131 * in stat(). */
132#define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
133#define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
134#define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
135#define MNTOPT_QUOTA "quota" /* disk quotas (user) */
136#define MNTOPT_NOQUOTA "noquota" /* no quotas */
137#define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
138#define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
139#define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
140#define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
141#define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
142#define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
143#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
144#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
145#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
146#define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
147#define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
148#define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
149#define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
150
Christoph Hellwig62a877e2008-07-18 17:12:36 +1000151/*
152 * Table driven mount option parser.
153 *
154 * Currently only used for remount, but it will be used for mount
155 * in the future, too.
156 */
157enum {
158 Opt_barrier, Opt_nobarrier, Opt_err
159};
160
161static match_table_t tokens = {
162 {Opt_barrier, "barrier"},
163 {Opt_nobarrier, "nobarrier"},
164 {Opt_err, NULL}
165};
166
167
David Chinnera67d7c52007-11-23 16:29:32 +1100168STATIC unsigned long
169suffix_strtoul(char *s, char **endp, unsigned int base)
170{
171 int last, shift_left_factor = 0;
172 char *value = s;
173
174 last = strlen(value) - 1;
175 if (value[last] == 'K' || value[last] == 'k') {
176 shift_left_factor = 10;
177 value[last] = '\0';
178 }
179 if (value[last] == 'M' || value[last] == 'm') {
180 shift_left_factor = 20;
181 value[last] = '\0';
182 }
183 if (value[last] == 'G' || value[last] == 'g') {
184 shift_left_factor = 30;
185 value[last] = '\0';
186 }
187
188 return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
189}
190
191STATIC int
192xfs_parseargs(
193 struct xfs_mount *mp,
194 char *options,
195 struct xfs_mount_args *args,
196 int update)
197{
198 char *this_char, *value, *eov;
199 int dsunit, dswidth, vol_dsunit, vol_dswidth;
200 int iosize;
Josef Jeff Sipek1bd960e2008-02-29 13:58:40 +1100201 int dmapi_implies_ikeep = 1;
David Chinnera67d7c52007-11-23 16:29:32 +1100202
203 args->flags |= XFSMNT_BARRIER;
204 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
205
206 if (!options)
207 goto done;
208
209 iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0;
210
211 while ((this_char = strsep(&options, ",")) != NULL) {
212 if (!*this_char)
213 continue;
214 if ((value = strchr(this_char, '=')) != NULL)
215 *value++ = 0;
216
217 if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
218 if (!value || !*value) {
219 cmn_err(CE_WARN,
220 "XFS: %s option requires an argument",
221 this_char);
222 return EINVAL;
223 }
224 args->logbufs = simple_strtoul(value, &eov, 10);
225 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
226 if (!value || !*value) {
227 cmn_err(CE_WARN,
228 "XFS: %s option requires an argument",
229 this_char);
230 return EINVAL;
231 }
232 args->logbufsize = suffix_strtoul(value, &eov, 10);
233 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
234 if (!value || !*value) {
235 cmn_err(CE_WARN,
236 "XFS: %s option requires an argument",
237 this_char);
238 return EINVAL;
239 }
240 strncpy(args->logname, value, MAXNAMELEN);
241 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
242 if (!value || !*value) {
243 cmn_err(CE_WARN,
244 "XFS: %s option requires an argument",
245 this_char);
246 return EINVAL;
247 }
248 strncpy(args->mtpt, value, MAXNAMELEN);
249 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
250 if (!value || !*value) {
251 cmn_err(CE_WARN,
252 "XFS: %s option requires an argument",
253 this_char);
254 return EINVAL;
255 }
256 strncpy(args->rtname, value, MAXNAMELEN);
257 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
258 if (!value || !*value) {
259 cmn_err(CE_WARN,
260 "XFS: %s option requires an argument",
261 this_char);
262 return EINVAL;
263 }
264 iosize = simple_strtoul(value, &eov, 10);
265 args->flags |= XFSMNT_IOSIZE;
266 args->iosizelog = (uint8_t) iosize;
267 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
268 if (!value || !*value) {
269 cmn_err(CE_WARN,
270 "XFS: %s option requires an argument",
271 this_char);
272 return EINVAL;
273 }
274 iosize = suffix_strtoul(value, &eov, 10);
275 args->flags |= XFSMNT_IOSIZE;
276 args->iosizelog = ffs(iosize) - 1;
277 } else if (!strcmp(this_char, MNTOPT_GRPID) ||
278 !strcmp(this_char, MNTOPT_BSDGROUPS)) {
279 mp->m_flags |= XFS_MOUNT_GRPID;
280 } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
281 !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
282 mp->m_flags &= ~XFS_MOUNT_GRPID;
283 } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
284 args->flags |= XFSMNT_WSYNC;
285 } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) {
286 args->flags |= XFSMNT_OSYNCISOSYNC;
287 } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
288 args->flags |= XFSMNT_NORECOVERY;
289 } else if (!strcmp(this_char, MNTOPT_INO64)) {
290 args->flags |= XFSMNT_INO64;
291#if !XFS_BIG_INUMS
292 cmn_err(CE_WARN,
293 "XFS: %s option not allowed on this system",
294 this_char);
295 return EINVAL;
296#endif
297 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
298 args->flags |= XFSMNT_NOALIGN;
299 } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
300 args->flags |= XFSMNT_SWALLOC;
301 } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
302 if (!value || !*value) {
303 cmn_err(CE_WARN,
304 "XFS: %s option requires an argument",
305 this_char);
306 return EINVAL;
307 }
308 dsunit = simple_strtoul(value, &eov, 10);
309 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
310 if (!value || !*value) {
311 cmn_err(CE_WARN,
312 "XFS: %s option requires an argument",
313 this_char);
314 return EINVAL;
315 }
316 dswidth = simple_strtoul(value, &eov, 10);
317 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
318 args->flags &= ~XFSMNT_32BITINODES;
319#if !XFS_BIG_INUMS
320 cmn_err(CE_WARN,
321 "XFS: %s option not allowed on this system",
322 this_char);
323 return EINVAL;
324#endif
325 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
326 args->flags |= XFSMNT_NOUUID;
327 } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
328 args->flags |= XFSMNT_BARRIER;
329 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
330 args->flags &= ~XFSMNT_BARRIER;
331 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
Josef Jeff Sipek1bd960e2008-02-29 13:58:40 +1100332 args->flags |= XFSMNT_IKEEP;
David Chinnera67d7c52007-11-23 16:29:32 +1100333 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
Josef Jeff Sipek1bd960e2008-02-29 13:58:40 +1100334 dmapi_implies_ikeep = 0;
335 args->flags &= ~XFSMNT_IKEEP;
David Chinnera67d7c52007-11-23 16:29:32 +1100336 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
337 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
338 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
339 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
340 } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
341 args->flags |= XFSMNT_ATTR2;
342 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
343 args->flags &= ~XFSMNT_ATTR2;
Tim Shimmin7c12f292008-04-30 18:15:28 +1000344 args->flags |= XFSMNT_NOATTR2;
David Chinnera67d7c52007-11-23 16:29:32 +1100345 } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
346 args->flags2 |= XFSMNT2_FILESTREAMS;
347 } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
348 args->flags &= ~(XFSMNT_UQUOTAENF|XFSMNT_UQUOTA);
349 args->flags &= ~(XFSMNT_GQUOTAENF|XFSMNT_GQUOTA);
350 } else if (!strcmp(this_char, MNTOPT_QUOTA) ||
351 !strcmp(this_char, MNTOPT_UQUOTA) ||
352 !strcmp(this_char, MNTOPT_USRQUOTA)) {
353 args->flags |= XFSMNT_UQUOTA | XFSMNT_UQUOTAENF;
354 } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
355 !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
356 args->flags |= XFSMNT_UQUOTA;
357 args->flags &= ~XFSMNT_UQUOTAENF;
358 } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
359 !strcmp(this_char, MNTOPT_PRJQUOTA)) {
360 args->flags |= XFSMNT_PQUOTA | XFSMNT_PQUOTAENF;
361 } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
362 args->flags |= XFSMNT_PQUOTA;
363 args->flags &= ~XFSMNT_PQUOTAENF;
364 } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
365 !strcmp(this_char, MNTOPT_GRPQUOTA)) {
366 args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF;
367 } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
368 args->flags |= XFSMNT_GQUOTA;
369 args->flags &= ~XFSMNT_GQUOTAENF;
370 } else if (!strcmp(this_char, MNTOPT_DMAPI)) {
371 args->flags |= XFSMNT_DMAPI;
372 } else if (!strcmp(this_char, MNTOPT_XDSM)) {
373 args->flags |= XFSMNT_DMAPI;
374 } else if (!strcmp(this_char, MNTOPT_DMI)) {
375 args->flags |= XFSMNT_DMAPI;
376 } else if (!strcmp(this_char, "ihashsize")) {
377 cmn_err(CE_WARN,
378 "XFS: ihashsize no longer used, option is deprecated.");
379 } else if (!strcmp(this_char, "osyncisdsync")) {
380 /* no-op, this is now the default */
381 cmn_err(CE_WARN,
382 "XFS: osyncisdsync is now the default, option is deprecated.");
383 } else if (!strcmp(this_char, "irixsgid")) {
384 cmn_err(CE_WARN,
385 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
386 } else {
387 cmn_err(CE_WARN,
388 "XFS: unknown mount option [%s].", this_char);
389 return EINVAL;
390 }
391 }
392
393 if (args->flags & XFSMNT_NORECOVERY) {
394 if ((mp->m_flags & XFS_MOUNT_RDONLY) == 0) {
395 cmn_err(CE_WARN,
396 "XFS: no-recovery mounts must be read-only.");
397 return EINVAL;
398 }
399 }
400
401 if ((args->flags & XFSMNT_NOALIGN) && (dsunit || dswidth)) {
402 cmn_err(CE_WARN,
403 "XFS: sunit and swidth options incompatible with the noalign option");
404 return EINVAL;
405 }
406
407 if ((args->flags & XFSMNT_GQUOTA) && (args->flags & XFSMNT_PQUOTA)) {
408 cmn_err(CE_WARN,
409 "XFS: cannot mount with both project and group quota");
410 return EINVAL;
411 }
412
413 if ((args->flags & XFSMNT_DMAPI) && *args->mtpt == '\0') {
414 printk("XFS: %s option needs the mount point option as well\n",
415 MNTOPT_DMAPI);
416 return EINVAL;
417 }
418
419 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
420 cmn_err(CE_WARN,
421 "XFS: sunit and swidth must be specified together");
422 return EINVAL;
423 }
424
425 if (dsunit && (dswidth % dsunit != 0)) {
426 cmn_err(CE_WARN,
427 "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
428 dswidth, dsunit);
429 return EINVAL;
430 }
431
432 /*
433 * Applications using DMI filesystems often expect the
434 * inode generation number to be monotonically increasing.
435 * If we delete inode chunks we break this assumption, so
436 * keep unused inode chunks on disk for DMI filesystems
437 * until we come up with a better solution.
438 * Note that if "ikeep" or "noikeep" mount options are
439 * supplied, then they are honored.
440 */
Josef Jeff Sipek1bd960e2008-02-29 13:58:40 +1100441 if ((args->flags & XFSMNT_DMAPI) && dmapi_implies_ikeep)
442 args->flags |= XFSMNT_IKEEP;
David Chinnera67d7c52007-11-23 16:29:32 +1100443
444 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
445 if (dsunit) {
446 args->sunit = dsunit;
447 args->flags |= XFSMNT_RETERR;
448 } else {
449 args->sunit = vol_dsunit;
450 }
451 dswidth ? (args->swidth = dswidth) :
452 (args->swidth = vol_dswidth);
453 } else {
454 args->sunit = args->swidth = 0;
455 }
456
457done:
458 if (args->flags & XFSMNT_32BITINODES)
459 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
460 if (args->flags2)
461 args->flags |= XFSMNT_FLAGS2;
462 return 0;
463}
464
465struct proc_xfs_info {
466 int flag;
467 char *str;
468};
469
470STATIC int
471xfs_showargs(
472 struct xfs_mount *mp,
473 struct seq_file *m)
474{
475 static struct proc_xfs_info xfs_info_set[] = {
476 /* the few simple ones we can get from the mount struct */
Josef Jeff Sipek1bd960e2008-02-29 13:58:40 +1100477 { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
David Chinnera67d7c52007-11-23 16:29:32 +1100478 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
479 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
480 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
481 { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
482 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
483 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
484 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
485 { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 },
486 { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
487 { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI },
488 { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
489 { 0, NULL }
490 };
491 static struct proc_xfs_info xfs_info_unset[] = {
492 /* the few simple ones we can get from the mount struct */
David Chinnera67d7c52007-11-23 16:29:32 +1100493 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
494 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
495 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
496 { 0, NULL }
497 };
498 struct proc_xfs_info *xfs_infop;
499
500 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
501 if (mp->m_flags & xfs_infop->flag)
502 seq_puts(m, xfs_infop->str);
503 }
504 for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
505 if (!(mp->m_flags & xfs_infop->flag))
506 seq_puts(m, xfs_infop->str);
507 }
508
509 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
510 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
511 (int)(1 << mp->m_writeio_log) >> 10);
512
513 if (mp->m_logbufs > 0)
514 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
515 if (mp->m_logbsize > 0)
516 seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
517
518 if (mp->m_logname)
519 seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
520 if (mp->m_rtname)
521 seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
522
523 if (mp->m_dalign > 0)
524 seq_printf(m, "," MNTOPT_SUNIT "=%d",
525 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
526 if (mp->m_swidth > 0)
527 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
528 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
529
530 if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
531 seq_puts(m, "," MNTOPT_USRQUOTA);
532 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
533 seq_puts(m, "," MNTOPT_UQUOTANOENF);
534
535 if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
536 seq_puts(m, "," MNTOPT_PRJQUOTA);
537 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
538 seq_puts(m, "," MNTOPT_PQUOTANOENF);
539
540 if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
541 seq_puts(m, "," MNTOPT_GRPQUOTA);
542 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
543 seq_puts(m, "," MNTOPT_GQUOTANOENF);
544
545 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
546 seq_puts(m, "," MNTOPT_NOQUOTA);
547
548 return 0;
549}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550__uint64_t
551xfs_max_file_offset(
552 unsigned int blockshift)
553{
554 unsigned int pagefactor = 1;
555 unsigned int bitshift = BITS_PER_LONG - 1;
556
557 /* Figure out maximum filesize, on Linux this can depend on
558 * the filesystem blocksize (on 32 bit platforms).
559 * __block_prepare_write does this in an [unsigned] long...
560 * page->index << (PAGE_CACHE_SHIFT - bbits)
561 * So, for page sized blocks (4K on 32 bit platforms),
562 * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
563 * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
564 * but for smaller blocksizes it is less (bbits = log2 bsize).
565 * Note1: get_block_t takes a long (implicit cast from above)
566 * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
567 * can optionally convert the [unsigned] long from above into
568 * an [unsigned] long long.
569 */
570
571#if BITS_PER_LONG == 32
572# if defined(CONFIG_LBD)
573 ASSERT(sizeof(sector_t) == 8);
574 pagefactor = PAGE_CACHE_SIZE;
575 bitshift = BITS_PER_LONG;
576# else
577 pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
578# endif
579#endif
580
581 return (((__uint64_t)pagefactor) << bitshift) - 1;
582}
583
David Chinner7989cb82007-02-10 18:34:56 +1100584STATIC_INLINE void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585xfs_set_inodeops(
586 struct inode *inode)
587{
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000588 switch (inode->i_mode & S_IFMT) {
589 case S_IFREG:
Nathan Scott416c6d52006-03-14 14:00:51 +1100590 inode->i_op = &xfs_inode_operations;
Nathan Scott3562fd42006-03-14 14:00:35 +1100591 inode->i_fop = &xfs_file_operations;
Nathan Scotte4c573b2006-03-14 13:54:26 +1100592 inode->i_mapping->a_ops = &xfs_address_space_operations;
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000593 break;
594 case S_IFDIR:
Barry Naujok189f4bf2008-05-21 16:58:55 +1000595 if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
596 inode->i_op = &xfs_dir_ci_inode_operations;
597 else
598 inode->i_op = &xfs_dir_inode_operations;
Nathan Scott3562fd42006-03-14 14:00:35 +1100599 inode->i_fop = &xfs_dir_file_operations;
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000600 break;
601 case S_IFLNK:
Nathan Scott416c6d52006-03-14 14:00:51 +1100602 inode->i_op = &xfs_symlink_inode_operations;
Christoph Hellwig222096a2008-02-05 12:13:46 +1100603 if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
Nathan Scotte4c573b2006-03-14 13:54:26 +1100604 inode->i_mapping->a_ops = &xfs_address_space_operations;
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000605 break;
606 default:
Nathan Scott416c6d52006-03-14 14:00:51 +1100607 inode->i_op = &xfs_inode_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 init_special_inode(inode, inode->i_mode, inode->i_rdev);
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000609 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 }
611}
612
David Chinner7989cb82007-02-10 18:34:56 +1100613STATIC_INLINE void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614xfs_revalidate_inode(
615 xfs_mount_t *mp,
Christoph Hellwig863890c2008-08-13 16:12:05 +1000616 struct inode *inode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 xfs_inode_t *ip)
618{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000620 inode->i_mode = ip->i_d.di_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 inode->i_nlink = ip->i_d.di_nlink;
622 inode->i_uid = ip->i_d.di_uid;
623 inode->i_gid = ip->i_d.di_gid;
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000624
625 switch (inode->i_mode & S_IFMT) {
626 case S_IFBLK:
627 case S_IFCHR:
628 inode->i_rdev =
629 MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
630 sysv_minor(ip->i_df.if_u2.if_rdev));
631 break;
632 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 inode->i_rdev = 0;
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000634 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 }
Christoph Hellwig0432dab2005-09-02 16:46:51 +1000636
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 inode->i_generation = ip->i_d.di_gen;
638 i_size_write(inode, ip->i_d.di_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
640 inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
641 inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
642 inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
643 inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
644 inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
645 if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
646 inode->i_flags |= S_IMMUTABLE;
647 else
648 inode->i_flags &= ~S_IMMUTABLE;
649 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
650 inode->i_flags |= S_APPEND;
651 else
652 inode->i_flags &= ~S_APPEND;
653 if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
654 inode->i_flags |= S_SYNC;
655 else
656 inode->i_flags &= ~S_SYNC;
657 if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
658 inode->i_flags |= S_NOATIME;
659 else
660 inode->i_flags &= ~S_NOATIME;
Christoph Hellwigb3aea4e2007-08-29 11:44:37 +1000661 xfs_iflags_clear(ip, XFS_IMODIFIED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662}
663
664void
665xfs_initialize_vnode(
Christoph Hellwig48c872a9f2007-08-30 17:20:31 +1000666 struct xfs_mount *mp,
Christoph Hellwig863890c2008-08-13 16:12:05 +1000667 struct inode *inode,
Christoph Hellwig745f6912007-08-30 17:20:39 +1000668 struct xfs_inode *ip)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670
Christoph Hellwig739bfb22007-08-29 10:58:01 +1000671 if (!ip->i_vnode) {
Christoph Hellwig863890c2008-08-13 16:12:05 +1000672 ip->i_vnode = inode;
Christoph Hellwig739bfb22007-08-29 10:58:01 +1000673 inode->i_private = ip;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 }
675
676 /*
677 * We need to set the ops vectors, and unlock the inode, but if
678 * we have been called during the new inode create process, it is
679 * too early to fill in the Linux inode. We will get called a
680 * second time once the inode is properly set up, and then we can
681 * finish our work.
682 */
Christoph Hellwig745f6912007-08-30 17:20:39 +1000683 if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
Christoph Hellwig863890c2008-08-13 16:12:05 +1000684 xfs_revalidate_inode(mp, inode, ip);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 xfs_set_inodeops(inode);
Nathan Scottec86dc02006-03-17 17:25:36 +1100686
David Chinner7a18c382006-11-11 18:04:54 +1100687 xfs_iflags_clear(ip, XFS_INEW);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 barrier();
689
690 unlock_new_inode(inode);
691 }
692}
693
694int
695xfs_blkdev_get(
696 xfs_mount_t *mp,
697 const char *name,
698 struct block_device **bdevp)
699{
700 int error = 0;
701
702 *bdevp = open_bdev_excl(name, 0, mp);
703 if (IS_ERR(*bdevp)) {
704 error = PTR_ERR(*bdevp);
705 printk("XFS: Invalid device [%s], error=%d\n", name, error);
706 }
707
708 return -error;
709}
710
711void
712xfs_blkdev_put(
713 struct block_device *bdev)
714{
715 if (bdev)
716 close_bdev_excl(bdev);
717}
718
Christoph Hellwigf538d4d2005-11-02 10:26:59 +1100719/*
720 * Try to write out the superblock using barriers.
721 */
722STATIC int
723xfs_barrier_test(
724 xfs_mount_t *mp)
725{
726 xfs_buf_t *sbp = xfs_getsb(mp, 0);
727 int error;
728
729 XFS_BUF_UNDONE(sbp);
730 XFS_BUF_UNREAD(sbp);
731 XFS_BUF_UNDELAYWRITE(sbp);
732 XFS_BUF_WRITE(sbp);
733 XFS_BUF_UNASYNC(sbp);
734 XFS_BUF_ORDERED(sbp);
735
736 xfsbdstrat(mp, sbp);
737 error = xfs_iowait(sbp);
738
739 /*
740 * Clear all the flags we set and possible error state in the
741 * buffer. We only did the write to try out whether barriers
742 * worked and shouldn't leave any traces in the superblock
743 * buffer.
744 */
745 XFS_BUF_DONE(sbp);
746 XFS_BUF_ERROR(sbp, 0);
747 XFS_BUF_UNORDERED(sbp);
748
749 xfs_buf_relse(sbp);
750 return error;
751}
752
753void
754xfs_mountfs_check_barriers(xfs_mount_t *mp)
755{
756 int error;
757
758 if (mp->m_logdev_targp != mp->m_ddev_targp) {
759 xfs_fs_cmn_err(CE_NOTE, mp,
760 "Disabling barriers, not supported with external log device");
761 mp->m_flags &= ~XFS_MOUNT_BARRIER;
Christoph Hellwig4ef19dd2006-01-11 15:27:18 +1100762 return;
Christoph Hellwigf538d4d2005-11-02 10:26:59 +1100763 }
764
Nathan Scottb2ea4012006-07-28 17:05:13 +1000765 if (xfs_readonly_buftarg(mp->m_ddev_targp)) {
766 xfs_fs_cmn_err(CE_NOTE, mp,
767 "Disabling barriers, underlying device is readonly");
768 mp->m_flags &= ~XFS_MOUNT_BARRIER;
769 return;
770 }
771
Christoph Hellwigf538d4d2005-11-02 10:26:59 +1100772 error = xfs_barrier_test(mp);
773 if (error) {
774 xfs_fs_cmn_err(CE_NOTE, mp,
775 "Disabling barriers, trial barrier write failed");
776 mp->m_flags &= ~XFS_MOUNT_BARRIER;
Christoph Hellwig4ef19dd2006-01-11 15:27:18 +1100777 return;
Christoph Hellwigf538d4d2005-11-02 10:26:59 +1100778 }
779}
780
781void
782xfs_blkdev_issue_flush(
783 xfs_buftarg_t *buftarg)
784{
Nathan Scottce8e9222006-01-11 15:39:08 +1100785 blkdev_issue_flush(buftarg->bt_bdev, NULL);
Christoph Hellwigf538d4d2005-11-02 10:26:59 +1100786}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000788STATIC void
789xfs_close_devices(
790 struct xfs_mount *mp)
791{
792 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
Lachlan McIlroyc032bfc2008-07-18 17:13:12 +1000793 struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000794 xfs_free_buftarg(mp->m_logdev_targp);
Lachlan McIlroyc032bfc2008-07-18 17:13:12 +1000795 xfs_blkdev_put(logdev);
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000796 }
797 if (mp->m_rtdev_targp) {
Lachlan McIlroyc032bfc2008-07-18 17:13:12 +1000798 struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000799 xfs_free_buftarg(mp->m_rtdev_targp);
Lachlan McIlroyc032bfc2008-07-18 17:13:12 +1000800 xfs_blkdev_put(rtdev);
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000801 }
802 xfs_free_buftarg(mp->m_ddev_targp);
803}
804
805/*
806 * The file system configurations are:
807 * (1) device (partition) with data and internal log
808 * (2) logical volume with data and log subvolumes.
809 * (3) logical volume with data, log, and realtime subvolumes.
810 *
811 * We only have to handle opening the log and realtime volumes here if
812 * they are present. The data subvolume has already been opened by
813 * get_sb_bdev() and is stored in sb->s_bdev.
814 */
815STATIC int
816xfs_open_devices(
817 struct xfs_mount *mp,
818 struct xfs_mount_args *args)
819{
820 struct block_device *ddev = mp->m_super->s_bdev;
821 struct block_device *logdev = NULL, *rtdev = NULL;
822 int error;
823
824 /*
825 * Open real time and log devices - order is important.
826 */
827 if (args->logname[0]) {
828 error = xfs_blkdev_get(mp, args->logname, &logdev);
829 if (error)
830 goto out;
831 }
832
833 if (args->rtname[0]) {
834 error = xfs_blkdev_get(mp, args->rtname, &rtdev);
835 if (error)
836 goto out_close_logdev;
837
838 if (rtdev == ddev || rtdev == logdev) {
839 cmn_err(CE_WARN,
840 "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev.");
841 error = EINVAL;
842 goto out_close_rtdev;
843 }
844 }
845
846 /*
847 * Setup xfs_mount buffer target pointers
848 */
849 error = ENOMEM;
850 mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0);
851 if (!mp->m_ddev_targp)
852 goto out_close_rtdev;
853
854 if (rtdev) {
855 mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1);
856 if (!mp->m_rtdev_targp)
857 goto out_free_ddev_targ;
858 }
859
860 if (logdev && logdev != ddev) {
861 mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1);
862 if (!mp->m_logdev_targp)
863 goto out_free_rtdev_targ;
864 } else {
865 mp->m_logdev_targp = mp->m_ddev_targp;
866 }
867
868 return 0;
869
870 out_free_rtdev_targ:
871 if (mp->m_rtdev_targp)
872 xfs_free_buftarg(mp->m_rtdev_targp);
873 out_free_ddev_targ:
874 xfs_free_buftarg(mp->m_ddev_targp);
875 out_close_rtdev:
876 if (rtdev)
877 xfs_blkdev_put(rtdev);
878 out_close_logdev:
879 if (logdev && logdev != ddev)
880 xfs_blkdev_put(logdev);
881 out:
882 return error;
883}
884
Christoph Hellwige34b5622008-05-20 15:10:36 +1000885/*
886 * Setup xfs_mount buffer target pointers based on superblock
887 */
888STATIC int
889xfs_setup_devices(
890 struct xfs_mount *mp)
891{
892 int error;
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000893
Christoph Hellwige34b5622008-05-20 15:10:36 +1000894 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
895 mp->m_sb.sb_sectsize);
896 if (error)
897 return error;
898
899 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
900 unsigned int log_sector_size = BBSIZE;
901
902 if (xfs_sb_version_hassector(&mp->m_sb))
903 log_sector_size = mp->m_sb.sb_logsectsize;
904 error = xfs_setsize_buftarg(mp->m_logdev_targp,
905 mp->m_sb.sb_blocksize,
906 log_sector_size);
907 if (error)
908 return error;
909 }
910 if (mp->m_rtdev_targp) {
911 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
912 mp->m_sb.sb_blocksize,
913 mp->m_sb.sb_sectsize);
914 if (error)
915 return error;
916 }
917
918 return 0;
919}
Christoph Hellwig19f354d2008-05-20 11:31:13 +1000920
David Chinner249a8c12008-02-05 12:13:32 +1100921/*
922 * XFS AIL push thread support
923 */
924void
925xfsaild_wakeup(
926 xfs_mount_t *mp,
927 xfs_lsn_t threshold_lsn)
928{
929 mp->m_ail.xa_target = threshold_lsn;
930 wake_up_process(mp->m_ail.xa_task);
931}
932
933int
934xfsaild(
935 void *data)
936{
937 xfs_mount_t *mp = (xfs_mount_t *)data;
938 xfs_lsn_t last_pushed_lsn = 0;
939 long tout = 0;
940
941 while (!kthread_should_stop()) {
942 if (tout)
943 schedule_timeout_interruptible(msecs_to_jiffies(tout));
944 tout = 1000;
945
946 /* swsusp */
947 try_to_freeze();
948
949 ASSERT(mp->m_log);
950 if (XFS_FORCED_SHUTDOWN(mp))
951 continue;
952
953 tout = xfsaild_push(mp, &last_pushed_lsn);
954 }
955
956 return 0;
957} /* xfsaild */
958
959int
960xfsaild_start(
961 xfs_mount_t *mp)
962{
963 mp->m_ail.xa_target = 0;
964 mp->m_ail.xa_task = kthread_run(xfsaild, mp, "xfsaild");
965 if (IS_ERR(mp->m_ail.xa_task))
966 return -PTR_ERR(mp->m_ail.xa_task);
967 return 0;
968}
969
970void
971xfsaild_stop(
972 xfs_mount_t *mp)
973{
974 kthread_stop(mp->m_ail.xa_task);
975}
976
977
978
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979STATIC struct inode *
Nathan Scotta50cd262006-03-14 14:06:18 +1100980xfs_fs_alloc_inode(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 struct super_block *sb)
982{
Christoph Hellwigdf80c932008-08-13 16:22:09 +1000983 return kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984}
985
986STATIC void
Nathan Scotta50cd262006-03-14 14:06:18 +1100987xfs_fs_destroy_inode(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 struct inode *inode)
989{
Christoph Hellwiga19d0332008-08-13 16:11:26 +1000990 kmem_zone_free(xfs_vnode_zone, inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991}
992
993STATIC void
Nathan Scotta50cd262006-03-14 14:06:18 +1100994xfs_fs_inode_init_once(
Christoph Lameter4ba9b9d2007-10-16 23:25:51 -0700995 void *vnode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996{
Christoph Hellwig863890c2008-08-13 16:12:05 +1000997 inode_init_once((struct inode *)vnode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998}
999
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000/*
1001 * Attempt to flush the inode, this will actually fail
1002 * if the inode is pinned, but we dirty the inode again
1003 * at the point when it is unpinned after a log write,
Nathan Scott87582802006-03-14 13:18:19 +11001004 * since this is when the inode itself becomes flushable.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 */
1006STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001007xfs_fs_write_inode(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 struct inode *inode,
1009 int sync)
1010{
David Chinnera3f74ff2008-03-06 13:43:42 +11001011 int error = 0;
1012 int flags = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013
Lachlan McIlroycf441ee2008-02-07 16:42:19 +11001014 xfs_itrace_entry(XFS_I(inode));
Christoph Hellwig739bfb22007-08-29 10:58:01 +10001015 if (sync) {
1016 filemap_fdatawait(inode->i_mapping);
1017 flags |= FLUSH_SYNC;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 }
Christoph Hellwig739bfb22007-08-29 10:58:01 +10001019 error = xfs_inode_flush(XFS_I(inode), flags);
Lachlan McIlroye893bff2007-10-12 11:13:35 +10001020 /*
1021 * if we failed to write out the inode then mark
1022 * it dirty again so we'll try again later.
1023 */
1024 if (error)
1025 mark_inode_dirty_sync(inode);
Christoph Hellwig739bfb22007-08-29 10:58:01 +10001026
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 return -error;
1028}
1029
1030STATIC void
Nathan Scotta50cd262006-03-14 14:06:18 +11001031xfs_fs_clear_inode(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 struct inode *inode)
1033{
Christoph Hellwig1543d792007-08-29 11:46:47 +10001034 xfs_inode_t *ip = XFS_I(inode);
Christoph Hellwig56d433e2005-09-05 08:23:54 +10001035
Christoph Hellwig02ba71d2005-09-05 08:28:02 +10001036 /*
Christoph Hellwig1543d792007-08-29 11:46:47 +10001037 * ip can be null when xfs_iget_core calls xfs_idestroy if we
Christoph Hellwig02ba71d2005-09-05 08:28:02 +10001038 * find an inode with di_mode == 0 but without IGET_CREATE set.
1039 */
Christoph Hellwig1543d792007-08-29 11:46:47 +10001040 if (ip) {
Lachlan McIlroycf441ee2008-02-07 16:42:19 +11001041 xfs_itrace_entry(ip);
Christoph Hellwig1543d792007-08-29 11:46:47 +10001042 XFS_STATS_INC(vn_rele);
1043 XFS_STATS_INC(vn_remove);
1044 XFS_STATS_INC(vn_reclaim);
1045 XFS_STATS_DEC(vn_active);
Christoph Hellwig56d433e2005-09-05 08:23:54 +10001046
Christoph Hellwig1543d792007-08-29 11:46:47 +10001047 xfs_inactive(ip);
1048 xfs_iflags_clear(ip, XFS_IMODIFIED);
1049 if (xfs_reclaim(ip))
Harvey Harrison34a622b2008-04-10 12:19:21 +10001050 panic("%s: cannot reclaim 0x%p\n", __func__, inode);
Christoph Hellwigb3aea4e2007-08-29 11:44:37 +10001051 }
Christoph Hellwig56d433e2005-09-05 08:23:54 +10001052
Christoph Hellwig739bfb22007-08-29 10:58:01 +10001053 ASSERT(XFS_I(inode) == NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054}
1055
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056/*
1057 * Enqueue a work item to be picked up by the vfs xfssyncd thread.
1058 * Doing this has two advantages:
1059 * - It saves on stack space, which is tight in certain situations
1060 * - It can be used (with care) as a mechanism to avoid deadlocks.
1061 * Flushing while allocating in a full filesystem requires both.
1062 */
1063STATIC void
1064xfs_syncd_queue_work(
Christoph Hellwig74394492007-08-30 17:21:22 +10001065 struct xfs_mount *mp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 void *data,
Christoph Hellwig74394492007-08-30 17:21:22 +10001067 void (*syncer)(struct xfs_mount *, void *))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068{
Nathan Scottb83bd132006-06-09 16:48:30 +10001069 struct bhv_vfs_sync_work *work;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070
Nathan Scottb83bd132006-06-09 16:48:30 +10001071 work = kmem_alloc(sizeof(struct bhv_vfs_sync_work), KM_SLEEP);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072 INIT_LIST_HEAD(&work->w_list);
1073 work->w_syncer = syncer;
1074 work->w_data = data;
Christoph Hellwig74394492007-08-30 17:21:22 +10001075 work->w_mount = mp;
1076 spin_lock(&mp->m_sync_lock);
1077 list_add_tail(&work->w_list, &mp->m_sync_list);
1078 spin_unlock(&mp->m_sync_lock);
1079 wake_up_process(mp->m_sync_task);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080}
1081
1082/*
1083 * Flush delayed allocate data, attempting to free up reserved space
1084 * from existing allocations. At this point a new allocation attempt
1085 * has failed with ENOSPC and we are in the process of scratching our
1086 * heads, looking about for more room...
1087 */
1088STATIC void
1089xfs_flush_inode_work(
Christoph Hellwig74394492007-08-30 17:21:22 +10001090 struct xfs_mount *mp,
1091 void *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092{
Christoph Hellwig74394492007-08-30 17:21:22 +10001093 struct inode *inode = arg;
1094 filemap_flush(inode->i_mapping);
1095 iput(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096}
1097
1098void
1099xfs_flush_inode(
1100 xfs_inode_t *ip)
1101{
David Chinner01651642008-08-13 15:45:15 +10001102 struct inode *inode = VFS_I(ip);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103
1104 igrab(inode);
Christoph Hellwig74394492007-08-30 17:21:22 +10001105 xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work);
Nishanth Aravamudan041e0e32005-09-10 00:27:23 -07001106 delay(msecs_to_jiffies(500));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107}
1108
1109/*
1110 * This is the "bigger hammer" version of xfs_flush_inode_work...
1111 * (IOW, "If at first you don't succeed, use a Bigger Hammer").
1112 */
1113STATIC void
1114xfs_flush_device_work(
Christoph Hellwig74394492007-08-30 17:21:22 +10001115 struct xfs_mount *mp,
1116 void *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117{
Christoph Hellwig74394492007-08-30 17:21:22 +10001118 struct inode *inode = arg;
Christoph Hellwigb267ce92007-08-30 17:21:30 +10001119 sync_blockdev(mp->m_super->s_bdev);
Christoph Hellwig74394492007-08-30 17:21:22 +10001120 iput(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121}
1122
1123void
1124xfs_flush_device(
1125 xfs_inode_t *ip)
1126{
David Chinnere4f75292008-08-13 16:00:45 +10001127 struct inode *inode = VFS_I(ip);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128
1129 igrab(inode);
Christoph Hellwig74394492007-08-30 17:21:22 +10001130 xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_device_work);
Nishanth Aravamudan041e0e32005-09-10 00:27:23 -07001131 delay(msecs_to_jiffies(500));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
1133}
1134
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135STATIC void
Christoph Hellwig74394492007-08-30 17:21:22 +10001136xfs_sync_worker(
1137 struct xfs_mount *mp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 void *unused)
1139{
1140 int error;
1141
Christoph Hellwig74394492007-08-30 17:21:22 +10001142 if (!(mp->m_flags & XFS_MOUNT_RDONLY))
David Chinner7e206942008-04-17 16:49:55 +10001143 error = xfs_sync(mp, SYNC_FSDATA | SYNC_BDFLUSH | SYNC_ATTR);
Christoph Hellwig74394492007-08-30 17:21:22 +10001144 mp->m_sync_seq++;
1145 wake_up(&mp->m_wait_single_sync_task);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146}
1147
1148STATIC int
1149xfssyncd(
1150 void *arg)
1151{
Christoph Hellwig74394492007-08-30 17:21:22 +10001152 struct xfs_mount *mp = arg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 long timeleft;
Nathan Scottb83bd132006-06-09 16:48:30 +10001154 bhv_vfs_sync_work_t *work, *n;
Christoph Hellwig4df08c52005-09-05 08:34:18 +10001155 LIST_HEAD (tmp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156
Rafael J. Wysocki83144182007-07-17 04:03:35 -07001157 set_freezable();
Nishanth Aravamudan041e0e32005-09-10 00:27:23 -07001158 timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 for (;;) {
Nishanth Aravamudan041e0e32005-09-10 00:27:23 -07001160 timeleft = schedule_timeout_interruptible(timeleft);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 /* swsusp */
Christoph Lameter3e1d1d22005-06-24 23:13:50 -07001162 try_to_freeze();
Christoph Hellwig74394492007-08-30 17:21:22 +10001163 if (kthread_should_stop() && list_empty(&mp->m_sync_list))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 break;
1165
Christoph Hellwig74394492007-08-30 17:21:22 +10001166 spin_lock(&mp->m_sync_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 /*
1168 * We can get woken by laptop mode, to do a sync -
1169 * that's the (only!) case where the list would be
1170 * empty with time remaining.
1171 */
Christoph Hellwig74394492007-08-30 17:21:22 +10001172 if (!timeleft || list_empty(&mp->m_sync_list)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 if (!timeleft)
Nishanth Aravamudan041e0e32005-09-10 00:27:23 -07001174 timeleft = xfs_syncd_centisecs *
1175 msecs_to_jiffies(10);
Christoph Hellwig74394492007-08-30 17:21:22 +10001176 INIT_LIST_HEAD(&mp->m_sync_work.w_list);
1177 list_add_tail(&mp->m_sync_work.w_list,
1178 &mp->m_sync_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 }
Christoph Hellwig74394492007-08-30 17:21:22 +10001180 list_for_each_entry_safe(work, n, &mp->m_sync_list, w_list)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 list_move(&work->w_list, &tmp);
Christoph Hellwig74394492007-08-30 17:21:22 +10001182 spin_unlock(&mp->m_sync_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183
1184 list_for_each_entry_safe(work, n, &tmp, w_list) {
Christoph Hellwig74394492007-08-30 17:21:22 +10001185 (*work->w_syncer)(mp, work->w_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 list_del(&work->w_list);
Christoph Hellwig74394492007-08-30 17:21:22 +10001187 if (work == &mp->m_sync_work)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 continue;
Denys Vlasenkof0e2d932008-05-19 16:31:57 +10001189 kmem_free(work);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 }
1191 }
1192
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 return 0;
1194}
1195
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196STATIC void
Christoph Hellwiga7381592008-08-13 16:04:05 +10001197xfs_free_fsname(
1198 struct xfs_mount *mp)
1199{
1200 kfree(mp->m_fsname);
1201 kfree(mp->m_rtname);
1202 kfree(mp->m_logname);
1203}
1204
1205STATIC void
Nathan Scotta50cd262006-03-14 14:06:18 +11001206xfs_fs_put_super(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 struct super_block *sb)
1208{
Christoph Hellwig745f6912007-08-30 17:20:39 +10001209 struct xfs_mount *mp = XFS_M(sb);
Christoph Hellwige48ad312008-05-20 11:30:52 +10001210 struct xfs_inode *rip = mp->m_rootip;
1211 int unmount_event_flags = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 int error;
1213
Christoph Hellwig74394492007-08-30 17:21:22 +10001214 kthread_stop(mp->m_sync_task);
1215
Christoph Hellwig745f6912007-08-30 17:20:39 +10001216 xfs_sync(mp, SYNC_ATTR | SYNC_DELWRI);
Christoph Hellwige48ad312008-05-20 11:30:52 +10001217
1218#ifdef HAVE_DMAPI
1219 if (mp->m_flags & XFS_MOUNT_DMAPI) {
1220 unmount_event_flags =
1221 (mp->m_dmevmask & (1 << DM_EVENT_UNMOUNT)) ?
1222 0 : DM_FLAGS_UNWANTED;
1223 /*
1224 * Ignore error from dmapi here, first unmount is not allowed
1225 * to fail anyway, and second we wouldn't want to fail a
1226 * unmount because of dmapi.
1227 */
1228 XFS_SEND_PREUNMOUNT(mp, rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL,
1229 NULL, NULL, 0, 0, unmount_event_flags);
1230 }
1231#endif
1232
1233 /*
1234 * Blow away any referenced inode in the filestreams cache.
1235 * This can and will cause log traffic as inodes go inactive
1236 * here.
1237 */
1238 xfs_filestream_unmount(mp);
1239
1240 XFS_bflush(mp->m_ddev_targp);
1241 error = xfs_unmount_flush(mp, 0);
1242 WARN_ON(error);
1243
1244 IRELE(rip);
1245
1246 /*
1247 * If we're forcing a shutdown, typically because of a media error,
1248 * we want to make sure we invalidate dirty pages that belong to
1249 * referenced vnodes as well.
1250 */
1251 if (XFS_FORCED_SHUTDOWN(mp)) {
1252 error = xfs_sync(mp, SYNC_WAIT | SYNC_CLOSE);
1253 ASSERT(error != EFSCORRUPTED);
1254 }
1255
1256 if (mp->m_flags & XFS_MOUNT_DMAPI) {
1257 XFS_SEND_UNMOUNT(mp, rip, DM_RIGHT_NULL, 0, 0,
1258 unmount_event_flags);
1259 }
1260
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001261 xfs_unmountfs(mp);
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001262 xfs_icsb_destroy_counters(mp);
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001263 xfs_close_devices(mp);
Christoph Hellwige48ad312008-05-20 11:30:52 +10001264 xfs_qmops_put(mp);
1265 xfs_dmops_put(mp);
Christoph Hellwiga7381592008-08-13 16:04:05 +10001266 xfs_free_fsname(mp);
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001267 kfree(mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268}
1269
1270STATIC void
Nathan Scotta50cd262006-03-14 14:06:18 +11001271xfs_fs_write_super(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272 struct super_block *sb)
1273{
Nathan Scottb83bd132006-06-09 16:48:30 +10001274 if (!(sb->s_flags & MS_RDONLY))
Christoph Hellwig745f6912007-08-30 17:20:39 +10001275 xfs_sync(XFS_M(sb), SYNC_FSDATA);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 sb->s_dirt = 0;
1277}
1278
1279STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001280xfs_fs_sync_super(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 struct super_block *sb,
1282 int wait)
1283{
Christoph Hellwig745f6912007-08-30 17:20:39 +10001284 struct xfs_mount *mp = XFS_M(sb);
Nathan Scottb83bd132006-06-09 16:48:30 +10001285 int error;
1286 int flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287
Lachlan McIlroye893bff2007-10-12 11:13:35 +10001288 /*
1289 * Treat a sync operation like a freeze. This is to work
1290 * around a race in sync_inodes() which works in two phases
1291 * - an asynchronous flush, which can write out an inode
1292 * without waiting for file size updates to complete, and a
1293 * synchronous flush, which wont do anything because the
1294 * async flush removed the inode's dirty flag. Also
1295 * sync_inodes() will not see any files that just have
1296 * outstanding transactions to be flushed because we don't
1297 * dirty the Linux inode until after the transaction I/O
1298 * completes.
1299 */
1300 if (wait || unlikely(sb->s_frozen == SB_FREEZE_WRITE)) {
David Chinner28239452007-02-10 18:36:40 +11001301 /*
1302 * First stage of freeze - no more writers will make progress
1303 * now we are here, so we flush delwri and delalloc buffers
1304 * here, then wait for all I/O to complete. Data is frozen at
1305 * that point. Metadata is not frozen, transactions can still
1306 * occur here so don't bother flushing the buftarg (i.e
1307 * SYNC_QUIESCE) because it'll just get dirty again.
1308 */
David Chinner516b2e72007-06-18 16:50:48 +10001309 flags = SYNC_DATA_QUIESCE;
David Chinner28239452007-02-10 18:36:40 +11001310 } else
Lachlan McIlroye893bff2007-10-12 11:13:35 +10001311 flags = SYNC_FSDATA;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
Christoph Hellwig745f6912007-08-30 17:20:39 +10001313 error = xfs_sync(mp, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 sb->s_dirt = 0;
1315
1316 if (unlikely(laptop_mode)) {
Christoph Hellwig74394492007-08-30 17:21:22 +10001317 int prev_sync_seq = mp->m_sync_seq;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318
1319 /*
1320 * The disk must be active because we're syncing.
1321 * We schedule xfssyncd now (now that the disk is
1322 * active) instead of later (when it might not be).
1323 */
Christoph Hellwig74394492007-08-30 17:21:22 +10001324 wake_up_process(mp->m_sync_task);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 /*
1326 * We have to wait for the sync iteration to complete.
1327 * If we don't, the disk activity caused by the sync
1328 * will come after the sync is completed, and that
1329 * triggers another sync from laptop mode.
1330 */
Christoph Hellwig74394492007-08-30 17:21:22 +10001331 wait_event(mp->m_wait_single_sync_task,
1332 mp->m_sync_seq != prev_sync_seq);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 }
1334
1335 return -error;
1336}
1337
1338STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001339xfs_fs_statfs(
David Howells726c3342006-06-23 02:02:58 -07001340 struct dentry *dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 struct kstatfs *statp)
1342{
Christoph Hellwig4ca488e2007-10-11 18:09:40 +10001343 struct xfs_mount *mp = XFS_M(dentry->d_sb);
1344 xfs_sb_t *sbp = &mp->m_sb;
1345 __uint64_t fakeinos, id;
1346 xfs_extlen_t lsize;
1347
1348 statp->f_type = XFS_SB_MAGIC;
1349 statp->f_namelen = MAXNAMELEN - 1;
1350
1351 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
1352 statp->f_fsid.val[0] = (u32)id;
1353 statp->f_fsid.val[1] = (u32)(id >> 32);
1354
Christoph Hellwigd4d90b52008-04-22 17:34:37 +10001355 xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
Christoph Hellwig4ca488e2007-10-11 18:09:40 +10001356
1357 spin_lock(&mp->m_sb_lock);
1358 statp->f_bsize = sbp->sb_blocksize;
1359 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
1360 statp->f_blocks = sbp->sb_dblocks - lsize;
1361 statp->f_bfree = statp->f_bavail =
1362 sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
1363 fakeinos = statp->f_bfree << sbp->sb_inopblog;
1364#if XFS_BIG_INUMS
1365 fakeinos += mp->m_inoadd;
1366#endif
1367 statp->f_files =
1368 MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
1369 if (mp->m_maxicount)
1370#if XFS_BIG_INUMS
1371 if (!mp->m_inoadd)
1372#endif
1373 statp->f_files = min_t(typeof(statp->f_files),
1374 statp->f_files,
1375 mp->m_maxicount);
1376 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
1377 spin_unlock(&mp->m_sb_lock);
1378
1379 XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp);
1380 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381}
1382
1383STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001384xfs_fs_remount(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 struct super_block *sb,
1386 int *flags,
1387 char *options)
1388{
Christoph Hellwig745f6912007-08-30 17:20:39 +10001389 struct xfs_mount *mp = XFS_M(sb);
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001390 substring_t args[MAX_OPT_ARGS];
1391 char *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001393 while ((p = strsep(&options, ",")) != NULL) {
1394 int token;
Christoph Hellwigbdd907b2008-05-20 15:10:44 +10001395
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001396 if (!*p)
1397 continue;
Christoph Hellwig48b62a12008-05-20 11:30:39 +10001398
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001399 token = match_token(p, tokens, args);
1400 switch (token) {
1401 case Opt_barrier:
Christoph Hellwig48b62a12008-05-20 11:30:39 +10001402 mp->m_flags |= XFS_MOUNT_BARRIER;
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001403
1404 /*
1405 * Test if barriers are actually working if we can,
1406 * else delay this check until the filesystem is
1407 * marked writeable.
1408 */
1409 if (!(mp->m_flags & XFS_MOUNT_RDONLY))
1410 xfs_mountfs_check_barriers(mp);
1411 break;
1412 case Opt_nobarrier:
Christoph Hellwig48b62a12008-05-20 11:30:39 +10001413 mp->m_flags &= ~XFS_MOUNT_BARRIER;
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001414 break;
1415 default:
1416 printk(KERN_INFO
1417 "XFS: mount option \"%s\" not supported for remount\n", p);
1418 return -EINVAL;
Christoph Hellwig48b62a12008-05-20 11:30:39 +10001419 }
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001420 }
1421
1422 /* rw/ro -> rw */
1423 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
1424 mp->m_flags &= ~XFS_MOUNT_RDONLY;
1425 if (mp->m_flags & XFS_MOUNT_BARRIER)
1426 xfs_mountfs_check_barriers(mp);
1427 }
1428
1429 /* rw -> ro */
1430 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
Christoph Hellwig48b62a12008-05-20 11:30:39 +10001431 xfs_filestream_flush(mp);
1432 xfs_sync(mp, SYNC_DATA_QUIESCE);
1433 xfs_attr_quiesce(mp);
1434 mp->m_flags |= XFS_MOUNT_RDONLY;
1435 }
1436
Christoph Hellwig62a877e2008-07-18 17:12:36 +10001437 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438}
1439
Christoph Hellwig9909c4a2007-10-11 18:11:14 +10001440/*
1441 * Second stage of a freeze. The data is already frozen so we only
1442 * need to take care of themetadata. Once that's done write a dummy
1443 * record to dirty the log in case of a crash while frozen.
1444 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445STATIC void
Nathan Scotta50cd262006-03-14 14:06:18 +11001446xfs_fs_lockfs(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 struct super_block *sb)
1448{
Christoph Hellwig9909c4a2007-10-11 18:11:14 +10001449 struct xfs_mount *mp = XFS_M(sb);
1450
1451 xfs_attr_quiesce(mp);
1452 xfs_fs_log_dummy(mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453}
1454
1455STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001456xfs_fs_show_options(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 struct seq_file *m,
1458 struct vfsmount *mnt)
1459{
Christoph Hellwig745f6912007-08-30 17:20:39 +10001460 return -xfs_showargs(XFS_M(mnt->mnt_sb), m);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461}
1462
1463STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001464xfs_fs_quotasync(
Nathan Scottee348072005-11-02 10:32:38 +11001465 struct super_block *sb,
1466 int type)
1467{
Christoph Hellwigb09cc772007-08-30 17:19:57 +10001468 return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XQUOTASYNC, 0, NULL);
Nathan Scottee348072005-11-02 10:32:38 +11001469}
1470
1471STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001472xfs_fs_getxstate(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 struct super_block *sb,
1474 struct fs_quota_stat *fqs)
1475{
Christoph Hellwigb09cc772007-08-30 17:19:57 +10001476 return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XGETQSTAT, 0, (caddr_t)fqs);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477}
1478
1479STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001480xfs_fs_setxstate(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 struct super_block *sb,
1482 unsigned int flags,
1483 int op)
1484{
Christoph Hellwigb09cc772007-08-30 17:19:57 +10001485 return -XFS_QM_QUOTACTL(XFS_M(sb), op, 0, (caddr_t)&flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486}
1487
1488STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001489xfs_fs_getxquota(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 struct super_block *sb,
1491 int type,
1492 qid_t id,
1493 struct fs_disk_quota *fdq)
1494{
Christoph Hellwigb09cc772007-08-30 17:19:57 +10001495 return -XFS_QM_QUOTACTL(XFS_M(sb),
Nathan Scottb83bd132006-06-09 16:48:30 +10001496 (type == USRQUOTA) ? Q_XGETQUOTA :
1497 ((type == GRPQUOTA) ? Q_XGETGQUOTA :
1498 Q_XGETPQUOTA), id, (caddr_t)fdq);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499}
1500
1501STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001502xfs_fs_setxquota(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 struct super_block *sb,
1504 int type,
1505 qid_t id,
1506 struct fs_disk_quota *fdq)
1507{
Christoph Hellwigb09cc772007-08-30 17:19:57 +10001508 return -XFS_QM_QUOTACTL(XFS_M(sb),
Nathan Scottb83bd132006-06-09 16:48:30 +10001509 (type == USRQUOTA) ? Q_XSETQLIM :
1510 ((type == GRPQUOTA) ? Q_XSETGQLIM :
1511 Q_XSETPQLIM), id, (caddr_t)fdq);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512}
1513
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001514/*
1515 * This function fills in xfs_mount_t fields based on mount args.
1516 * Note: the superblock has _not_ yet been read in.
1517 */
1518STATIC int
1519xfs_start_flags(
1520 struct xfs_mount_args *ap,
1521 struct xfs_mount *mp)
1522{
Christoph Hellwiga7381592008-08-13 16:04:05 +10001523 int error;
1524
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001525 /* Values are in BBs */
1526 if ((ap->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
1527 /*
1528 * At this point the superblock has not been read
1529 * in, therefore we do not know the block size.
1530 * Before the mount call ends we will convert
1531 * these to FSBs.
1532 */
1533 mp->m_dalign = ap->sunit;
1534 mp->m_swidth = ap->swidth;
1535 }
1536
1537 if (ap->logbufs != -1 &&
1538 ap->logbufs != 0 &&
1539 (ap->logbufs < XLOG_MIN_ICLOGS ||
1540 ap->logbufs > XLOG_MAX_ICLOGS)) {
1541 cmn_err(CE_WARN,
1542 "XFS: invalid logbufs value: %d [not %d-%d]",
1543 ap->logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
1544 return XFS_ERROR(EINVAL);
1545 }
1546 mp->m_logbufs = ap->logbufs;
1547 if (ap->logbufsize != -1 &&
1548 ap->logbufsize != 0 &&
1549 (ap->logbufsize < XLOG_MIN_RECORD_BSIZE ||
1550 ap->logbufsize > XLOG_MAX_RECORD_BSIZE ||
1551 !is_power_of_2(ap->logbufsize))) {
1552 cmn_err(CE_WARN,
1553 "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
1554 ap->logbufsize);
1555 return XFS_ERROR(EINVAL);
1556 }
Christoph Hellwiga7381592008-08-13 16:04:05 +10001557
1558 error = ENOMEM;
1559
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001560 mp->m_logbsize = ap->logbufsize;
1561 mp->m_fsname_len = strlen(ap->fsname) + 1;
Christoph Hellwiga7381592008-08-13 16:04:05 +10001562
1563 mp->m_fsname = kstrdup(ap->fsname, GFP_KERNEL);
1564 if (!mp->m_fsname)
1565 goto out;
1566
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001567 if (ap->rtname[0]) {
Christoph Hellwiga7381592008-08-13 16:04:05 +10001568 mp->m_rtname = kstrdup(ap->rtname, GFP_KERNEL);
1569 if (!mp->m_rtname)
1570 goto out_free_fsname;
1571
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001572 }
Christoph Hellwiga7381592008-08-13 16:04:05 +10001573
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001574 if (ap->logname[0]) {
Christoph Hellwiga7381592008-08-13 16:04:05 +10001575 mp->m_logname = kstrdup(ap->logname, GFP_KERNEL);
1576 if (!mp->m_logname)
1577 goto out_free_rtname;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001578 }
1579
1580 if (ap->flags & XFSMNT_WSYNC)
1581 mp->m_flags |= XFS_MOUNT_WSYNC;
1582#if XFS_BIG_INUMS
1583 if (ap->flags & XFSMNT_INO64) {
1584 mp->m_flags |= XFS_MOUNT_INO64;
1585 mp->m_inoadd = XFS_INO64_OFFSET;
1586 }
1587#endif
1588 if (ap->flags & XFSMNT_RETERR)
1589 mp->m_flags |= XFS_MOUNT_RETERR;
1590 if (ap->flags & XFSMNT_NOALIGN)
1591 mp->m_flags |= XFS_MOUNT_NOALIGN;
1592 if (ap->flags & XFSMNT_SWALLOC)
1593 mp->m_flags |= XFS_MOUNT_SWALLOC;
1594 if (ap->flags & XFSMNT_OSYNCISOSYNC)
1595 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
1596 if (ap->flags & XFSMNT_32BITINODES)
1597 mp->m_flags |= XFS_MOUNT_32BITINODES;
1598
1599 if (ap->flags & XFSMNT_IOSIZE) {
1600 if (ap->iosizelog > XFS_MAX_IO_LOG ||
1601 ap->iosizelog < XFS_MIN_IO_LOG) {
1602 cmn_err(CE_WARN,
1603 "XFS: invalid log iosize: %d [not %d-%d]",
1604 ap->iosizelog, XFS_MIN_IO_LOG,
1605 XFS_MAX_IO_LOG);
1606 return XFS_ERROR(EINVAL);
1607 }
1608
1609 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
1610 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
1611 }
1612
1613 if (ap->flags & XFSMNT_IKEEP)
1614 mp->m_flags |= XFS_MOUNT_IKEEP;
1615 if (ap->flags & XFSMNT_DIRSYNC)
1616 mp->m_flags |= XFS_MOUNT_DIRSYNC;
1617 if (ap->flags & XFSMNT_ATTR2)
1618 mp->m_flags |= XFS_MOUNT_ATTR2;
1619 if (ap->flags & XFSMNT_NOATTR2)
1620 mp->m_flags |= XFS_MOUNT_NOATTR2;
1621
1622 if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
1623 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
1624
1625 /*
1626 * no recovery flag requires a read-only mount
1627 */
1628 if (ap->flags & XFSMNT_NORECOVERY) {
1629 if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
1630 cmn_err(CE_WARN,
1631 "XFS: tried to mount a FS read-write without recovery!");
1632 return XFS_ERROR(EINVAL);
1633 }
1634 mp->m_flags |= XFS_MOUNT_NORECOVERY;
1635 }
1636
1637 if (ap->flags & XFSMNT_NOUUID)
1638 mp->m_flags |= XFS_MOUNT_NOUUID;
1639 if (ap->flags & XFSMNT_BARRIER)
1640 mp->m_flags |= XFS_MOUNT_BARRIER;
1641 else
1642 mp->m_flags &= ~XFS_MOUNT_BARRIER;
1643
1644 if (ap->flags2 & XFSMNT2_FILESTREAMS)
1645 mp->m_flags |= XFS_MOUNT_FILESTREAMS;
1646
1647 if (ap->flags & XFSMNT_DMAPI)
1648 mp->m_flags |= XFS_MOUNT_DMAPI;
1649 return 0;
Christoph Hellwiga7381592008-08-13 16:04:05 +10001650
1651
1652 out_free_rtname:
1653 kfree(mp->m_rtname);
1654 out_free_fsname:
1655 kfree(mp->m_fsname);
1656 out:
1657 return error;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001658}
1659
1660/*
1661 * This function fills in xfs_mount_t fields based on mount args.
1662 * Note: the superblock _has_ now been read in.
1663 */
1664STATIC int
1665xfs_finish_flags(
1666 struct xfs_mount_args *ap,
1667 struct xfs_mount *mp)
1668{
1669 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
1670
1671 /* Fail a mount where the logbuf is smaller then the log stripe */
1672 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
1673 if ((ap->logbufsize <= 0) &&
1674 (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) {
1675 mp->m_logbsize = mp->m_sb.sb_logsunit;
1676 } else if (ap->logbufsize > 0 &&
1677 ap->logbufsize < mp->m_sb.sb_logsunit) {
1678 cmn_err(CE_WARN,
1679 "XFS: logbuf size must be greater than or equal to log stripe size");
1680 return XFS_ERROR(EINVAL);
1681 }
1682 } else {
1683 /* Fail a mount if the logbuf is larger than 32K */
1684 if (ap->logbufsize > XLOG_BIG_RECORD_BSIZE) {
1685 cmn_err(CE_WARN,
1686 "XFS: logbuf size for version 1 logs must be 16K or 32K");
1687 return XFS_ERROR(EINVAL);
1688 }
1689 }
1690
1691 /*
1692 * mkfs'ed attr2 will turn on attr2 mount unless explicitly
1693 * told by noattr2 to turn it off
1694 */
1695 if (xfs_sb_version_hasattr2(&mp->m_sb) &&
1696 !(ap->flags & XFSMNT_NOATTR2))
1697 mp->m_flags |= XFS_MOUNT_ATTR2;
1698
1699 /*
1700 * prohibit r/w mounts of read-only filesystems
1701 */
1702 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
1703 cmn_err(CE_WARN,
1704 "XFS: cannot mount a read-only filesystem as read-write");
1705 return XFS_ERROR(EROFS);
1706 }
1707
1708 /*
1709 * check for shared mount.
1710 */
1711 if (ap->flags & XFSMNT_SHARED) {
1712 if (!xfs_sb_version_hasshared(&mp->m_sb))
1713 return XFS_ERROR(EINVAL);
1714
1715 /*
1716 * For IRIX 6.5, shared mounts must have the shared
1717 * version bit set, have the persistent readonly
1718 * field set, must be version 0 and can only be mounted
1719 * read-only.
1720 */
1721 if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
1722 (mp->m_sb.sb_shared_vn != 0))
1723 return XFS_ERROR(EINVAL);
1724
1725 mp->m_flags |= XFS_MOUNT_SHARED;
1726
1727 /*
1728 * Shared XFS V0 can't deal with DMI. Return EINVAL.
1729 */
1730 if (mp->m_sb.sb_shared_vn == 0 && (ap->flags & XFSMNT_DMAPI))
1731 return XFS_ERROR(EINVAL);
1732 }
1733
1734 if (ap->flags & XFSMNT_UQUOTA) {
1735 mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
1736 if (ap->flags & XFSMNT_UQUOTAENF)
1737 mp->m_qflags |= XFS_UQUOTA_ENFD;
1738 }
1739
1740 if (ap->flags & XFSMNT_GQUOTA) {
1741 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
1742 if (ap->flags & XFSMNT_GQUOTAENF)
1743 mp->m_qflags |= XFS_OQUOTA_ENFD;
1744 } else if (ap->flags & XFSMNT_PQUOTA) {
1745 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
1746 if (ap->flags & XFSMNT_PQUOTAENF)
1747 mp->m_qflags |= XFS_OQUOTA_ENFD;
1748 }
1749
1750 return 0;
1751}
1752
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001754xfs_fs_fill_super(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 struct super_block *sb,
1756 void *data,
1757 int silent)
1758{
Christoph Hellwigf3dcc132008-03-27 18:00:54 +11001759 struct inode *root;
Christoph Hellwig745f6912007-08-30 17:20:39 +10001760 struct xfs_mount *mp = NULL;
Christoph Hellwigbdd907b2008-05-20 15:10:44 +10001761 struct xfs_mount_args *args;
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001762 int flags = 0, error = ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763
Christoph Hellwigbdd907b2008-05-20 15:10:44 +10001764 args = xfs_args_allocate(sb, silent);
1765 if (!args)
1766 return -ENOMEM;
1767
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001768 mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
1769 if (!mp)
1770 goto out_free_args;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001772 spin_lock_init(&mp->m_sb_lock);
1773 mutex_init(&mp->m_ilock);
1774 mutex_init(&mp->m_growlock);
1775 atomic_set(&mp->m_active_trans, 0);
Christoph Hellwig74394492007-08-30 17:21:22 +10001776 INIT_LIST_HEAD(&mp->m_sync_list);
1777 spin_lock_init(&mp->m_sync_lock);
1778 init_waitqueue_head(&mp->m_wait_single_sync_task);
1779
Christoph Hellwigb267ce92007-08-30 17:21:30 +10001780 mp->m_super = sb;
1781 sb->s_fs_info = mp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782
Christoph Hellwigbd186aa2007-08-30 17:21:12 +10001783 if (sb->s_flags & MS_RDONLY)
1784 mp->m_flags |= XFS_MOUNT_RDONLY;
1785
Christoph Hellwig745f6912007-08-30 17:20:39 +10001786 error = xfs_parseargs(mp, (char *)data, args, 0);
1787 if (error)
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001788 goto out_free_mp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001789
1790 sb_min_blocksize(sb, BBSIZE);
Lachlan McIlroy0ec58512008-06-23 13:23:01 +10001791 sb->s_xattr = xfs_xattr_handlers;
Nathan Scotta50cd262006-03-14 14:06:18 +11001792 sb->s_export_op = &xfs_export_operations;
Nathan Scotta50cd262006-03-14 14:06:18 +11001793 sb->s_qcop = &xfs_quotactl_operations;
1794 sb->s_op = &xfs_super_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001796 error = xfs_dmops_get(mp, args);
Christoph Hellwig745f6912007-08-30 17:20:39 +10001797 if (error)
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001798 goto out_free_mp;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001799 error = xfs_qmops_get(mp, args);
1800 if (error)
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001801 goto out_put_dmops;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001802
1803 if (args->flags & XFSMNT_QUIET)
1804 flags |= XFS_MFSI_QUIET;
1805
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001806 error = xfs_open_devices(mp, args);
1807 if (error)
1808 goto out_put_qmops;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001809
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001810 if (xfs_icsb_init_counters(mp))
1811 mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB;
1812
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001813 /*
1814 * Setup flags based on mount(2) options and then the superblock
1815 */
1816 error = xfs_start_flags(args, mp);
1817 if (error)
Christoph Hellwiga7381592008-08-13 16:04:05 +10001818 goto out_free_fsname;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001819 error = xfs_readsb(mp, flags);
1820 if (error)
Christoph Hellwiga7381592008-08-13 16:04:05 +10001821 goto out_free_fsname;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001822 error = xfs_finish_flags(args, mp);
1823 if (error)
Christoph Hellwigeffa2ed2008-05-20 15:11:05 +10001824 goto out_free_sb;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001825
Christoph Hellwige34b5622008-05-20 15:10:36 +10001826 error = xfs_setup_devices(mp);
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001827 if (error)
Christoph Hellwigeffa2ed2008-05-20 15:11:05 +10001828 goto out_free_sb;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001829
1830 if (mp->m_flags & XFS_MOUNT_BARRIER)
1831 xfs_mountfs_check_barriers(mp);
1832
1833 error = xfs_filestream_mount(mp);
1834 if (error)
Christoph Hellwigeffa2ed2008-05-20 15:11:05 +10001835 goto out_free_sb;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001836
1837 error = xfs_mountfs(mp, flags);
1838 if (error)
Christoph Hellwig120226c2008-05-20 15:11:11 +10001839 goto out_filestream_unmount;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001840
1841 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, args->mtpt, args->fsname);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 sb->s_dirt = 1;
Christoph Hellwig4ca488e2007-10-11 18:09:40 +10001844 sb->s_magic = XFS_SB_MAGIC;
1845 sb->s_blocksize = mp->m_sb.sb_blocksize;
1846 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
1848 sb->s_time_gran = 1;
1849 set_posix_acl_flag(sb);
1850
David Chinner01651642008-08-13 15:45:15 +10001851 root = igrab(VFS_I(mp->m_rootip));
Christoph Hellwigf3dcc132008-03-27 18:00:54 +11001852 if (!root) {
Christoph Hellwigcbc89dc2008-02-05 12:14:01 +11001853 error = ENOENT;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001854 goto fail_unmount;
Christoph Hellwigcbc89dc2008-02-05 12:14:01 +11001855 }
Christoph Hellwigf3dcc132008-03-27 18:00:54 +11001856 if (is_bad_inode(root)) {
1857 error = EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001858 goto fail_vnrele;
1859 }
Christoph Hellwigf3dcc132008-03-27 18:00:54 +11001860 sb->s_root = d_alloc_root(root);
1861 if (!sb->s_root) {
1862 error = ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 goto fail_vnrele;
1864 }
Christoph Hellwig74394492007-08-30 17:21:22 +10001865
1866 mp->m_sync_work.w_syncer = xfs_sync_worker;
1867 mp->m_sync_work.w_mount = mp;
1868 mp->m_sync_task = kthread_run(xfssyncd, mp, "xfssyncd");
1869 if (IS_ERR(mp->m_sync_task)) {
1870 error = -PTR_ERR(mp->m_sync_task);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871 goto fail_vnrele;
Christoph Hellwig74394492007-08-30 17:21:22 +10001872 }
1873
Lachlan McIlroycf441ee2008-02-07 16:42:19 +11001874 xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875
Christoph Hellwigbdd907b2008-05-20 15:10:44 +10001876 kfree(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 return 0;
1878
Christoph Hellwig120226c2008-05-20 15:11:11 +10001879 out_filestream_unmount:
1880 xfs_filestream_unmount(mp);
Christoph Hellwigeffa2ed2008-05-20 15:11:05 +10001881 out_free_sb:
1882 xfs_freesb(mp);
Christoph Hellwiga7381592008-08-13 16:04:05 +10001883 out_free_fsname:
1884 xfs_free_fsname(mp);
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001885 xfs_icsb_destroy_counters(mp);
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001886 xfs_close_devices(mp);
1887 out_put_qmops:
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001888 xfs_qmops_put(mp);
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001889 out_put_dmops:
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001890 xfs_dmops_put(mp);
Christoph Hellwigc962fb72008-05-20 15:10:52 +10001891 out_free_mp:
1892 kfree(mp);
1893 out_free_args:
1894 kfree(args);
1895 return -error;
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001896
1897 fail_vnrele:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898 if (sb->s_root) {
1899 dput(sb->s_root);
1900 sb->s_root = NULL;
1901 } else {
Christoph Hellwigf3dcc132008-03-27 18:00:54 +11001902 iput(root);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903 }
1904
Christoph Hellwigf8f15e42008-05-20 11:30:59 +10001905 fail_unmount:
Christoph Hellwige48ad312008-05-20 11:30:52 +10001906 /*
1907 * Blow away any referenced inode in the filestreams cache.
1908 * This can and will cause log traffic as inodes go inactive
1909 * here.
1910 */
1911 xfs_filestream_unmount(mp);
1912
1913 XFS_bflush(mp->m_ddev_targp);
1914 error = xfs_unmount_flush(mp, 0);
1915 WARN_ON(error);
1916
1917 IRELE(mp->m_rootip);
1918
Christoph Hellwig19f354d2008-05-20 11:31:13 +10001919 xfs_unmountfs(mp);
Christoph Hellwiga7381592008-08-13 16:04:05 +10001920 goto out_free_fsname;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921}
1922
David Howells454e2392006-06-23 02:02:57 -07001923STATIC int
Nathan Scotta50cd262006-03-14 14:06:18 +11001924xfs_fs_get_sb(
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 struct file_system_type *fs_type,
1926 int flags,
1927 const char *dev_name,
David Howells454e2392006-06-23 02:02:57 -07001928 void *data,
1929 struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930{
David Howells454e2392006-06-23 02:02:57 -07001931 return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super,
1932 mnt);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933}
1934
David Chinner7989cb82007-02-10 18:34:56 +11001935static struct super_operations xfs_super_operations = {
Nathan Scotta50cd262006-03-14 14:06:18 +11001936 .alloc_inode = xfs_fs_alloc_inode,
1937 .destroy_inode = xfs_fs_destroy_inode,
1938 .write_inode = xfs_fs_write_inode,
1939 .clear_inode = xfs_fs_clear_inode,
1940 .put_super = xfs_fs_put_super,
1941 .write_super = xfs_fs_write_super,
1942 .sync_fs = xfs_fs_sync_super,
1943 .write_super_lockfs = xfs_fs_lockfs,
1944 .statfs = xfs_fs_statfs,
1945 .remount_fs = xfs_fs_remount,
1946 .show_options = xfs_fs_show_options,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947};
1948
David Chinner7989cb82007-02-10 18:34:56 +11001949static struct quotactl_ops xfs_quotactl_operations = {
Nathan Scotta50cd262006-03-14 14:06:18 +11001950 .quota_sync = xfs_fs_quotasync,
1951 .get_xstate = xfs_fs_getxstate,
1952 .set_xstate = xfs_fs_setxstate,
1953 .get_xquota = xfs_fs_getxquota,
1954 .set_xquota = xfs_fs_setxquota,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001955};
1956
Andrew Morton5085b602007-02-20 13:57:47 -08001957static struct file_system_type xfs_fs_type = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 .owner = THIS_MODULE,
1959 .name = "xfs",
Nathan Scotta50cd262006-03-14 14:06:18 +11001960 .get_sb = xfs_fs_get_sb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 .kill_sb = kill_block_super,
1962 .fs_flags = FS_REQUIRES_DEV,
1963};
1964
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10001965STATIC int __init
1966xfs_alloc_trace_bufs(void)
1967{
1968#ifdef XFS_ALLOC_TRACE
1969 xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL);
1970 if (!xfs_alloc_trace_buf)
1971 goto out;
1972#endif
1973#ifdef XFS_BMAP_TRACE
1974 xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL);
1975 if (!xfs_bmap_trace_buf)
1976 goto out_free_alloc_trace;
1977#endif
1978#ifdef XFS_BMBT_TRACE
1979 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
1980 if (!xfs_bmbt_trace_buf)
1981 goto out_free_bmap_trace;
1982#endif
1983#ifdef XFS_ATTR_TRACE
1984 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
1985 if (!xfs_attr_trace_buf)
1986 goto out_free_bmbt_trace;
1987#endif
1988#ifdef XFS_DIR2_TRACE
1989 xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL);
1990 if (!xfs_dir2_trace_buf)
1991 goto out_free_attr_trace;
1992#endif
1993
1994 return 0;
1995
1996#ifdef XFS_DIR2_TRACE
1997 out_free_attr_trace:
1998#endif
1999#ifdef XFS_ATTR_TRACE
2000 ktrace_free(xfs_attr_trace_buf);
2001 out_free_bmbt_trace:
2002#endif
2003#ifdef XFS_BMBT_TRACE
2004 ktrace_free(xfs_bmbt_trace_buf);
2005 out_free_bmap_trace:
2006#endif
2007#ifdef XFS_BMAP_TRACE
2008 ktrace_free(xfs_bmap_trace_buf);
2009 out_free_alloc_trace:
2010#endif
2011#ifdef XFS_ALLOC_TRACE
2012 ktrace_free(xfs_alloc_trace_buf);
2013 out:
2014#endif
2015 return -ENOMEM;
2016}
2017
2018STATIC void
2019xfs_free_trace_bufs(void)
2020{
2021#ifdef XFS_DIR2_TRACE
2022 ktrace_free(xfs_dir2_trace_buf);
2023#endif
2024#ifdef XFS_ATTR_TRACE
2025 ktrace_free(xfs_attr_trace_buf);
2026#endif
2027#ifdef XFS_BMBT_TRACE
2028 ktrace_free(xfs_bmbt_trace_buf);
2029#endif
2030#ifdef XFS_BMAP_TRACE
2031 ktrace_free(xfs_bmap_trace_buf);
2032#endif
2033#ifdef XFS_ALLOC_TRACE
2034 ktrace_free(xfs_alloc_trace_buf);
2035#endif
2036}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002037
2038STATIC int __init
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002039xfs_init_zones(void)
2040{
2041 xfs_vnode_zone = kmem_zone_init_flags(sizeof(bhv_vnode_t), "xfs_vnode",
2042 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
2043 KM_ZONE_SPREAD,
2044 xfs_fs_inode_init_once);
2045 if (!xfs_vnode_zone)
2046 goto out;
2047
2048 xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
2049 if (!xfs_ioend_zone)
2050 goto out_destroy_vnode_zone;
2051
2052 xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
2053 xfs_ioend_zone);
2054 if (!xfs_ioend_pool)
2055 goto out_destroy_ioend_zone;
2056
2057 xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
2058 "xfs_log_ticket");
2059 if (!xfs_log_ticket_zone)
2060 goto out_destroy_ioend_pool;
2061
2062 xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
2063 "xfs_bmap_free_item");
2064 if (!xfs_bmap_free_item_zone)
2065 goto out_destroy_log_ticket_zone;
2066 xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
2067 "xfs_btree_cur");
2068 if (!xfs_btree_cur_zone)
2069 goto out_destroy_bmap_free_item_zone;
2070
2071 xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
2072 "xfs_da_state");
2073 if (!xfs_da_state_zone)
2074 goto out_destroy_btree_cur_zone;
2075
2076 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
2077 if (!xfs_dabuf_zone)
2078 goto out_destroy_da_state_zone;
2079
2080 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
2081 if (!xfs_ifork_zone)
2082 goto out_destroy_dabuf_zone;
2083
2084 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
2085 if (!xfs_trans_zone)
2086 goto out_destroy_ifork_zone;
2087
2088 /*
2089 * The size of the zone allocated buf log item is the maximum
2090 * size possible under XFS. This wastes a little bit of memory,
2091 * but it is much faster.
2092 */
2093 xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) +
2094 (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
2095 NBWORD) * sizeof(int))), "xfs_buf_item");
2096 if (!xfs_buf_item_zone)
2097 goto out_destroy_trans_zone;
2098
2099 xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
2100 ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
2101 sizeof(xfs_extent_t))), "xfs_efd_item");
2102 if (!xfs_efd_zone)
2103 goto out_destroy_buf_item_zone;
2104
2105 xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
2106 ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
2107 sizeof(xfs_extent_t))), "xfs_efi_item");
2108 if (!xfs_efi_zone)
2109 goto out_destroy_efd_zone;
2110
2111 xfs_inode_zone =
2112 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
2113 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
2114 KM_ZONE_SPREAD, NULL);
2115 if (!xfs_inode_zone)
2116 goto out_destroy_efi_zone;
2117
2118 xfs_ili_zone =
2119 kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
2120 KM_ZONE_SPREAD, NULL);
2121 if (!xfs_ili_zone)
2122 goto out_destroy_inode_zone;
2123
2124#ifdef CONFIG_XFS_POSIX_ACL
2125 xfs_acl_zone = kmem_zone_init(sizeof(xfs_acl_t), "xfs_acl");
2126 if (!xfs_acl_zone)
2127 goto out_destroy_ili_zone;
2128#endif
2129
2130 return 0;
2131
2132#ifdef CONFIG_XFS_POSIX_ACL
2133 out_destroy_ili_zone:
2134#endif
2135 kmem_zone_destroy(xfs_ili_zone);
2136 out_destroy_inode_zone:
2137 kmem_zone_destroy(xfs_inode_zone);
2138 out_destroy_efi_zone:
2139 kmem_zone_destroy(xfs_efi_zone);
2140 out_destroy_efd_zone:
2141 kmem_zone_destroy(xfs_efd_zone);
2142 out_destroy_buf_item_zone:
2143 kmem_zone_destroy(xfs_buf_item_zone);
2144 out_destroy_trans_zone:
2145 kmem_zone_destroy(xfs_trans_zone);
2146 out_destroy_ifork_zone:
2147 kmem_zone_destroy(xfs_ifork_zone);
2148 out_destroy_dabuf_zone:
2149 kmem_zone_destroy(xfs_dabuf_zone);
2150 out_destroy_da_state_zone:
2151 kmem_zone_destroy(xfs_da_state_zone);
2152 out_destroy_btree_cur_zone:
2153 kmem_zone_destroy(xfs_btree_cur_zone);
2154 out_destroy_bmap_free_item_zone:
2155 kmem_zone_destroy(xfs_bmap_free_item_zone);
2156 out_destroy_log_ticket_zone:
2157 kmem_zone_destroy(xfs_log_ticket_zone);
2158 out_destroy_ioend_pool:
2159 mempool_destroy(xfs_ioend_pool);
2160 out_destroy_ioend_zone:
2161 kmem_zone_destroy(xfs_ioend_zone);
2162 out_destroy_vnode_zone:
2163 kmem_zone_destroy(xfs_vnode_zone);
2164 out:
2165 return -ENOMEM;
2166}
2167
2168STATIC void
2169xfs_destroy_zones(void)
2170{
2171#ifdef CONFIG_XFS_POSIX_ACL
2172 kmem_zone_destroy(xfs_acl_zone);
2173#endif
2174 kmem_zone_destroy(xfs_ili_zone);
2175 kmem_zone_destroy(xfs_inode_zone);
2176 kmem_zone_destroy(xfs_efi_zone);
2177 kmem_zone_destroy(xfs_efd_zone);
2178 kmem_zone_destroy(xfs_buf_item_zone);
2179 kmem_zone_destroy(xfs_trans_zone);
2180 kmem_zone_destroy(xfs_ifork_zone);
2181 kmem_zone_destroy(xfs_dabuf_zone);
2182 kmem_zone_destroy(xfs_da_state_zone);
2183 kmem_zone_destroy(xfs_btree_cur_zone);
2184 kmem_zone_destroy(xfs_bmap_free_item_zone);
2185 kmem_zone_destroy(xfs_log_ticket_zone);
2186 mempool_destroy(xfs_ioend_pool);
2187 kmem_zone_destroy(xfs_ioend_zone);
2188 kmem_zone_destroy(xfs_vnode_zone);
2189
2190}
2191
2192STATIC int __init
2193init_xfs_fs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194{
2195 int error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 static char message[] __initdata = KERN_INFO \
2197 XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
2198
2199 printk(message);
2200
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 ktrace_init(64);
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002202 vn_init();
2203 xfs_dir_startup();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204
Nathan Scott87582802006-03-14 13:18:19 +11002205 error = xfs_init_zones();
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002206 if (error)
2207 goto out;
2208
2209 error = xfs_alloc_trace_bufs();
2210 if (error)
2211 goto out_destroy_zones;
2212
2213 error = xfs_mru_cache_init();
2214 if (error)
2215 goto out_free_trace_buffers;
2216
2217 error = xfs_filestream_init();
2218 if (error)
2219 goto out_mru_cache_uninit;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220
Nathan Scottce8e9222006-01-11 15:39:08 +11002221 error = xfs_buf_init();
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002222 if (error)
2223 goto out_filestream_uninit;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002225 error = xfs_init_procfs();
2226 if (error)
2227 goto out_buf_terminate;
2228
2229 error = xfs_sysctl_register();
2230 if (error)
2231 goto out_cleanup_procfs;
2232
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 vfs_initquota();
2234
2235 error = register_filesystem(&xfs_fs_type);
2236 if (error)
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002237 goto out_sysctl_unregister;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 return 0;
2239
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002240 out_sysctl_unregister:
2241 xfs_sysctl_unregister();
2242 out_cleanup_procfs:
2243 xfs_cleanup_procfs();
2244 out_buf_terminate:
Nathan Scottce8e9222006-01-11 15:39:08 +11002245 xfs_buf_terminate();
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002246 out_filestream_uninit:
2247 xfs_filestream_uninit();
2248 out_mru_cache_uninit:
2249 xfs_mru_cache_uninit();
2250 out_free_trace_buffers:
2251 xfs_free_trace_bufs();
2252 out_destroy_zones:
Nathan Scott87582802006-03-14 13:18:19 +11002253 xfs_destroy_zones();
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002254 out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 return error;
2256}
2257
2258STATIC void __exit
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002259exit_xfs_fs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260{
2261 vfs_exitquota();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 unregister_filesystem(&xfs_fs_type);
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002263 xfs_sysctl_unregister();
2264 xfs_cleanup_procfs();
Nathan Scottce8e9222006-01-11 15:39:08 +11002265 xfs_buf_terminate();
Christoph Hellwig9f8868f2008-07-18 17:11:46 +10002266 xfs_filestream_uninit();
2267 xfs_mru_cache_uninit();
2268 xfs_free_trace_bufs();
Nathan Scott87582802006-03-14 13:18:19 +11002269 xfs_destroy_zones();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 ktrace_uninit();
2271}
2272
2273module_init(init_xfs_fs);
2274module_exit(exit_xfs_fs);
2275
2276MODULE_AUTHOR("Silicon Graphics, Inc.");
2277MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
2278MODULE_LICENSE("GPL");