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 "xfs_rtbitmap.h"
46 #include "scrub/stats.h"
48 #include <linux/magic.h>
49 #include <linux/fs_context.h>
50 #include <linux/fs_parser.h>
52 static const struct super_operations xfs_super_operations;
54 static struct dentry *xfs_debugfs; /* top-level xfs debugfs dir */
55 static struct kset *xfs_kset; /* top-level xfs sysfs dir */
57 static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
67 xfs_mount_set_dax_mode(
69 enum xfs_dax_mode mode)
73 mp->m_features &= ~(XFS_FEAT_DAX_ALWAYS | XFS_FEAT_DAX_NEVER);
76 mp->m_features |= XFS_FEAT_DAX_ALWAYS;
77 mp->m_features &= ~XFS_FEAT_DAX_NEVER;
80 mp->m_features |= XFS_FEAT_DAX_NEVER;
81 mp->m_features &= ~XFS_FEAT_DAX_ALWAYS;
86 static const struct constant_table dax_param_enums[] = {
87 {"inode", XFS_DAX_INODE },
88 {"always", XFS_DAX_ALWAYS },
89 {"never", XFS_DAX_NEVER },
94 * Table driven mount option parser.
97 Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev,
98 Opt_wsync, Opt_noalign, Opt_swalloc, Opt_sunit, Opt_swidth, Opt_nouuid,
99 Opt_grpid, Opt_nogrpid, Opt_bsdgroups, Opt_sysvgroups,
100 Opt_allocsize, Opt_norecovery, Opt_inode64, Opt_inode32, Opt_ikeep,
101 Opt_noikeep, Opt_largeio, Opt_nolargeio, Opt_attr2, Opt_noattr2,
102 Opt_filestreams, Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota,
103 Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota,
104 Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce,
105 Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum,
108 static const struct fs_parameter_spec xfs_fs_parameters[] = {
109 fsparam_u32("logbufs", Opt_logbufs),
110 fsparam_string("logbsize", Opt_logbsize),
111 fsparam_string("logdev", Opt_logdev),
112 fsparam_string("rtdev", Opt_rtdev),
113 fsparam_flag("wsync", Opt_wsync),
114 fsparam_flag("noalign", Opt_noalign),
115 fsparam_flag("swalloc", Opt_swalloc),
116 fsparam_u32("sunit", Opt_sunit),
117 fsparam_u32("swidth", Opt_swidth),
118 fsparam_flag("nouuid", Opt_nouuid),
119 fsparam_flag("grpid", Opt_grpid),
120 fsparam_flag("nogrpid", Opt_nogrpid),
121 fsparam_flag("bsdgroups", Opt_bsdgroups),
122 fsparam_flag("sysvgroups", Opt_sysvgroups),
123 fsparam_string("allocsize", Opt_allocsize),
124 fsparam_flag("norecovery", Opt_norecovery),
125 fsparam_flag("inode64", Opt_inode64),
126 fsparam_flag("inode32", Opt_inode32),
127 fsparam_flag("ikeep", Opt_ikeep),
128 fsparam_flag("noikeep", Opt_noikeep),
129 fsparam_flag("largeio", Opt_largeio),
130 fsparam_flag("nolargeio", Opt_nolargeio),
131 fsparam_flag("attr2", Opt_attr2),
132 fsparam_flag("noattr2", Opt_noattr2),
133 fsparam_flag("filestreams", Opt_filestreams),
134 fsparam_flag("quota", Opt_quota),
135 fsparam_flag("noquota", Opt_noquota),
136 fsparam_flag("usrquota", Opt_usrquota),
137 fsparam_flag("grpquota", Opt_grpquota),
138 fsparam_flag("prjquota", Opt_prjquota),
139 fsparam_flag("uquota", Opt_uquota),
140 fsparam_flag("gquota", Opt_gquota),
141 fsparam_flag("pquota", Opt_pquota),
142 fsparam_flag("uqnoenforce", Opt_uqnoenforce),
143 fsparam_flag("gqnoenforce", Opt_gqnoenforce),
144 fsparam_flag("pqnoenforce", Opt_pqnoenforce),
145 fsparam_flag("qnoenforce", Opt_qnoenforce),
146 fsparam_flag("discard", Opt_discard),
147 fsparam_flag("nodiscard", Opt_nodiscard),
148 fsparam_flag("dax", Opt_dax),
149 fsparam_enum("dax", Opt_dax_enum, dax_param_enums),
153 struct proc_xfs_info {
163 static struct proc_xfs_info xfs_info_set[] = {
164 /* the few simple ones we can get from the mount struct */
165 { XFS_FEAT_IKEEP, ",ikeep" },
166 { XFS_FEAT_WSYNC, ",wsync" },
167 { XFS_FEAT_NOALIGN, ",noalign" },
168 { XFS_FEAT_SWALLOC, ",swalloc" },
169 { XFS_FEAT_NOUUID, ",nouuid" },
170 { XFS_FEAT_NORECOVERY, ",norecovery" },
171 { XFS_FEAT_ATTR2, ",attr2" },
172 { XFS_FEAT_FILESTREAMS, ",filestreams" },
173 { XFS_FEAT_GRPID, ",grpid" },
174 { XFS_FEAT_DISCARD, ",discard" },
175 { XFS_FEAT_LARGE_IOSIZE, ",largeio" },
176 { XFS_FEAT_DAX_ALWAYS, ",dax=always" },
177 { XFS_FEAT_DAX_NEVER, ",dax=never" },
180 struct xfs_mount *mp = XFS_M(root->d_sb);
181 struct proc_xfs_info *xfs_infop;
183 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
184 if (mp->m_features & xfs_infop->flag)
185 seq_puts(m, xfs_infop->str);
188 seq_printf(m, ",inode%d", xfs_has_small_inums(mp) ? 32 : 64);
190 if (xfs_has_allocsize(mp))
191 seq_printf(m, ",allocsize=%dk",
192 (1 << mp->m_allocsize_log) >> 10);
194 if (mp->m_logbufs > 0)
195 seq_printf(m, ",logbufs=%d", mp->m_logbufs);
196 if (mp->m_logbsize > 0)
197 seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10);
200 seq_show_option(m, "logdev", mp->m_logname);
202 seq_show_option(m, "rtdev", mp->m_rtname);
204 if (mp->m_dalign > 0)
205 seq_printf(m, ",sunit=%d",
206 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
207 if (mp->m_swidth > 0)
208 seq_printf(m, ",swidth=%d",
209 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
211 if (mp->m_qflags & XFS_UQUOTA_ENFD)
212 seq_puts(m, ",usrquota");
213 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
214 seq_puts(m, ",uqnoenforce");
216 if (mp->m_qflags & XFS_PQUOTA_ENFD)
217 seq_puts(m, ",prjquota");
218 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
219 seq_puts(m, ",pqnoenforce");
221 if (mp->m_qflags & XFS_GQUOTA_ENFD)
222 seq_puts(m, ",grpquota");
223 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
224 seq_puts(m, ",gqnoenforce");
226 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
227 seq_puts(m, ",noquota");
233 xfs_set_inode_alloc_perag(
234 struct xfs_perag *pag,
236 xfs_agnumber_t max_metadata)
238 if (!xfs_is_inode32(pag->pag_mount)) {
239 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
240 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
244 if (ino > XFS_MAXINUMBER_32) {
245 clear_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
246 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
250 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
251 if (pag->pag_agno < max_metadata)
252 set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
254 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
259 * Set parameters for inode allocation heuristics, taking into account
260 * filesystem size and inode32/inode64 mount options; i.e. specifically
261 * whether or not XFS_FEAT_SMALL_INUMS is set.
263 * Inode allocation patterns are altered only if inode32 is requested
264 * (XFS_FEAT_SMALL_INUMS), and the filesystem is sufficiently large.
265 * If altered, XFS_OPSTATE_INODE32 is set as well.
267 * An agcount independent of that in the mount structure is provided
268 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
269 * to the potentially higher ag count.
271 * Returns the maximum AG index which may contain inodes.
275 struct xfs_mount *mp,
276 xfs_agnumber_t agcount)
278 xfs_agnumber_t index;
279 xfs_agnumber_t maxagi = 0;
280 xfs_sb_t *sbp = &mp->m_sb;
281 xfs_agnumber_t max_metadata;
286 * Calculate how much should be reserved for inodes to meet
287 * the max inode percentage. Used only for inode32.
289 if (M_IGEO(mp)->maxicount) {
292 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
294 icount += sbp->sb_agblocks - 1;
295 do_div(icount, sbp->sb_agblocks);
296 max_metadata = icount;
298 max_metadata = agcount;
301 /* Get the last possible inode in the filesystem */
302 agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1);
303 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino);
306 * If user asked for no more than 32-bit inodes, and the fs is
307 * sufficiently large, set XFS_OPSTATE_INODE32 if we must alter
308 * the allocator to accommodate the request.
310 if (xfs_has_small_inums(mp) && ino > XFS_MAXINUMBER_32)
311 set_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
313 clear_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
315 for (index = 0; index < agcount; index++) {
316 struct xfs_perag *pag;
318 ino = XFS_AGINO_TO_INO(mp, index, agino);
320 pag = xfs_perag_get(mp, index);
321 if (xfs_set_inode_alloc_perag(pag, ino, max_metadata))
326 return xfs_is_inode32(mp) ? maxagi : agcount;
330 xfs_setup_dax_always(
331 struct xfs_mount *mp)
333 if (!mp->m_ddev_targp->bt_daxdev &&
334 (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) {
336 "DAX unsupported by block device. Turning off DAX.");
340 if (mp->m_super->s_blocksize != PAGE_SIZE) {
342 "DAX not supported for blocksize. Turning off DAX.");
346 if (xfs_has_reflink(mp) &&
347 bdev_is_partition(mp->m_ddev_targp->bt_bdev)) {
349 "DAX and reflink cannot work with multi-partitions!");
353 xfs_warn(mp, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
357 xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
365 struct bdev_handle **handlep)
369 *handlep = bdev_open_by_path(name,
370 BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
371 mp->m_super, &fs_holder_ops);
372 if (IS_ERR(*handlep)) {
373 error = PTR_ERR(*handlep);
375 xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
382 xfs_shutdown_devices(
383 struct xfs_mount *mp)
386 * Udev is triggered whenever anyone closes a block device or unmounts
387 * a file systemm on a block device.
388 * The default udev rules invoke blkid to read the fs super and create
389 * symlinks to the bdev under /dev/disk. For this, it uses buffered
390 * reads through the page cache.
392 * xfs_db also uses buffered reads to examine metadata. There is no
393 * coordination between xfs_db and udev, which means that they can run
394 * concurrently. Note there is no coordination between the kernel and
397 * On a system with 64k pages, the page cache can cache the superblock
398 * and the root inode (and hence the root directory) with the same 64k
399 * page. If udev spawns blkid after the mkfs and the system is busy
400 * enough that it is still running when xfs_db starts up, they'll both
401 * read from the same page in the pagecache.
403 * The unmount writes updated inode metadata to disk directly. The XFS
404 * buffer cache does not use the bdev pagecache, so it needs to
405 * invalidate that pagecache on unmount. If the above scenario occurs,
406 * the pagecache no longer reflects what's on disk, xfs_db reads the
407 * stale metadata, and fails to find /a. Most of the time this succeeds
408 * because closing a bdev invalidates the page cache, but when processes
409 * race, everyone loses.
411 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
412 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev);
413 invalidate_bdev(mp->m_logdev_targp->bt_bdev);
415 if (mp->m_rtdev_targp) {
416 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev);
417 invalidate_bdev(mp->m_rtdev_targp->bt_bdev);
419 blkdev_issue_flush(mp->m_ddev_targp->bt_bdev);
420 invalidate_bdev(mp->m_ddev_targp->bt_bdev);
424 * The file system configurations are:
425 * (1) device (partition) with data and internal log
426 * (2) logical volume with data and log subvolumes.
427 * (3) logical volume with data, log, and realtime subvolumes.
429 * We only have to handle opening the log and realtime volumes here if
430 * they are present. The data subvolume has already been opened by
431 * get_sb_bdev() and is stored in sb->s_bdev.
435 struct xfs_mount *mp)
437 struct super_block *sb = mp->m_super;
438 struct block_device *ddev = sb->s_bdev;
439 struct bdev_handle *logdev_handle = NULL, *rtdev_handle = NULL;
443 * Open real time and log devices - order is important.
446 error = xfs_blkdev_get(mp, mp->m_logname, &logdev_handle);
452 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev_handle);
454 goto out_close_logdev;
456 if (rtdev_handle->bdev == ddev ||
458 rtdev_handle->bdev == logdev_handle->bdev)) {
460 "Cannot mount filesystem with identical rtdev and ddev/logdev.");
462 goto out_close_rtdev;
467 * Setup xfs_mount buffer target pointers
470 mp->m_ddev_targp = xfs_alloc_buftarg(mp, sb->s_bdev_handle);
471 if (!mp->m_ddev_targp)
472 goto out_close_rtdev;
475 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev_handle);
476 if (!mp->m_rtdev_targp)
477 goto out_free_ddev_targ;
480 if (logdev_handle && logdev_handle->bdev != ddev) {
481 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev_handle);
482 if (!mp->m_logdev_targp)
483 goto out_free_rtdev_targ;
485 mp->m_logdev_targp = mp->m_ddev_targp;
486 /* Handle won't be used, drop it */
488 bdev_release(logdev_handle);
494 if (mp->m_rtdev_targp)
495 xfs_free_buftarg(mp->m_rtdev_targp);
497 xfs_free_buftarg(mp->m_ddev_targp);
500 bdev_release(rtdev_handle);
503 bdev_release(logdev_handle);
508 * Setup xfs_mount buffer target pointers based on superblock
512 struct xfs_mount *mp)
516 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize);
520 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
521 unsigned int log_sector_size = BBSIZE;
523 if (xfs_has_sector(mp))
524 log_sector_size = mp->m_sb.sb_logsectsize;
525 error = xfs_setsize_buftarg(mp->m_logdev_targp,
530 if (mp->m_rtdev_targp) {
531 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
532 mp->m_sb.sb_sectsize);
541 xfs_init_mount_workqueues(
542 struct xfs_mount *mp)
544 mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
545 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
546 1, mp->m_super->s_id);
547 if (!mp->m_buf_workqueue)
550 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
551 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
552 0, mp->m_super->s_id);
553 if (!mp->m_unwritten_workqueue)
554 goto out_destroy_buf;
556 mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s",
557 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
558 0, mp->m_super->s_id);
559 if (!mp->m_reclaim_workqueue)
560 goto out_destroy_unwritten;
562 mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s",
563 XFS_WQFLAGS(WQ_UNBOUND | WQ_FREEZABLE | WQ_MEM_RECLAIM),
564 0, mp->m_super->s_id);
565 if (!mp->m_blockgc_wq)
566 goto out_destroy_reclaim;
568 mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s",
569 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
570 1, mp->m_super->s_id);
571 if (!mp->m_inodegc_wq)
572 goto out_destroy_blockgc;
574 mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s",
575 XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id);
576 if (!mp->m_sync_workqueue)
577 goto out_destroy_inodegc;
582 destroy_workqueue(mp->m_inodegc_wq);
584 destroy_workqueue(mp->m_blockgc_wq);
586 destroy_workqueue(mp->m_reclaim_workqueue);
587 out_destroy_unwritten:
588 destroy_workqueue(mp->m_unwritten_workqueue);
590 destroy_workqueue(mp->m_buf_workqueue);
596 xfs_destroy_mount_workqueues(
597 struct xfs_mount *mp)
599 destroy_workqueue(mp->m_sync_workqueue);
600 destroy_workqueue(mp->m_blockgc_wq);
601 destroy_workqueue(mp->m_inodegc_wq);
602 destroy_workqueue(mp->m_reclaim_workqueue);
603 destroy_workqueue(mp->m_unwritten_workqueue);
604 destroy_workqueue(mp->m_buf_workqueue);
608 xfs_flush_inodes_worker(
609 struct work_struct *work)
611 struct xfs_mount *mp = container_of(work, struct xfs_mount,
612 m_flush_inodes_work);
613 struct super_block *sb = mp->m_super;
615 if (down_read_trylock(&sb->s_umount)) {
617 up_read(&sb->s_umount);
622 * Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK
623 * or a page lock. We use sync_inodes_sb() here to ensure we block while waiting
624 * for IO to complete so that we effectively throttle multiple callers to the
625 * rate at which IO is completing.
629 struct xfs_mount *mp)
632 * If flush_work() returns true then that means we waited for a flush
633 * which was already in progress. Don't bother running another scan.
635 if (flush_work(&mp->m_flush_inodes_work))
638 queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work);
639 flush_work(&mp->m_flush_inodes_work);
642 /* Catch misguided souls that try to use this interface on XFS */
643 STATIC struct inode *
645 struct super_block *sb)
652 * Now that the generic code is guaranteed not to be accessing
653 * the linux inode, we can inactivate and reclaim the inode.
656 xfs_fs_destroy_inode(
659 struct xfs_inode *ip = XFS_I(inode);
661 trace_xfs_destroy_inode(ip);
663 ASSERT(!rwsem_is_locked(&inode->i_rwsem));
664 XFS_STATS_INC(ip->i_mount, vn_rele);
665 XFS_STATS_INC(ip->i_mount, vn_remove);
666 xfs_inode_mark_reclaimable(ip);
674 struct xfs_inode *ip = XFS_I(inode);
675 struct xfs_mount *mp = ip->i_mount;
676 struct xfs_trans *tp;
678 if (!(inode->i_sb->s_flags & SB_LAZYTIME))
682 * Only do the timestamp update if the inode is dirty (I_DIRTY_SYNC)
683 * and has dirty timestamp (I_DIRTY_TIME). I_DIRTY_TIME can be passed
684 * in flags possibly together with I_DIRTY_SYNC.
686 if ((flags & ~I_DIRTY_TIME) != I_DIRTY_SYNC || !(flags & I_DIRTY_TIME))
689 if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp))
691 xfs_ilock(ip, XFS_ILOCK_EXCL);
692 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
693 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
694 xfs_trans_commit(tp);
698 * Slab object creation initialisation for the XFS inode.
699 * This covers only the idempotent fields in the XFS inode;
700 * all other fields need to be initialised on allocation
701 * from the slab. This avoids the need to repeatedly initialise
702 * fields in the xfs inode that left in the initialise state
703 * when freeing the inode.
706 xfs_fs_inode_init_once(
709 struct xfs_inode *ip = inode;
711 memset(ip, 0, sizeof(struct xfs_inode));
714 inode_init_once(VFS_I(ip));
717 atomic_set(&ip->i_pincount, 0);
718 spin_lock_init(&ip->i_flags_lock);
720 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
721 "xfsino", ip->i_ino);
725 * We do an unlocked check for XFS_IDONTCACHE here because we are already
726 * serialised against cache hits here via the inode->i_lock and igrab() in
727 * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
728 * racing with us, and it avoids needing to grab a spinlock here for every inode
729 * we drop the final reference on.
735 struct xfs_inode *ip = XFS_I(inode);
738 * If this unlinked inode is in the middle of recovery, don't
739 * drop the inode just yet; log recovery will take care of
740 * that. See the comment for this inode flag.
742 if (ip->i_flags & XFS_IRECOVERY) {
743 ASSERT(xlog_recovery_needed(ip->i_mount->m_log));
747 return generic_drop_inode(inode);
752 struct xfs_mount *mp)
754 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
755 xfs_free_buftarg(mp->m_logdev_targp);
756 if (mp->m_rtdev_targp)
757 xfs_free_buftarg(mp->m_rtdev_targp);
758 if (mp->m_ddev_targp)
759 xfs_free_buftarg(mp->m_ddev_targp);
761 debugfs_remove(mp->m_debugfs);
763 kfree(mp->m_logname);
769 struct super_block *sb,
772 struct xfs_mount *mp = XFS_M(sb);
775 trace_xfs_fs_sync_fs(mp, __return_address);
778 * Doing anything during the async pass would be counterproductive.
783 error = xfs_log_force(mp, XFS_LOG_SYNC);
789 * The disk must be active because we're syncing.
790 * We schedule log work now (now that the disk is
791 * active) instead of later (when it might not be).
793 flush_delayed_work(&mp->m_log->l_work);
797 * If we are called with page faults frozen out, it means we are about
798 * to freeze the transaction subsystem. Take the opportunity to shut
799 * down inodegc because once SB_FREEZE_FS is set it's too late to
800 * prevent inactivation races with freeze. The fs doesn't get called
801 * again by the freezing process until after SB_FREEZE_FS has been set,
802 * so it's now or never. Same logic applies to speculative allocation
803 * garbage collection.
805 * We don't care if this is a normal syncfs call that does this or
806 * freeze that does this - we can run this multiple times without issue
807 * and we won't race with a restart because a restart can only occur
808 * when the state is either SB_FREEZE_FS or SB_FREEZE_COMPLETE.
810 if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) {
811 xfs_inodegc_stop(mp);
812 xfs_blockgc_stop(mp);
820 struct dentry *dentry,
821 struct kstatfs *statp)
823 struct xfs_mount *mp = XFS_M(dentry->d_sb);
824 xfs_sb_t *sbp = &mp->m_sb;
825 struct xfs_inode *ip = XFS_I(d_inode(dentry));
826 uint64_t fakeinos, id;
834 * Expedite background inodegc but don't wait. We do not want to block
835 * here waiting hours for a billion extent file to be truncated.
837 xfs_inodegc_push(mp);
839 statp->f_type = XFS_SUPER_MAGIC;
840 statp->f_namelen = MAXNAMELEN - 1;
842 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
843 statp->f_fsid = u64_to_fsid(id);
845 icount = percpu_counter_sum(&mp->m_icount);
846 ifree = percpu_counter_sum(&mp->m_ifree);
847 fdblocks = percpu_counter_sum(&mp->m_fdblocks);
849 spin_lock(&mp->m_sb_lock);
850 statp->f_bsize = sbp->sb_blocksize;
851 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
852 statp->f_blocks = sbp->sb_dblocks - lsize;
853 spin_unlock(&mp->m_sb_lock);
855 /* make sure statp->f_bfree does not underflow */
856 statp->f_bfree = max_t(int64_t, 0,
857 fdblocks - xfs_fdblocks_unavailable(mp));
858 statp->f_bavail = statp->f_bfree;
860 fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);
861 statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
862 if (M_IGEO(mp)->maxicount)
863 statp->f_files = min_t(typeof(statp->f_files),
865 M_IGEO(mp)->maxicount);
867 /* If sb_icount overshot maxicount, report actual allocation */
868 statp->f_files = max_t(typeof(statp->f_files),
872 /* make sure statp->f_ffree does not underflow */
873 ffree = statp->f_files - (icount - ifree);
874 statp->f_ffree = max_t(int64_t, ffree, 0);
877 if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
878 ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
879 (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
880 xfs_qm_statvfs(ip, statp);
882 if (XFS_IS_REALTIME_MOUNT(mp) &&
883 (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
886 statp->f_blocks = sbp->sb_rblocks;
887 freertx = percpu_counter_sum_positive(&mp->m_frextents);
888 statp->f_bavail = statp->f_bfree = xfs_rtx_to_rtb(mp, freertx);
895 xfs_save_resvblks(struct xfs_mount *mp)
897 mp->m_resblks_save = mp->m_resblks;
898 xfs_reserve_blocks(mp, 0);
902 xfs_restore_resvblks(struct xfs_mount *mp)
906 if (mp->m_resblks_save) {
907 resblks = mp->m_resblks_save;
908 mp->m_resblks_save = 0;
910 resblks = xfs_default_resblks(mp);
912 xfs_reserve_blocks(mp, resblks);
916 * Second stage of a freeze. The data is already frozen so we only
917 * need to take care of the metadata. Once that's done sync the superblock
918 * to the log to dirty it in case of a crash while frozen. This ensures that we
919 * will recover the unlinked inode lists on the next mount.
923 struct super_block *sb)
925 struct xfs_mount *mp = XFS_M(sb);
930 * The filesystem is now frozen far enough that memory reclaim
931 * cannot safely operate on the filesystem. Hence we need to
932 * set a GFP_NOFS context here to avoid recursion deadlocks.
934 flags = memalloc_nofs_save();
935 xfs_save_resvblks(mp);
936 ret = xfs_log_quiesce(mp);
937 memalloc_nofs_restore(flags);
940 * For read-write filesystems, we need to restart the inodegc on error
941 * because we stopped it at SB_FREEZE_PAGEFAULT level and a thaw is not
942 * going to be run to restart it now. We are at SB_FREEZE_FS level
943 * here, so we can restart safely without racing with a stop in
946 if (ret && !xfs_is_readonly(mp)) {
947 xfs_blockgc_start(mp);
948 xfs_inodegc_start(mp);
956 struct super_block *sb)
958 struct xfs_mount *mp = XFS_M(sb);
960 xfs_restore_resvblks(mp);
961 xfs_log_work_queue(mp);
964 * Don't reactivate the inodegc worker on a readonly filesystem because
965 * inodes are sent directly to reclaim. Don't reactivate the blockgc
966 * worker because there are no speculative preallocations on a readonly
969 if (!xfs_is_readonly(mp)) {
970 xfs_blockgc_start(mp);
971 xfs_inodegc_start(mp);
978 * This function fills in xfs_mount_t fields based on mount args.
979 * Note: the superblock _has_ now been read in.
983 struct xfs_mount *mp)
985 /* Fail a mount where the logbuf is smaller than the log stripe */
986 if (xfs_has_logv2(mp)) {
987 if (mp->m_logbsize <= 0 &&
988 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
989 mp->m_logbsize = mp->m_sb.sb_logsunit;
990 } else if (mp->m_logbsize > 0 &&
991 mp->m_logbsize < mp->m_sb.sb_logsunit) {
993 "logbuf size must be greater than or equal to log stripe size");
997 /* Fail a mount if the logbuf is larger than 32K */
998 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1000 "logbuf size for version 1 logs must be 16K or 32K");
1006 * V5 filesystems always use attr2 format for attributes.
1008 if (xfs_has_crc(mp) && xfs_has_noattr2(mp)) {
1009 xfs_warn(mp, "Cannot mount a V5 filesystem as noattr2. "
1010 "attr2 is always enabled for V5 filesystems.");
1015 * prohibit r/w mounts of read-only filesystems
1017 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) {
1019 "cannot mount a read-only filesystem as read-write");
1023 if ((mp->m_qflags & XFS_GQUOTA_ACCT) &&
1024 (mp->m_qflags & XFS_PQUOTA_ACCT) &&
1025 !xfs_has_pquotino(mp)) {
1027 "Super block does not support project and group quota together");
1035 xfs_init_percpu_counters(
1036 struct xfs_mount *mp)
1040 error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL);
1044 error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL);
1048 error = percpu_counter_init(&mp->m_fdblocks, 0, GFP_KERNEL);
1052 error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL);
1056 error = percpu_counter_init(&mp->m_frextents, 0, GFP_KERNEL);
1063 percpu_counter_destroy(&mp->m_delalloc_blks);
1065 percpu_counter_destroy(&mp->m_fdblocks);
1067 percpu_counter_destroy(&mp->m_ifree);
1069 percpu_counter_destroy(&mp->m_icount);
1074 xfs_reinit_percpu_counters(
1075 struct xfs_mount *mp)
1077 percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount);
1078 percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree);
1079 percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks);
1080 percpu_counter_set(&mp->m_frextents, mp->m_sb.sb_frextents);
1084 xfs_destroy_percpu_counters(
1085 struct xfs_mount *mp)
1087 percpu_counter_destroy(&mp->m_icount);
1088 percpu_counter_destroy(&mp->m_ifree);
1089 percpu_counter_destroy(&mp->m_fdblocks);
1090 ASSERT(xfs_is_shutdown(mp) ||
1091 percpu_counter_sum(&mp->m_delalloc_blks) == 0);
1092 percpu_counter_destroy(&mp->m_delalloc_blks);
1093 percpu_counter_destroy(&mp->m_frextents);
1097 xfs_inodegc_init_percpu(
1098 struct xfs_mount *mp)
1100 struct xfs_inodegc *gc;
1103 mp->m_inodegc = alloc_percpu(struct xfs_inodegc);
1107 for_each_possible_cpu(cpu) {
1108 gc = per_cpu_ptr(mp->m_inodegc, cpu);
1111 init_llist_head(&gc->list);
1114 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker);
1120 xfs_inodegc_free_percpu(
1121 struct xfs_mount *mp)
1125 free_percpu(mp->m_inodegc);
1130 struct super_block *sb)
1132 struct xfs_mount *mp = XFS_M(sb);
1134 xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid);
1135 xfs_filestream_unmount(mp);
1139 xchk_mount_stats_free(mp);
1140 free_percpu(mp->m_stats.xs_stats);
1141 xfs_inodegc_free_percpu(mp);
1142 xfs_destroy_percpu_counters(mp);
1143 xfs_destroy_mount_workqueues(mp);
1144 xfs_shutdown_devices(mp);
1148 xfs_fs_nr_cached_objects(
1149 struct super_block *sb,
1150 struct shrink_control *sc)
1152 /* Paranoia: catch incorrect calls during mount setup or teardown */
1153 if (WARN_ON_ONCE(!sb->s_fs_info))
1155 return xfs_reclaim_inodes_count(XFS_M(sb));
1159 xfs_fs_free_cached_objects(
1160 struct super_block *sb,
1161 struct shrink_control *sc)
1163 return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan);
1168 struct super_block *sb)
1170 xfs_force_shutdown(XFS_M(sb), SHUTDOWN_DEVICE_REMOVED);
1173 static const struct super_operations xfs_super_operations = {
1174 .alloc_inode = xfs_fs_alloc_inode,
1175 .destroy_inode = xfs_fs_destroy_inode,
1176 .dirty_inode = xfs_fs_dirty_inode,
1177 .drop_inode = xfs_fs_drop_inode,
1178 .put_super = xfs_fs_put_super,
1179 .sync_fs = xfs_fs_sync_fs,
1180 .freeze_fs = xfs_fs_freeze,
1181 .unfreeze_fs = xfs_fs_unfreeze,
1182 .statfs = xfs_fs_statfs,
1183 .show_options = xfs_fs_show_options,
1184 .nr_cached_objects = xfs_fs_nr_cached_objects,
1185 .free_cached_objects = xfs_fs_free_cached_objects,
1186 .shutdown = xfs_fs_shutdown,
1195 int last, shift_left_factor = 0, _res;
1199 value = kstrdup(s, GFP_KERNEL);
1203 last = strlen(value) - 1;
1204 if (value[last] == 'K' || value[last] == 'k') {
1205 shift_left_factor = 10;
1208 if (value[last] == 'M' || value[last] == 'm') {
1209 shift_left_factor = 20;
1212 if (value[last] == 'G' || value[last] == 'g') {
1213 shift_left_factor = 30;
1217 if (kstrtoint(value, base, &_res))
1220 *res = _res << shift_left_factor;
1225 xfs_fs_warn_deprecated(
1226 struct fs_context *fc,
1227 struct fs_parameter *param,
1231 /* Don't print the warning if reconfiguring and current mount point
1232 * already had the flag set
1234 if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) &&
1235 !!(XFS_M(fc->root->d_sb)->m_features & flag) == value)
1237 xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key);
1241 * Set mount state from a mount option.
1243 * NOTE: mp->m_super is NULL here!
1247 struct fs_context *fc,
1248 struct fs_parameter *param)
1250 struct xfs_mount *parsing_mp = fc->s_fs_info;
1251 struct fs_parse_result result;
1255 opt = fs_parse(fc, xfs_fs_parameters, param, &result);
1261 parsing_mp->m_logbufs = result.uint_32;
1264 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize))
1268 kfree(parsing_mp->m_logname);
1269 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL);
1270 if (!parsing_mp->m_logname)
1274 kfree(parsing_mp->m_rtname);
1275 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL);
1276 if (!parsing_mp->m_rtname)
1280 if (suffix_kstrtoint(param->string, 10, &size))
1282 parsing_mp->m_allocsize_log = ffs(size) - 1;
1283 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE;
1287 parsing_mp->m_features |= XFS_FEAT_GRPID;
1290 case Opt_sysvgroups:
1291 parsing_mp->m_features &= ~XFS_FEAT_GRPID;
1294 parsing_mp->m_features |= XFS_FEAT_WSYNC;
1296 case Opt_norecovery:
1297 parsing_mp->m_features |= XFS_FEAT_NORECOVERY;
1300 parsing_mp->m_features |= XFS_FEAT_NOALIGN;
1303 parsing_mp->m_features |= XFS_FEAT_SWALLOC;
1306 parsing_mp->m_dalign = result.uint_32;
1309 parsing_mp->m_swidth = result.uint_32;
1312 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS;
1315 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1318 parsing_mp->m_features |= XFS_FEAT_NOUUID;
1321 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE;
1324 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE;
1326 case Opt_filestreams:
1327 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS;
1330 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
1331 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
1336 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD);
1338 case Opt_qnoenforce:
1339 case Opt_uqnoenforce:
1340 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT;
1341 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD;
1345 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD);
1347 case Opt_pqnoenforce:
1348 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT;
1349 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD;
1353 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD);
1355 case Opt_gqnoenforce:
1356 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT;
1357 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD;
1360 parsing_mp->m_features |= XFS_FEAT_DISCARD;
1363 parsing_mp->m_features &= ~XFS_FEAT_DISCARD;
1365 #ifdef CONFIG_FS_DAX
1367 xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
1370 xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
1373 /* Following mount options will be removed in September 2025 */
1375 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, true);
1376 parsing_mp->m_features |= XFS_FEAT_IKEEP;
1379 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, false);
1380 parsing_mp->m_features &= ~XFS_FEAT_IKEEP;
1383 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_ATTR2, true);
1384 parsing_mp->m_features |= XFS_FEAT_ATTR2;
1387 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_NOATTR2, true);
1388 parsing_mp->m_features |= XFS_FEAT_NOATTR2;
1391 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key);
1399 xfs_fs_validate_params(
1400 struct xfs_mount *mp)
1402 /* No recovery flag requires a read-only mount */
1403 if (xfs_has_norecovery(mp) && !xfs_is_readonly(mp)) {
1404 xfs_warn(mp, "no-recovery mounts must be read-only.");
1409 * We have not read the superblock at this point, so only the attr2
1410 * mount option can set the attr2 feature by this stage.
1412 if (xfs_has_attr2(mp) && xfs_has_noattr2(mp)) {
1413 xfs_warn(mp, "attr2 and noattr2 cannot both be specified.");
1418 if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) {
1420 "sunit and swidth options incompatible with the noalign option");
1424 if (!IS_ENABLED(CONFIG_XFS_QUOTA) && mp->m_qflags != 0) {
1425 xfs_warn(mp, "quota support not available in this kernel.");
1429 if ((mp->m_dalign && !mp->m_swidth) ||
1430 (!mp->m_dalign && mp->m_swidth)) {
1431 xfs_warn(mp, "sunit and swidth must be specified together");
1435 if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) {
1437 "stripe width (%d) must be a multiple of the stripe unit (%d)",
1438 mp->m_swidth, mp->m_dalign);
1442 if (mp->m_logbufs != -1 &&
1443 mp->m_logbufs != 0 &&
1444 (mp->m_logbufs < XLOG_MIN_ICLOGS ||
1445 mp->m_logbufs > XLOG_MAX_ICLOGS)) {
1446 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
1447 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
1451 if (mp->m_logbsize != -1 &&
1452 mp->m_logbsize != 0 &&
1453 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
1454 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
1455 !is_power_of_2(mp->m_logbsize))) {
1457 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
1462 if (xfs_has_allocsize(mp) &&
1463 (mp->m_allocsize_log > XFS_MAX_IO_LOG ||
1464 mp->m_allocsize_log < XFS_MIN_IO_LOG)) {
1465 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
1466 mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
1476 struct dentry *parent)
1478 struct dentry *child;
1480 /* Apparently we're expected to ignore error returns?? */
1481 child = debugfs_create_dir(name, parent);
1490 struct super_block *sb,
1491 struct fs_context *fc)
1493 struct xfs_mount *mp = sb->s_fs_info;
1495 int flags = 0, error;
1500 * Copy VFS mount flags from the context now that all parameter parsing
1501 * is guaranteed to have been completed by either the old mount API or
1502 * the newer fsopen/fsconfig API.
1504 if (fc->sb_flags & SB_RDONLY)
1505 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1506 if (fc->sb_flags & SB_DIRSYNC)
1507 mp->m_features |= XFS_FEAT_DIRSYNC;
1508 if (fc->sb_flags & SB_SYNCHRONOUS)
1509 mp->m_features |= XFS_FEAT_WSYNC;
1511 error = xfs_fs_validate_params(mp);
1515 sb_min_blocksize(sb, BBSIZE);
1516 sb->s_xattr = xfs_xattr_handlers;
1517 sb->s_export_op = &xfs_export_operations;
1518 #ifdef CONFIG_XFS_QUOTA
1519 sb->s_qcop = &xfs_quotactl_operations;
1520 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
1522 sb->s_op = &xfs_super_operations;
1525 * Delay mount work if the debug hook is set. This is debug
1526 * instrumention to coordinate simulation of xfs mount failures with
1527 * VFS superblock operations
1529 if (xfs_globals.mount_delay) {
1530 xfs_notice(mp, "Delaying mount for %d seconds.",
1531 xfs_globals.mount_delay);
1532 msleep(xfs_globals.mount_delay * 1000);
1535 if (fc->sb_flags & SB_SILENT)
1536 flags |= XFS_MFSI_QUIET;
1538 error = xfs_open_devices(mp);
1543 mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id,
1546 mp->m_debugfs = NULL;
1549 error = xfs_init_mount_workqueues(mp);
1551 goto out_shutdown_devices;
1553 error = xfs_init_percpu_counters(mp);
1555 goto out_destroy_workqueues;
1557 error = xfs_inodegc_init_percpu(mp);
1559 goto out_destroy_counters;
1561 /* Allocate stats memory before we do operations that might use it */
1562 mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
1563 if (!mp->m_stats.xs_stats) {
1565 goto out_destroy_inodegc;
1568 error = xchk_mount_stats_alloc(mp);
1570 goto out_free_stats;
1572 error = xfs_readsb(mp, flags);
1574 goto out_free_scrub_stats;
1576 error = xfs_finish_flags(mp);
1580 error = xfs_setup_devices(mp);
1584 /* V4 support is undergoing deprecation. */
1585 if (!xfs_has_crc(mp)) {
1586 #ifdef CONFIG_XFS_SUPPORT_V4
1588 "Deprecated V4 format (crc=0) will not be supported after September 2030.");
1591 "Deprecated V4 format (crc=0) not supported by kernel.");
1597 /* ASCII case insensitivity is undergoing deprecation. */
1598 if (xfs_has_asciici(mp)) {
1599 #ifdef CONFIG_XFS_SUPPORT_ASCII_CI
1601 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 2030.");
1604 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel.");
1610 /* Filesystem claims it needs repair, so refuse the mount. */
1611 if (xfs_has_needsrepair(mp)) {
1612 xfs_warn(mp, "Filesystem needs repair. Please run xfs_repair.");
1613 error = -EFSCORRUPTED;
1618 * Don't touch the filesystem if a user tool thinks it owns the primary
1619 * superblock. mkfs doesn't clear the flag from secondary supers, so
1620 * we don't check them at all.
1622 if (mp->m_sb.sb_inprogress) {
1623 xfs_warn(mp, "Offline file system operation in progress!");
1624 error = -EFSCORRUPTED;
1629 * Until this is fixed only page-sized or smaller data blocks work.
1631 if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
1633 "File system with blocksize %d bytes. "
1634 "Only pagesize (%ld) or less will currently work.",
1635 mp->m_sb.sb_blocksize, PAGE_SIZE);
1640 /* Ensure this filesystem fits in the page cache limits */
1641 if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) ||
1642 xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) {
1644 "file system too large to be mounted on this system.");
1650 * XFS block mappings use 54 bits to store the logical block offset.
1651 * This should suffice to handle the maximum file size that the VFS
1652 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT
1653 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes
1654 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON
1655 * to check this assertion.
1657 * Avoid integer overflow by comparing the maximum bmbt offset to the
1658 * maximum pagecache offset in units of fs blocks.
1660 if (!xfs_verify_fileoff(mp, XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE))) {
1662 "MAX_LFS_FILESIZE block offset (%llu) exceeds extent map maximum (%llu)!",
1663 XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE),
1669 error = xfs_filestream_mount(mp);
1674 * we must configure the block size in the superblock before we run the
1675 * full mount process as the mount process can lookup and cache inodes.
1677 sb->s_magic = XFS_SUPER_MAGIC;
1678 sb->s_blocksize = mp->m_sb.sb_blocksize;
1679 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
1680 sb->s_maxbytes = MAX_LFS_FILESIZE;
1681 sb->s_max_links = XFS_MAXLINK;
1682 sb->s_time_gran = 1;
1683 if (xfs_has_bigtime(mp)) {
1684 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN);
1685 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX);
1687 sb->s_time_min = XFS_LEGACY_TIME_MIN;
1688 sb->s_time_max = XFS_LEGACY_TIME_MAX;
1690 trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max);
1691 sb->s_iflags |= SB_I_CGROUPWB;
1693 set_posix_acl_flag(sb);
1695 /* version 5 superblocks support inode version counters. */
1696 if (xfs_has_crc(mp))
1697 sb->s_flags |= SB_I_VERSION;
1699 if (xfs_has_dax_always(mp)) {
1700 error = xfs_setup_dax_always(mp);
1702 goto out_filestream_unmount;
1705 if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) {
1707 "mounting with \"discard\" option, but the device does not support discard");
1708 mp->m_features &= ~XFS_FEAT_DISCARD;
1711 if (xfs_has_reflink(mp)) {
1712 if (mp->m_sb.sb_rblocks) {
1714 "reflink not compatible with realtime device!");
1716 goto out_filestream_unmount;
1719 if (xfs_globals.always_cow) {
1720 xfs_info(mp, "using DEBUG-only always_cow mode.");
1721 mp->m_always_cow = true;
1725 if (xfs_has_rmapbt(mp) && mp->m_sb.sb_rblocks) {
1727 "reverse mapping btree not compatible with realtime device!");
1729 goto out_filestream_unmount;
1732 error = xfs_mountfs(mp);
1734 goto out_filestream_unmount;
1736 root = igrab(VFS_I(mp->m_rootip));
1741 sb->s_root = d_make_root(root);
1749 out_filestream_unmount:
1750 xfs_filestream_unmount(mp);
1753 out_free_scrub_stats:
1754 xchk_mount_stats_free(mp);
1756 free_percpu(mp->m_stats.xs_stats);
1757 out_destroy_inodegc:
1758 xfs_inodegc_free_percpu(mp);
1759 out_destroy_counters:
1760 xfs_destroy_percpu_counters(mp);
1761 out_destroy_workqueues:
1762 xfs_destroy_mount_workqueues(mp);
1763 out_shutdown_devices:
1764 xfs_shutdown_devices(mp);
1768 xfs_filestream_unmount(mp);
1775 struct fs_context *fc)
1777 return get_tree_bdev(fc, xfs_fs_fill_super);
1782 struct xfs_mount *mp)
1784 struct xfs_sb *sbp = &mp->m_sb;
1787 if (xfs_has_norecovery(mp)) {
1789 "ro->rw transition prohibited on norecovery mount");
1793 if (xfs_sb_is_v5(sbp) &&
1794 xfs_sb_has_ro_compat_feature(sbp, XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
1796 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
1797 (sbp->sb_features_ro_compat &
1798 XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
1802 clear_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1805 * If this is the first remount to writeable state we might have some
1806 * superblock changes to update.
1808 if (mp->m_update_sb) {
1809 error = xfs_sync_sb(mp, false);
1811 xfs_warn(mp, "failed to write sb changes");
1814 mp->m_update_sb = false;
1818 * Fill out the reserve pool if it is empty. Use the stashed value if
1819 * it is non-zero, otherwise go with the default.
1821 xfs_restore_resvblks(mp);
1822 xfs_log_work_queue(mp);
1823 xfs_blockgc_start(mp);
1825 /* Create the per-AG metadata reservation pool .*/
1826 error = xfs_fs_reserve_ag_blocks(mp);
1827 if (error && error != -ENOSPC)
1830 /* Re-enable the background inode inactivation worker. */
1831 xfs_inodegc_start(mp);
1838 struct xfs_mount *mp)
1840 struct xfs_icwalk icw = {
1841 .icw_flags = XFS_ICWALK_FLAG_SYNC,
1845 /* Flush all the dirty data to disk. */
1846 error = sync_filesystem(mp->m_super);
1851 * Cancel background eofb scanning so it cannot race with the final
1852 * log force+buftarg wait and deadlock the remount.
1854 xfs_blockgc_stop(mp);
1857 * Clear out all remaining COW staging extents and speculative post-EOF
1858 * preallocations so that we don't leave inodes requiring inactivation
1859 * cleanups during reclaim on a read-only mount. We must process every
1860 * cached inode, so this requires a synchronous cache scan.
1862 error = xfs_blockgc_free_space(mp, &icw);
1864 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1869 * Stop the inodegc background worker. xfs_fs_reconfigure already
1870 * flushed all pending inodegc work when it sync'd the filesystem.
1871 * The VFS holds s_umount, so we know that inodes cannot enter
1872 * xfs_fs_destroy_inode during a remount operation. In readonly mode
1873 * we send inodes straight to reclaim, so no inodes will be queued.
1875 xfs_inodegc_stop(mp);
1877 /* Free the per-AG metadata reservation pool. */
1878 error = xfs_fs_unreserve_ag_blocks(mp);
1880 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1885 * Before we sync the metadata, we need to free up the reserve block
1886 * pool so that the used block count in the superblock on disk is
1887 * correct at the end of the remount. Stash the current* reserve pool
1888 * size so that if we get remounted rw, we can return it to the same
1891 xfs_save_resvblks(mp);
1894 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1900 * Logically we would return an error here to prevent users from believing
1901 * they might have changed mount options using remount which can't be changed.
1903 * But unfortunately mount(8) adds all options from mtab and fstab to the mount
1904 * arguments in some cases so we can't blindly reject options, but have to
1905 * check for each specified option if it actually differs from the currently
1906 * set option and only reject it if that's the case.
1908 * Until that is implemented we return success for every remount request, and
1909 * silently ignore all options that we can't actually change.
1913 struct fs_context *fc)
1915 struct xfs_mount *mp = XFS_M(fc->root->d_sb);
1916 struct xfs_mount *new_mp = fc->s_fs_info;
1917 int flags = fc->sb_flags;
1920 /* version 5 superblocks always support version counters. */
1921 if (xfs_has_crc(mp))
1922 fc->sb_flags |= SB_I_VERSION;
1924 error = xfs_fs_validate_params(new_mp);
1928 /* inode32 -> inode64 */
1929 if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) {
1930 mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1931 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1934 /* inode64 -> inode32 */
1935 if (!xfs_has_small_inums(mp) && xfs_has_small_inums(new_mp)) {
1936 mp->m_features |= XFS_FEAT_SMALL_INUMS;
1937 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1941 if (xfs_is_readonly(mp) && !(flags & SB_RDONLY)) {
1942 error = xfs_remount_rw(mp);
1948 if (!xfs_is_readonly(mp) && (flags & SB_RDONLY)) {
1949 error = xfs_remount_ro(mp);
1959 struct fs_context *fc)
1961 struct xfs_mount *mp = fc->s_fs_info;
1964 * mp is stored in the fs_context when it is initialized.
1965 * mp is transferred to the superblock on a successful mount,
1966 * but if an error occurs before the transfer we have to free
1973 static const struct fs_context_operations xfs_context_ops = {
1974 .parse_param = xfs_fs_parse_param,
1975 .get_tree = xfs_fs_get_tree,
1976 .reconfigure = xfs_fs_reconfigure,
1977 .free = xfs_fs_free,
1981 * WARNING: do not initialise any parameters in this function that depend on
1982 * mount option parsing having already been performed as this can be called from
1983 * fsopen() before any parameters have been set.
1985 static int xfs_init_fs_context(
1986 struct fs_context *fc)
1988 struct xfs_mount *mp;
1990 mp = kmem_alloc(sizeof(struct xfs_mount), KM_ZERO);
1994 spin_lock_init(&mp->m_sb_lock);
1995 INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC);
1996 spin_lock_init(&mp->m_perag_lock);
1997 mutex_init(&mp->m_growlock);
1998 INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker);
1999 INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker);
2000 mp->m_kobj.kobject.kset = xfs_kset;
2002 * We don't create the finobt per-ag space reservation until after log
2003 * recovery, so we must set this to true so that an ifree transaction
2004 * started during log recovery will not depend on space reservations
2005 * for finobt expansion.
2007 mp->m_finobt_nores = true;
2010 * These can be overridden by the mount option parsing.
2013 mp->m_logbsize = -1;
2014 mp->m_allocsize_log = 16; /* 64k */
2017 fc->ops = &xfs_context_ops;
2024 struct super_block *sb)
2026 kill_block_super(sb);
2027 xfs_mount_free(XFS_M(sb));
2030 static struct file_system_type xfs_fs_type = {
2031 .owner = THIS_MODULE,
2033 .init_fs_context = xfs_init_fs_context,
2034 .parameters = xfs_fs_parameters,
2035 .kill_sb = xfs_kill_sb,
2036 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
2038 MODULE_ALIAS_FS("xfs");
2041 xfs_init_caches(void)
2045 xfs_buf_cache = kmem_cache_create("xfs_buf", sizeof(struct xfs_buf), 0,
2046 SLAB_HWCACHE_ALIGN |
2047 SLAB_RECLAIM_ACCOUNT |
2053 xfs_log_ticket_cache = kmem_cache_create("xfs_log_ticket",
2054 sizeof(struct xlog_ticket),
2056 if (!xfs_log_ticket_cache)
2057 goto out_destroy_buf_cache;
2059 error = xfs_btree_init_cur_caches();
2061 goto out_destroy_log_ticket_cache;
2063 error = xfs_defer_init_item_caches();
2065 goto out_destroy_btree_cur_cache;
2067 xfs_da_state_cache = kmem_cache_create("xfs_da_state",
2068 sizeof(struct xfs_da_state),
2070 if (!xfs_da_state_cache)
2071 goto out_destroy_defer_item_cache;
2073 xfs_ifork_cache = kmem_cache_create("xfs_ifork",
2074 sizeof(struct xfs_ifork),
2076 if (!xfs_ifork_cache)
2077 goto out_destroy_da_state_cache;
2079 xfs_trans_cache = kmem_cache_create("xfs_trans",
2080 sizeof(struct xfs_trans),
2082 if (!xfs_trans_cache)
2083 goto out_destroy_ifork_cache;
2087 * The size of the cache-allocated buf log item is the maximum
2088 * size possible under XFS. This wastes a little bit of memory,
2089 * but it is much faster.
2091 xfs_buf_item_cache = kmem_cache_create("xfs_buf_item",
2092 sizeof(struct xfs_buf_log_item),
2094 if (!xfs_buf_item_cache)
2095 goto out_destroy_trans_cache;
2097 xfs_efd_cache = kmem_cache_create("xfs_efd_item",
2098 xfs_efd_log_item_sizeof(XFS_EFD_MAX_FAST_EXTENTS),
2101 goto out_destroy_buf_item_cache;
2103 xfs_efi_cache = kmem_cache_create("xfs_efi_item",
2104 xfs_efi_log_item_sizeof(XFS_EFI_MAX_FAST_EXTENTS),
2107 goto out_destroy_efd_cache;
2109 xfs_inode_cache = kmem_cache_create("xfs_inode",
2110 sizeof(struct xfs_inode), 0,
2111 (SLAB_HWCACHE_ALIGN |
2112 SLAB_RECLAIM_ACCOUNT |
2113 SLAB_MEM_SPREAD | SLAB_ACCOUNT),
2114 xfs_fs_inode_init_once);
2115 if (!xfs_inode_cache)
2116 goto out_destroy_efi_cache;
2118 xfs_ili_cache = kmem_cache_create("xfs_ili",
2119 sizeof(struct xfs_inode_log_item), 0,
2120 SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
2123 goto out_destroy_inode_cache;
2125 xfs_icreate_cache = kmem_cache_create("xfs_icr",
2126 sizeof(struct xfs_icreate_item),
2128 if (!xfs_icreate_cache)
2129 goto out_destroy_ili_cache;
2131 xfs_rud_cache = kmem_cache_create("xfs_rud_item",
2132 sizeof(struct xfs_rud_log_item),
2135 goto out_destroy_icreate_cache;
2137 xfs_rui_cache = kmem_cache_create("xfs_rui_item",
2138 xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS),
2141 goto out_destroy_rud_cache;
2143 xfs_cud_cache = kmem_cache_create("xfs_cud_item",
2144 sizeof(struct xfs_cud_log_item),
2147 goto out_destroy_rui_cache;
2149 xfs_cui_cache = kmem_cache_create("xfs_cui_item",
2150 xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS),
2153 goto out_destroy_cud_cache;
2155 xfs_bud_cache = kmem_cache_create("xfs_bud_item",
2156 sizeof(struct xfs_bud_log_item),
2159 goto out_destroy_cui_cache;
2161 xfs_bui_cache = kmem_cache_create("xfs_bui_item",
2162 xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS),
2165 goto out_destroy_bud_cache;
2167 xfs_attrd_cache = kmem_cache_create("xfs_attrd_item",
2168 sizeof(struct xfs_attrd_log_item),
2170 if (!xfs_attrd_cache)
2171 goto out_destroy_bui_cache;
2173 xfs_attri_cache = kmem_cache_create("xfs_attri_item",
2174 sizeof(struct xfs_attri_log_item),
2176 if (!xfs_attri_cache)
2177 goto out_destroy_attrd_cache;
2179 xfs_iunlink_cache = kmem_cache_create("xfs_iul_item",
2180 sizeof(struct xfs_iunlink_item),
2182 if (!xfs_iunlink_cache)
2183 goto out_destroy_attri_cache;
2187 out_destroy_attri_cache:
2188 kmem_cache_destroy(xfs_attri_cache);
2189 out_destroy_attrd_cache:
2190 kmem_cache_destroy(xfs_attrd_cache);
2191 out_destroy_bui_cache:
2192 kmem_cache_destroy(xfs_bui_cache);
2193 out_destroy_bud_cache:
2194 kmem_cache_destroy(xfs_bud_cache);
2195 out_destroy_cui_cache:
2196 kmem_cache_destroy(xfs_cui_cache);
2197 out_destroy_cud_cache:
2198 kmem_cache_destroy(xfs_cud_cache);
2199 out_destroy_rui_cache:
2200 kmem_cache_destroy(xfs_rui_cache);
2201 out_destroy_rud_cache:
2202 kmem_cache_destroy(xfs_rud_cache);
2203 out_destroy_icreate_cache:
2204 kmem_cache_destroy(xfs_icreate_cache);
2205 out_destroy_ili_cache:
2206 kmem_cache_destroy(xfs_ili_cache);
2207 out_destroy_inode_cache:
2208 kmem_cache_destroy(xfs_inode_cache);
2209 out_destroy_efi_cache:
2210 kmem_cache_destroy(xfs_efi_cache);
2211 out_destroy_efd_cache:
2212 kmem_cache_destroy(xfs_efd_cache);
2213 out_destroy_buf_item_cache:
2214 kmem_cache_destroy(xfs_buf_item_cache);
2215 out_destroy_trans_cache:
2216 kmem_cache_destroy(xfs_trans_cache);
2217 out_destroy_ifork_cache:
2218 kmem_cache_destroy(xfs_ifork_cache);
2219 out_destroy_da_state_cache:
2220 kmem_cache_destroy(xfs_da_state_cache);
2221 out_destroy_defer_item_cache:
2222 xfs_defer_destroy_item_caches();
2223 out_destroy_btree_cur_cache:
2224 xfs_btree_destroy_cur_caches();
2225 out_destroy_log_ticket_cache:
2226 kmem_cache_destroy(xfs_log_ticket_cache);
2227 out_destroy_buf_cache:
2228 kmem_cache_destroy(xfs_buf_cache);
2234 xfs_destroy_caches(void)
2237 * Make sure all delayed rcu free are flushed before we
2241 kmem_cache_destroy(xfs_iunlink_cache);
2242 kmem_cache_destroy(xfs_attri_cache);
2243 kmem_cache_destroy(xfs_attrd_cache);
2244 kmem_cache_destroy(xfs_bui_cache);
2245 kmem_cache_destroy(xfs_bud_cache);
2246 kmem_cache_destroy(xfs_cui_cache);
2247 kmem_cache_destroy(xfs_cud_cache);
2248 kmem_cache_destroy(xfs_rui_cache);
2249 kmem_cache_destroy(xfs_rud_cache);
2250 kmem_cache_destroy(xfs_icreate_cache);
2251 kmem_cache_destroy(xfs_ili_cache);
2252 kmem_cache_destroy(xfs_inode_cache);
2253 kmem_cache_destroy(xfs_efi_cache);
2254 kmem_cache_destroy(xfs_efd_cache);
2255 kmem_cache_destroy(xfs_buf_item_cache);
2256 kmem_cache_destroy(xfs_trans_cache);
2257 kmem_cache_destroy(xfs_ifork_cache);
2258 kmem_cache_destroy(xfs_da_state_cache);
2259 xfs_defer_destroy_item_caches();
2260 xfs_btree_destroy_cur_caches();
2261 kmem_cache_destroy(xfs_log_ticket_cache);
2262 kmem_cache_destroy(xfs_buf_cache);
2266 xfs_init_workqueues(void)
2269 * The allocation workqueue can be used in memory reclaim situations
2270 * (writepage path), and parallelism is only limited by the number of
2271 * AGs in all the filesystems mounted. Hence use the default large
2272 * max_active value for this workqueue.
2274 xfs_alloc_wq = alloc_workqueue("xfsalloc",
2275 XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 0);
2279 xfs_discard_wq = alloc_workqueue("xfsdiscard", XFS_WQFLAGS(WQ_UNBOUND),
2281 if (!xfs_discard_wq)
2282 goto out_free_alloc_wq;
2286 destroy_workqueue(xfs_alloc_wq);
2291 xfs_destroy_workqueues(void)
2293 destroy_workqueue(xfs_discard_wq);
2294 destroy_workqueue(xfs_alloc_wq);
2302 xfs_check_ondisk_structs();
2304 error = xfs_dahash_test();
2308 printk(KERN_INFO XFS_VERSION_STRING " with "
2309 XFS_BUILD_OPTIONS " enabled\n");
2313 error = xfs_init_caches();
2317 error = xfs_init_workqueues();
2319 goto out_destroy_caches;
2321 error = xfs_mru_cache_init();
2323 goto out_destroy_wq;
2325 error = xfs_init_procfs();
2327 goto out_mru_cache_uninit;
2329 error = xfs_sysctl_register();
2331 goto out_cleanup_procfs;
2333 xfs_debugfs = xfs_debugfs_mkdir("xfs", NULL);
2335 xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
2338 goto out_debugfs_unregister;
2341 xfsstats.xs_kobj.kobject.kset = xfs_kset;
2343 xfsstats.xs_stats = alloc_percpu(struct xfsstats);
2344 if (!xfsstats.xs_stats) {
2346 goto out_kset_unregister;
2349 error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
2352 goto out_free_stats;
2354 error = xchk_global_stats_setup(xfs_debugfs);
2356 goto out_remove_stats_kobj;
2359 xfs_dbg_kobj.kobject.kset = xfs_kset;
2360 error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
2362 goto out_remove_scrub_stats;
2365 error = xfs_qm_init();
2367 goto out_remove_dbg_kobj;
2369 error = register_filesystem(&xfs_fs_type);
2376 out_remove_dbg_kobj:
2378 xfs_sysfs_del(&xfs_dbg_kobj);
2379 out_remove_scrub_stats:
2381 xchk_global_stats_teardown();
2382 out_remove_stats_kobj:
2383 xfs_sysfs_del(&xfsstats.xs_kobj);
2385 free_percpu(xfsstats.xs_stats);
2386 out_kset_unregister:
2387 kset_unregister(xfs_kset);
2388 out_debugfs_unregister:
2389 debugfs_remove(xfs_debugfs);
2390 xfs_sysctl_unregister();
2392 xfs_cleanup_procfs();
2393 out_mru_cache_uninit:
2394 xfs_mru_cache_uninit();
2396 xfs_destroy_workqueues();
2398 xfs_destroy_caches();
2407 unregister_filesystem(&xfs_fs_type);
2409 xfs_sysfs_del(&xfs_dbg_kobj);
2411 xchk_global_stats_teardown();
2412 xfs_sysfs_del(&xfsstats.xs_kobj);
2413 free_percpu(xfsstats.xs_stats);
2414 kset_unregister(xfs_kset);
2415 debugfs_remove(xfs_debugfs);
2416 xfs_sysctl_unregister();
2417 xfs_cleanup_procfs();
2418 xfs_mru_cache_uninit();
2419 xfs_destroy_workqueues();
2420 xfs_destroy_caches();
2421 xfs_uuid_table_free();
2424 module_init(init_xfs_fs);
2425 module_exit(exit_xfs_fs);
2427 MODULE_AUTHOR("Silicon Graphics, Inc.");
2428 MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
2429 MODULE_LICENSE("GPL");