1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
8 #include "xfs_shared.h"
9 #include "xfs_format.h"
10 #include "xfs_log_format.h"
11 #include "xfs_trans_resv.h"
13 #include "xfs_mount.h"
14 #include "xfs_inode.h"
15 #include "xfs_btree.h"
17 #include "xfs_alloc.h"
18 #include "xfs_fsops.h"
19 #include "xfs_trans.h"
20 #include "xfs_buf_item.h"
22 #include "xfs_log_priv.h"
24 #include "xfs_extfree_item.h"
25 #include "xfs_mru_cache.h"
26 #include "xfs_inode_item.h"
27 #include "xfs_icache.h"
28 #include "xfs_trace.h"
29 #include "xfs_icreate_item.h"
30 #include "xfs_filestream.h"
31 #include "xfs_quota.h"
32 #include "xfs_sysfs.h"
33 #include "xfs_ondisk.h"
34 #include "xfs_rmap_item.h"
35 #include "xfs_refcount_item.h"
36 #include "xfs_bmap_item.h"
37 #include "xfs_reflink.h"
38 #include "xfs_pwork.h"
40 #include "xfs_defer.h"
41 #include "xfs_attr_item.h"
42 #include "xfs_xattr.h"
43 #include "xfs_iunlink_item.h"
44 #include "xfs_dahash_test.h"
45 #include "scrub/stats.h"
47 #include <linux/magic.h>
48 #include <linux/fs_context.h>
49 #include <linux/fs_parser.h>
51 static const struct super_operations xfs_super_operations;
53 static struct dentry *xfs_debugfs; /* top-level xfs debugfs dir */
54 static struct kset *xfs_kset; /* top-level xfs sysfs dir */
56 static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
66 xfs_mount_set_dax_mode(
68 enum xfs_dax_mode mode)
72 mp->m_features &= ~(XFS_FEAT_DAX_ALWAYS | XFS_FEAT_DAX_NEVER);
75 mp->m_features |= XFS_FEAT_DAX_ALWAYS;
76 mp->m_features &= ~XFS_FEAT_DAX_NEVER;
79 mp->m_features |= XFS_FEAT_DAX_NEVER;
80 mp->m_features &= ~XFS_FEAT_DAX_ALWAYS;
85 static const struct constant_table dax_param_enums[] = {
86 {"inode", XFS_DAX_INODE },
87 {"always", XFS_DAX_ALWAYS },
88 {"never", XFS_DAX_NEVER },
93 * Table driven mount option parser.
96 Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev,
97 Opt_wsync, Opt_noalign, Opt_swalloc, Opt_sunit, Opt_swidth, Opt_nouuid,
98 Opt_grpid, Opt_nogrpid, Opt_bsdgroups, Opt_sysvgroups,
99 Opt_allocsize, Opt_norecovery, Opt_inode64, Opt_inode32, Opt_ikeep,
100 Opt_noikeep, Opt_largeio, Opt_nolargeio, Opt_attr2, Opt_noattr2,
101 Opt_filestreams, Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota,
102 Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota,
103 Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce,
104 Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum,
107 static const struct fs_parameter_spec xfs_fs_parameters[] = {
108 fsparam_u32("logbufs", Opt_logbufs),
109 fsparam_string("logbsize", Opt_logbsize),
110 fsparam_string("logdev", Opt_logdev),
111 fsparam_string("rtdev", Opt_rtdev),
112 fsparam_flag("wsync", Opt_wsync),
113 fsparam_flag("noalign", Opt_noalign),
114 fsparam_flag("swalloc", Opt_swalloc),
115 fsparam_u32("sunit", Opt_sunit),
116 fsparam_u32("swidth", Opt_swidth),
117 fsparam_flag("nouuid", Opt_nouuid),
118 fsparam_flag("grpid", Opt_grpid),
119 fsparam_flag("nogrpid", Opt_nogrpid),
120 fsparam_flag("bsdgroups", Opt_bsdgroups),
121 fsparam_flag("sysvgroups", Opt_sysvgroups),
122 fsparam_string("allocsize", Opt_allocsize),
123 fsparam_flag("norecovery", Opt_norecovery),
124 fsparam_flag("inode64", Opt_inode64),
125 fsparam_flag("inode32", Opt_inode32),
126 fsparam_flag("ikeep", Opt_ikeep),
127 fsparam_flag("noikeep", Opt_noikeep),
128 fsparam_flag("largeio", Opt_largeio),
129 fsparam_flag("nolargeio", Opt_nolargeio),
130 fsparam_flag("attr2", Opt_attr2),
131 fsparam_flag("noattr2", Opt_noattr2),
132 fsparam_flag("filestreams", Opt_filestreams),
133 fsparam_flag("quota", Opt_quota),
134 fsparam_flag("noquota", Opt_noquota),
135 fsparam_flag("usrquota", Opt_usrquota),
136 fsparam_flag("grpquota", Opt_grpquota),
137 fsparam_flag("prjquota", Opt_prjquota),
138 fsparam_flag("uquota", Opt_uquota),
139 fsparam_flag("gquota", Opt_gquota),
140 fsparam_flag("pquota", Opt_pquota),
141 fsparam_flag("uqnoenforce", Opt_uqnoenforce),
142 fsparam_flag("gqnoenforce", Opt_gqnoenforce),
143 fsparam_flag("pqnoenforce", Opt_pqnoenforce),
144 fsparam_flag("qnoenforce", Opt_qnoenforce),
145 fsparam_flag("discard", Opt_discard),
146 fsparam_flag("nodiscard", Opt_nodiscard),
147 fsparam_flag("dax", Opt_dax),
148 fsparam_enum("dax", Opt_dax_enum, dax_param_enums),
152 struct proc_xfs_info {
162 static struct proc_xfs_info xfs_info_set[] = {
163 /* the few simple ones we can get from the mount struct */
164 { XFS_FEAT_IKEEP, ",ikeep" },
165 { XFS_FEAT_WSYNC, ",wsync" },
166 { XFS_FEAT_NOALIGN, ",noalign" },
167 { XFS_FEAT_SWALLOC, ",swalloc" },
168 { XFS_FEAT_NOUUID, ",nouuid" },
169 { XFS_FEAT_NORECOVERY, ",norecovery" },
170 { XFS_FEAT_ATTR2, ",attr2" },
171 { XFS_FEAT_FILESTREAMS, ",filestreams" },
172 { XFS_FEAT_GRPID, ",grpid" },
173 { XFS_FEAT_DISCARD, ",discard" },
174 { XFS_FEAT_LARGE_IOSIZE, ",largeio" },
175 { XFS_FEAT_DAX_ALWAYS, ",dax=always" },
176 { XFS_FEAT_DAX_NEVER, ",dax=never" },
179 struct xfs_mount *mp = XFS_M(root->d_sb);
180 struct proc_xfs_info *xfs_infop;
182 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
183 if (mp->m_features & xfs_infop->flag)
184 seq_puts(m, xfs_infop->str);
187 seq_printf(m, ",inode%d", xfs_has_small_inums(mp) ? 32 : 64);
189 if (xfs_has_allocsize(mp))
190 seq_printf(m, ",allocsize=%dk",
191 (1 << mp->m_allocsize_log) >> 10);
193 if (mp->m_logbufs > 0)
194 seq_printf(m, ",logbufs=%d", mp->m_logbufs);
195 if (mp->m_logbsize > 0)
196 seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10);
199 seq_show_option(m, "logdev", mp->m_logname);
201 seq_show_option(m, "rtdev", mp->m_rtname);
203 if (mp->m_dalign > 0)
204 seq_printf(m, ",sunit=%d",
205 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
206 if (mp->m_swidth > 0)
207 seq_printf(m, ",swidth=%d",
208 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
210 if (mp->m_qflags & XFS_UQUOTA_ENFD)
211 seq_puts(m, ",usrquota");
212 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
213 seq_puts(m, ",uqnoenforce");
215 if (mp->m_qflags & XFS_PQUOTA_ENFD)
216 seq_puts(m, ",prjquota");
217 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
218 seq_puts(m, ",pqnoenforce");
220 if (mp->m_qflags & XFS_GQUOTA_ENFD)
221 seq_puts(m, ",grpquota");
222 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
223 seq_puts(m, ",gqnoenforce");
225 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
226 seq_puts(m, ",noquota");
232 xfs_set_inode_alloc_perag(
233 struct xfs_perag *pag,
235 xfs_agnumber_t max_metadata)
237 if (!xfs_is_inode32(pag->pag_mount)) {
238 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
239 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
243 if (ino > XFS_MAXINUMBER_32) {
244 clear_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
245 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
249 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
250 if (pag->pag_agno < max_metadata)
251 set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
253 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
258 * Set parameters for inode allocation heuristics, taking into account
259 * filesystem size and inode32/inode64 mount options; i.e. specifically
260 * whether or not XFS_FEAT_SMALL_INUMS is set.
262 * Inode allocation patterns are altered only if inode32 is requested
263 * (XFS_FEAT_SMALL_INUMS), and the filesystem is sufficiently large.
264 * If altered, XFS_OPSTATE_INODE32 is set as well.
266 * An agcount independent of that in the mount structure is provided
267 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
268 * to the potentially higher ag count.
270 * Returns the maximum AG index which may contain inodes.
274 struct xfs_mount *mp,
275 xfs_agnumber_t agcount)
277 xfs_agnumber_t index;
278 xfs_agnumber_t maxagi = 0;
279 xfs_sb_t *sbp = &mp->m_sb;
280 xfs_agnumber_t max_metadata;
285 * Calculate how much should be reserved for inodes to meet
286 * the max inode percentage. Used only for inode32.
288 if (M_IGEO(mp)->maxicount) {
291 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
293 icount += sbp->sb_agblocks - 1;
294 do_div(icount, sbp->sb_agblocks);
295 max_metadata = icount;
297 max_metadata = agcount;
300 /* Get the last possible inode in the filesystem */
301 agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1);
302 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino);
305 * If user asked for no more than 32-bit inodes, and the fs is
306 * sufficiently large, set XFS_OPSTATE_INODE32 if we must alter
307 * the allocator to accommodate the request.
309 if (xfs_has_small_inums(mp) && ino > XFS_MAXINUMBER_32)
310 set_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
312 clear_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
314 for (index = 0; index < agcount; index++) {
315 struct xfs_perag *pag;
317 ino = XFS_AGINO_TO_INO(mp, index, agino);
319 pag = xfs_perag_get(mp, index);
320 if (xfs_set_inode_alloc_perag(pag, ino, max_metadata))
325 return xfs_is_inode32(mp) ? maxagi : agcount;
329 xfs_setup_dax_always(
330 struct xfs_mount *mp)
332 if (!mp->m_ddev_targp->bt_daxdev &&
333 (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) {
335 "DAX unsupported by block device. Turning off DAX.");
339 if (mp->m_super->s_blocksize != PAGE_SIZE) {
341 "DAX not supported for blocksize. Turning off DAX.");
345 if (xfs_has_reflink(mp) &&
346 bdev_is_partition(mp->m_ddev_targp->bt_bdev)) {
348 "DAX and reflink cannot work with multi-partitions!");
352 xfs_warn(mp, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
356 xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
364 struct block_device **bdevp)
368 *bdevp = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE,
369 mp->m_super, &fs_holder_ops);
370 if (IS_ERR(*bdevp)) {
371 error = PTR_ERR(*bdevp);
372 xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
379 xfs_shutdown_devices(
380 struct xfs_mount *mp)
383 * Udev is triggered whenever anyone closes a block device or unmounts
384 * a file systemm on a block device.
385 * The default udev rules invoke blkid to read the fs super and create
386 * symlinks to the bdev under /dev/disk. For this, it uses buffered
387 * reads through the page cache.
389 * xfs_db also uses buffered reads to examine metadata. There is no
390 * coordination between xfs_db and udev, which means that they can run
391 * concurrently. Note there is no coordination between the kernel and
394 * On a system with 64k pages, the page cache can cache the superblock
395 * and the root inode (and hence the root directory) with the same 64k
396 * page. If udev spawns blkid after the mkfs and the system is busy
397 * enough that it is still running when xfs_db starts up, they'll both
398 * read from the same page in the pagecache.
400 * The unmount writes updated inode metadata to disk directly. The XFS
401 * buffer cache does not use the bdev pagecache, so it needs to
402 * invalidate that pagecache on unmount. If the above scenario occurs,
403 * the pagecache no longer reflects what's on disk, xfs_db reads the
404 * stale metadata, and fails to find /a. Most of the time this succeeds
405 * because closing a bdev invalidates the page cache, but when processes
406 * race, everyone loses.
408 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
409 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev);
410 invalidate_bdev(mp->m_logdev_targp->bt_bdev);
412 if (mp->m_rtdev_targp) {
413 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev);
414 invalidate_bdev(mp->m_rtdev_targp->bt_bdev);
416 blkdev_issue_flush(mp->m_ddev_targp->bt_bdev);
417 invalidate_bdev(mp->m_ddev_targp->bt_bdev);
421 * The file system configurations are:
422 * (1) device (partition) with data and internal log
423 * (2) logical volume with data and log subvolumes.
424 * (3) logical volume with data, log, and realtime subvolumes.
426 * We only have to handle opening the log and realtime volumes here if
427 * they are present. The data subvolume has already been opened by
428 * get_sb_bdev() and is stored in sb->s_bdev.
432 struct xfs_mount *mp)
434 struct super_block *sb = mp->m_super;
435 struct block_device *ddev = sb->s_bdev;
436 struct block_device *logdev = NULL, *rtdev = NULL;
440 * blkdev_put() can't be called under s_umount, see the comment
441 * in get_tree_bdev() for more details
443 up_write(&sb->s_umount);
446 * Open real time and log devices - order is important.
449 error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
455 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
457 goto out_close_logdev;
459 if (rtdev == ddev || rtdev == logdev) {
461 "Cannot mount filesystem with identical rtdev and ddev/logdev.");
463 goto out_close_rtdev;
468 * Setup xfs_mount buffer target pointers
471 mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev);
472 if (!mp->m_ddev_targp)
473 goto out_close_rtdev;
476 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev);
477 if (!mp->m_rtdev_targp)
478 goto out_free_ddev_targ;
481 if (logdev && logdev != ddev) {
482 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev);
483 if (!mp->m_logdev_targp)
484 goto out_free_rtdev_targ;
486 mp->m_logdev_targp = mp->m_ddev_targp;
491 down_write(&sb->s_umount);
495 if (mp->m_rtdev_targp)
496 xfs_free_buftarg(mp->m_rtdev_targp);
498 xfs_free_buftarg(mp->m_ddev_targp);
501 blkdev_put(rtdev, sb);
503 if (logdev && logdev != ddev)
504 blkdev_put(logdev, sb);
509 * Setup xfs_mount buffer target pointers based on superblock
513 struct xfs_mount *mp)
517 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize);
521 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
522 unsigned int log_sector_size = BBSIZE;
524 if (xfs_has_sector(mp))
525 log_sector_size = mp->m_sb.sb_logsectsize;
526 error = xfs_setsize_buftarg(mp->m_logdev_targp,
531 if (mp->m_rtdev_targp) {
532 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
533 mp->m_sb.sb_sectsize);
542 xfs_init_mount_workqueues(
543 struct xfs_mount *mp)
545 mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
546 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
547 1, mp->m_super->s_id);
548 if (!mp->m_buf_workqueue)
551 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
552 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
553 0, mp->m_super->s_id);
554 if (!mp->m_unwritten_workqueue)
555 goto out_destroy_buf;
557 mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s",
558 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
559 0, mp->m_super->s_id);
560 if (!mp->m_reclaim_workqueue)
561 goto out_destroy_unwritten;
563 mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s",
564 XFS_WQFLAGS(WQ_UNBOUND | WQ_FREEZABLE | WQ_MEM_RECLAIM),
565 0, mp->m_super->s_id);
566 if (!mp->m_blockgc_wq)
567 goto out_destroy_reclaim;
569 mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s",
570 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
571 1, mp->m_super->s_id);
572 if (!mp->m_inodegc_wq)
573 goto out_destroy_blockgc;
575 mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s",
576 XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id);
577 if (!mp->m_sync_workqueue)
578 goto out_destroy_inodegc;
583 destroy_workqueue(mp->m_inodegc_wq);
585 destroy_workqueue(mp->m_blockgc_wq);
587 destroy_workqueue(mp->m_reclaim_workqueue);
588 out_destroy_unwritten:
589 destroy_workqueue(mp->m_unwritten_workqueue);
591 destroy_workqueue(mp->m_buf_workqueue);
597 xfs_destroy_mount_workqueues(
598 struct xfs_mount *mp)
600 destroy_workqueue(mp->m_sync_workqueue);
601 destroy_workqueue(mp->m_blockgc_wq);
602 destroy_workqueue(mp->m_inodegc_wq);
603 destroy_workqueue(mp->m_reclaim_workqueue);
604 destroy_workqueue(mp->m_unwritten_workqueue);
605 destroy_workqueue(mp->m_buf_workqueue);
609 xfs_flush_inodes_worker(
610 struct work_struct *work)
612 struct xfs_mount *mp = container_of(work, struct xfs_mount,
613 m_flush_inodes_work);
614 struct super_block *sb = mp->m_super;
616 if (down_read_trylock(&sb->s_umount)) {
618 up_read(&sb->s_umount);
623 * Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK
624 * or a page lock. We use sync_inodes_sb() here to ensure we block while waiting
625 * for IO to complete so that we effectively throttle multiple callers to the
626 * rate at which IO is completing.
630 struct xfs_mount *mp)
633 * If flush_work() returns true then that means we waited for a flush
634 * which was already in progress. Don't bother running another scan.
636 if (flush_work(&mp->m_flush_inodes_work))
639 queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work);
640 flush_work(&mp->m_flush_inodes_work);
643 /* Catch misguided souls that try to use this interface on XFS */
644 STATIC struct inode *
646 struct super_block *sb)
653 * Now that the generic code is guaranteed not to be accessing
654 * the linux inode, we can inactivate and reclaim the inode.
657 xfs_fs_destroy_inode(
660 struct xfs_inode *ip = XFS_I(inode);
662 trace_xfs_destroy_inode(ip);
664 ASSERT(!rwsem_is_locked(&inode->i_rwsem));
665 XFS_STATS_INC(ip->i_mount, vn_rele);
666 XFS_STATS_INC(ip->i_mount, vn_remove);
667 xfs_inode_mark_reclaimable(ip);
675 struct xfs_inode *ip = XFS_I(inode);
676 struct xfs_mount *mp = ip->i_mount;
677 struct xfs_trans *tp;
679 if (!(inode->i_sb->s_flags & SB_LAZYTIME))
683 * Only do the timestamp update if the inode is dirty (I_DIRTY_SYNC)
684 * and has dirty timestamp (I_DIRTY_TIME). I_DIRTY_TIME can be passed
685 * in flags possibly together with I_DIRTY_SYNC.
687 if ((flags & ~I_DIRTY_TIME) != I_DIRTY_SYNC || !(flags & I_DIRTY_TIME))
690 if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp))
692 xfs_ilock(ip, XFS_ILOCK_EXCL);
693 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
694 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
695 xfs_trans_commit(tp);
699 * Slab object creation initialisation for the XFS inode.
700 * This covers only the idempotent fields in the XFS inode;
701 * all other fields need to be initialised on allocation
702 * from the slab. This avoids the need to repeatedly initialise
703 * fields in the xfs inode that left in the initialise state
704 * when freeing the inode.
707 xfs_fs_inode_init_once(
710 struct xfs_inode *ip = inode;
712 memset(ip, 0, sizeof(struct xfs_inode));
715 inode_init_once(VFS_I(ip));
718 atomic_set(&ip->i_pincount, 0);
719 spin_lock_init(&ip->i_flags_lock);
721 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
722 "xfsino", ip->i_ino);
726 * We do an unlocked check for XFS_IDONTCACHE here because we are already
727 * serialised against cache hits here via the inode->i_lock and igrab() in
728 * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
729 * racing with us, and it avoids needing to grab a spinlock here for every inode
730 * we drop the final reference on.
736 struct xfs_inode *ip = XFS_I(inode);
739 * If this unlinked inode is in the middle of recovery, don't
740 * drop the inode just yet; log recovery will take care of
741 * that. See the comment for this inode flag.
743 if (ip->i_flags & XFS_IRECOVERY) {
744 ASSERT(xlog_recovery_needed(ip->i_mount->m_log));
748 return generic_drop_inode(inode);
753 struct xfs_mount *mp)
756 * Free the buftargs here because blkdev_put needs to be called outside
757 * of sb->s_umount, which is held around the call to ->put_super.
759 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
760 xfs_free_buftarg(mp->m_logdev_targp);
761 if (mp->m_rtdev_targp)
762 xfs_free_buftarg(mp->m_rtdev_targp);
763 if (mp->m_ddev_targp)
764 xfs_free_buftarg(mp->m_ddev_targp);
766 debugfs_remove(mp->m_debugfs);
768 kfree(mp->m_logname);
774 struct super_block *sb,
777 struct xfs_mount *mp = XFS_M(sb);
780 trace_xfs_fs_sync_fs(mp, __return_address);
783 * Doing anything during the async pass would be counterproductive.
788 error = xfs_log_force(mp, XFS_LOG_SYNC);
794 * The disk must be active because we're syncing.
795 * We schedule log work now (now that the disk is
796 * active) instead of later (when it might not be).
798 flush_delayed_work(&mp->m_log->l_work);
802 * If we are called with page faults frozen out, it means we are about
803 * to freeze the transaction subsystem. Take the opportunity to shut
804 * down inodegc because once SB_FREEZE_FS is set it's too late to
805 * prevent inactivation races with freeze. The fs doesn't get called
806 * again by the freezing process until after SB_FREEZE_FS has been set,
807 * so it's now or never. Same logic applies to speculative allocation
808 * garbage collection.
810 * We don't care if this is a normal syncfs call that does this or
811 * freeze that does this - we can run this multiple times without issue
812 * and we won't race with a restart because a restart can only occur
813 * when the state is either SB_FREEZE_FS or SB_FREEZE_COMPLETE.
815 if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) {
816 xfs_inodegc_stop(mp);
817 xfs_blockgc_stop(mp);
825 struct dentry *dentry,
826 struct kstatfs *statp)
828 struct xfs_mount *mp = XFS_M(dentry->d_sb);
829 xfs_sb_t *sbp = &mp->m_sb;
830 struct xfs_inode *ip = XFS_I(d_inode(dentry));
831 uint64_t fakeinos, id;
839 * Expedite background inodegc but don't wait. We do not want to block
840 * here waiting hours for a billion extent file to be truncated.
842 xfs_inodegc_push(mp);
844 statp->f_type = XFS_SUPER_MAGIC;
845 statp->f_namelen = MAXNAMELEN - 1;
847 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
848 statp->f_fsid = u64_to_fsid(id);
850 icount = percpu_counter_sum(&mp->m_icount);
851 ifree = percpu_counter_sum(&mp->m_ifree);
852 fdblocks = percpu_counter_sum(&mp->m_fdblocks);
854 spin_lock(&mp->m_sb_lock);
855 statp->f_bsize = sbp->sb_blocksize;
856 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
857 statp->f_blocks = sbp->sb_dblocks - lsize;
858 spin_unlock(&mp->m_sb_lock);
860 /* make sure statp->f_bfree does not underflow */
861 statp->f_bfree = max_t(int64_t, 0,
862 fdblocks - xfs_fdblocks_unavailable(mp));
863 statp->f_bavail = statp->f_bfree;
865 fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);
866 statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
867 if (M_IGEO(mp)->maxicount)
868 statp->f_files = min_t(typeof(statp->f_files),
870 M_IGEO(mp)->maxicount);
872 /* If sb_icount overshot maxicount, report actual allocation */
873 statp->f_files = max_t(typeof(statp->f_files),
877 /* make sure statp->f_ffree does not underflow */
878 ffree = statp->f_files - (icount - ifree);
879 statp->f_ffree = max_t(int64_t, ffree, 0);
882 if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
883 ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
884 (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
885 xfs_qm_statvfs(ip, statp);
887 if (XFS_IS_REALTIME_MOUNT(mp) &&
888 (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
891 statp->f_blocks = sbp->sb_rblocks;
892 freertx = percpu_counter_sum_positive(&mp->m_frextents);
893 statp->f_bavail = statp->f_bfree = freertx * sbp->sb_rextsize;
900 xfs_save_resvblks(struct xfs_mount *mp)
902 uint64_t resblks = 0;
904 mp->m_resblks_save = mp->m_resblks;
905 xfs_reserve_blocks(mp, &resblks, NULL);
909 xfs_restore_resvblks(struct xfs_mount *mp)
913 if (mp->m_resblks_save) {
914 resblks = mp->m_resblks_save;
915 mp->m_resblks_save = 0;
917 resblks = xfs_default_resblks(mp);
919 xfs_reserve_blocks(mp, &resblks, NULL);
923 * Second stage of a freeze. The data is already frozen so we only
924 * need to take care of the metadata. Once that's done sync the superblock
925 * to the log to dirty it in case of a crash while frozen. This ensures that we
926 * will recover the unlinked inode lists on the next mount.
930 struct super_block *sb)
932 struct xfs_mount *mp = XFS_M(sb);
937 * The filesystem is now frozen far enough that memory reclaim
938 * cannot safely operate on the filesystem. Hence we need to
939 * set a GFP_NOFS context here to avoid recursion deadlocks.
941 flags = memalloc_nofs_save();
942 xfs_save_resvblks(mp);
943 ret = xfs_log_quiesce(mp);
944 memalloc_nofs_restore(flags);
947 * For read-write filesystems, we need to restart the inodegc on error
948 * because we stopped it at SB_FREEZE_PAGEFAULT level and a thaw is not
949 * going to be run to restart it now. We are at SB_FREEZE_FS level
950 * here, so we can restart safely without racing with a stop in
953 if (ret && !xfs_is_readonly(mp)) {
954 xfs_blockgc_start(mp);
955 xfs_inodegc_start(mp);
963 struct super_block *sb)
965 struct xfs_mount *mp = XFS_M(sb);
967 xfs_restore_resvblks(mp);
968 xfs_log_work_queue(mp);
971 * Don't reactivate the inodegc worker on a readonly filesystem because
972 * inodes are sent directly to reclaim. Don't reactivate the blockgc
973 * worker because there are no speculative preallocations on a readonly
976 if (!xfs_is_readonly(mp)) {
977 xfs_blockgc_start(mp);
978 xfs_inodegc_start(mp);
985 * This function fills in xfs_mount_t fields based on mount args.
986 * Note: the superblock _has_ now been read in.
990 struct xfs_mount *mp)
992 /* Fail a mount where the logbuf is smaller than the log stripe */
993 if (xfs_has_logv2(mp)) {
994 if (mp->m_logbsize <= 0 &&
995 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
996 mp->m_logbsize = mp->m_sb.sb_logsunit;
997 } else if (mp->m_logbsize > 0 &&
998 mp->m_logbsize < mp->m_sb.sb_logsunit) {
1000 "logbuf size must be greater than or equal to log stripe size");
1004 /* Fail a mount if the logbuf is larger than 32K */
1005 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1007 "logbuf size for version 1 logs must be 16K or 32K");
1013 * V5 filesystems always use attr2 format for attributes.
1015 if (xfs_has_crc(mp) && xfs_has_noattr2(mp)) {
1016 xfs_warn(mp, "Cannot mount a V5 filesystem as noattr2. "
1017 "attr2 is always enabled for V5 filesystems.");
1022 * prohibit r/w mounts of read-only filesystems
1024 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) {
1026 "cannot mount a read-only filesystem as read-write");
1030 if ((mp->m_qflags & XFS_GQUOTA_ACCT) &&
1031 (mp->m_qflags & XFS_PQUOTA_ACCT) &&
1032 !xfs_has_pquotino(mp)) {
1034 "Super block does not support project and group quota together");
1042 xfs_init_percpu_counters(
1043 struct xfs_mount *mp)
1047 error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL);
1051 error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL);
1055 error = percpu_counter_init(&mp->m_fdblocks, 0, GFP_KERNEL);
1059 error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL);
1063 error = percpu_counter_init(&mp->m_frextents, 0, GFP_KERNEL);
1070 percpu_counter_destroy(&mp->m_delalloc_blks);
1072 percpu_counter_destroy(&mp->m_fdblocks);
1074 percpu_counter_destroy(&mp->m_ifree);
1076 percpu_counter_destroy(&mp->m_icount);
1081 xfs_reinit_percpu_counters(
1082 struct xfs_mount *mp)
1084 percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount);
1085 percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree);
1086 percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks);
1087 percpu_counter_set(&mp->m_frextents, mp->m_sb.sb_frextents);
1091 xfs_destroy_percpu_counters(
1092 struct xfs_mount *mp)
1094 percpu_counter_destroy(&mp->m_icount);
1095 percpu_counter_destroy(&mp->m_ifree);
1096 percpu_counter_destroy(&mp->m_fdblocks);
1097 ASSERT(xfs_is_shutdown(mp) ||
1098 percpu_counter_sum(&mp->m_delalloc_blks) == 0);
1099 percpu_counter_destroy(&mp->m_delalloc_blks);
1100 percpu_counter_destroy(&mp->m_frextents);
1104 xfs_inodegc_init_percpu(
1105 struct xfs_mount *mp)
1107 struct xfs_inodegc *gc;
1110 mp->m_inodegc = alloc_percpu(struct xfs_inodegc);
1114 for_each_possible_cpu(cpu) {
1115 gc = per_cpu_ptr(mp->m_inodegc, cpu);
1118 init_llist_head(&gc->list);
1121 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker);
1127 xfs_inodegc_free_percpu(
1128 struct xfs_mount *mp)
1132 free_percpu(mp->m_inodegc);
1137 struct super_block *sb)
1139 struct xfs_mount *mp = XFS_M(sb);
1141 xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid);
1142 xfs_filestream_unmount(mp);
1146 xchk_mount_stats_free(mp);
1147 free_percpu(mp->m_stats.xs_stats);
1148 xfs_inodegc_free_percpu(mp);
1149 xfs_destroy_percpu_counters(mp);
1150 xfs_destroy_mount_workqueues(mp);
1151 xfs_shutdown_devices(mp);
1155 xfs_fs_nr_cached_objects(
1156 struct super_block *sb,
1157 struct shrink_control *sc)
1159 /* Paranoia: catch incorrect calls during mount setup or teardown */
1160 if (WARN_ON_ONCE(!sb->s_fs_info))
1162 return xfs_reclaim_inodes_count(XFS_M(sb));
1166 xfs_fs_free_cached_objects(
1167 struct super_block *sb,
1168 struct shrink_control *sc)
1170 return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan);
1175 struct super_block *sb)
1177 xfs_force_shutdown(XFS_M(sb), SHUTDOWN_DEVICE_REMOVED);
1180 static const struct super_operations xfs_super_operations = {
1181 .alloc_inode = xfs_fs_alloc_inode,
1182 .destroy_inode = xfs_fs_destroy_inode,
1183 .dirty_inode = xfs_fs_dirty_inode,
1184 .drop_inode = xfs_fs_drop_inode,
1185 .put_super = xfs_fs_put_super,
1186 .sync_fs = xfs_fs_sync_fs,
1187 .freeze_fs = xfs_fs_freeze,
1188 .unfreeze_fs = xfs_fs_unfreeze,
1189 .statfs = xfs_fs_statfs,
1190 .show_options = xfs_fs_show_options,
1191 .nr_cached_objects = xfs_fs_nr_cached_objects,
1192 .free_cached_objects = xfs_fs_free_cached_objects,
1193 .shutdown = xfs_fs_shutdown,
1202 int last, shift_left_factor = 0, _res;
1206 value = kstrdup(s, GFP_KERNEL);
1210 last = strlen(value) - 1;
1211 if (value[last] == 'K' || value[last] == 'k') {
1212 shift_left_factor = 10;
1215 if (value[last] == 'M' || value[last] == 'm') {
1216 shift_left_factor = 20;
1219 if (value[last] == 'G' || value[last] == 'g') {
1220 shift_left_factor = 30;
1224 if (kstrtoint(value, base, &_res))
1227 *res = _res << shift_left_factor;
1232 xfs_fs_warn_deprecated(
1233 struct fs_context *fc,
1234 struct fs_parameter *param,
1238 /* Don't print the warning if reconfiguring and current mount point
1239 * already had the flag set
1241 if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) &&
1242 !!(XFS_M(fc->root->d_sb)->m_features & flag) == value)
1244 xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key);
1248 * Set mount state from a mount option.
1250 * NOTE: mp->m_super is NULL here!
1254 struct fs_context *fc,
1255 struct fs_parameter *param)
1257 struct xfs_mount *parsing_mp = fc->s_fs_info;
1258 struct fs_parse_result result;
1262 opt = fs_parse(fc, xfs_fs_parameters, param, &result);
1268 parsing_mp->m_logbufs = result.uint_32;
1271 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize))
1275 kfree(parsing_mp->m_logname);
1276 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL);
1277 if (!parsing_mp->m_logname)
1281 kfree(parsing_mp->m_rtname);
1282 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL);
1283 if (!parsing_mp->m_rtname)
1287 if (suffix_kstrtoint(param->string, 10, &size))
1289 parsing_mp->m_allocsize_log = ffs(size) - 1;
1290 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE;
1294 parsing_mp->m_features |= XFS_FEAT_GRPID;
1297 case Opt_sysvgroups:
1298 parsing_mp->m_features &= ~XFS_FEAT_GRPID;
1301 parsing_mp->m_features |= XFS_FEAT_WSYNC;
1303 case Opt_norecovery:
1304 parsing_mp->m_features |= XFS_FEAT_NORECOVERY;
1307 parsing_mp->m_features |= XFS_FEAT_NOALIGN;
1310 parsing_mp->m_features |= XFS_FEAT_SWALLOC;
1313 parsing_mp->m_dalign = result.uint_32;
1316 parsing_mp->m_swidth = result.uint_32;
1319 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS;
1322 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1325 parsing_mp->m_features |= XFS_FEAT_NOUUID;
1328 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE;
1331 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE;
1333 case Opt_filestreams:
1334 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS;
1337 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
1338 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
1343 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD);
1345 case Opt_qnoenforce:
1346 case Opt_uqnoenforce:
1347 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT;
1348 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD;
1352 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD);
1354 case Opt_pqnoenforce:
1355 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT;
1356 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD;
1360 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD);
1362 case Opt_gqnoenforce:
1363 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT;
1364 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD;
1367 parsing_mp->m_features |= XFS_FEAT_DISCARD;
1370 parsing_mp->m_features &= ~XFS_FEAT_DISCARD;
1372 #ifdef CONFIG_FS_DAX
1374 xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
1377 xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
1380 /* Following mount options will be removed in September 2025 */
1382 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, true);
1383 parsing_mp->m_features |= XFS_FEAT_IKEEP;
1386 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, false);
1387 parsing_mp->m_features &= ~XFS_FEAT_IKEEP;
1390 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_ATTR2, true);
1391 parsing_mp->m_features |= XFS_FEAT_ATTR2;
1394 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_NOATTR2, true);
1395 parsing_mp->m_features |= XFS_FEAT_NOATTR2;
1398 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key);
1406 xfs_fs_validate_params(
1407 struct xfs_mount *mp)
1409 /* No recovery flag requires a read-only mount */
1410 if (xfs_has_norecovery(mp) && !xfs_is_readonly(mp)) {
1411 xfs_warn(mp, "no-recovery mounts must be read-only.");
1416 * We have not read the superblock at this point, so only the attr2
1417 * mount option can set the attr2 feature by this stage.
1419 if (xfs_has_attr2(mp) && xfs_has_noattr2(mp)) {
1420 xfs_warn(mp, "attr2 and noattr2 cannot both be specified.");
1425 if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) {
1427 "sunit and swidth options incompatible with the noalign option");
1431 if (!IS_ENABLED(CONFIG_XFS_QUOTA) && mp->m_qflags != 0) {
1432 xfs_warn(mp, "quota support not available in this kernel.");
1436 if ((mp->m_dalign && !mp->m_swidth) ||
1437 (!mp->m_dalign && mp->m_swidth)) {
1438 xfs_warn(mp, "sunit and swidth must be specified together");
1442 if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) {
1444 "stripe width (%d) must be a multiple of the stripe unit (%d)",
1445 mp->m_swidth, mp->m_dalign);
1449 if (mp->m_logbufs != -1 &&
1450 mp->m_logbufs != 0 &&
1451 (mp->m_logbufs < XLOG_MIN_ICLOGS ||
1452 mp->m_logbufs > XLOG_MAX_ICLOGS)) {
1453 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
1454 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
1458 if (mp->m_logbsize != -1 &&
1459 mp->m_logbsize != 0 &&
1460 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
1461 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
1462 !is_power_of_2(mp->m_logbsize))) {
1464 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
1469 if (xfs_has_allocsize(mp) &&
1470 (mp->m_allocsize_log > XFS_MAX_IO_LOG ||
1471 mp->m_allocsize_log < XFS_MIN_IO_LOG)) {
1472 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
1473 mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
1483 struct dentry *parent)
1485 struct dentry *child;
1487 /* Apparently we're expected to ignore error returns?? */
1488 child = debugfs_create_dir(name, parent);
1497 struct super_block *sb,
1498 struct fs_context *fc)
1500 struct xfs_mount *mp = sb->s_fs_info;
1502 int flags = 0, error;
1507 * Copy VFS mount flags from the context now that all parameter parsing
1508 * is guaranteed to have been completed by either the old mount API or
1509 * the newer fsopen/fsconfig API.
1511 if (fc->sb_flags & SB_RDONLY)
1512 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1513 if (fc->sb_flags & SB_DIRSYNC)
1514 mp->m_features |= XFS_FEAT_DIRSYNC;
1515 if (fc->sb_flags & SB_SYNCHRONOUS)
1516 mp->m_features |= XFS_FEAT_WSYNC;
1518 error = xfs_fs_validate_params(mp);
1522 sb_min_blocksize(sb, BBSIZE);
1523 sb->s_xattr = xfs_xattr_handlers;
1524 sb->s_export_op = &xfs_export_operations;
1525 #ifdef CONFIG_XFS_QUOTA
1526 sb->s_qcop = &xfs_quotactl_operations;
1527 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
1529 sb->s_op = &xfs_super_operations;
1532 * Delay mount work if the debug hook is set. This is debug
1533 * instrumention to coordinate simulation of xfs mount failures with
1534 * VFS superblock operations
1536 if (xfs_globals.mount_delay) {
1537 xfs_notice(mp, "Delaying mount for %d seconds.",
1538 xfs_globals.mount_delay);
1539 msleep(xfs_globals.mount_delay * 1000);
1542 if (fc->sb_flags & SB_SILENT)
1543 flags |= XFS_MFSI_QUIET;
1545 error = xfs_open_devices(mp);
1550 mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id,
1553 mp->m_debugfs = NULL;
1556 error = xfs_init_mount_workqueues(mp);
1558 goto out_shutdown_devices;
1560 error = xfs_init_percpu_counters(mp);
1562 goto out_destroy_workqueues;
1564 error = xfs_inodegc_init_percpu(mp);
1566 goto out_destroy_counters;
1568 /* Allocate stats memory before we do operations that might use it */
1569 mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
1570 if (!mp->m_stats.xs_stats) {
1572 goto out_destroy_inodegc;
1575 error = xchk_mount_stats_alloc(mp);
1577 goto out_free_stats;
1579 error = xfs_readsb(mp, flags);
1581 goto out_free_scrub_stats;
1583 error = xfs_finish_flags(mp);
1587 error = xfs_setup_devices(mp);
1591 /* V4 support is undergoing deprecation. */
1592 if (!xfs_has_crc(mp)) {
1593 #ifdef CONFIG_XFS_SUPPORT_V4
1595 "Deprecated V4 format (crc=0) will not be supported after September 2030.");
1598 "Deprecated V4 format (crc=0) not supported by kernel.");
1604 /* ASCII case insensitivity is undergoing deprecation. */
1605 if (xfs_has_asciici(mp)) {
1606 #ifdef CONFIG_XFS_SUPPORT_ASCII_CI
1608 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 2030.");
1611 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel.");
1617 /* Filesystem claims it needs repair, so refuse the mount. */
1618 if (xfs_has_needsrepair(mp)) {
1619 xfs_warn(mp, "Filesystem needs repair. Please run xfs_repair.");
1620 error = -EFSCORRUPTED;
1625 * Don't touch the filesystem if a user tool thinks it owns the primary
1626 * superblock. mkfs doesn't clear the flag from secondary supers, so
1627 * we don't check them at all.
1629 if (mp->m_sb.sb_inprogress) {
1630 xfs_warn(mp, "Offline file system operation in progress!");
1631 error = -EFSCORRUPTED;
1636 * Until this is fixed only page-sized or smaller data blocks work.
1638 if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
1640 "File system with blocksize %d bytes. "
1641 "Only pagesize (%ld) or less will currently work.",
1642 mp->m_sb.sb_blocksize, PAGE_SIZE);
1647 /* Ensure this filesystem fits in the page cache limits */
1648 if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) ||
1649 xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) {
1651 "file system too large to be mounted on this system.");
1657 * XFS block mappings use 54 bits to store the logical block offset.
1658 * This should suffice to handle the maximum file size that the VFS
1659 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT
1660 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes
1661 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON
1662 * to check this assertion.
1664 * Avoid integer overflow by comparing the maximum bmbt offset to the
1665 * maximum pagecache offset in units of fs blocks.
1667 if (!xfs_verify_fileoff(mp, XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE))) {
1669 "MAX_LFS_FILESIZE block offset (%llu) exceeds extent map maximum (%llu)!",
1670 XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE),
1676 error = xfs_filestream_mount(mp);
1681 * we must configure the block size in the superblock before we run the
1682 * full mount process as the mount process can lookup and cache inodes.
1684 sb->s_magic = XFS_SUPER_MAGIC;
1685 sb->s_blocksize = mp->m_sb.sb_blocksize;
1686 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
1687 sb->s_maxbytes = MAX_LFS_FILESIZE;
1688 sb->s_max_links = XFS_MAXLINK;
1689 sb->s_time_gran = 1;
1690 if (xfs_has_bigtime(mp)) {
1691 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN);
1692 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX);
1694 sb->s_time_min = XFS_LEGACY_TIME_MIN;
1695 sb->s_time_max = XFS_LEGACY_TIME_MAX;
1697 trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max);
1698 sb->s_iflags |= SB_I_CGROUPWB;
1700 set_posix_acl_flag(sb);
1702 /* version 5 superblocks support inode version counters. */
1703 if (xfs_has_crc(mp))
1704 sb->s_flags |= SB_I_VERSION;
1706 if (xfs_has_dax_always(mp)) {
1707 error = xfs_setup_dax_always(mp);
1709 goto out_filestream_unmount;
1712 if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) {
1714 "mounting with \"discard\" option, but the device does not support discard");
1715 mp->m_features &= ~XFS_FEAT_DISCARD;
1718 if (xfs_has_reflink(mp)) {
1719 if (mp->m_sb.sb_rblocks) {
1721 "reflink not compatible with realtime device!");
1723 goto out_filestream_unmount;
1726 if (xfs_globals.always_cow) {
1727 xfs_info(mp, "using DEBUG-only always_cow mode.");
1728 mp->m_always_cow = true;
1732 if (xfs_has_rmapbt(mp) && mp->m_sb.sb_rblocks) {
1734 "reverse mapping btree not compatible with realtime device!");
1736 goto out_filestream_unmount;
1739 error = xfs_mountfs(mp);
1741 goto out_filestream_unmount;
1743 root = igrab(VFS_I(mp->m_rootip));
1748 sb->s_root = d_make_root(root);
1756 out_filestream_unmount:
1757 xfs_filestream_unmount(mp);
1760 out_free_scrub_stats:
1761 xchk_mount_stats_free(mp);
1763 free_percpu(mp->m_stats.xs_stats);
1764 out_destroy_inodegc:
1765 xfs_inodegc_free_percpu(mp);
1766 out_destroy_counters:
1767 xfs_destroy_percpu_counters(mp);
1768 out_destroy_workqueues:
1769 xfs_destroy_mount_workqueues(mp);
1770 out_shutdown_devices:
1771 xfs_shutdown_devices(mp);
1775 xfs_filestream_unmount(mp);
1782 struct fs_context *fc)
1784 return get_tree_bdev(fc, xfs_fs_fill_super);
1789 struct xfs_mount *mp)
1791 struct xfs_sb *sbp = &mp->m_sb;
1794 if (xfs_has_norecovery(mp)) {
1796 "ro->rw transition prohibited on norecovery mount");
1800 if (xfs_sb_is_v5(sbp) &&
1801 xfs_sb_has_ro_compat_feature(sbp, XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
1803 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
1804 (sbp->sb_features_ro_compat &
1805 XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
1809 clear_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1812 * If this is the first remount to writeable state we might have some
1813 * superblock changes to update.
1815 if (mp->m_update_sb) {
1816 error = xfs_sync_sb(mp, false);
1818 xfs_warn(mp, "failed to write sb changes");
1821 mp->m_update_sb = false;
1825 * Fill out the reserve pool if it is empty. Use the stashed value if
1826 * it is non-zero, otherwise go with the default.
1828 xfs_restore_resvblks(mp);
1829 xfs_log_work_queue(mp);
1830 xfs_blockgc_start(mp);
1832 /* Create the per-AG metadata reservation pool .*/
1833 error = xfs_fs_reserve_ag_blocks(mp);
1834 if (error && error != -ENOSPC)
1837 /* Re-enable the background inode inactivation worker. */
1838 xfs_inodegc_start(mp);
1845 struct xfs_mount *mp)
1847 struct xfs_icwalk icw = {
1848 .icw_flags = XFS_ICWALK_FLAG_SYNC,
1852 /* Flush all the dirty data to disk. */
1853 error = sync_filesystem(mp->m_super);
1858 * Cancel background eofb scanning so it cannot race with the final
1859 * log force+buftarg wait and deadlock the remount.
1861 xfs_blockgc_stop(mp);
1864 * Clear out all remaining COW staging extents and speculative post-EOF
1865 * preallocations so that we don't leave inodes requiring inactivation
1866 * cleanups during reclaim on a read-only mount. We must process every
1867 * cached inode, so this requires a synchronous cache scan.
1869 error = xfs_blockgc_free_space(mp, &icw);
1871 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1876 * Stop the inodegc background worker. xfs_fs_reconfigure already
1877 * flushed all pending inodegc work when it sync'd the filesystem.
1878 * The VFS holds s_umount, so we know that inodes cannot enter
1879 * xfs_fs_destroy_inode during a remount operation. In readonly mode
1880 * we send inodes straight to reclaim, so no inodes will be queued.
1882 xfs_inodegc_stop(mp);
1884 /* Free the per-AG metadata reservation pool. */
1885 error = xfs_fs_unreserve_ag_blocks(mp);
1887 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1892 * Before we sync the metadata, we need to free up the reserve block
1893 * pool so that the used block count in the superblock on disk is
1894 * correct at the end of the remount. Stash the current* reserve pool
1895 * size so that if we get remounted rw, we can return it to the same
1898 xfs_save_resvblks(mp);
1901 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1907 * Logically we would return an error here to prevent users from believing
1908 * they might have changed mount options using remount which can't be changed.
1910 * But unfortunately mount(8) adds all options from mtab and fstab to the mount
1911 * arguments in some cases so we can't blindly reject options, but have to
1912 * check for each specified option if it actually differs from the currently
1913 * set option and only reject it if that's the case.
1915 * Until that is implemented we return success for every remount request, and
1916 * silently ignore all options that we can't actually change.
1920 struct fs_context *fc)
1922 struct xfs_mount *mp = XFS_M(fc->root->d_sb);
1923 struct xfs_mount *new_mp = fc->s_fs_info;
1924 int flags = fc->sb_flags;
1927 /* version 5 superblocks always support version counters. */
1928 if (xfs_has_crc(mp))
1929 fc->sb_flags |= SB_I_VERSION;
1931 error = xfs_fs_validate_params(new_mp);
1935 /* inode32 -> inode64 */
1936 if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) {
1937 mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1938 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1941 /* inode64 -> inode32 */
1942 if (!xfs_has_small_inums(mp) && xfs_has_small_inums(new_mp)) {
1943 mp->m_features |= XFS_FEAT_SMALL_INUMS;
1944 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1948 if (xfs_is_readonly(mp) && !(flags & SB_RDONLY)) {
1949 error = xfs_remount_rw(mp);
1955 if (!xfs_is_readonly(mp) && (flags & SB_RDONLY)) {
1956 error = xfs_remount_ro(mp);
1966 struct fs_context *fc)
1968 struct xfs_mount *mp = fc->s_fs_info;
1971 * mp is stored in the fs_context when it is initialized.
1972 * mp is transferred to the superblock on a successful mount,
1973 * but if an error occurs before the transfer we have to free
1980 static const struct fs_context_operations xfs_context_ops = {
1981 .parse_param = xfs_fs_parse_param,
1982 .get_tree = xfs_fs_get_tree,
1983 .reconfigure = xfs_fs_reconfigure,
1984 .free = xfs_fs_free,
1988 * WARNING: do not initialise any parameters in this function that depend on
1989 * mount option parsing having already been performed as this can be called from
1990 * fsopen() before any parameters have been set.
1992 static int xfs_init_fs_context(
1993 struct fs_context *fc)
1995 struct xfs_mount *mp;
1997 mp = kmem_alloc(sizeof(struct xfs_mount), KM_ZERO);
2001 spin_lock_init(&mp->m_sb_lock);
2002 INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC);
2003 spin_lock_init(&mp->m_perag_lock);
2004 mutex_init(&mp->m_growlock);
2005 INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker);
2006 INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker);
2007 mp->m_kobj.kobject.kset = xfs_kset;
2009 * We don't create the finobt per-ag space reservation until after log
2010 * recovery, so we must set this to true so that an ifree transaction
2011 * started during log recovery will not depend on space reservations
2012 * for finobt expansion.
2014 mp->m_finobt_nores = true;
2017 * These can be overridden by the mount option parsing.
2020 mp->m_logbsize = -1;
2021 mp->m_allocsize_log = 16; /* 64k */
2024 fc->ops = &xfs_context_ops;
2031 struct super_block *sb)
2033 kill_block_super(sb);
2034 xfs_mount_free(XFS_M(sb));
2037 static struct file_system_type xfs_fs_type = {
2038 .owner = THIS_MODULE,
2040 .init_fs_context = xfs_init_fs_context,
2041 .parameters = xfs_fs_parameters,
2042 .kill_sb = xfs_kill_sb,
2043 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
2045 MODULE_ALIAS_FS("xfs");
2048 xfs_init_caches(void)
2052 xfs_buf_cache = kmem_cache_create("xfs_buf", sizeof(struct xfs_buf), 0,
2053 SLAB_HWCACHE_ALIGN |
2054 SLAB_RECLAIM_ACCOUNT |
2060 xfs_log_ticket_cache = kmem_cache_create("xfs_log_ticket",
2061 sizeof(struct xlog_ticket),
2063 if (!xfs_log_ticket_cache)
2064 goto out_destroy_buf_cache;
2066 error = xfs_btree_init_cur_caches();
2068 goto out_destroy_log_ticket_cache;
2070 error = xfs_defer_init_item_caches();
2072 goto out_destroy_btree_cur_cache;
2074 xfs_da_state_cache = kmem_cache_create("xfs_da_state",
2075 sizeof(struct xfs_da_state),
2077 if (!xfs_da_state_cache)
2078 goto out_destroy_defer_item_cache;
2080 xfs_ifork_cache = kmem_cache_create("xfs_ifork",
2081 sizeof(struct xfs_ifork),
2083 if (!xfs_ifork_cache)
2084 goto out_destroy_da_state_cache;
2086 xfs_trans_cache = kmem_cache_create("xfs_trans",
2087 sizeof(struct xfs_trans),
2089 if (!xfs_trans_cache)
2090 goto out_destroy_ifork_cache;
2094 * The size of the cache-allocated buf log item is the maximum
2095 * size possible under XFS. This wastes a little bit of memory,
2096 * but it is much faster.
2098 xfs_buf_item_cache = kmem_cache_create("xfs_buf_item",
2099 sizeof(struct xfs_buf_log_item),
2101 if (!xfs_buf_item_cache)
2102 goto out_destroy_trans_cache;
2104 xfs_efd_cache = kmem_cache_create("xfs_efd_item",
2105 xfs_efd_log_item_sizeof(XFS_EFD_MAX_FAST_EXTENTS),
2108 goto out_destroy_buf_item_cache;
2110 xfs_efi_cache = kmem_cache_create("xfs_efi_item",
2111 xfs_efi_log_item_sizeof(XFS_EFI_MAX_FAST_EXTENTS),
2114 goto out_destroy_efd_cache;
2116 xfs_inode_cache = kmem_cache_create("xfs_inode",
2117 sizeof(struct xfs_inode), 0,
2118 (SLAB_HWCACHE_ALIGN |
2119 SLAB_RECLAIM_ACCOUNT |
2120 SLAB_MEM_SPREAD | SLAB_ACCOUNT),
2121 xfs_fs_inode_init_once);
2122 if (!xfs_inode_cache)
2123 goto out_destroy_efi_cache;
2125 xfs_ili_cache = kmem_cache_create("xfs_ili",
2126 sizeof(struct xfs_inode_log_item), 0,
2127 SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
2130 goto out_destroy_inode_cache;
2132 xfs_icreate_cache = kmem_cache_create("xfs_icr",
2133 sizeof(struct xfs_icreate_item),
2135 if (!xfs_icreate_cache)
2136 goto out_destroy_ili_cache;
2138 xfs_rud_cache = kmem_cache_create("xfs_rud_item",
2139 sizeof(struct xfs_rud_log_item),
2142 goto out_destroy_icreate_cache;
2144 xfs_rui_cache = kmem_cache_create("xfs_rui_item",
2145 xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS),
2148 goto out_destroy_rud_cache;
2150 xfs_cud_cache = kmem_cache_create("xfs_cud_item",
2151 sizeof(struct xfs_cud_log_item),
2154 goto out_destroy_rui_cache;
2156 xfs_cui_cache = kmem_cache_create("xfs_cui_item",
2157 xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS),
2160 goto out_destroy_cud_cache;
2162 xfs_bud_cache = kmem_cache_create("xfs_bud_item",
2163 sizeof(struct xfs_bud_log_item),
2166 goto out_destroy_cui_cache;
2168 xfs_bui_cache = kmem_cache_create("xfs_bui_item",
2169 xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS),
2172 goto out_destroy_bud_cache;
2174 xfs_attrd_cache = kmem_cache_create("xfs_attrd_item",
2175 sizeof(struct xfs_attrd_log_item),
2177 if (!xfs_attrd_cache)
2178 goto out_destroy_bui_cache;
2180 xfs_attri_cache = kmem_cache_create("xfs_attri_item",
2181 sizeof(struct xfs_attri_log_item),
2183 if (!xfs_attri_cache)
2184 goto out_destroy_attrd_cache;
2186 xfs_iunlink_cache = kmem_cache_create("xfs_iul_item",
2187 sizeof(struct xfs_iunlink_item),
2189 if (!xfs_iunlink_cache)
2190 goto out_destroy_attri_cache;
2194 out_destroy_attri_cache:
2195 kmem_cache_destroy(xfs_attri_cache);
2196 out_destroy_attrd_cache:
2197 kmem_cache_destroy(xfs_attrd_cache);
2198 out_destroy_bui_cache:
2199 kmem_cache_destroy(xfs_bui_cache);
2200 out_destroy_bud_cache:
2201 kmem_cache_destroy(xfs_bud_cache);
2202 out_destroy_cui_cache:
2203 kmem_cache_destroy(xfs_cui_cache);
2204 out_destroy_cud_cache:
2205 kmem_cache_destroy(xfs_cud_cache);
2206 out_destroy_rui_cache:
2207 kmem_cache_destroy(xfs_rui_cache);
2208 out_destroy_rud_cache:
2209 kmem_cache_destroy(xfs_rud_cache);
2210 out_destroy_icreate_cache:
2211 kmem_cache_destroy(xfs_icreate_cache);
2212 out_destroy_ili_cache:
2213 kmem_cache_destroy(xfs_ili_cache);
2214 out_destroy_inode_cache:
2215 kmem_cache_destroy(xfs_inode_cache);
2216 out_destroy_efi_cache:
2217 kmem_cache_destroy(xfs_efi_cache);
2218 out_destroy_efd_cache:
2219 kmem_cache_destroy(xfs_efd_cache);
2220 out_destroy_buf_item_cache:
2221 kmem_cache_destroy(xfs_buf_item_cache);
2222 out_destroy_trans_cache:
2223 kmem_cache_destroy(xfs_trans_cache);
2224 out_destroy_ifork_cache:
2225 kmem_cache_destroy(xfs_ifork_cache);
2226 out_destroy_da_state_cache:
2227 kmem_cache_destroy(xfs_da_state_cache);
2228 out_destroy_defer_item_cache:
2229 xfs_defer_destroy_item_caches();
2230 out_destroy_btree_cur_cache:
2231 xfs_btree_destroy_cur_caches();
2232 out_destroy_log_ticket_cache:
2233 kmem_cache_destroy(xfs_log_ticket_cache);
2234 out_destroy_buf_cache:
2235 kmem_cache_destroy(xfs_buf_cache);
2241 xfs_destroy_caches(void)
2244 * Make sure all delayed rcu free are flushed before we
2248 kmem_cache_destroy(xfs_iunlink_cache);
2249 kmem_cache_destroy(xfs_attri_cache);
2250 kmem_cache_destroy(xfs_attrd_cache);
2251 kmem_cache_destroy(xfs_bui_cache);
2252 kmem_cache_destroy(xfs_bud_cache);
2253 kmem_cache_destroy(xfs_cui_cache);
2254 kmem_cache_destroy(xfs_cud_cache);
2255 kmem_cache_destroy(xfs_rui_cache);
2256 kmem_cache_destroy(xfs_rud_cache);
2257 kmem_cache_destroy(xfs_icreate_cache);
2258 kmem_cache_destroy(xfs_ili_cache);
2259 kmem_cache_destroy(xfs_inode_cache);
2260 kmem_cache_destroy(xfs_efi_cache);
2261 kmem_cache_destroy(xfs_efd_cache);
2262 kmem_cache_destroy(xfs_buf_item_cache);
2263 kmem_cache_destroy(xfs_trans_cache);
2264 kmem_cache_destroy(xfs_ifork_cache);
2265 kmem_cache_destroy(xfs_da_state_cache);
2266 xfs_defer_destroy_item_caches();
2267 xfs_btree_destroy_cur_caches();
2268 kmem_cache_destroy(xfs_log_ticket_cache);
2269 kmem_cache_destroy(xfs_buf_cache);
2273 xfs_init_workqueues(void)
2276 * The allocation workqueue can be used in memory reclaim situations
2277 * (writepage path), and parallelism is only limited by the number of
2278 * AGs in all the filesystems mounted. Hence use the default large
2279 * max_active value for this workqueue.
2281 xfs_alloc_wq = alloc_workqueue("xfsalloc",
2282 XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 0);
2286 xfs_discard_wq = alloc_workqueue("xfsdiscard", XFS_WQFLAGS(WQ_UNBOUND),
2288 if (!xfs_discard_wq)
2289 goto out_free_alloc_wq;
2293 destroy_workqueue(xfs_alloc_wq);
2298 xfs_destroy_workqueues(void)
2300 destroy_workqueue(xfs_discard_wq);
2301 destroy_workqueue(xfs_alloc_wq);
2309 xfs_check_ondisk_structs();
2311 error = xfs_dahash_test();
2315 printk(KERN_INFO XFS_VERSION_STRING " with "
2316 XFS_BUILD_OPTIONS " enabled\n");
2320 error = xfs_init_caches();
2324 error = xfs_init_workqueues();
2326 goto out_destroy_caches;
2328 error = xfs_mru_cache_init();
2330 goto out_destroy_wq;
2332 error = xfs_init_procfs();
2334 goto out_mru_cache_uninit;
2336 error = xfs_sysctl_register();
2338 goto out_cleanup_procfs;
2340 xfs_debugfs = xfs_debugfs_mkdir("xfs", NULL);
2342 xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
2345 goto out_debugfs_unregister;
2348 xfsstats.xs_kobj.kobject.kset = xfs_kset;
2350 xfsstats.xs_stats = alloc_percpu(struct xfsstats);
2351 if (!xfsstats.xs_stats) {
2353 goto out_kset_unregister;
2356 error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
2359 goto out_free_stats;
2361 error = xchk_global_stats_setup(xfs_debugfs);
2363 goto out_remove_stats_kobj;
2366 xfs_dbg_kobj.kobject.kset = xfs_kset;
2367 error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
2369 goto out_remove_scrub_stats;
2372 error = xfs_qm_init();
2374 goto out_remove_dbg_kobj;
2376 error = register_filesystem(&xfs_fs_type);
2383 out_remove_dbg_kobj:
2385 xfs_sysfs_del(&xfs_dbg_kobj);
2386 out_remove_scrub_stats:
2388 xchk_global_stats_teardown();
2389 out_remove_stats_kobj:
2390 xfs_sysfs_del(&xfsstats.xs_kobj);
2392 free_percpu(xfsstats.xs_stats);
2393 out_kset_unregister:
2394 kset_unregister(xfs_kset);
2395 out_debugfs_unregister:
2396 debugfs_remove(xfs_debugfs);
2397 xfs_sysctl_unregister();
2399 xfs_cleanup_procfs();
2400 out_mru_cache_uninit:
2401 xfs_mru_cache_uninit();
2403 xfs_destroy_workqueues();
2405 xfs_destroy_caches();
2414 unregister_filesystem(&xfs_fs_type);
2416 xfs_sysfs_del(&xfs_dbg_kobj);
2418 xchk_global_stats_teardown();
2419 xfs_sysfs_del(&xfsstats.xs_kobj);
2420 free_percpu(xfsstats.xs_stats);
2421 kset_unregister(xfs_kset);
2422 debugfs_remove(xfs_debugfs);
2423 xfs_sysctl_unregister();
2424 xfs_cleanup_procfs();
2425 xfs_mru_cache_uninit();
2426 xfs_destroy_workqueues();
2427 xfs_destroy_caches();
2428 xfs_uuid_table_free();
2431 module_init(init_xfs_fs);
2432 module_exit(exit_xfs_fs);
2434 MODULE_AUTHOR("Silicon Graphics, Inc.");
2435 MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
2436 MODULE_LICENSE("GPL");