2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
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
7 * published by the Free Software Foundation.
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.
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
22 #include "xfs_trans.h"
26 #include "xfs_alloc.h"
27 #include "xfs_dmapi.h"
28 #include "xfs_quota.h"
29 #include "xfs_mount.h"
30 #include "xfs_bmap_btree.h"
31 #include "xfs_alloc_btree.h"
32 #include "xfs_ialloc_btree.h"
33 #include "xfs_dir2_sf.h"
34 #include "xfs_attr_sf.h"
35 #include "xfs_dinode.h"
36 #include "xfs_inode.h"
37 #include "xfs_btree.h"
38 #include "xfs_btree_trace.h"
39 #include "xfs_ialloc.h"
41 #include "xfs_rtalloc.h"
42 #include "xfs_error.h"
43 #include "xfs_itable.h"
44 #include "xfs_fsops.h"
48 #include "xfs_buf_item.h"
49 #include "xfs_utils.h"
50 #include "xfs_vnodeops.h"
51 #include "xfs_version.h"
52 #include "xfs_log_priv.h"
53 #include "xfs_trans_priv.h"
54 #include "xfs_filestream.h"
55 #include "xfs_da_btree.h"
56 #include "xfs_dir2_trace.h"
57 #include "xfs_extfree_item.h"
58 #include "xfs_mru_cache.h"
59 #include "xfs_inode_item.h"
62 #include <linux/namei.h>
63 #include <linux/init.h>
64 #include <linux/mount.h>
65 #include <linux/mempool.h>
66 #include <linux/writeback.h>
67 #include <linux/kthread.h>
68 #include <linux/freezer.h>
69 #include <linux/parser.h>
71 static struct quotactl_ops xfs_quotactl_operations;
72 static struct super_operations xfs_super_operations;
73 static kmem_zone_t *xfs_ioend_zone;
74 mempool_t *xfs_ioend_pool;
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 */
82 #define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */
83 #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
84 #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
85 #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
86 #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
87 #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
88 #define MNTOPT_MTPT "mtpt" /* filesystem mount point */
89 #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
90 #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
91 #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
92 #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
93 #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
94 #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
95 #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
96 * unwritten extent conversion */
97 #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
98 #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
99 #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
100 #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
101 #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
102 #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
103 #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
105 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
106 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
107 #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
108 #define MNTOPT_QUOTA "quota" /* disk quotas (user) */
109 #define MNTOPT_NOQUOTA "noquota" /* no quotas */
110 #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
111 #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
112 #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
113 #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
114 #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
115 #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
116 #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
117 #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
118 #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
119 #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
120 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
121 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
122 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
125 * Table driven mount option parser.
127 * Currently only used for remount, but it will be used for mount
128 * in the future, too.
131 Opt_barrier, Opt_nobarrier, Opt_err
134 static const match_table_t tokens = {
135 {Opt_barrier, "barrier"},
136 {Opt_nobarrier, "nobarrier"},
142 suffix_strtoul(char *s, char **endp, unsigned int base)
144 int last, shift_left_factor = 0;
147 last = strlen(value) - 1;
148 if (value[last] == 'K' || value[last] == 'k') {
149 shift_left_factor = 10;
152 if (value[last] == 'M' || value[last] == 'm') {
153 shift_left_factor = 20;
156 if (value[last] == 'G' || value[last] == 'g') {
157 shift_left_factor = 30;
161 return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
165 * This function fills in xfs_mount_t fields based on mount args.
166 * Note: the superblock has _not_ yet been read in.
168 * Note that this function leaks the various device name allocations on
169 * failure. The caller takes care of them.
173 struct xfs_mount *mp,
177 struct super_block *sb = mp->m_super;
178 char *this_char, *value, *eov;
182 int dmapi_implies_ikeep = 1;
183 uchar_t iosizelog = 0;
186 * Copy binary VFS mount flags we are interested in.
188 if (sb->s_flags & MS_RDONLY)
189 mp->m_flags |= XFS_MOUNT_RDONLY;
190 if (sb->s_flags & MS_DIRSYNC)
191 mp->m_flags |= XFS_MOUNT_DIRSYNC;
192 if (sb->s_flags & MS_SYNCHRONOUS)
193 mp->m_flags |= XFS_MOUNT_WSYNC;
196 * Set some default flags that could be cleared by the mount option
199 mp->m_flags |= XFS_MOUNT_BARRIER;
200 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
201 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
204 * These can be overridden by the mount option parsing.
212 while ((this_char = strsep(&options, ",")) != NULL) {
215 if ((value = strchr(this_char, '=')) != NULL)
218 if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
219 if (!value || !*value) {
221 "XFS: %s option requires an argument",
225 mp->m_logbufs = simple_strtoul(value, &eov, 10);
226 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
227 if (!value || !*value) {
229 "XFS: %s option requires an argument",
233 mp->m_logbsize = suffix_strtoul(value, &eov, 10);
234 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
235 if (!value || !*value) {
237 "XFS: %s option requires an argument",
241 mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
244 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
245 if (!value || !*value) {
247 "XFS: %s option requires an argument",
251 *mtpt = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
254 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
255 if (!value || !*value) {
257 "XFS: %s option requires an argument",
261 mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
264 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
265 if (!value || !*value) {
267 "XFS: %s option requires an argument",
271 iosize = simple_strtoul(value, &eov, 10);
272 iosizelog = ffs(iosize) - 1;
273 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
274 if (!value || !*value) {
276 "XFS: %s option requires an argument",
280 iosize = suffix_strtoul(value, &eov, 10);
281 iosizelog = ffs(iosize) - 1;
282 } else if (!strcmp(this_char, MNTOPT_GRPID) ||
283 !strcmp(this_char, MNTOPT_BSDGROUPS)) {
284 mp->m_flags |= XFS_MOUNT_GRPID;
285 } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
286 !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
287 mp->m_flags &= ~XFS_MOUNT_GRPID;
288 } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
289 mp->m_flags |= XFS_MOUNT_WSYNC;
290 } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) {
291 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
292 } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
293 mp->m_flags |= XFS_MOUNT_NORECOVERY;
294 } else if (!strcmp(this_char, MNTOPT_INO64)) {
296 mp->m_flags |= XFS_MOUNT_INO64;
297 mp->m_inoadd = XFS_INO64_OFFSET;
300 "XFS: %s option not allowed on this system",
304 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
305 mp->m_flags |= XFS_MOUNT_NOALIGN;
306 } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
307 mp->m_flags |= XFS_MOUNT_SWALLOC;
308 } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
309 if (!value || !*value) {
311 "XFS: %s option requires an argument",
315 dsunit = simple_strtoul(value, &eov, 10);
316 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
317 if (!value || !*value) {
319 "XFS: %s option requires an argument",
323 dswidth = simple_strtoul(value, &eov, 10);
324 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
325 mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
328 "XFS: %s option not allowed on this system",
332 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
333 mp->m_flags |= XFS_MOUNT_NOUUID;
334 } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
335 mp->m_flags |= XFS_MOUNT_BARRIER;
336 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
337 mp->m_flags &= ~XFS_MOUNT_BARRIER;
338 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
339 mp->m_flags |= XFS_MOUNT_IKEEP;
340 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
341 dmapi_implies_ikeep = 0;
342 mp->m_flags &= ~XFS_MOUNT_IKEEP;
343 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
344 mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
345 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
346 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
347 } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
348 mp->m_flags |= XFS_MOUNT_ATTR2;
349 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
350 mp->m_flags &= ~XFS_MOUNT_ATTR2;
351 mp->m_flags |= XFS_MOUNT_NOATTR2;
352 } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
353 mp->m_flags |= XFS_MOUNT_FILESTREAMS;
354 } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
355 mp->m_qflags &= ~(XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
356 XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
357 XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
358 XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD);
359 } else if (!strcmp(this_char, MNTOPT_QUOTA) ||
360 !strcmp(this_char, MNTOPT_UQUOTA) ||
361 !strcmp(this_char, MNTOPT_USRQUOTA)) {
362 mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
364 } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
365 !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
366 mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
367 mp->m_qflags &= ~XFS_UQUOTA_ENFD;
368 } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
369 !strcmp(this_char, MNTOPT_PRJQUOTA)) {
370 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
372 } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
373 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
374 mp->m_qflags &= ~XFS_OQUOTA_ENFD;
375 } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
376 !strcmp(this_char, MNTOPT_GRPQUOTA)) {
377 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
379 } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
380 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
381 mp->m_qflags &= ~XFS_OQUOTA_ENFD;
382 } else if (!strcmp(this_char, MNTOPT_DMAPI)) {
383 mp->m_flags |= XFS_MOUNT_DMAPI;
384 } else if (!strcmp(this_char, MNTOPT_XDSM)) {
385 mp->m_flags |= XFS_MOUNT_DMAPI;
386 } else if (!strcmp(this_char, MNTOPT_DMI)) {
387 mp->m_flags |= XFS_MOUNT_DMAPI;
388 } else if (!strcmp(this_char, "ihashsize")) {
390 "XFS: ihashsize no longer used, option is deprecated.");
391 } else if (!strcmp(this_char, "osyncisdsync")) {
392 /* no-op, this is now the default */
394 "XFS: osyncisdsync is now the default, option is deprecated.");
395 } else if (!strcmp(this_char, "irixsgid")) {
397 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
400 "XFS: unknown mount option [%s].", this_char);
406 * no recovery flag requires a read-only mount
408 if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
409 !(mp->m_flags & XFS_MOUNT_RDONLY)) {
410 cmn_err(CE_WARN, "XFS: no-recovery mounts must be read-only.");
414 if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
416 "XFS: sunit and swidth options incompatible with the noalign option");
420 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) &&
421 (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) {
423 "XFS: cannot mount with both project and group quota");
427 if ((mp->m_flags & XFS_MOUNT_DMAPI) && (!*mtpt || *mtpt[0] == '\0')) {
428 printk("XFS: %s option needs the mount point option as well\n",
433 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
435 "XFS: sunit and swidth must be specified together");
439 if (dsunit && (dswidth % dsunit != 0)) {
441 "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
447 * Applications using DMI filesystems often expect the
448 * inode generation number to be monotonically increasing.
449 * If we delete inode chunks we break this assumption, so
450 * keep unused inode chunks on disk for DMI filesystems
451 * until we come up with a better solution.
452 * Note that if "ikeep" or "noikeep" mount options are
453 * supplied, then they are honored.
455 if ((mp->m_flags & XFS_MOUNT_DMAPI) && dmapi_implies_ikeep)
456 mp->m_flags |= XFS_MOUNT_IKEEP;
459 if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) {
461 * At this point the superblock has not been read
462 * in, therefore we do not know the block size.
463 * Before the mount call ends we will convert
467 mp->m_dalign = dsunit;
468 mp->m_flags |= XFS_MOUNT_RETERR;
472 mp->m_swidth = dswidth;
475 if (mp->m_logbufs != -1 &&
476 mp->m_logbufs != 0 &&
477 (mp->m_logbufs < XLOG_MIN_ICLOGS ||
478 mp->m_logbufs > XLOG_MAX_ICLOGS)) {
480 "XFS: invalid logbufs value: %d [not %d-%d]",
481 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
482 return XFS_ERROR(EINVAL);
484 if (mp->m_logbsize != -1 &&
485 mp->m_logbsize != 0 &&
486 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
487 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
488 !is_power_of_2(mp->m_logbsize))) {
490 "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
492 return XFS_ERROR(EINVAL);
495 mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
498 mp->m_fsname_len = strlen(mp->m_fsname) + 1;
501 if (iosizelog > XFS_MAX_IO_LOG ||
502 iosizelog < XFS_MIN_IO_LOG) {
504 "XFS: invalid log iosize: %d [not %d-%d]",
505 iosizelog, XFS_MIN_IO_LOG,
507 return XFS_ERROR(EINVAL);
510 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
511 mp->m_readio_log = iosizelog;
512 mp->m_writeio_log = iosizelog;
518 struct proc_xfs_info {
525 struct xfs_mount *mp,
528 static struct proc_xfs_info xfs_info_set[] = {
529 /* the few simple ones we can get from the mount struct */
530 { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
531 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
532 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
533 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
534 { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
535 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
536 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
537 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
538 { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 },
539 { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
540 { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI },
541 { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
544 static struct proc_xfs_info xfs_info_unset[] = {
545 /* the few simple ones we can get from the mount struct */
546 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
547 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
548 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
551 struct proc_xfs_info *xfs_infop;
553 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
554 if (mp->m_flags & xfs_infop->flag)
555 seq_puts(m, xfs_infop->str);
557 for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
558 if (!(mp->m_flags & xfs_infop->flag))
559 seq_puts(m, xfs_infop->str);
562 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
563 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
564 (int)(1 << mp->m_writeio_log) >> 10);
566 if (mp->m_logbufs > 0)
567 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
568 if (mp->m_logbsize > 0)
569 seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
572 seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
574 seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
576 if (mp->m_dalign > 0)
577 seq_printf(m, "," MNTOPT_SUNIT "=%d",
578 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
579 if (mp->m_swidth > 0)
580 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
581 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
583 if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
584 seq_puts(m, "," MNTOPT_USRQUOTA);
585 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
586 seq_puts(m, "," MNTOPT_UQUOTANOENF);
588 if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
589 seq_puts(m, "," MNTOPT_PRJQUOTA);
590 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
591 seq_puts(m, "," MNTOPT_PQUOTANOENF);
593 if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
594 seq_puts(m, "," MNTOPT_GRPQUOTA);
595 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
596 seq_puts(m, "," MNTOPT_GQUOTANOENF);
598 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
599 seq_puts(m, "," MNTOPT_NOQUOTA);
605 unsigned int blockshift)
607 unsigned int pagefactor = 1;
608 unsigned int bitshift = BITS_PER_LONG - 1;
610 /* Figure out maximum filesize, on Linux this can depend on
611 * the filesystem blocksize (on 32 bit platforms).
612 * __block_prepare_write does this in an [unsigned] long...
613 * page->index << (PAGE_CACHE_SHIFT - bbits)
614 * So, for page sized blocks (4K on 32 bit platforms),
615 * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
616 * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
617 * but for smaller blocksizes it is less (bbits = log2 bsize).
618 * Note1: get_block_t takes a long (implicit cast from above)
619 * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
620 * can optionally convert the [unsigned] long from above into
621 * an [unsigned] long long.
624 #if BITS_PER_LONG == 32
625 # if defined(CONFIG_LBD)
626 ASSERT(sizeof(sector_t) == 8);
627 pagefactor = PAGE_CACHE_SIZE;
628 bitshift = BITS_PER_LONG;
630 pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
634 return (((__uint64_t)pagefactor) << bitshift) - 1;
641 struct block_device **bdevp)
645 *bdevp = open_bdev_exclusive(name, FMODE_READ|FMODE_WRITE, mp);
646 if (IS_ERR(*bdevp)) {
647 error = PTR_ERR(*bdevp);
648 printk("XFS: Invalid device [%s], error=%d\n", name, error);
656 struct block_device *bdev)
659 close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE);
663 * Try to write out the superblock using barriers.
669 xfs_buf_t *sbp = xfs_getsb(mp, 0);
674 XFS_BUF_UNDELAYWRITE(sbp);
676 XFS_BUF_UNASYNC(sbp);
677 XFS_BUF_ORDERED(sbp);
680 error = xfs_iowait(sbp);
683 * Clear all the flags we set and possible error state in the
684 * buffer. We only did the write to try out whether barriers
685 * worked and shouldn't leave any traces in the superblock
689 XFS_BUF_ERROR(sbp, 0);
690 XFS_BUF_UNORDERED(sbp);
697 xfs_mountfs_check_barriers(xfs_mount_t *mp)
701 if (mp->m_logdev_targp != mp->m_ddev_targp) {
702 xfs_fs_cmn_err(CE_NOTE, mp,
703 "Disabling barriers, not supported with external log device");
704 mp->m_flags &= ~XFS_MOUNT_BARRIER;
708 if (xfs_readonly_buftarg(mp->m_ddev_targp)) {
709 xfs_fs_cmn_err(CE_NOTE, mp,
710 "Disabling barriers, underlying device is readonly");
711 mp->m_flags &= ~XFS_MOUNT_BARRIER;
715 error = xfs_barrier_test(mp);
717 xfs_fs_cmn_err(CE_NOTE, mp,
718 "Disabling barriers, trial barrier write failed");
719 mp->m_flags &= ~XFS_MOUNT_BARRIER;
725 xfs_blkdev_issue_flush(
726 xfs_buftarg_t *buftarg)
728 blkdev_issue_flush(buftarg->bt_bdev, NULL);
733 struct xfs_mount *mp)
735 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
736 struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
737 xfs_free_buftarg(mp, mp->m_logdev_targp);
738 xfs_blkdev_put(logdev);
740 if (mp->m_rtdev_targp) {
741 struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
742 xfs_free_buftarg(mp, mp->m_rtdev_targp);
743 xfs_blkdev_put(rtdev);
745 xfs_free_buftarg(mp, mp->m_ddev_targp);
749 * The file system configurations are:
750 * (1) device (partition) with data and internal log
751 * (2) logical volume with data and log subvolumes.
752 * (3) logical volume with data, log, and realtime subvolumes.
754 * We only have to handle opening the log and realtime volumes here if
755 * they are present. The data subvolume has already been opened by
756 * get_sb_bdev() and is stored in sb->s_bdev.
760 struct xfs_mount *mp)
762 struct block_device *ddev = mp->m_super->s_bdev;
763 struct block_device *logdev = NULL, *rtdev = NULL;
767 * Open real time and log devices - order is important.
770 error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
776 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
778 goto out_close_logdev;
780 if (rtdev == ddev || rtdev == logdev) {
782 "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev.");
784 goto out_close_rtdev;
789 * Setup xfs_mount buffer target pointers
792 mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0);
793 if (!mp->m_ddev_targp)
794 goto out_close_rtdev;
797 mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1);
798 if (!mp->m_rtdev_targp)
799 goto out_free_ddev_targ;
802 if (logdev && logdev != ddev) {
803 mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1);
804 if (!mp->m_logdev_targp)
805 goto out_free_rtdev_targ;
807 mp->m_logdev_targp = mp->m_ddev_targp;
813 if (mp->m_rtdev_targp)
814 xfs_free_buftarg(mp, mp->m_rtdev_targp);
816 xfs_free_buftarg(mp, mp->m_ddev_targp);
819 xfs_blkdev_put(rtdev);
821 if (logdev && logdev != ddev)
822 xfs_blkdev_put(logdev);
828 * Setup xfs_mount buffer target pointers based on superblock
832 struct xfs_mount *mp)
836 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
837 mp->m_sb.sb_sectsize);
841 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
842 unsigned int log_sector_size = BBSIZE;
844 if (xfs_sb_version_hassector(&mp->m_sb))
845 log_sector_size = mp->m_sb.sb_logsectsize;
846 error = xfs_setsize_buftarg(mp->m_logdev_targp,
847 mp->m_sb.sb_blocksize,
852 if (mp->m_rtdev_targp) {
853 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
854 mp->m_sb.sb_blocksize,
855 mp->m_sb.sb_sectsize);
864 * XFS AIL push thread support
868 struct xfs_ail *ailp,
869 xfs_lsn_t threshold_lsn)
871 ailp->xa_target = threshold_lsn;
872 wake_up_process(ailp->xa_task);
879 struct xfs_ail *ailp = data;
880 xfs_lsn_t last_pushed_lsn = 0;
883 while (!kthread_should_stop()) {
885 schedule_timeout_interruptible(msecs_to_jiffies(tout));
891 ASSERT(ailp->xa_mount->m_log);
892 if (XFS_FORCED_SHUTDOWN(ailp->xa_mount))
895 tout = xfsaild_push(ailp, &last_pushed_lsn);
903 struct xfs_ail *ailp)
906 ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild");
907 if (IS_ERR(ailp->xa_task))
908 return -PTR_ERR(ailp->xa_task);
914 struct xfs_ail *ailp)
916 kthread_stop(ailp->xa_task);
920 /* Catch misguided souls that try to use this interface on XFS */
921 STATIC struct inode *
923 struct super_block *sb)
930 * Now that the generic code is guaranteed not to be accessing
931 * the linux inode, we can reclaim the inode.
934 xfs_fs_destroy_inode(
937 xfs_inode_t *ip = XFS_I(inode);
939 XFS_STATS_INC(vn_reclaim);
941 panic("%s: cannot reclaim 0x%p\n", __func__, inode);
945 * Slab object creation initialisation for the XFS inode.
946 * This covers only the idempotent fields in the XFS inode;
947 * all other fields need to be initialised on allocation
948 * from the slab. This avoids the need to repeatedly intialise
949 * fields in the xfs inode that left in the initialise state
950 * when freeing the inode.
953 xfs_fs_inode_init_once(
956 struct xfs_inode *ip = inode;
958 memset(ip, 0, sizeof(struct xfs_inode));
961 inode_init_once(VFS_I(ip));
964 atomic_set(&ip->i_iocount, 0);
965 atomic_set(&ip->i_pincount, 0);
966 spin_lock_init(&ip->i_flags_lock);
967 init_waitqueue_head(&ip->i_ipin_wait);
969 * Because we want to use a counting completion, complete
970 * the flush completion once to allow a single access to
971 * the flush completion without blocking.
973 init_completion(&ip->i_flush);
974 complete(&ip->i_flush);
976 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
977 "xfsino", ip->i_ino);
978 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
982 * Attempt to flush the inode, this will actually fail
983 * if the inode is pinned, but we dirty the inode again
984 * at the point when it is unpinned after a log write,
985 * since this is when the inode itself becomes flushable.
992 struct xfs_inode *ip = XFS_I(inode);
996 xfs_itrace_entry(ip);
998 error = xfs_wait_on_pages(ip, 0, -1);
1001 flags |= FLUSH_SYNC;
1003 error = xfs_inode_flush(ip, flags);
1007 * if we failed to write out the inode then mark
1008 * it dirty again so we'll try again later.
1011 xfs_mark_inode_dirty_sync(ip);
1018 struct inode *inode)
1020 xfs_inode_t *ip = XFS_I(inode);
1022 xfs_itrace_entry(ip);
1023 XFS_STATS_INC(vn_rele);
1024 XFS_STATS_INC(vn_remove);
1025 XFS_STATS_DEC(vn_active);
1032 struct xfs_mount *mp)
1034 kfree(mp->m_fsname);
1035 kfree(mp->m_rtname);
1036 kfree(mp->m_logname);
1041 struct super_block *sb)
1043 struct xfs_mount *mp = XFS_M(sb);
1044 struct xfs_inode *rip = mp->m_rootip;
1045 int unmount_event_flags = 0;
1048 xfs_sync_inodes(mp, SYNC_ATTR|SYNC_DELWRI);
1051 if (mp->m_flags & XFS_MOUNT_DMAPI) {
1052 unmount_event_flags =
1053 (mp->m_dmevmask & (1 << DM_EVENT_UNMOUNT)) ?
1054 0 : DM_FLAGS_UNWANTED;
1056 * Ignore error from dmapi here, first unmount is not allowed
1057 * to fail anyway, and second we wouldn't want to fail a
1058 * unmount because of dmapi.
1060 XFS_SEND_PREUNMOUNT(mp, rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL,
1061 NULL, NULL, 0, 0, unmount_event_flags);
1066 * Blow away any referenced inode in the filestreams cache.
1067 * This can and will cause log traffic as inodes go inactive
1070 xfs_filestream_unmount(mp);
1072 XFS_bflush(mp->m_ddev_targp);
1074 if (mp->m_flags & XFS_MOUNT_DMAPI) {
1075 XFS_SEND_UNMOUNT(mp, rip, DM_RIGHT_NULL, 0, 0,
1076 unmount_event_flags);
1081 xfs_icsb_destroy_counters(mp);
1082 xfs_close_devices(mp);
1085 xfs_free_fsname(mp);
1091 struct super_block *sb)
1093 if (!(sb->s_flags & MS_RDONLY))
1094 xfs_sync_fsdata(XFS_M(sb), 0);
1100 struct super_block *sb,
1103 struct xfs_mount *mp = XFS_M(sb);
1107 * Treat a sync operation like a freeze. This is to work
1108 * around a race in sync_inodes() which works in two phases
1109 * - an asynchronous flush, which can write out an inode
1110 * without waiting for file size updates to complete, and a
1111 * synchronous flush, which wont do anything because the
1112 * async flush removed the inode's dirty flag. Also
1113 * sync_inodes() will not see any files that just have
1114 * outstanding transactions to be flushed because we don't
1115 * dirty the Linux inode until after the transaction I/O
1118 if (wait || unlikely(sb->s_frozen == SB_FREEZE_WRITE))
1119 error = xfs_quiesce_data(mp);
1121 error = xfs_sync_fsdata(mp, 0);
1124 if (unlikely(laptop_mode)) {
1125 int prev_sync_seq = mp->m_sync_seq;
1128 * The disk must be active because we're syncing.
1129 * We schedule xfssyncd now (now that the disk is
1130 * active) instead of later (when it might not be).
1132 wake_up_process(mp->m_sync_task);
1134 * We have to wait for the sync iteration to complete.
1135 * If we don't, the disk activity caused by the sync
1136 * will come after the sync is completed, and that
1137 * triggers another sync from laptop mode.
1139 wait_event(mp->m_wait_single_sync_task,
1140 mp->m_sync_seq != prev_sync_seq);
1148 struct dentry *dentry,
1149 struct kstatfs *statp)
1151 struct xfs_mount *mp = XFS_M(dentry->d_sb);
1152 xfs_sb_t *sbp = &mp->m_sb;
1153 __uint64_t fakeinos, id;
1156 statp->f_type = XFS_SB_MAGIC;
1157 statp->f_namelen = MAXNAMELEN - 1;
1159 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
1160 statp->f_fsid.val[0] = (u32)id;
1161 statp->f_fsid.val[1] = (u32)(id >> 32);
1163 xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
1165 spin_lock(&mp->m_sb_lock);
1166 statp->f_bsize = sbp->sb_blocksize;
1167 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
1168 statp->f_blocks = sbp->sb_dblocks - lsize;
1169 statp->f_bfree = statp->f_bavail =
1170 sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
1171 fakeinos = statp->f_bfree << sbp->sb_inopblog;
1173 fakeinos += mp->m_inoadd;
1176 MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
1177 if (mp->m_maxicount)
1181 statp->f_files = min_t(typeof(statp->f_files),
1184 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
1185 spin_unlock(&mp->m_sb_lock);
1187 XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp);
1193 struct super_block *sb,
1197 struct xfs_mount *mp = XFS_M(sb);
1198 substring_t args[MAX_OPT_ARGS];
1202 while ((p = strsep(&options, ",")) != NULL) {
1208 token = match_token(p, tokens, args);
1211 mp->m_flags |= XFS_MOUNT_BARRIER;
1214 * Test if barriers are actually working if we can,
1215 * else delay this check until the filesystem is
1218 if (!(mp->m_flags & XFS_MOUNT_RDONLY))
1219 xfs_mountfs_check_barriers(mp);
1222 mp->m_flags &= ~XFS_MOUNT_BARRIER;
1226 * Logically we would return an error here to prevent
1227 * users from believing they might have changed
1228 * mount options using remount which can't be changed.
1230 * But unfortunately mount(8) adds all options from
1231 * mtab and fstab to the mount arguments in some cases
1232 * so we can't blindly reject options, but have to
1233 * check for each specified option if it actually
1234 * differs from the currently set option and only
1235 * reject it if that's the case.
1237 * Until that is implemented we return success for
1238 * every remount request, and silently ignore all
1239 * options that we can't actually change.
1243 "XFS: mount option \"%s\" not supported for remount\n", p);
1252 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
1253 mp->m_flags &= ~XFS_MOUNT_RDONLY;
1254 if (mp->m_flags & XFS_MOUNT_BARRIER)
1255 xfs_mountfs_check_barriers(mp);
1258 * If this is the first remount to writeable state we
1259 * might have some superblock changes to update.
1261 if (mp->m_update_flags) {
1262 error = xfs_mount_log_sb(mp, mp->m_update_flags);
1265 "XFS: failed to write sb changes");
1268 mp->m_update_flags = 0;
1273 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
1274 xfs_quiesce_data(mp);
1275 xfs_quiesce_attr(mp);
1276 mp->m_flags |= XFS_MOUNT_RDONLY;
1283 * Second stage of a freeze. The data is already frozen so we only
1284 * need to take care of the metadata. Once that's done write a dummy
1285 * record to dirty the log in case of a crash while frozen.
1289 struct super_block *sb)
1291 struct xfs_mount *mp = XFS_M(sb);
1293 xfs_quiesce_attr(mp);
1294 return -xfs_fs_log_dummy(mp);
1298 xfs_fs_show_options(
1300 struct vfsmount *mnt)
1302 return -xfs_showargs(XFS_M(mnt->mnt_sb), m);
1307 struct super_block *sb,
1310 return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XQUOTASYNC, 0, NULL);
1315 struct super_block *sb,
1316 struct fs_quota_stat *fqs)
1318 return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XGETQSTAT, 0, (caddr_t)fqs);
1323 struct super_block *sb,
1327 return -XFS_QM_QUOTACTL(XFS_M(sb), op, 0, (caddr_t)&flags);
1332 struct super_block *sb,
1335 struct fs_disk_quota *fdq)
1337 return -XFS_QM_QUOTACTL(XFS_M(sb),
1338 (type == USRQUOTA) ? Q_XGETQUOTA :
1339 ((type == GRPQUOTA) ? Q_XGETGQUOTA :
1340 Q_XGETPQUOTA), id, (caddr_t)fdq);
1345 struct super_block *sb,
1348 struct fs_disk_quota *fdq)
1350 return -XFS_QM_QUOTACTL(XFS_M(sb),
1351 (type == USRQUOTA) ? Q_XSETQLIM :
1352 ((type == GRPQUOTA) ? Q_XSETGQLIM :
1353 Q_XSETPQLIM), id, (caddr_t)fdq);
1357 * This function fills in xfs_mount_t fields based on mount args.
1358 * Note: the superblock _has_ now been read in.
1362 struct xfs_mount *mp)
1364 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
1366 /* Fail a mount where the logbuf is smaller than the log stripe */
1367 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
1368 if (mp->m_logbsize <= 0 &&
1369 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
1370 mp->m_logbsize = mp->m_sb.sb_logsunit;
1371 } else if (mp->m_logbsize > 0 &&
1372 mp->m_logbsize < mp->m_sb.sb_logsunit) {
1374 "XFS: logbuf size must be greater than or equal to log stripe size");
1375 return XFS_ERROR(EINVAL);
1378 /* Fail a mount if the logbuf is larger than 32K */
1379 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1381 "XFS: logbuf size for version 1 logs must be 16K or 32K");
1382 return XFS_ERROR(EINVAL);
1387 * mkfs'ed attr2 will turn on attr2 mount unless explicitly
1388 * told by noattr2 to turn it off
1390 if (xfs_sb_version_hasattr2(&mp->m_sb) &&
1391 !(mp->m_flags & XFS_MOUNT_NOATTR2))
1392 mp->m_flags |= XFS_MOUNT_ATTR2;
1395 * prohibit r/w mounts of read-only filesystems
1397 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
1399 "XFS: cannot mount a read-only filesystem as read-write");
1400 return XFS_ERROR(EROFS);
1408 struct super_block *sb,
1413 struct xfs_mount *mp = NULL;
1414 int flags = 0, error = ENOMEM;
1417 mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
1421 spin_lock_init(&mp->m_sb_lock);
1422 mutex_init(&mp->m_growlock);
1423 atomic_set(&mp->m_active_trans, 0);
1424 INIT_LIST_HEAD(&mp->m_sync_list);
1425 spin_lock_init(&mp->m_sync_lock);
1426 init_waitqueue_head(&mp->m_wait_single_sync_task);
1431 error = xfs_parseargs(mp, (char *)data, &mtpt);
1433 goto out_free_fsname;
1435 sb_min_blocksize(sb, BBSIZE);
1436 sb->s_xattr = xfs_xattr_handlers;
1437 sb->s_export_op = &xfs_export_operations;
1438 sb->s_qcop = &xfs_quotactl_operations;
1439 sb->s_op = &xfs_super_operations;
1441 error = xfs_dmops_get(mp);
1443 goto out_free_fsname;
1444 error = xfs_qmops_get(mp);
1449 flags |= XFS_MFSI_QUIET;
1451 error = xfs_open_devices(mp);
1455 if (xfs_icsb_init_counters(mp))
1456 mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB;
1458 error = xfs_readsb(mp, flags);
1460 goto out_destroy_counters;
1462 error = xfs_finish_flags(mp);
1466 error = xfs_setup_devices(mp);
1470 if (mp->m_flags & XFS_MOUNT_BARRIER)
1471 xfs_mountfs_check_barriers(mp);
1473 error = xfs_filestream_mount(mp);
1477 error = xfs_mountfs(mp);
1479 goto out_filestream_unmount;
1481 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
1484 sb->s_magic = XFS_SB_MAGIC;
1485 sb->s_blocksize = mp->m_sb.sb_blocksize;
1486 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
1487 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
1488 sb->s_time_gran = 1;
1489 set_posix_acl_flag(sb);
1491 root = igrab(VFS_I(mp->m_rootip));
1496 if (is_bad_inode(root)) {
1500 sb->s_root = d_alloc_root(root);
1506 error = xfs_syncd_init(mp);
1512 xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
1515 out_filestream_unmount:
1516 xfs_filestream_unmount(mp);
1519 out_destroy_counters:
1520 xfs_icsb_destroy_counters(mp);
1521 xfs_close_devices(mp);
1527 xfs_free_fsname(mp);
1543 * Blow away any referenced inode in the filestreams cache.
1544 * This can and will cause log traffic as inodes go inactive
1547 xfs_filestream_unmount(mp);
1549 XFS_bflush(mp->m_ddev_targp);
1557 struct file_system_type *fs_type,
1559 const char *dev_name,
1561 struct vfsmount *mnt)
1563 return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super,
1567 static struct super_operations xfs_super_operations = {
1568 .alloc_inode = xfs_fs_alloc_inode,
1569 .destroy_inode = xfs_fs_destroy_inode,
1570 .write_inode = xfs_fs_write_inode,
1571 .clear_inode = xfs_fs_clear_inode,
1572 .put_super = xfs_fs_put_super,
1573 .write_super = xfs_fs_write_super,
1574 .sync_fs = xfs_fs_sync_super,
1575 .freeze_fs = xfs_fs_freeze,
1576 .statfs = xfs_fs_statfs,
1577 .remount_fs = xfs_fs_remount,
1578 .show_options = xfs_fs_show_options,
1581 static struct quotactl_ops xfs_quotactl_operations = {
1582 .quota_sync = xfs_fs_quotasync,
1583 .get_xstate = xfs_fs_getxstate,
1584 .set_xstate = xfs_fs_setxstate,
1585 .get_xquota = xfs_fs_getxquota,
1586 .set_xquota = xfs_fs_setxquota,
1589 static struct file_system_type xfs_fs_type = {
1590 .owner = THIS_MODULE,
1592 .get_sb = xfs_fs_get_sb,
1593 .kill_sb = kill_block_super,
1594 .fs_flags = FS_REQUIRES_DEV,
1598 xfs_alloc_trace_bufs(void)
1600 #ifdef XFS_ALLOC_TRACE
1601 xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL);
1602 if (!xfs_alloc_trace_buf)
1605 #ifdef XFS_BMAP_TRACE
1606 xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL);
1607 if (!xfs_bmap_trace_buf)
1608 goto out_free_alloc_trace;
1610 #ifdef XFS_BTREE_TRACE
1611 xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE,
1613 if (!xfs_allocbt_trace_buf)
1614 goto out_free_bmap_trace;
1616 xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL);
1617 if (!xfs_inobt_trace_buf)
1618 goto out_free_allocbt_trace;
1620 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
1621 if (!xfs_bmbt_trace_buf)
1622 goto out_free_inobt_trace;
1624 #ifdef XFS_ATTR_TRACE
1625 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
1626 if (!xfs_attr_trace_buf)
1627 goto out_free_bmbt_trace;
1629 #ifdef XFS_DIR2_TRACE
1630 xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL);
1631 if (!xfs_dir2_trace_buf)
1632 goto out_free_attr_trace;
1637 #ifdef XFS_DIR2_TRACE
1638 out_free_attr_trace:
1640 #ifdef XFS_ATTR_TRACE
1641 ktrace_free(xfs_attr_trace_buf);
1642 out_free_bmbt_trace:
1644 #ifdef XFS_BTREE_TRACE
1645 ktrace_free(xfs_bmbt_trace_buf);
1646 out_free_inobt_trace:
1647 ktrace_free(xfs_inobt_trace_buf);
1648 out_free_allocbt_trace:
1649 ktrace_free(xfs_allocbt_trace_buf);
1650 out_free_bmap_trace:
1652 #ifdef XFS_BMAP_TRACE
1653 ktrace_free(xfs_bmap_trace_buf);
1654 out_free_alloc_trace:
1656 #ifdef XFS_ALLOC_TRACE
1657 ktrace_free(xfs_alloc_trace_buf);
1664 xfs_free_trace_bufs(void)
1666 #ifdef XFS_DIR2_TRACE
1667 ktrace_free(xfs_dir2_trace_buf);
1669 #ifdef XFS_ATTR_TRACE
1670 ktrace_free(xfs_attr_trace_buf);
1672 #ifdef XFS_BTREE_TRACE
1673 ktrace_free(xfs_bmbt_trace_buf);
1674 ktrace_free(xfs_inobt_trace_buf);
1675 ktrace_free(xfs_allocbt_trace_buf);
1677 #ifdef XFS_BMAP_TRACE
1678 ktrace_free(xfs_bmap_trace_buf);
1680 #ifdef XFS_ALLOC_TRACE
1681 ktrace_free(xfs_alloc_trace_buf);
1686 xfs_init_zones(void)
1689 xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
1690 if (!xfs_ioend_zone)
1693 xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
1695 if (!xfs_ioend_pool)
1696 goto out_destroy_ioend_zone;
1698 xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
1700 if (!xfs_log_ticket_zone)
1701 goto out_destroy_ioend_pool;
1703 xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
1704 "xfs_bmap_free_item");
1705 if (!xfs_bmap_free_item_zone)
1706 goto out_destroy_log_ticket_zone;
1708 xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
1710 if (!xfs_btree_cur_zone)
1711 goto out_destroy_bmap_free_item_zone;
1713 xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
1715 if (!xfs_da_state_zone)
1716 goto out_destroy_btree_cur_zone;
1718 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
1719 if (!xfs_dabuf_zone)
1720 goto out_destroy_da_state_zone;
1722 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
1723 if (!xfs_ifork_zone)
1724 goto out_destroy_dabuf_zone;
1726 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
1727 if (!xfs_trans_zone)
1728 goto out_destroy_ifork_zone;
1731 * The size of the zone allocated buf log item is the maximum
1732 * size possible under XFS. This wastes a little bit of memory,
1733 * but it is much faster.
1735 xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) +
1736 (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
1737 NBWORD) * sizeof(int))), "xfs_buf_item");
1738 if (!xfs_buf_item_zone)
1739 goto out_destroy_trans_zone;
1741 xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
1742 ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
1743 sizeof(xfs_extent_t))), "xfs_efd_item");
1745 goto out_destroy_buf_item_zone;
1747 xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
1748 ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
1749 sizeof(xfs_extent_t))), "xfs_efi_item");
1751 goto out_destroy_efd_zone;
1754 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
1755 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD,
1756 xfs_fs_inode_init_once);
1757 if (!xfs_inode_zone)
1758 goto out_destroy_efi_zone;
1761 kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
1762 KM_ZONE_SPREAD, NULL);
1764 goto out_destroy_inode_zone;
1766 #ifdef CONFIG_XFS_POSIX_ACL
1767 xfs_acl_zone = kmem_zone_init(sizeof(xfs_acl_t), "xfs_acl");
1769 goto out_destroy_ili_zone;
1774 #ifdef CONFIG_XFS_POSIX_ACL
1775 out_destroy_ili_zone:
1777 kmem_zone_destroy(xfs_ili_zone);
1778 out_destroy_inode_zone:
1779 kmem_zone_destroy(xfs_inode_zone);
1780 out_destroy_efi_zone:
1781 kmem_zone_destroy(xfs_efi_zone);
1782 out_destroy_efd_zone:
1783 kmem_zone_destroy(xfs_efd_zone);
1784 out_destroy_buf_item_zone:
1785 kmem_zone_destroy(xfs_buf_item_zone);
1786 out_destroy_trans_zone:
1787 kmem_zone_destroy(xfs_trans_zone);
1788 out_destroy_ifork_zone:
1789 kmem_zone_destroy(xfs_ifork_zone);
1790 out_destroy_dabuf_zone:
1791 kmem_zone_destroy(xfs_dabuf_zone);
1792 out_destroy_da_state_zone:
1793 kmem_zone_destroy(xfs_da_state_zone);
1794 out_destroy_btree_cur_zone:
1795 kmem_zone_destroy(xfs_btree_cur_zone);
1796 out_destroy_bmap_free_item_zone:
1797 kmem_zone_destroy(xfs_bmap_free_item_zone);
1798 out_destroy_log_ticket_zone:
1799 kmem_zone_destroy(xfs_log_ticket_zone);
1800 out_destroy_ioend_pool:
1801 mempool_destroy(xfs_ioend_pool);
1802 out_destroy_ioend_zone:
1803 kmem_zone_destroy(xfs_ioend_zone);
1809 xfs_destroy_zones(void)
1811 #ifdef CONFIG_XFS_POSIX_ACL
1812 kmem_zone_destroy(xfs_acl_zone);
1814 kmem_zone_destroy(xfs_ili_zone);
1815 kmem_zone_destroy(xfs_inode_zone);
1816 kmem_zone_destroy(xfs_efi_zone);
1817 kmem_zone_destroy(xfs_efd_zone);
1818 kmem_zone_destroy(xfs_buf_item_zone);
1819 kmem_zone_destroy(xfs_trans_zone);
1820 kmem_zone_destroy(xfs_ifork_zone);
1821 kmem_zone_destroy(xfs_dabuf_zone);
1822 kmem_zone_destroy(xfs_da_state_zone);
1823 kmem_zone_destroy(xfs_btree_cur_zone);
1824 kmem_zone_destroy(xfs_bmap_free_item_zone);
1825 kmem_zone_destroy(xfs_log_ticket_zone);
1826 mempool_destroy(xfs_ioend_pool);
1827 kmem_zone_destroy(xfs_ioend_zone);
1836 printk(KERN_INFO XFS_VERSION_STRING " with "
1837 XFS_BUILD_OPTIONS " enabled\n");
1843 error = xfs_init_zones();
1847 error = xfs_alloc_trace_bufs();
1849 goto out_destroy_zones;
1851 error = xfs_mru_cache_init();
1853 goto out_free_trace_buffers;
1855 error = xfs_filestream_init();
1857 goto out_mru_cache_uninit;
1859 error = xfs_buf_init();
1861 goto out_filestream_uninit;
1863 error = xfs_init_procfs();
1865 goto out_buf_terminate;
1867 error = xfs_sysctl_register();
1869 goto out_cleanup_procfs;
1873 error = register_filesystem(&xfs_fs_type);
1875 goto out_sysctl_unregister;
1878 out_sysctl_unregister:
1879 xfs_sysctl_unregister();
1881 xfs_cleanup_procfs();
1883 xfs_buf_terminate();
1884 out_filestream_uninit:
1885 xfs_filestream_uninit();
1886 out_mru_cache_uninit:
1887 xfs_mru_cache_uninit();
1888 out_free_trace_buffers:
1889 xfs_free_trace_bufs();
1891 xfs_destroy_zones();
1900 unregister_filesystem(&xfs_fs_type);
1901 xfs_sysctl_unregister();
1902 xfs_cleanup_procfs();
1903 xfs_buf_terminate();
1904 xfs_filestream_uninit();
1905 xfs_mru_cache_uninit();
1906 xfs_free_trace_bufs();
1907 xfs_destroy_zones();
1911 module_init(init_xfs_fs);
1912 module_exit(exit_xfs_fs);
1914 MODULE_AUTHOR("Silicon Graphics, Inc.");
1915 MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
1916 MODULE_LICENSE("GPL");