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_vfsops.h"
52 #include "xfs_version.h"
53 #include "xfs_log_priv.h"
54 #include "xfs_trans_priv.h"
55 #include "xfs_filestream.h"
56 #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"
63 #include <linux/namei.h>
64 #include <linux/init.h>
65 #include <linux/mount.h>
66 #include <linux/mempool.h>
67 #include <linux/writeback.h>
68 #include <linux/kthread.h>
69 #include <linux/freezer.h>
70 #include <linux/parser.h>
72 static struct quotactl_ops xfs_quotactl_operations;
73 static struct super_operations xfs_super_operations;
74 static kmem_zone_t *xfs_ioend_zone;
75 mempool_t *xfs_ioend_pool;
77 #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
78 #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
79 #define MNTOPT_LOGDEV "logdev" /* log device */
80 #define MNTOPT_RTDEV "rtdev" /* realtime I/O device */
81 #define MNTOPT_BIOSIZE "biosize" /* log2 of preferred buffered io size */
82 #define MNTOPT_WSYNC "wsync" /* safe-mode nfs compatible mount */
83 #define MNTOPT_INO64 "ino64" /* force inodes into 64-bit range */
84 #define MNTOPT_NOALIGN "noalign" /* turn off stripe alignment */
85 #define MNTOPT_SWALLOC "swalloc" /* turn on stripe width allocation */
86 #define MNTOPT_SUNIT "sunit" /* data volume stripe unit */
87 #define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
88 #define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
89 #define MNTOPT_MTPT "mtpt" /* filesystem mount point */
90 #define MNTOPT_GRPID "grpid" /* group-ID from parent directory */
91 #define MNTOPT_NOGRPID "nogrpid" /* group-ID from current process */
92 #define MNTOPT_BSDGROUPS "bsdgroups" /* group-ID from parent directory */
93 #define MNTOPT_SYSVGROUPS "sysvgroups" /* group-ID from current process */
94 #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
95 #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
96 #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and
97 * unwritten extent conversion */
98 #define MNTOPT_NOBARRIER "nobarrier" /* .. disable */
99 #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
100 #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */
101 #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
102 #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
103 #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */
104 #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes
106 #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */
107 #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */
108 #define MNTOPT_FILESTREAM "filestreams" /* use filestreams allocator */
109 #define MNTOPT_QUOTA "quota" /* disk quotas (user) */
110 #define MNTOPT_NOQUOTA "noquota" /* no quotas */
111 #define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
112 #define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
113 #define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
114 #define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
115 #define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
116 #define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
117 #define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
118 #define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
119 #define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
120 #define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
121 #define MNTOPT_DMAPI "dmapi" /* DMI enabled (DMAPI / XDSM) */
122 #define MNTOPT_XDSM "xdsm" /* DMI enabled (DMAPI / XDSM) */
123 #define MNTOPT_DMI "dmi" /* DMI enabled (DMAPI / XDSM) */
126 * Table driven mount option parser.
128 * Currently only used for remount, but it will be used for mount
129 * in the future, too.
132 Opt_barrier, Opt_nobarrier, Opt_err
135 static const match_table_t tokens = {
136 {Opt_barrier, "barrier"},
137 {Opt_nobarrier, "nobarrier"},
143 suffix_strtoul(char *s, char **endp, unsigned int base)
145 int last, shift_left_factor = 0;
148 last = strlen(value) - 1;
149 if (value[last] == 'K' || value[last] == 'k') {
150 shift_left_factor = 10;
153 if (value[last] == 'M' || value[last] == 'm') {
154 shift_left_factor = 20;
157 if (value[last] == 'G' || value[last] == 'g') {
158 shift_left_factor = 30;
162 return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
166 * This function fills in xfs_mount_t fields based on mount args.
167 * Note: the superblock has _not_ yet been read in.
169 * Note that this function leaks the various device name allocations on
170 * failure. The caller takes care of them.
174 struct xfs_mount *mp,
178 struct super_block *sb = mp->m_super;
179 char *this_char, *value, *eov;
183 int dmapi_implies_ikeep = 1;
184 uchar_t iosizelog = 0;
187 * Copy binary VFS mount flags we are interested in.
189 if (sb->s_flags & MS_RDONLY)
190 mp->m_flags |= XFS_MOUNT_RDONLY;
191 if (sb->s_flags & MS_DIRSYNC)
192 mp->m_flags |= XFS_MOUNT_DIRSYNC;
193 if (sb->s_flags & MS_SYNCHRONOUS)
194 mp->m_flags |= XFS_MOUNT_WSYNC;
197 * Set some default flags that could be cleared by the mount option
200 mp->m_flags |= XFS_MOUNT_BARRIER;
201 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
202 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
205 * These can be overridden by the mount option parsing.
213 while ((this_char = strsep(&options, ",")) != NULL) {
216 if ((value = strchr(this_char, '=')) != NULL)
219 if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
220 if (!value || !*value) {
222 "XFS: %s option requires an argument",
226 mp->m_logbufs = simple_strtoul(value, &eov, 10);
227 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
228 if (!value || !*value) {
230 "XFS: %s option requires an argument",
234 mp->m_logbsize = suffix_strtoul(value, &eov, 10);
235 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
236 if (!value || !*value) {
238 "XFS: %s option requires an argument",
242 mp->m_logname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
245 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
246 if (!value || !*value) {
248 "XFS: %s option requires an argument",
252 *mtpt = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
255 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
256 if (!value || !*value) {
258 "XFS: %s option requires an argument",
262 mp->m_rtname = kstrndup(value, MAXNAMELEN, GFP_KERNEL);
265 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
266 if (!value || !*value) {
268 "XFS: %s option requires an argument",
272 iosize = simple_strtoul(value, &eov, 10);
273 iosizelog = ffs(iosize) - 1;
274 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
275 if (!value || !*value) {
277 "XFS: %s option requires an argument",
281 iosize = suffix_strtoul(value, &eov, 10);
282 iosizelog = ffs(iosize) - 1;
283 } else if (!strcmp(this_char, MNTOPT_GRPID) ||
284 !strcmp(this_char, MNTOPT_BSDGROUPS)) {
285 mp->m_flags |= XFS_MOUNT_GRPID;
286 } else if (!strcmp(this_char, MNTOPT_NOGRPID) ||
287 !strcmp(this_char, MNTOPT_SYSVGROUPS)) {
288 mp->m_flags &= ~XFS_MOUNT_GRPID;
289 } else if (!strcmp(this_char, MNTOPT_WSYNC)) {
290 mp->m_flags |= XFS_MOUNT_WSYNC;
291 } else if (!strcmp(this_char, MNTOPT_OSYNCISOSYNC)) {
292 mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC;
293 } else if (!strcmp(this_char, MNTOPT_NORECOVERY)) {
294 mp->m_flags |= XFS_MOUNT_NORECOVERY;
295 } else if (!strcmp(this_char, MNTOPT_INO64)) {
297 mp->m_flags |= XFS_MOUNT_INO64;
298 mp->m_inoadd = XFS_INO64_OFFSET;
301 "XFS: %s option not allowed on this system",
305 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
306 mp->m_flags |= XFS_MOUNT_NOALIGN;
307 } else if (!strcmp(this_char, MNTOPT_SWALLOC)) {
308 mp->m_flags |= XFS_MOUNT_SWALLOC;
309 } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
310 if (!value || !*value) {
312 "XFS: %s option requires an argument",
316 dsunit = simple_strtoul(value, &eov, 10);
317 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
318 if (!value || !*value) {
320 "XFS: %s option requires an argument",
324 dswidth = simple_strtoul(value, &eov, 10);
325 } else if (!strcmp(this_char, MNTOPT_64BITINODE)) {
326 mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
329 "XFS: %s option not allowed on this system",
333 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
334 mp->m_flags |= XFS_MOUNT_NOUUID;
335 } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
336 mp->m_flags |= XFS_MOUNT_BARRIER;
337 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
338 mp->m_flags &= ~XFS_MOUNT_BARRIER;
339 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
340 mp->m_flags |= XFS_MOUNT_IKEEP;
341 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
342 dmapi_implies_ikeep = 0;
343 mp->m_flags &= ~XFS_MOUNT_IKEEP;
344 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
345 mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
346 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
347 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
348 } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
349 mp->m_flags |= XFS_MOUNT_ATTR2;
350 } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
351 mp->m_flags &= ~XFS_MOUNT_ATTR2;
352 mp->m_flags |= XFS_MOUNT_NOATTR2;
353 } else if (!strcmp(this_char, MNTOPT_FILESTREAM)) {
354 mp->m_flags |= XFS_MOUNT_FILESTREAMS;
355 } else if (!strcmp(this_char, MNTOPT_NOQUOTA)) {
356 mp->m_qflags &= ~(XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
357 XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
358 XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
359 XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD);
360 } else if (!strcmp(this_char, MNTOPT_QUOTA) ||
361 !strcmp(this_char, MNTOPT_UQUOTA) ||
362 !strcmp(this_char, MNTOPT_USRQUOTA)) {
363 mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE |
365 } else if (!strcmp(this_char, MNTOPT_QUOTANOENF) ||
366 !strcmp(this_char, MNTOPT_UQUOTANOENF)) {
367 mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE);
368 mp->m_qflags &= ~XFS_UQUOTA_ENFD;
369 } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
370 !strcmp(this_char, MNTOPT_PRJQUOTA)) {
371 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE |
373 } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
374 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
375 mp->m_qflags &= ~XFS_OQUOTA_ENFD;
376 } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
377 !strcmp(this_char, MNTOPT_GRPQUOTA)) {
378 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE |
380 } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) {
381 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
382 mp->m_qflags &= ~XFS_OQUOTA_ENFD;
383 } else if (!strcmp(this_char, MNTOPT_DMAPI)) {
384 mp->m_flags |= XFS_MOUNT_DMAPI;
385 } else if (!strcmp(this_char, MNTOPT_XDSM)) {
386 mp->m_flags |= XFS_MOUNT_DMAPI;
387 } else if (!strcmp(this_char, MNTOPT_DMI)) {
388 mp->m_flags |= XFS_MOUNT_DMAPI;
389 } else if (!strcmp(this_char, "ihashsize")) {
391 "XFS: ihashsize no longer used, option is deprecated.");
392 } else if (!strcmp(this_char, "osyncisdsync")) {
393 /* no-op, this is now the default */
395 "XFS: osyncisdsync is now the default, option is deprecated.");
396 } else if (!strcmp(this_char, "irixsgid")) {
398 "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
401 "XFS: unknown mount option [%s].", this_char);
407 * no recovery flag requires a read-only mount
409 if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
410 !(mp->m_flags & XFS_MOUNT_RDONLY)) {
411 cmn_err(CE_WARN, "XFS: no-recovery mounts must be read-only.");
415 if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
417 "XFS: sunit and swidth options incompatible with the noalign option");
421 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) &&
422 (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) {
424 "XFS: cannot mount with both project and group quota");
428 if ((mp->m_flags & XFS_MOUNT_DMAPI) && (!*mtpt || *mtpt[0] == '\0')) {
429 printk("XFS: %s option needs the mount point option as well\n",
434 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
436 "XFS: sunit and swidth must be specified together");
440 if (dsunit && (dswidth % dsunit != 0)) {
442 "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)",
448 * Applications using DMI filesystems often expect the
449 * inode generation number to be monotonically increasing.
450 * If we delete inode chunks we break this assumption, so
451 * keep unused inode chunks on disk for DMI filesystems
452 * until we come up with a better solution.
453 * Note that if "ikeep" or "noikeep" mount options are
454 * supplied, then they are honored.
456 if ((mp->m_flags & XFS_MOUNT_DMAPI) && dmapi_implies_ikeep)
457 mp->m_flags |= XFS_MOUNT_IKEEP;
460 if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) {
462 * At this point the superblock has not been read
463 * in, therefore we do not know the block size.
464 * Before the mount call ends we will convert
468 mp->m_dalign = dsunit;
469 mp->m_flags |= XFS_MOUNT_RETERR;
473 mp->m_swidth = dswidth;
476 if (mp->m_logbufs != -1 &&
477 mp->m_logbufs != 0 &&
478 (mp->m_logbufs < XLOG_MIN_ICLOGS ||
479 mp->m_logbufs > XLOG_MAX_ICLOGS)) {
481 "XFS: invalid logbufs value: %d [not %d-%d]",
482 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
483 return XFS_ERROR(EINVAL);
485 if (mp->m_logbsize != -1 &&
486 mp->m_logbsize != 0 &&
487 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
488 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
489 !is_power_of_2(mp->m_logbsize))) {
491 "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
493 return XFS_ERROR(EINVAL);
496 mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL);
499 mp->m_fsname_len = strlen(mp->m_fsname) + 1;
502 if (iosizelog > XFS_MAX_IO_LOG ||
503 iosizelog < XFS_MIN_IO_LOG) {
505 "XFS: invalid log iosize: %d [not %d-%d]",
506 iosizelog, XFS_MIN_IO_LOG,
508 return XFS_ERROR(EINVAL);
511 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
512 mp->m_readio_log = iosizelog;
513 mp->m_writeio_log = iosizelog;
519 struct proc_xfs_info {
526 struct xfs_mount *mp,
529 static struct proc_xfs_info xfs_info_set[] = {
530 /* the few simple ones we can get from the mount struct */
531 { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
532 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
533 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
534 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
535 { XFS_MOUNT_SWALLOC, "," MNTOPT_SWALLOC },
536 { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
537 { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
538 { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
539 { XFS_MOUNT_ATTR2, "," MNTOPT_ATTR2 },
540 { XFS_MOUNT_FILESTREAMS, "," MNTOPT_FILESTREAM },
541 { XFS_MOUNT_DMAPI, "," MNTOPT_DMAPI },
542 { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
545 static struct proc_xfs_info xfs_info_unset[] = {
546 /* the few simple ones we can get from the mount struct */
547 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
548 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
549 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
552 struct proc_xfs_info *xfs_infop;
554 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
555 if (mp->m_flags & xfs_infop->flag)
556 seq_puts(m, xfs_infop->str);
558 for (xfs_infop = xfs_info_unset; xfs_infop->flag; xfs_infop++) {
559 if (!(mp->m_flags & xfs_infop->flag))
560 seq_puts(m, xfs_infop->str);
563 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
564 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk",
565 (int)(1 << mp->m_writeio_log) >> 10);
567 if (mp->m_logbufs > 0)
568 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
569 if (mp->m_logbsize > 0)
570 seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
573 seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
575 seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
577 if (mp->m_dalign > 0)
578 seq_printf(m, "," MNTOPT_SUNIT "=%d",
579 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
580 if (mp->m_swidth > 0)
581 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
582 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
584 if (mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD))
585 seq_puts(m, "," MNTOPT_USRQUOTA);
586 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
587 seq_puts(m, "," MNTOPT_UQUOTANOENF);
589 if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))
590 seq_puts(m, "," MNTOPT_PRJQUOTA);
591 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
592 seq_puts(m, "," MNTOPT_PQUOTANOENF);
594 if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD))
595 seq_puts(m, "," MNTOPT_GRPQUOTA);
596 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
597 seq_puts(m, "," MNTOPT_GQUOTANOENF);
599 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
600 seq_puts(m, "," MNTOPT_NOQUOTA);
606 unsigned int blockshift)
608 unsigned int pagefactor = 1;
609 unsigned int bitshift = BITS_PER_LONG - 1;
611 /* Figure out maximum filesize, on Linux this can depend on
612 * the filesystem blocksize (on 32 bit platforms).
613 * __block_prepare_write does this in an [unsigned] long...
614 * page->index << (PAGE_CACHE_SHIFT - bbits)
615 * So, for page sized blocks (4K on 32 bit platforms),
616 * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
617 * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
618 * but for smaller blocksizes it is less (bbits = log2 bsize).
619 * Note1: get_block_t takes a long (implicit cast from above)
620 * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
621 * can optionally convert the [unsigned] long from above into
622 * an [unsigned] long long.
625 #if BITS_PER_LONG == 32
626 # if defined(CONFIG_LBD)
627 ASSERT(sizeof(sector_t) == 8);
628 pagefactor = PAGE_CACHE_SIZE;
629 bitshift = BITS_PER_LONG;
631 pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
635 return (((__uint64_t)pagefactor) << bitshift) - 1;
642 struct block_device **bdevp)
646 *bdevp = open_bdev_exclusive(name, FMODE_READ|FMODE_WRITE, mp);
647 if (IS_ERR(*bdevp)) {
648 error = PTR_ERR(*bdevp);
649 printk("XFS: Invalid device [%s], error=%d\n", name, error);
657 struct block_device *bdev)
660 close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE);
664 * Try to write out the superblock using barriers.
670 xfs_buf_t *sbp = xfs_getsb(mp, 0);
675 XFS_BUF_UNDELAYWRITE(sbp);
677 XFS_BUF_UNASYNC(sbp);
678 XFS_BUF_ORDERED(sbp);
681 error = xfs_iowait(sbp);
684 * Clear all the flags we set and possible error state in the
685 * buffer. We only did the write to try out whether barriers
686 * worked and shouldn't leave any traces in the superblock
690 XFS_BUF_ERROR(sbp, 0);
691 XFS_BUF_UNORDERED(sbp);
698 xfs_mountfs_check_barriers(xfs_mount_t *mp)
702 if (mp->m_logdev_targp != mp->m_ddev_targp) {
703 xfs_fs_cmn_err(CE_NOTE, mp,
704 "Disabling barriers, not supported with external log device");
705 mp->m_flags &= ~XFS_MOUNT_BARRIER;
709 if (xfs_readonly_buftarg(mp->m_ddev_targp)) {
710 xfs_fs_cmn_err(CE_NOTE, mp,
711 "Disabling barriers, underlying device is readonly");
712 mp->m_flags &= ~XFS_MOUNT_BARRIER;
716 error = xfs_barrier_test(mp);
718 xfs_fs_cmn_err(CE_NOTE, mp,
719 "Disabling barriers, trial barrier write failed");
720 mp->m_flags &= ~XFS_MOUNT_BARRIER;
726 xfs_blkdev_issue_flush(
727 xfs_buftarg_t *buftarg)
729 blkdev_issue_flush(buftarg->bt_bdev, NULL);
734 struct xfs_mount *mp)
736 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
737 struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
738 xfs_free_buftarg(mp->m_logdev_targp);
739 xfs_blkdev_put(logdev);
741 if (mp->m_rtdev_targp) {
742 struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
743 xfs_free_buftarg(mp->m_rtdev_targp);
744 xfs_blkdev_put(rtdev);
746 xfs_free_buftarg(mp->m_ddev_targp);
750 * The file system configurations are:
751 * (1) device (partition) with data and internal log
752 * (2) logical volume with data and log subvolumes.
753 * (3) logical volume with data, log, and realtime subvolumes.
755 * We only have to handle opening the log and realtime volumes here if
756 * they are present. The data subvolume has already been opened by
757 * get_sb_bdev() and is stored in sb->s_bdev.
761 struct xfs_mount *mp)
763 struct block_device *ddev = mp->m_super->s_bdev;
764 struct block_device *logdev = NULL, *rtdev = NULL;
768 * Open real time and log devices - order is important.
771 error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
777 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
779 goto out_close_logdev;
781 if (rtdev == ddev || rtdev == logdev) {
783 "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev.");
785 goto out_close_rtdev;
790 * Setup xfs_mount buffer target pointers
793 mp->m_ddev_targp = xfs_alloc_buftarg(ddev, 0);
794 if (!mp->m_ddev_targp)
795 goto out_close_rtdev;
798 mp->m_rtdev_targp = xfs_alloc_buftarg(rtdev, 1);
799 if (!mp->m_rtdev_targp)
800 goto out_free_ddev_targ;
803 if (logdev && logdev != ddev) {
804 mp->m_logdev_targp = xfs_alloc_buftarg(logdev, 1);
805 if (!mp->m_logdev_targp)
806 goto out_free_rtdev_targ;
808 mp->m_logdev_targp = mp->m_ddev_targp;
814 if (mp->m_rtdev_targp)
815 xfs_free_buftarg(mp->m_rtdev_targp);
817 xfs_free_buftarg(mp->m_ddev_targp);
820 xfs_blkdev_put(rtdev);
822 if (logdev && logdev != ddev)
823 xfs_blkdev_put(logdev);
829 * Setup xfs_mount buffer target pointers based on superblock
833 struct xfs_mount *mp)
837 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
838 mp->m_sb.sb_sectsize);
842 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
843 unsigned int log_sector_size = BBSIZE;
845 if (xfs_sb_version_hassector(&mp->m_sb))
846 log_sector_size = mp->m_sb.sb_logsectsize;
847 error = xfs_setsize_buftarg(mp->m_logdev_targp,
848 mp->m_sb.sb_blocksize,
853 if (mp->m_rtdev_targp) {
854 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
855 mp->m_sb.sb_blocksize,
856 mp->m_sb.sb_sectsize);
865 * XFS AIL push thread support
869 struct xfs_ail *ailp,
870 xfs_lsn_t threshold_lsn)
872 ailp->xa_target = threshold_lsn;
873 wake_up_process(ailp->xa_task);
880 struct xfs_ail *ailp = data;
881 xfs_lsn_t last_pushed_lsn = 0;
884 while (!kthread_should_stop()) {
886 schedule_timeout_interruptible(msecs_to_jiffies(tout));
892 ASSERT(ailp->xa_mount->m_log);
893 if (XFS_FORCED_SHUTDOWN(ailp->xa_mount))
896 tout = xfsaild_push(ailp, &last_pushed_lsn);
904 struct xfs_ail *ailp)
907 ailp->xa_task = kthread_run(xfsaild, ailp, "xfsaild");
908 if (IS_ERR(ailp->xa_task))
909 return -PTR_ERR(ailp->xa_task);
915 struct xfs_ail *ailp)
917 kthread_stop(ailp->xa_task);
921 /* Catch misguided souls that try to use this interface on XFS */
922 STATIC struct inode *
924 struct super_block *sb)
931 * Now that the generic code is guaranteed not to be accessing
932 * the linux inode, we can reclaim the inode.
935 xfs_fs_destroy_inode(
938 xfs_inode_t *ip = XFS_I(inode);
940 XFS_STATS_INC(vn_reclaim);
942 panic("%s: cannot reclaim 0x%p\n", __func__, inode);
946 * Slab object creation initialisation for the XFS inode.
947 * This covers only the idempotent fields in the XFS inode;
948 * all other fields need to be initialised on allocation
949 * from the slab. This avoids the need to repeatedly intialise
950 * fields in the xfs inode that left in the initialise state
951 * when freeing the inode.
954 xfs_fs_inode_init_once(
957 struct xfs_inode *ip = inode;
959 memset(ip, 0, sizeof(struct xfs_inode));
962 inode_init_once(VFS_I(ip));
965 atomic_set(&ip->i_iocount, 0);
966 atomic_set(&ip->i_pincount, 0);
967 spin_lock_init(&ip->i_flags_lock);
968 init_waitqueue_head(&ip->i_ipin_wait);
970 * Because we want to use a counting completion, complete
971 * the flush completion once to allow a single access to
972 * the flush completion without blocking.
974 init_completion(&ip->i_flush);
975 complete(&ip->i_flush);
977 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
978 "xfsino", ip->i_ino);
979 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
983 * Attempt to flush the inode, this will actually fail
984 * if the inode is pinned, but we dirty the inode again
985 * at the point when it is unpinned after a log write,
986 * since this is when the inode itself becomes flushable.
996 xfs_itrace_entry(XFS_I(inode));
998 filemap_fdatawait(inode->i_mapping);
1001 error = xfs_inode_flush(XFS_I(inode), flags);
1003 * if we failed to write out the inode then mark
1004 * it dirty again so we'll try again later.
1007 xfs_mark_inode_dirty_sync(XFS_I(inode));
1014 struct inode *inode)
1016 xfs_inode_t *ip = XFS_I(inode);
1018 xfs_itrace_entry(ip);
1019 XFS_STATS_INC(vn_rele);
1020 XFS_STATS_INC(vn_remove);
1021 XFS_STATS_DEC(vn_active);
1024 xfs_iflags_clear(ip, XFS_IMODIFIED);
1029 struct xfs_mount *mp)
1031 kfree(mp->m_fsname);
1032 kfree(mp->m_rtname);
1033 kfree(mp->m_logname);
1038 struct super_block *sb)
1040 struct xfs_mount *mp = XFS_M(sb);
1041 struct xfs_inode *rip = mp->m_rootip;
1042 int unmount_event_flags = 0;
1046 xfs_sync_inodes(mp, SYNC_ATTR|SYNC_DELWRI);
1049 if (mp->m_flags & XFS_MOUNT_DMAPI) {
1050 unmount_event_flags =
1051 (mp->m_dmevmask & (1 << DM_EVENT_UNMOUNT)) ?
1052 0 : DM_FLAGS_UNWANTED;
1054 * Ignore error from dmapi here, first unmount is not allowed
1055 * to fail anyway, and second we wouldn't want to fail a
1056 * unmount because of dmapi.
1058 XFS_SEND_PREUNMOUNT(mp, rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL,
1059 NULL, NULL, 0, 0, unmount_event_flags);
1064 * Blow away any referenced inode in the filestreams cache.
1065 * This can and will cause log traffic as inodes go inactive
1068 xfs_filestream_unmount(mp);
1070 XFS_bflush(mp->m_ddev_targp);
1071 error = xfs_unmount_flush(mp, 0);
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];
1201 while ((p = strsep(&options, ",")) != NULL) {
1207 token = match_token(p, tokens, args);
1210 mp->m_flags |= XFS_MOUNT_BARRIER;
1213 * Test if barriers are actually working if we can,
1214 * else delay this check until the filesystem is
1217 if (!(mp->m_flags & XFS_MOUNT_RDONLY))
1218 xfs_mountfs_check_barriers(mp);
1221 mp->m_flags &= ~XFS_MOUNT_BARRIER;
1225 * Logically we would return an error here to prevent
1226 * users from believing they might have changed
1227 * mount options using remount which can't be changed.
1229 * But unfortunately mount(8) adds all options from
1230 * mtab and fstab to the mount arguments in some cases
1231 * so we can't blindly reject options, but have to
1232 * check for each specified option if it actually
1233 * differs from the currently set option and only
1234 * reject it if that's the case.
1236 * Until that is implemented we return success for
1237 * every remount request, and silently ignore all
1238 * options that we can't actually change.
1242 "XFS: mount option \"%s\" not supported for remount\n", p);
1251 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
1252 mp->m_flags &= ~XFS_MOUNT_RDONLY;
1253 if (mp->m_flags & XFS_MOUNT_BARRIER)
1254 xfs_mountfs_check_barriers(mp);
1258 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
1259 xfs_quiesce_data(mp);
1260 xfs_quiesce_attr(mp);
1261 mp->m_flags |= XFS_MOUNT_RDONLY;
1268 * Second stage of a freeze. The data is already frozen so we only
1269 * need to take care of the metadata. Once that's done write a dummy
1270 * record to dirty the log in case of a crash while frozen.
1274 struct super_block *sb)
1276 struct xfs_mount *mp = XFS_M(sb);
1278 xfs_quiesce_attr(mp);
1279 xfs_fs_log_dummy(mp);
1283 xfs_fs_show_options(
1285 struct vfsmount *mnt)
1287 return -xfs_showargs(XFS_M(mnt->mnt_sb), m);
1292 struct super_block *sb,
1295 return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XQUOTASYNC, 0, NULL);
1300 struct super_block *sb,
1301 struct fs_quota_stat *fqs)
1303 return -XFS_QM_QUOTACTL(XFS_M(sb), Q_XGETQSTAT, 0, (caddr_t)fqs);
1308 struct super_block *sb,
1312 return -XFS_QM_QUOTACTL(XFS_M(sb), op, 0, (caddr_t)&flags);
1317 struct super_block *sb,
1320 struct fs_disk_quota *fdq)
1322 return -XFS_QM_QUOTACTL(XFS_M(sb),
1323 (type == USRQUOTA) ? Q_XGETQUOTA :
1324 ((type == GRPQUOTA) ? Q_XGETGQUOTA :
1325 Q_XGETPQUOTA), id, (caddr_t)fdq);
1330 struct super_block *sb,
1333 struct fs_disk_quota *fdq)
1335 return -XFS_QM_QUOTACTL(XFS_M(sb),
1336 (type == USRQUOTA) ? Q_XSETQLIM :
1337 ((type == GRPQUOTA) ? Q_XSETGQLIM :
1338 Q_XSETPQLIM), id, (caddr_t)fdq);
1342 * This function fills in xfs_mount_t fields based on mount args.
1343 * Note: the superblock _has_ now been read in.
1347 struct xfs_mount *mp)
1349 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
1351 /* Fail a mount where the logbuf is smaller then the log stripe */
1352 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
1353 if (mp->m_logbsize <= 0 &&
1354 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
1355 mp->m_logbsize = mp->m_sb.sb_logsunit;
1356 } else if (mp->m_logbsize > 0 &&
1357 mp->m_logbsize < mp->m_sb.sb_logsunit) {
1359 "XFS: logbuf size must be greater than or equal to log stripe size");
1360 return XFS_ERROR(EINVAL);
1363 /* Fail a mount if the logbuf is larger than 32K */
1364 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1366 "XFS: logbuf size for version 1 logs must be 16K or 32K");
1367 return XFS_ERROR(EINVAL);
1372 * mkfs'ed attr2 will turn on attr2 mount unless explicitly
1373 * told by noattr2 to turn it off
1375 if (xfs_sb_version_hasattr2(&mp->m_sb) &&
1376 !(mp->m_flags & XFS_MOUNT_NOATTR2))
1377 mp->m_flags |= XFS_MOUNT_ATTR2;
1380 * prohibit r/w mounts of read-only filesystems
1382 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) {
1384 "XFS: cannot mount a read-only filesystem as read-write");
1385 return XFS_ERROR(EROFS);
1388 #if 0 /* shared mounts were never supported on Linux */
1390 * check for shared mount.
1392 if (ap->flags & XFSMNT_SHARED) {
1393 if (!xfs_sb_version_hasshared(&mp->m_sb))
1394 return XFS_ERROR(EINVAL);
1397 * For IRIX 6.5, shared mounts must have the shared
1398 * version bit set, have the persistent readonly
1399 * field set, must be version 0 and can only be mounted
1402 if (!ronly || !(mp->m_sb.sb_flags & XFS_SBF_READONLY) ||
1403 (mp->m_sb.sb_shared_vn != 0))
1404 return XFS_ERROR(EINVAL);
1406 mp->m_flags |= XFS_MOUNT_SHARED;
1409 * Shared XFS V0 can't deal with DMI. Return EINVAL.
1411 if (mp->m_sb.sb_shared_vn == 0 &&
1412 (mp->m_flags & XFS_MOUNT_DMAPI))
1413 return XFS_ERROR(EINVAL);
1422 struct super_block *sb,
1427 struct xfs_mount *mp = NULL;
1428 int flags = 0, error = ENOMEM;
1431 mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
1435 spin_lock_init(&mp->m_sb_lock);
1436 mutex_init(&mp->m_growlock);
1437 atomic_set(&mp->m_active_trans, 0);
1438 INIT_LIST_HEAD(&mp->m_sync_list);
1439 spin_lock_init(&mp->m_sync_lock);
1440 init_waitqueue_head(&mp->m_wait_single_sync_task);
1445 error = xfs_parseargs(mp, (char *)data, &mtpt);
1447 goto out_free_fsname;
1449 sb_min_blocksize(sb, BBSIZE);
1450 sb->s_xattr = xfs_xattr_handlers;
1451 sb->s_export_op = &xfs_export_operations;
1452 sb->s_qcop = &xfs_quotactl_operations;
1453 sb->s_op = &xfs_super_operations;
1455 error = xfs_dmops_get(mp);
1457 goto out_free_fsname;
1458 error = xfs_qmops_get(mp);
1463 flags |= XFS_MFSI_QUIET;
1465 error = xfs_open_devices(mp);
1469 if (xfs_icsb_init_counters(mp))
1470 mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB;
1472 error = xfs_readsb(mp, flags);
1474 goto out_destroy_counters;
1476 error = xfs_finish_flags(mp);
1480 error = xfs_setup_devices(mp);
1484 if (mp->m_flags & XFS_MOUNT_BARRIER)
1485 xfs_mountfs_check_barriers(mp);
1487 error = xfs_filestream_mount(mp);
1491 error = xfs_mountfs(mp);
1493 goto out_filestream_unmount;
1495 XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
1498 sb->s_magic = XFS_SB_MAGIC;
1499 sb->s_blocksize = mp->m_sb.sb_blocksize;
1500 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
1501 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
1502 sb->s_time_gran = 1;
1503 set_posix_acl_flag(sb);
1505 root = igrab(VFS_I(mp->m_rootip));
1510 if (is_bad_inode(root)) {
1514 sb->s_root = d_alloc_root(root);
1520 error = xfs_syncd_init(mp);
1526 xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
1529 out_filestream_unmount:
1530 xfs_filestream_unmount(mp);
1533 out_destroy_counters:
1534 xfs_icsb_destroy_counters(mp);
1535 xfs_close_devices(mp);
1541 xfs_free_fsname(mp);
1557 * Blow away any referenced inode in the filestreams cache.
1558 * This can and will cause log traffic as inodes go inactive
1561 xfs_filestream_unmount(mp);
1563 XFS_bflush(mp->m_ddev_targp);
1564 error = xfs_unmount_flush(mp, 0);
1573 struct file_system_type *fs_type,
1575 const char *dev_name,
1577 struct vfsmount *mnt)
1579 return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super,
1583 static struct super_operations xfs_super_operations = {
1584 .alloc_inode = xfs_fs_alloc_inode,
1585 .destroy_inode = xfs_fs_destroy_inode,
1586 .write_inode = xfs_fs_write_inode,
1587 .clear_inode = xfs_fs_clear_inode,
1588 .put_super = xfs_fs_put_super,
1589 .write_super = xfs_fs_write_super,
1590 .sync_fs = xfs_fs_sync_super,
1591 .write_super_lockfs = xfs_fs_lockfs,
1592 .statfs = xfs_fs_statfs,
1593 .remount_fs = xfs_fs_remount,
1594 .show_options = xfs_fs_show_options,
1597 static struct quotactl_ops xfs_quotactl_operations = {
1598 .quota_sync = xfs_fs_quotasync,
1599 .get_xstate = xfs_fs_getxstate,
1600 .set_xstate = xfs_fs_setxstate,
1601 .get_xquota = xfs_fs_getxquota,
1602 .set_xquota = xfs_fs_setxquota,
1605 static struct file_system_type xfs_fs_type = {
1606 .owner = THIS_MODULE,
1608 .get_sb = xfs_fs_get_sb,
1609 .kill_sb = kill_block_super,
1610 .fs_flags = FS_REQUIRES_DEV,
1614 xfs_alloc_trace_bufs(void)
1616 #ifdef XFS_ALLOC_TRACE
1617 xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL);
1618 if (!xfs_alloc_trace_buf)
1621 #ifdef XFS_BMAP_TRACE
1622 xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL);
1623 if (!xfs_bmap_trace_buf)
1624 goto out_free_alloc_trace;
1626 #ifdef XFS_BTREE_TRACE
1627 xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE,
1629 if (!xfs_allocbt_trace_buf)
1630 goto out_free_bmap_trace;
1632 xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL);
1633 if (!xfs_inobt_trace_buf)
1634 goto out_free_allocbt_trace;
1636 xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
1637 if (!xfs_bmbt_trace_buf)
1638 goto out_free_inobt_trace;
1640 #ifdef XFS_ATTR_TRACE
1641 xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
1642 if (!xfs_attr_trace_buf)
1643 goto out_free_bmbt_trace;
1645 #ifdef XFS_DIR2_TRACE
1646 xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL);
1647 if (!xfs_dir2_trace_buf)
1648 goto out_free_attr_trace;
1653 #ifdef XFS_DIR2_TRACE
1654 out_free_attr_trace:
1656 #ifdef XFS_ATTR_TRACE
1657 ktrace_free(xfs_attr_trace_buf);
1658 out_free_bmbt_trace:
1660 #ifdef XFS_BTREE_TRACE
1661 ktrace_free(xfs_bmbt_trace_buf);
1662 out_free_inobt_trace:
1663 ktrace_free(xfs_inobt_trace_buf);
1664 out_free_allocbt_trace:
1665 ktrace_free(xfs_allocbt_trace_buf);
1666 out_free_bmap_trace:
1668 #ifdef XFS_BMAP_TRACE
1669 ktrace_free(xfs_bmap_trace_buf);
1670 out_free_alloc_trace:
1672 #ifdef XFS_ALLOC_TRACE
1673 ktrace_free(xfs_alloc_trace_buf);
1680 xfs_free_trace_bufs(void)
1682 #ifdef XFS_DIR2_TRACE
1683 ktrace_free(xfs_dir2_trace_buf);
1685 #ifdef XFS_ATTR_TRACE
1686 ktrace_free(xfs_attr_trace_buf);
1688 #ifdef XFS_BTREE_TRACE
1689 ktrace_free(xfs_bmbt_trace_buf);
1690 ktrace_free(xfs_inobt_trace_buf);
1691 ktrace_free(xfs_allocbt_trace_buf);
1693 #ifdef XFS_BMAP_TRACE
1694 ktrace_free(xfs_bmap_trace_buf);
1696 #ifdef XFS_ALLOC_TRACE
1697 ktrace_free(xfs_alloc_trace_buf);
1702 xfs_init_zones(void)
1705 xfs_ioend_zone = kmem_zone_init(sizeof(xfs_ioend_t), "xfs_ioend");
1706 if (!xfs_ioend_zone)
1709 xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
1711 if (!xfs_ioend_pool)
1712 goto out_destroy_ioend_zone;
1714 xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
1716 if (!xfs_log_ticket_zone)
1717 goto out_destroy_ioend_pool;
1719 xfs_bmap_free_item_zone = kmem_zone_init(sizeof(xfs_bmap_free_item_t),
1720 "xfs_bmap_free_item");
1721 if (!xfs_bmap_free_item_zone)
1722 goto out_destroy_log_ticket_zone;
1724 xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
1726 if (!xfs_btree_cur_zone)
1727 goto out_destroy_bmap_free_item_zone;
1729 xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
1731 if (!xfs_da_state_zone)
1732 goto out_destroy_btree_cur_zone;
1734 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
1735 if (!xfs_dabuf_zone)
1736 goto out_destroy_da_state_zone;
1738 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
1739 if (!xfs_ifork_zone)
1740 goto out_destroy_dabuf_zone;
1742 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
1743 if (!xfs_trans_zone)
1744 goto out_destroy_ifork_zone;
1747 * The size of the zone allocated buf log item is the maximum
1748 * size possible under XFS. This wastes a little bit of memory,
1749 * but it is much faster.
1751 xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) +
1752 (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
1753 NBWORD) * sizeof(int))), "xfs_buf_item");
1754 if (!xfs_buf_item_zone)
1755 goto out_destroy_trans_zone;
1757 xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
1758 ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
1759 sizeof(xfs_extent_t))), "xfs_efd_item");
1761 goto out_destroy_buf_item_zone;
1763 xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
1764 ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
1765 sizeof(xfs_extent_t))), "xfs_efi_item");
1767 goto out_destroy_efd_zone;
1770 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
1771 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD,
1772 xfs_fs_inode_init_once);
1773 if (!xfs_inode_zone)
1774 goto out_destroy_efi_zone;
1777 kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
1778 KM_ZONE_SPREAD, NULL);
1780 goto out_destroy_inode_zone;
1782 #ifdef CONFIG_XFS_POSIX_ACL
1783 xfs_acl_zone = kmem_zone_init(sizeof(xfs_acl_t), "xfs_acl");
1785 goto out_destroy_ili_zone;
1790 #ifdef CONFIG_XFS_POSIX_ACL
1791 out_destroy_ili_zone:
1793 kmem_zone_destroy(xfs_ili_zone);
1794 out_destroy_inode_zone:
1795 kmem_zone_destroy(xfs_inode_zone);
1796 out_destroy_efi_zone:
1797 kmem_zone_destroy(xfs_efi_zone);
1798 out_destroy_efd_zone:
1799 kmem_zone_destroy(xfs_efd_zone);
1800 out_destroy_buf_item_zone:
1801 kmem_zone_destroy(xfs_buf_item_zone);
1802 out_destroy_trans_zone:
1803 kmem_zone_destroy(xfs_trans_zone);
1804 out_destroy_ifork_zone:
1805 kmem_zone_destroy(xfs_ifork_zone);
1806 out_destroy_dabuf_zone:
1807 kmem_zone_destroy(xfs_dabuf_zone);
1808 out_destroy_da_state_zone:
1809 kmem_zone_destroy(xfs_da_state_zone);
1810 out_destroy_btree_cur_zone:
1811 kmem_zone_destroy(xfs_btree_cur_zone);
1812 out_destroy_bmap_free_item_zone:
1813 kmem_zone_destroy(xfs_bmap_free_item_zone);
1814 out_destroy_log_ticket_zone:
1815 kmem_zone_destroy(xfs_log_ticket_zone);
1816 out_destroy_ioend_pool:
1817 mempool_destroy(xfs_ioend_pool);
1818 out_destroy_ioend_zone:
1819 kmem_zone_destroy(xfs_ioend_zone);
1825 xfs_destroy_zones(void)
1827 #ifdef CONFIG_XFS_POSIX_ACL
1828 kmem_zone_destroy(xfs_acl_zone);
1830 kmem_zone_destroy(xfs_ili_zone);
1831 kmem_zone_destroy(xfs_inode_zone);
1832 kmem_zone_destroy(xfs_efi_zone);
1833 kmem_zone_destroy(xfs_efd_zone);
1834 kmem_zone_destroy(xfs_buf_item_zone);
1835 kmem_zone_destroy(xfs_trans_zone);
1836 kmem_zone_destroy(xfs_ifork_zone);
1837 kmem_zone_destroy(xfs_dabuf_zone);
1838 kmem_zone_destroy(xfs_da_state_zone);
1839 kmem_zone_destroy(xfs_btree_cur_zone);
1840 kmem_zone_destroy(xfs_bmap_free_item_zone);
1841 kmem_zone_destroy(xfs_log_ticket_zone);
1842 mempool_destroy(xfs_ioend_pool);
1843 kmem_zone_destroy(xfs_ioend_zone);
1851 static char message[] __initdata = KERN_INFO \
1852 XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
1860 error = xfs_init_zones();
1864 error = xfs_alloc_trace_bufs();
1866 goto out_destroy_zones;
1868 error = xfs_mru_cache_init();
1870 goto out_free_trace_buffers;
1872 error = xfs_filestream_init();
1874 goto out_mru_cache_uninit;
1876 error = xfs_buf_init();
1878 goto out_filestream_uninit;
1880 error = xfs_init_procfs();
1882 goto out_buf_terminate;
1884 error = xfs_sysctl_register();
1886 goto out_cleanup_procfs;
1890 error = register_filesystem(&xfs_fs_type);
1892 goto out_sysctl_unregister;
1895 out_sysctl_unregister:
1896 xfs_sysctl_unregister();
1898 xfs_cleanup_procfs();
1900 xfs_buf_terminate();
1901 out_filestream_uninit:
1902 xfs_filestream_uninit();
1903 out_mru_cache_uninit:
1904 xfs_mru_cache_uninit();
1905 out_free_trace_buffers:
1906 xfs_free_trace_bufs();
1908 xfs_destroy_zones();
1917 unregister_filesystem(&xfs_fs_type);
1918 xfs_sysctl_unregister();
1919 xfs_cleanup_procfs();
1920 xfs_buf_terminate();
1921 xfs_filestream_uninit();
1922 xfs_mru_cache_uninit();
1923 xfs_free_trace_bufs();
1924 xfs_destroy_zones();
1928 module_init(init_xfs_fs);
1929 module_exit(exit_xfs_fs);
1931 MODULE_AUTHOR("Silicon Graphics, Inc.");
1932 MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
1933 MODULE_LICENSE("GPL");