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"
46 #include <linux/magic.h>
47 #include <linux/fs_context.h>
48 #include <linux/fs_parser.h>
50 static const struct super_operations xfs_super_operations;
52 static struct kset *xfs_kset; /* top-level xfs sysfs dir */
54 static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
57 #ifdef CONFIG_HOTPLUG_CPU
58 static LIST_HEAD(xfs_mount_list);
59 static DEFINE_SPINLOCK(xfs_mount_list_lock);
61 static inline void xfs_mount_list_add(struct xfs_mount *mp)
63 spin_lock(&xfs_mount_list_lock);
64 list_add(&mp->m_mount_list, &xfs_mount_list);
65 spin_unlock(&xfs_mount_list_lock);
68 static inline void xfs_mount_list_del(struct xfs_mount *mp)
70 spin_lock(&xfs_mount_list_lock);
71 list_del(&mp->m_mount_list);
72 spin_unlock(&xfs_mount_list_lock);
74 #else /* !CONFIG_HOTPLUG_CPU */
75 static inline void xfs_mount_list_add(struct xfs_mount *mp) {}
76 static inline void xfs_mount_list_del(struct xfs_mount *mp) {}
86 xfs_mount_set_dax_mode(
88 enum xfs_dax_mode mode)
92 mp->m_features &= ~(XFS_FEAT_DAX_ALWAYS | XFS_FEAT_DAX_NEVER);
95 mp->m_features |= XFS_FEAT_DAX_ALWAYS;
96 mp->m_features &= ~XFS_FEAT_DAX_NEVER;
99 mp->m_features |= XFS_FEAT_DAX_NEVER;
100 mp->m_features &= ~XFS_FEAT_DAX_ALWAYS;
105 static const struct constant_table dax_param_enums[] = {
106 {"inode", XFS_DAX_INODE },
107 {"always", XFS_DAX_ALWAYS },
108 {"never", XFS_DAX_NEVER },
113 * Table driven mount option parser.
116 Opt_logbufs, Opt_logbsize, Opt_logdev, Opt_rtdev,
117 Opt_wsync, Opt_noalign, Opt_swalloc, Opt_sunit, Opt_swidth, Opt_nouuid,
118 Opt_grpid, Opt_nogrpid, Opt_bsdgroups, Opt_sysvgroups,
119 Opt_allocsize, Opt_norecovery, Opt_inode64, Opt_inode32, Opt_ikeep,
120 Opt_noikeep, Opt_largeio, Opt_nolargeio, Opt_attr2, Opt_noattr2,
121 Opt_filestreams, Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota,
122 Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota,
123 Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce,
124 Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum,
127 static const struct fs_parameter_spec xfs_fs_parameters[] = {
128 fsparam_u32("logbufs", Opt_logbufs),
129 fsparam_string("logbsize", Opt_logbsize),
130 fsparam_string("logdev", Opt_logdev),
131 fsparam_string("rtdev", Opt_rtdev),
132 fsparam_flag("wsync", Opt_wsync),
133 fsparam_flag("noalign", Opt_noalign),
134 fsparam_flag("swalloc", Opt_swalloc),
135 fsparam_u32("sunit", Opt_sunit),
136 fsparam_u32("swidth", Opt_swidth),
137 fsparam_flag("nouuid", Opt_nouuid),
138 fsparam_flag("grpid", Opt_grpid),
139 fsparam_flag("nogrpid", Opt_nogrpid),
140 fsparam_flag("bsdgroups", Opt_bsdgroups),
141 fsparam_flag("sysvgroups", Opt_sysvgroups),
142 fsparam_string("allocsize", Opt_allocsize),
143 fsparam_flag("norecovery", Opt_norecovery),
144 fsparam_flag("inode64", Opt_inode64),
145 fsparam_flag("inode32", Opt_inode32),
146 fsparam_flag("ikeep", Opt_ikeep),
147 fsparam_flag("noikeep", Opt_noikeep),
148 fsparam_flag("largeio", Opt_largeio),
149 fsparam_flag("nolargeio", Opt_nolargeio),
150 fsparam_flag("attr2", Opt_attr2),
151 fsparam_flag("noattr2", Opt_noattr2),
152 fsparam_flag("filestreams", Opt_filestreams),
153 fsparam_flag("quota", Opt_quota),
154 fsparam_flag("noquota", Opt_noquota),
155 fsparam_flag("usrquota", Opt_usrquota),
156 fsparam_flag("grpquota", Opt_grpquota),
157 fsparam_flag("prjquota", Opt_prjquota),
158 fsparam_flag("uquota", Opt_uquota),
159 fsparam_flag("gquota", Opt_gquota),
160 fsparam_flag("pquota", Opt_pquota),
161 fsparam_flag("uqnoenforce", Opt_uqnoenforce),
162 fsparam_flag("gqnoenforce", Opt_gqnoenforce),
163 fsparam_flag("pqnoenforce", Opt_pqnoenforce),
164 fsparam_flag("qnoenforce", Opt_qnoenforce),
165 fsparam_flag("discard", Opt_discard),
166 fsparam_flag("nodiscard", Opt_nodiscard),
167 fsparam_flag("dax", Opt_dax),
168 fsparam_enum("dax", Opt_dax_enum, dax_param_enums),
172 struct proc_xfs_info {
182 static struct proc_xfs_info xfs_info_set[] = {
183 /* the few simple ones we can get from the mount struct */
184 { XFS_FEAT_IKEEP, ",ikeep" },
185 { XFS_FEAT_WSYNC, ",wsync" },
186 { XFS_FEAT_NOALIGN, ",noalign" },
187 { XFS_FEAT_SWALLOC, ",swalloc" },
188 { XFS_FEAT_NOUUID, ",nouuid" },
189 { XFS_FEAT_NORECOVERY, ",norecovery" },
190 { XFS_FEAT_ATTR2, ",attr2" },
191 { XFS_FEAT_FILESTREAMS, ",filestreams" },
192 { XFS_FEAT_GRPID, ",grpid" },
193 { XFS_FEAT_DISCARD, ",discard" },
194 { XFS_FEAT_LARGE_IOSIZE, ",largeio" },
195 { XFS_FEAT_DAX_ALWAYS, ",dax=always" },
196 { XFS_FEAT_DAX_NEVER, ",dax=never" },
199 struct xfs_mount *mp = XFS_M(root->d_sb);
200 struct proc_xfs_info *xfs_infop;
202 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) {
203 if (mp->m_features & xfs_infop->flag)
204 seq_puts(m, xfs_infop->str);
207 seq_printf(m, ",inode%d", xfs_has_small_inums(mp) ? 32 : 64);
209 if (xfs_has_allocsize(mp))
210 seq_printf(m, ",allocsize=%dk",
211 (1 << mp->m_allocsize_log) >> 10);
213 if (mp->m_logbufs > 0)
214 seq_printf(m, ",logbufs=%d", mp->m_logbufs);
215 if (mp->m_logbsize > 0)
216 seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10);
219 seq_show_option(m, "logdev", mp->m_logname);
221 seq_show_option(m, "rtdev", mp->m_rtname);
223 if (mp->m_dalign > 0)
224 seq_printf(m, ",sunit=%d",
225 (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
226 if (mp->m_swidth > 0)
227 seq_printf(m, ",swidth=%d",
228 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
230 if (mp->m_qflags & XFS_UQUOTA_ENFD)
231 seq_puts(m, ",usrquota");
232 else if (mp->m_qflags & XFS_UQUOTA_ACCT)
233 seq_puts(m, ",uqnoenforce");
235 if (mp->m_qflags & XFS_PQUOTA_ENFD)
236 seq_puts(m, ",prjquota");
237 else if (mp->m_qflags & XFS_PQUOTA_ACCT)
238 seq_puts(m, ",pqnoenforce");
240 if (mp->m_qflags & XFS_GQUOTA_ENFD)
241 seq_puts(m, ",grpquota");
242 else if (mp->m_qflags & XFS_GQUOTA_ACCT)
243 seq_puts(m, ",gqnoenforce");
245 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
246 seq_puts(m, ",noquota");
252 xfs_set_inode_alloc_perag(
253 struct xfs_perag *pag,
255 xfs_agnumber_t max_metadata)
257 if (!xfs_is_inode32(pag->pag_mount)) {
258 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
259 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
263 if (ino > XFS_MAXINUMBER_32) {
264 clear_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
265 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
269 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate);
270 if (pag->pag_agno < max_metadata)
271 set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
273 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
278 * Set parameters for inode allocation heuristics, taking into account
279 * filesystem size and inode32/inode64 mount options; i.e. specifically
280 * whether or not XFS_FEAT_SMALL_INUMS is set.
282 * Inode allocation patterns are altered only if inode32 is requested
283 * (XFS_FEAT_SMALL_INUMS), and the filesystem is sufficiently large.
284 * If altered, XFS_OPSTATE_INODE32 is set as well.
286 * An agcount independent of that in the mount structure is provided
287 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
288 * to the potentially higher ag count.
290 * Returns the maximum AG index which may contain inodes.
294 struct xfs_mount *mp,
295 xfs_agnumber_t agcount)
297 xfs_agnumber_t index;
298 xfs_agnumber_t maxagi = 0;
299 xfs_sb_t *sbp = &mp->m_sb;
300 xfs_agnumber_t max_metadata;
305 * Calculate how much should be reserved for inodes to meet
306 * the max inode percentage. Used only for inode32.
308 if (M_IGEO(mp)->maxicount) {
311 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
313 icount += sbp->sb_agblocks - 1;
314 do_div(icount, sbp->sb_agblocks);
315 max_metadata = icount;
317 max_metadata = agcount;
320 /* Get the last possible inode in the filesystem */
321 agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1);
322 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino);
325 * If user asked for no more than 32-bit inodes, and the fs is
326 * sufficiently large, set XFS_OPSTATE_INODE32 if we must alter
327 * the allocator to accommodate the request.
329 if (xfs_has_small_inums(mp) && ino > XFS_MAXINUMBER_32)
330 set_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
332 clear_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
334 for (index = 0; index < agcount; index++) {
335 struct xfs_perag *pag;
337 ino = XFS_AGINO_TO_INO(mp, index, agino);
339 pag = xfs_perag_get(mp, index);
340 if (xfs_set_inode_alloc_perag(pag, ino, max_metadata))
345 return xfs_is_inode32(mp) ? maxagi : agcount;
349 xfs_setup_dax_always(
350 struct xfs_mount *mp)
352 if (!mp->m_ddev_targp->bt_daxdev &&
353 (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) {
355 "DAX unsupported by block device. Turning off DAX.");
359 if (mp->m_super->s_blocksize != PAGE_SIZE) {
361 "DAX not supported for blocksize. Turning off DAX.");
365 if (xfs_has_reflink(mp) &&
366 bdev_is_partition(mp->m_ddev_targp->bt_bdev)) {
368 "DAX and reflink cannot work with multi-partitions!");
372 xfs_warn(mp, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
376 xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
382 struct block_device *bdev)
384 xfs_force_shutdown(bdev->bd_holder, SHUTDOWN_DEVICE_REMOVED);
387 static const struct blk_holder_ops xfs_holder_ops = {
388 .mark_dead = xfs_bdev_mark_dead,
395 struct block_device **bdevp)
399 *bdevp = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE, mp,
401 if (IS_ERR(*bdevp)) {
402 error = PTR_ERR(*bdevp);
403 xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
411 struct xfs_mount *mp,
412 struct block_device *bdev)
415 blkdev_put(bdev, mp);
420 struct xfs_mount *mp)
422 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
423 struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
425 xfs_free_buftarg(mp->m_logdev_targp);
426 xfs_blkdev_put(mp, logdev);
428 if (mp->m_rtdev_targp) {
429 struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
431 xfs_free_buftarg(mp->m_rtdev_targp);
432 xfs_blkdev_put(mp, rtdev);
434 xfs_free_buftarg(mp->m_ddev_targp);
438 * The file system configurations are:
439 * (1) device (partition) with data and internal log
440 * (2) logical volume with data and log subvolumes.
441 * (3) logical volume with data, log, and realtime subvolumes.
443 * We only have to handle opening the log and realtime volumes here if
444 * they are present. The data subvolume has already been opened by
445 * get_sb_bdev() and is stored in sb->s_bdev.
449 struct xfs_mount *mp)
451 struct block_device *ddev = mp->m_super->s_bdev;
452 struct block_device *logdev = NULL, *rtdev = NULL;
456 * Open real time and log devices - order is important.
459 error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
465 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
467 goto out_close_logdev;
469 if (rtdev == ddev || rtdev == logdev) {
471 "Cannot mount filesystem with identical rtdev and ddev/logdev.");
473 goto out_close_rtdev;
478 * Setup xfs_mount buffer target pointers
481 mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev);
482 if (!mp->m_ddev_targp)
483 goto out_close_rtdev;
486 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev);
487 if (!mp->m_rtdev_targp)
488 goto out_free_ddev_targ;
491 if (logdev && logdev != ddev) {
492 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev);
493 if (!mp->m_logdev_targp)
494 goto out_free_rtdev_targ;
496 mp->m_logdev_targp = mp->m_ddev_targp;
502 if (mp->m_rtdev_targp)
503 xfs_free_buftarg(mp->m_rtdev_targp);
505 xfs_free_buftarg(mp->m_ddev_targp);
507 xfs_blkdev_put(mp, rtdev);
509 if (logdev && logdev != ddev)
510 xfs_blkdev_put(mp, logdev);
515 * Setup xfs_mount buffer target pointers based on superblock
519 struct xfs_mount *mp)
523 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize);
527 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
528 unsigned int log_sector_size = BBSIZE;
530 if (xfs_has_sector(mp))
531 log_sector_size = mp->m_sb.sb_logsectsize;
532 error = xfs_setsize_buftarg(mp->m_logdev_targp,
537 if (mp->m_rtdev_targp) {
538 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
539 mp->m_sb.sb_sectsize);
548 xfs_init_mount_workqueues(
549 struct xfs_mount *mp)
551 mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
552 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
553 1, mp->m_super->s_id);
554 if (!mp->m_buf_workqueue)
557 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
558 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
559 0, mp->m_super->s_id);
560 if (!mp->m_unwritten_workqueue)
561 goto out_destroy_buf;
563 mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s",
564 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
565 0, mp->m_super->s_id);
566 if (!mp->m_reclaim_workqueue)
567 goto out_destroy_unwritten;
569 mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s",
570 XFS_WQFLAGS(WQ_UNBOUND | WQ_FREEZABLE | WQ_MEM_RECLAIM),
571 0, mp->m_super->s_id);
572 if (!mp->m_blockgc_wq)
573 goto out_destroy_reclaim;
575 mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s",
576 XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
577 1, mp->m_super->s_id);
578 if (!mp->m_inodegc_wq)
579 goto out_destroy_blockgc;
581 mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s",
582 XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id);
583 if (!mp->m_sync_workqueue)
584 goto out_destroy_inodegc;
589 destroy_workqueue(mp->m_inodegc_wq);
591 destroy_workqueue(mp->m_blockgc_wq);
593 destroy_workqueue(mp->m_reclaim_workqueue);
594 out_destroy_unwritten:
595 destroy_workqueue(mp->m_unwritten_workqueue);
597 destroy_workqueue(mp->m_buf_workqueue);
603 xfs_destroy_mount_workqueues(
604 struct xfs_mount *mp)
606 destroy_workqueue(mp->m_sync_workqueue);
607 destroy_workqueue(mp->m_blockgc_wq);
608 destroy_workqueue(mp->m_inodegc_wq);
609 destroy_workqueue(mp->m_reclaim_workqueue);
610 destroy_workqueue(mp->m_unwritten_workqueue);
611 destroy_workqueue(mp->m_buf_workqueue);
615 xfs_flush_inodes_worker(
616 struct work_struct *work)
618 struct xfs_mount *mp = container_of(work, struct xfs_mount,
619 m_flush_inodes_work);
620 struct super_block *sb = mp->m_super;
622 if (down_read_trylock(&sb->s_umount)) {
624 up_read(&sb->s_umount);
629 * Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK
630 * or a page lock. We use sync_inodes_sb() here to ensure we block while waiting
631 * for IO to complete so that we effectively throttle multiple callers to the
632 * rate at which IO is completing.
636 struct xfs_mount *mp)
639 * If flush_work() returns true then that means we waited for a flush
640 * which was already in progress. Don't bother running another scan.
642 if (flush_work(&mp->m_flush_inodes_work))
645 queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work);
646 flush_work(&mp->m_flush_inodes_work);
649 /* Catch misguided souls that try to use this interface on XFS */
650 STATIC struct inode *
652 struct super_block *sb)
659 * Now that the generic code is guaranteed not to be accessing
660 * the linux inode, we can inactivate and reclaim the inode.
663 xfs_fs_destroy_inode(
666 struct xfs_inode *ip = XFS_I(inode);
668 trace_xfs_destroy_inode(ip);
670 ASSERT(!rwsem_is_locked(&inode->i_rwsem));
671 XFS_STATS_INC(ip->i_mount, vn_rele);
672 XFS_STATS_INC(ip->i_mount, vn_remove);
673 xfs_inode_mark_reclaimable(ip);
681 struct xfs_inode *ip = XFS_I(inode);
682 struct xfs_mount *mp = ip->i_mount;
683 struct xfs_trans *tp;
685 if (!(inode->i_sb->s_flags & SB_LAZYTIME))
689 * Only do the timestamp update if the inode is dirty (I_DIRTY_SYNC)
690 * and has dirty timestamp (I_DIRTY_TIME). I_DIRTY_TIME can be passed
691 * in flags possibly together with I_DIRTY_SYNC.
693 if ((flags & ~I_DIRTY_TIME) != I_DIRTY_SYNC || !(flags & I_DIRTY_TIME))
696 if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp))
698 xfs_ilock(ip, XFS_ILOCK_EXCL);
699 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
700 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
701 xfs_trans_commit(tp);
705 * Slab object creation initialisation for the XFS inode.
706 * This covers only the idempotent fields in the XFS inode;
707 * all other fields need to be initialised on allocation
708 * from the slab. This avoids the need to repeatedly initialise
709 * fields in the xfs inode that left in the initialise state
710 * when freeing the inode.
713 xfs_fs_inode_init_once(
716 struct xfs_inode *ip = inode;
718 memset(ip, 0, sizeof(struct xfs_inode));
721 inode_init_once(VFS_I(ip));
724 atomic_set(&ip->i_pincount, 0);
725 spin_lock_init(&ip->i_flags_lock);
727 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
728 "xfsino", ip->i_ino);
732 * We do an unlocked check for XFS_IDONTCACHE here because we are already
733 * serialised against cache hits here via the inode->i_lock and igrab() in
734 * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
735 * racing with us, and it avoids needing to grab a spinlock here for every inode
736 * we drop the final reference on.
742 struct xfs_inode *ip = XFS_I(inode);
745 * If this unlinked inode is in the middle of recovery, don't
746 * drop the inode just yet; log recovery will take care of
747 * that. See the comment for this inode flag.
749 if (ip->i_flags & XFS_IRECOVERY) {
750 ASSERT(xlog_recovery_needed(ip->i_mount->m_log));
754 return generic_drop_inode(inode);
759 struct xfs_mount *mp)
762 kfree(mp->m_logname);
768 struct super_block *sb,
771 struct xfs_mount *mp = XFS_M(sb);
774 trace_xfs_fs_sync_fs(mp, __return_address);
777 * Doing anything during the async pass would be counterproductive.
782 error = xfs_log_force(mp, XFS_LOG_SYNC);
788 * The disk must be active because we're syncing.
789 * We schedule log work now (now that the disk is
790 * active) instead of later (when it might not be).
792 flush_delayed_work(&mp->m_log->l_work);
796 * If we are called with page faults frozen out, it means we are about
797 * to freeze the transaction subsystem. Take the opportunity to shut
798 * down inodegc because once SB_FREEZE_FS is set it's too late to
799 * prevent inactivation races with freeze. The fs doesn't get called
800 * again by the freezing process until after SB_FREEZE_FS has been set,
801 * so it's now or never. Same logic applies to speculative allocation
802 * garbage collection.
804 * We don't care if this is a normal syncfs call that does this or
805 * freeze that does this - we can run this multiple times without issue
806 * and we won't race with a restart because a restart can only occur
807 * when the state is either SB_FREEZE_FS or SB_FREEZE_COMPLETE.
809 if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) {
810 xfs_inodegc_stop(mp);
811 xfs_blockgc_stop(mp);
819 struct dentry *dentry,
820 struct kstatfs *statp)
822 struct xfs_mount *mp = XFS_M(dentry->d_sb);
823 xfs_sb_t *sbp = &mp->m_sb;
824 struct xfs_inode *ip = XFS_I(d_inode(dentry));
825 uint64_t fakeinos, id;
833 * Expedite background inodegc but don't wait. We do not want to block
834 * here waiting hours for a billion extent file to be truncated.
836 xfs_inodegc_push(mp);
838 statp->f_type = XFS_SUPER_MAGIC;
839 statp->f_namelen = MAXNAMELEN - 1;
841 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
842 statp->f_fsid = u64_to_fsid(id);
844 icount = percpu_counter_sum(&mp->m_icount);
845 ifree = percpu_counter_sum(&mp->m_ifree);
846 fdblocks = percpu_counter_sum(&mp->m_fdblocks);
848 spin_lock(&mp->m_sb_lock);
849 statp->f_bsize = sbp->sb_blocksize;
850 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
851 statp->f_blocks = sbp->sb_dblocks - lsize;
852 spin_unlock(&mp->m_sb_lock);
854 /* make sure statp->f_bfree does not underflow */
855 statp->f_bfree = max_t(int64_t, 0,
856 fdblocks - xfs_fdblocks_unavailable(mp));
857 statp->f_bavail = statp->f_bfree;
859 fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);
860 statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
861 if (M_IGEO(mp)->maxicount)
862 statp->f_files = min_t(typeof(statp->f_files),
864 M_IGEO(mp)->maxicount);
866 /* If sb_icount overshot maxicount, report actual allocation */
867 statp->f_files = max_t(typeof(statp->f_files),
871 /* make sure statp->f_ffree does not underflow */
872 ffree = statp->f_files - (icount - ifree);
873 statp->f_ffree = max_t(int64_t, ffree, 0);
876 if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
877 ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
878 (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
879 xfs_qm_statvfs(ip, statp);
881 if (XFS_IS_REALTIME_MOUNT(mp) &&
882 (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
885 statp->f_blocks = sbp->sb_rblocks;
886 freertx = percpu_counter_sum_positive(&mp->m_frextents);
887 statp->f_bavail = statp->f_bfree = freertx * sbp->sb_rextsize;
894 xfs_save_resvblks(struct xfs_mount *mp)
896 uint64_t resblks = 0;
898 mp->m_resblks_save = mp->m_resblks;
899 xfs_reserve_blocks(mp, &resblks, NULL);
903 xfs_restore_resvblks(struct xfs_mount *mp)
907 if (mp->m_resblks_save) {
908 resblks = mp->m_resblks_save;
909 mp->m_resblks_save = 0;
911 resblks = xfs_default_resblks(mp);
913 xfs_reserve_blocks(mp, &resblks, NULL);
917 * Second stage of a freeze. The data is already frozen so we only
918 * need to take care of the metadata. Once that's done sync the superblock
919 * to the log to dirty it in case of a crash while frozen. This ensures that we
920 * will recover the unlinked inode lists on the next mount.
924 struct super_block *sb)
926 struct xfs_mount *mp = XFS_M(sb);
931 * The filesystem is now frozen far enough that memory reclaim
932 * cannot safely operate on the filesystem. Hence we need to
933 * set a GFP_NOFS context here to avoid recursion deadlocks.
935 flags = memalloc_nofs_save();
936 xfs_save_resvblks(mp);
937 ret = xfs_log_quiesce(mp);
938 memalloc_nofs_restore(flags);
941 * For read-write filesystems, we need to restart the inodegc on error
942 * because we stopped it at SB_FREEZE_PAGEFAULT level and a thaw is not
943 * going to be run to restart it now. We are at SB_FREEZE_FS level
944 * here, so we can restart safely without racing with a stop in
947 if (ret && !xfs_is_readonly(mp)) {
948 xfs_blockgc_start(mp);
949 xfs_inodegc_start(mp);
957 struct super_block *sb)
959 struct xfs_mount *mp = XFS_M(sb);
961 xfs_restore_resvblks(mp);
962 xfs_log_work_queue(mp);
965 * Don't reactivate the inodegc worker on a readonly filesystem because
966 * inodes are sent directly to reclaim. Don't reactivate the blockgc
967 * worker because there are no speculative preallocations on a readonly
970 if (!xfs_is_readonly(mp)) {
971 xfs_blockgc_start(mp);
972 xfs_inodegc_start(mp);
979 * This function fills in xfs_mount_t fields based on mount args.
980 * Note: the superblock _has_ now been read in.
984 struct xfs_mount *mp)
986 /* Fail a mount where the logbuf is smaller than the log stripe */
987 if (xfs_has_logv2(mp)) {
988 if (mp->m_logbsize <= 0 &&
989 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
990 mp->m_logbsize = mp->m_sb.sb_logsunit;
991 } else if (mp->m_logbsize > 0 &&
992 mp->m_logbsize < mp->m_sb.sb_logsunit) {
994 "logbuf size must be greater than or equal to log stripe size");
998 /* Fail a mount if the logbuf is larger than 32K */
999 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1001 "logbuf size for version 1 logs must be 16K or 32K");
1007 * V5 filesystems always use attr2 format for attributes.
1009 if (xfs_has_crc(mp) && xfs_has_noattr2(mp)) {
1010 xfs_warn(mp, "Cannot mount a V5 filesystem as noattr2. "
1011 "attr2 is always enabled for V5 filesystems.");
1016 * prohibit r/w mounts of read-only filesystems
1018 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) {
1020 "cannot mount a read-only filesystem as read-write");
1024 if ((mp->m_qflags & XFS_GQUOTA_ACCT) &&
1025 (mp->m_qflags & XFS_PQUOTA_ACCT) &&
1026 !xfs_has_pquotino(mp)) {
1028 "Super block does not support project and group quota together");
1036 xfs_init_percpu_counters(
1037 struct xfs_mount *mp)
1041 error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL);
1045 error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL);
1049 error = percpu_counter_init(&mp->m_fdblocks, 0, GFP_KERNEL);
1053 error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL);
1057 error = percpu_counter_init(&mp->m_frextents, 0, GFP_KERNEL);
1064 percpu_counter_destroy(&mp->m_delalloc_blks);
1066 percpu_counter_destroy(&mp->m_fdblocks);
1068 percpu_counter_destroy(&mp->m_ifree);
1070 percpu_counter_destroy(&mp->m_icount);
1075 xfs_reinit_percpu_counters(
1076 struct xfs_mount *mp)
1078 percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount);
1079 percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree);
1080 percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks);
1081 percpu_counter_set(&mp->m_frextents, mp->m_sb.sb_frextents);
1085 xfs_destroy_percpu_counters(
1086 struct xfs_mount *mp)
1088 percpu_counter_destroy(&mp->m_icount);
1089 percpu_counter_destroy(&mp->m_ifree);
1090 percpu_counter_destroy(&mp->m_fdblocks);
1091 ASSERT(xfs_is_shutdown(mp) ||
1092 percpu_counter_sum(&mp->m_delalloc_blks) == 0);
1093 percpu_counter_destroy(&mp->m_delalloc_blks);
1094 percpu_counter_destroy(&mp->m_frextents);
1098 xfs_inodegc_init_percpu(
1099 struct xfs_mount *mp)
1101 struct xfs_inodegc *gc;
1104 mp->m_inodegc = alloc_percpu(struct xfs_inodegc);
1108 for_each_possible_cpu(cpu) {
1109 gc = per_cpu_ptr(mp->m_inodegc, cpu);
1110 #if defined(DEBUG) || defined(XFS_WARN)
1113 init_llist_head(&gc->list);
1116 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker);
1122 xfs_inodegc_free_percpu(
1123 struct xfs_mount *mp)
1127 free_percpu(mp->m_inodegc);
1132 struct super_block *sb)
1134 struct xfs_mount *mp = XFS_M(sb);
1136 /* if ->fill_super failed, we have no mount to tear down */
1140 xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid);
1141 xfs_filestream_unmount(mp);
1145 free_percpu(mp->m_stats.xs_stats);
1146 xfs_mount_list_del(mp);
1147 xfs_inodegc_free_percpu(mp);
1148 xfs_destroy_percpu_counters(mp);
1149 xfs_destroy_mount_workqueues(mp);
1150 xfs_close_devices(mp);
1152 sb->s_fs_info = NULL;
1157 xfs_fs_nr_cached_objects(
1158 struct super_block *sb,
1159 struct shrink_control *sc)
1161 /* Paranoia: catch incorrect calls during mount setup or teardown */
1162 if (WARN_ON_ONCE(!sb->s_fs_info))
1164 return xfs_reclaim_inodes_count(XFS_M(sb));
1168 xfs_fs_free_cached_objects(
1169 struct super_block *sb,
1170 struct shrink_control *sc)
1172 return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan);
1177 struct super_block *sb)
1179 xfs_force_shutdown(XFS_M(sb), SHUTDOWN_DEVICE_REMOVED);
1182 static const struct super_operations xfs_super_operations = {
1183 .alloc_inode = xfs_fs_alloc_inode,
1184 .destroy_inode = xfs_fs_destroy_inode,
1185 .dirty_inode = xfs_fs_dirty_inode,
1186 .drop_inode = xfs_fs_drop_inode,
1187 .put_super = xfs_fs_put_super,
1188 .sync_fs = xfs_fs_sync_fs,
1189 .freeze_fs = xfs_fs_freeze,
1190 .unfreeze_fs = xfs_fs_unfreeze,
1191 .statfs = xfs_fs_statfs,
1192 .show_options = xfs_fs_show_options,
1193 .nr_cached_objects = xfs_fs_nr_cached_objects,
1194 .free_cached_objects = xfs_fs_free_cached_objects,
1195 .shutdown = xfs_fs_shutdown,
1204 int last, shift_left_factor = 0, _res;
1208 value = kstrdup(s, GFP_KERNEL);
1212 last = strlen(value) - 1;
1213 if (value[last] == 'K' || value[last] == 'k') {
1214 shift_left_factor = 10;
1217 if (value[last] == 'M' || value[last] == 'm') {
1218 shift_left_factor = 20;
1221 if (value[last] == 'G' || value[last] == 'g') {
1222 shift_left_factor = 30;
1226 if (kstrtoint(value, base, &_res))
1229 *res = _res << shift_left_factor;
1234 xfs_fs_warn_deprecated(
1235 struct fs_context *fc,
1236 struct fs_parameter *param,
1240 /* Don't print the warning if reconfiguring and current mount point
1241 * already had the flag set
1243 if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) &&
1244 !!(XFS_M(fc->root->d_sb)->m_features & flag) == value)
1246 xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key);
1250 * Set mount state from a mount option.
1252 * NOTE: mp->m_super is NULL here!
1256 struct fs_context *fc,
1257 struct fs_parameter *param)
1259 struct xfs_mount *parsing_mp = fc->s_fs_info;
1260 struct fs_parse_result result;
1264 opt = fs_parse(fc, xfs_fs_parameters, param, &result);
1270 parsing_mp->m_logbufs = result.uint_32;
1273 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize))
1277 kfree(parsing_mp->m_logname);
1278 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL);
1279 if (!parsing_mp->m_logname)
1283 kfree(parsing_mp->m_rtname);
1284 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL);
1285 if (!parsing_mp->m_rtname)
1289 if (suffix_kstrtoint(param->string, 10, &size))
1291 parsing_mp->m_allocsize_log = ffs(size) - 1;
1292 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE;
1296 parsing_mp->m_features |= XFS_FEAT_GRPID;
1299 case Opt_sysvgroups:
1300 parsing_mp->m_features &= ~XFS_FEAT_GRPID;
1303 parsing_mp->m_features |= XFS_FEAT_WSYNC;
1305 case Opt_norecovery:
1306 parsing_mp->m_features |= XFS_FEAT_NORECOVERY;
1309 parsing_mp->m_features |= XFS_FEAT_NOALIGN;
1312 parsing_mp->m_features |= XFS_FEAT_SWALLOC;
1315 parsing_mp->m_dalign = result.uint_32;
1318 parsing_mp->m_swidth = result.uint_32;
1321 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS;
1324 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1327 parsing_mp->m_features |= XFS_FEAT_NOUUID;
1330 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE;
1333 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE;
1335 case Opt_filestreams:
1336 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS;
1339 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
1340 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
1345 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD);
1347 case Opt_qnoenforce:
1348 case Opt_uqnoenforce:
1349 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT;
1350 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD;
1354 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD);
1356 case Opt_pqnoenforce:
1357 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT;
1358 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD;
1362 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD);
1364 case Opt_gqnoenforce:
1365 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT;
1366 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD;
1369 parsing_mp->m_features |= XFS_FEAT_DISCARD;
1372 parsing_mp->m_features &= ~XFS_FEAT_DISCARD;
1374 #ifdef CONFIG_FS_DAX
1376 xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
1379 xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
1382 /* Following mount options will be removed in September 2025 */
1384 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, true);
1385 parsing_mp->m_features |= XFS_FEAT_IKEEP;
1388 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, false);
1389 parsing_mp->m_features &= ~XFS_FEAT_IKEEP;
1392 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_ATTR2, true);
1393 parsing_mp->m_features |= XFS_FEAT_ATTR2;
1396 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_NOATTR2, true);
1397 parsing_mp->m_features |= XFS_FEAT_NOATTR2;
1400 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key);
1408 xfs_fs_validate_params(
1409 struct xfs_mount *mp)
1411 /* No recovery flag requires a read-only mount */
1412 if (xfs_has_norecovery(mp) && !xfs_is_readonly(mp)) {
1413 xfs_warn(mp, "no-recovery mounts must be read-only.");
1418 * We have not read the superblock at this point, so only the attr2
1419 * mount option can set the attr2 feature by this stage.
1421 if (xfs_has_attr2(mp) && xfs_has_noattr2(mp)) {
1422 xfs_warn(mp, "attr2 and noattr2 cannot both be specified.");
1427 if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) {
1429 "sunit and swidth options incompatible with the noalign option");
1433 if (!IS_ENABLED(CONFIG_XFS_QUOTA) && mp->m_qflags != 0) {
1434 xfs_warn(mp, "quota support not available in this kernel.");
1438 if ((mp->m_dalign && !mp->m_swidth) ||
1439 (!mp->m_dalign && mp->m_swidth)) {
1440 xfs_warn(mp, "sunit and swidth must be specified together");
1444 if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) {
1446 "stripe width (%d) must be a multiple of the stripe unit (%d)",
1447 mp->m_swidth, mp->m_dalign);
1451 if (mp->m_logbufs != -1 &&
1452 mp->m_logbufs != 0 &&
1453 (mp->m_logbufs < XLOG_MIN_ICLOGS ||
1454 mp->m_logbufs > XLOG_MAX_ICLOGS)) {
1455 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
1456 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
1460 if (mp->m_logbsize != -1 &&
1461 mp->m_logbsize != 0 &&
1462 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
1463 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
1464 !is_power_of_2(mp->m_logbsize))) {
1466 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
1471 if (xfs_has_allocsize(mp) &&
1472 (mp->m_allocsize_log > XFS_MAX_IO_LOG ||
1473 mp->m_allocsize_log < XFS_MIN_IO_LOG)) {
1474 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
1475 mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
1484 struct super_block *sb,
1485 struct fs_context *fc)
1487 struct xfs_mount *mp = sb->s_fs_info;
1489 int flags = 0, error;
1493 error = xfs_fs_validate_params(mp);
1495 goto out_free_names;
1497 sb_min_blocksize(sb, BBSIZE);
1498 sb->s_xattr = xfs_xattr_handlers;
1499 sb->s_export_op = &xfs_export_operations;
1500 #ifdef CONFIG_XFS_QUOTA
1501 sb->s_qcop = &xfs_quotactl_operations;
1502 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
1504 sb->s_op = &xfs_super_operations;
1507 * Delay mount work if the debug hook is set. This is debug
1508 * instrumention to coordinate simulation of xfs mount failures with
1509 * VFS superblock operations
1511 if (xfs_globals.mount_delay) {
1512 xfs_notice(mp, "Delaying mount for %d seconds.",
1513 xfs_globals.mount_delay);
1514 msleep(xfs_globals.mount_delay * 1000);
1517 if (fc->sb_flags & SB_SILENT)
1518 flags |= XFS_MFSI_QUIET;
1520 error = xfs_open_devices(mp);
1522 goto out_free_names;
1524 error = xfs_init_mount_workqueues(mp);
1526 goto out_close_devices;
1528 error = xfs_init_percpu_counters(mp);
1530 goto out_destroy_workqueues;
1532 error = xfs_inodegc_init_percpu(mp);
1534 goto out_destroy_counters;
1537 * All percpu data structures requiring cleanup when a cpu goes offline
1538 * must be allocated before adding this @mp to the cpu-dead handler's
1541 xfs_mount_list_add(mp);
1543 /* Allocate stats memory before we do operations that might use it */
1544 mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
1545 if (!mp->m_stats.xs_stats) {
1547 goto out_destroy_inodegc;
1550 error = xfs_readsb(mp, flags);
1552 goto out_free_stats;
1554 error = xfs_finish_flags(mp);
1558 error = xfs_setup_devices(mp);
1562 /* V4 support is undergoing deprecation. */
1563 if (!xfs_has_crc(mp)) {
1564 #ifdef CONFIG_XFS_SUPPORT_V4
1566 "Deprecated V4 format (crc=0) will not be supported after September 2030.");
1569 "Deprecated V4 format (crc=0) not supported by kernel.");
1575 /* ASCII case insensitivity is undergoing deprecation. */
1576 if (xfs_has_asciici(mp)) {
1577 #ifdef CONFIG_XFS_SUPPORT_ASCII_CI
1579 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 2030.");
1582 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel.");
1588 /* Filesystem claims it needs repair, so refuse the mount. */
1589 if (xfs_has_needsrepair(mp)) {
1590 xfs_warn(mp, "Filesystem needs repair. Please run xfs_repair.");
1591 error = -EFSCORRUPTED;
1596 * Don't touch the filesystem if a user tool thinks it owns the primary
1597 * superblock. mkfs doesn't clear the flag from secondary supers, so
1598 * we don't check them at all.
1600 if (mp->m_sb.sb_inprogress) {
1601 xfs_warn(mp, "Offline file system operation in progress!");
1602 error = -EFSCORRUPTED;
1607 * Until this is fixed only page-sized or smaller data blocks work.
1609 if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
1611 "File system with blocksize %d bytes. "
1612 "Only pagesize (%ld) or less will currently work.",
1613 mp->m_sb.sb_blocksize, PAGE_SIZE);
1618 /* Ensure this filesystem fits in the page cache limits */
1619 if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) ||
1620 xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) {
1622 "file system too large to be mounted on this system.");
1628 * XFS block mappings use 54 bits to store the logical block offset.
1629 * This should suffice to handle the maximum file size that the VFS
1630 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT
1631 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes
1632 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON
1633 * to check this assertion.
1635 * Avoid integer overflow by comparing the maximum bmbt offset to the
1636 * maximum pagecache offset in units of fs blocks.
1638 if (!xfs_verify_fileoff(mp, XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE))) {
1640 "MAX_LFS_FILESIZE block offset (%llu) exceeds extent map maximum (%llu)!",
1641 XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE),
1647 error = xfs_filestream_mount(mp);
1652 * we must configure the block size in the superblock before we run the
1653 * full mount process as the mount process can lookup and cache inodes.
1655 sb->s_magic = XFS_SUPER_MAGIC;
1656 sb->s_blocksize = mp->m_sb.sb_blocksize;
1657 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
1658 sb->s_maxbytes = MAX_LFS_FILESIZE;
1659 sb->s_max_links = XFS_MAXLINK;
1660 sb->s_time_gran = 1;
1661 if (xfs_has_bigtime(mp)) {
1662 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN);
1663 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX);
1665 sb->s_time_min = XFS_LEGACY_TIME_MIN;
1666 sb->s_time_max = XFS_LEGACY_TIME_MAX;
1668 trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max);
1669 sb->s_iflags |= SB_I_CGROUPWB;
1671 set_posix_acl_flag(sb);
1673 /* version 5 superblocks support inode version counters. */
1674 if (xfs_has_crc(mp))
1675 sb->s_flags |= SB_I_VERSION;
1677 if (xfs_has_dax_always(mp)) {
1678 error = xfs_setup_dax_always(mp);
1680 goto out_filestream_unmount;
1683 if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) {
1685 "mounting with \"discard\" option, but the device does not support discard");
1686 mp->m_features &= ~XFS_FEAT_DISCARD;
1689 if (xfs_has_reflink(mp)) {
1690 if (mp->m_sb.sb_rblocks) {
1692 "reflink not compatible with realtime device!");
1694 goto out_filestream_unmount;
1697 if (xfs_globals.always_cow) {
1698 xfs_info(mp, "using DEBUG-only always_cow mode.");
1699 mp->m_always_cow = true;
1703 if (xfs_has_rmapbt(mp) && mp->m_sb.sb_rblocks) {
1705 "reverse mapping btree not compatible with realtime device!");
1707 goto out_filestream_unmount;
1710 error = xfs_mountfs(mp);
1712 goto out_filestream_unmount;
1714 root = igrab(VFS_I(mp->m_rootip));
1719 sb->s_root = d_make_root(root);
1727 out_filestream_unmount:
1728 xfs_filestream_unmount(mp);
1732 free_percpu(mp->m_stats.xs_stats);
1733 out_destroy_inodegc:
1734 xfs_mount_list_del(mp);
1735 xfs_inodegc_free_percpu(mp);
1736 out_destroy_counters:
1737 xfs_destroy_percpu_counters(mp);
1738 out_destroy_workqueues:
1739 xfs_destroy_mount_workqueues(mp);
1741 xfs_close_devices(mp);
1743 sb->s_fs_info = NULL;
1748 xfs_filestream_unmount(mp);
1755 struct fs_context *fc)
1757 return get_tree_bdev(fc, xfs_fs_fill_super);
1762 struct xfs_mount *mp)
1764 struct xfs_sb *sbp = &mp->m_sb;
1767 if (xfs_has_norecovery(mp)) {
1769 "ro->rw transition prohibited on norecovery mount");
1773 if (xfs_sb_is_v5(sbp) &&
1774 xfs_sb_has_ro_compat_feature(sbp, XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
1776 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
1777 (sbp->sb_features_ro_compat &
1778 XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
1782 clear_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1785 * If this is the first remount to writeable state we might have some
1786 * superblock changes to update.
1788 if (mp->m_update_sb) {
1789 error = xfs_sync_sb(mp, false);
1791 xfs_warn(mp, "failed to write sb changes");
1794 mp->m_update_sb = false;
1798 * Fill out the reserve pool if it is empty. Use the stashed value if
1799 * it is non-zero, otherwise go with the default.
1801 xfs_restore_resvblks(mp);
1802 xfs_log_work_queue(mp);
1803 xfs_blockgc_start(mp);
1805 /* Create the per-AG metadata reservation pool .*/
1806 error = xfs_fs_reserve_ag_blocks(mp);
1807 if (error && error != -ENOSPC)
1810 /* Re-enable the background inode inactivation worker. */
1811 xfs_inodegc_start(mp);
1818 struct xfs_mount *mp)
1820 struct xfs_icwalk icw = {
1821 .icw_flags = XFS_ICWALK_FLAG_SYNC,
1825 /* Flush all the dirty data to disk. */
1826 error = sync_filesystem(mp->m_super);
1831 * Cancel background eofb scanning so it cannot race with the final
1832 * log force+buftarg wait and deadlock the remount.
1834 xfs_blockgc_stop(mp);
1837 * Clear out all remaining COW staging extents and speculative post-EOF
1838 * preallocations so that we don't leave inodes requiring inactivation
1839 * cleanups during reclaim on a read-only mount. We must process every
1840 * cached inode, so this requires a synchronous cache scan.
1842 error = xfs_blockgc_free_space(mp, &icw);
1844 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1849 * Stop the inodegc background worker. xfs_fs_reconfigure already
1850 * flushed all pending inodegc work when it sync'd the filesystem.
1851 * The VFS holds s_umount, so we know that inodes cannot enter
1852 * xfs_fs_destroy_inode during a remount operation. In readonly mode
1853 * we send inodes straight to reclaim, so no inodes will be queued.
1855 xfs_inodegc_stop(mp);
1857 /* Free the per-AG metadata reservation pool. */
1858 error = xfs_fs_unreserve_ag_blocks(mp);
1860 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1865 * Before we sync the metadata, we need to free up the reserve block
1866 * pool so that the used block count in the superblock on disk is
1867 * correct at the end of the remount. Stash the current* reserve pool
1868 * size so that if we get remounted rw, we can return it to the same
1871 xfs_save_resvblks(mp);
1874 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1880 * Logically we would return an error here to prevent users from believing
1881 * they might have changed mount options using remount which can't be changed.
1883 * But unfortunately mount(8) adds all options from mtab and fstab to the mount
1884 * arguments in some cases so we can't blindly reject options, but have to
1885 * check for each specified option if it actually differs from the currently
1886 * set option and only reject it if that's the case.
1888 * Until that is implemented we return success for every remount request, and
1889 * silently ignore all options that we can't actually change.
1893 struct fs_context *fc)
1895 struct xfs_mount *mp = XFS_M(fc->root->d_sb);
1896 struct xfs_mount *new_mp = fc->s_fs_info;
1897 int flags = fc->sb_flags;
1900 /* version 5 superblocks always support version counters. */
1901 if (xfs_has_crc(mp))
1902 fc->sb_flags |= SB_I_VERSION;
1904 error = xfs_fs_validate_params(new_mp);
1908 /* inode32 -> inode64 */
1909 if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) {
1910 mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1911 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1914 /* inode64 -> inode32 */
1915 if (!xfs_has_small_inums(mp) && xfs_has_small_inums(new_mp)) {
1916 mp->m_features |= XFS_FEAT_SMALL_INUMS;
1917 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1921 if (xfs_is_readonly(mp) && !(flags & SB_RDONLY)) {
1922 error = xfs_remount_rw(mp);
1928 if (!xfs_is_readonly(mp) && (flags & SB_RDONLY)) {
1929 error = xfs_remount_ro(mp);
1939 struct fs_context *fc)
1941 struct xfs_mount *mp = fc->s_fs_info;
1944 * mp is stored in the fs_context when it is initialized.
1945 * mp is transferred to the superblock on a successful mount,
1946 * but if an error occurs before the transfer we have to free
1953 static const struct fs_context_operations xfs_context_ops = {
1954 .parse_param = xfs_fs_parse_param,
1955 .get_tree = xfs_fs_get_tree,
1956 .reconfigure = xfs_fs_reconfigure,
1957 .free = xfs_fs_free,
1960 static int xfs_init_fs_context(
1961 struct fs_context *fc)
1963 struct xfs_mount *mp;
1965 mp = kmem_alloc(sizeof(struct xfs_mount), KM_ZERO);
1969 spin_lock_init(&mp->m_sb_lock);
1970 INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC);
1971 spin_lock_init(&mp->m_perag_lock);
1972 mutex_init(&mp->m_growlock);
1973 INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker);
1974 INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker);
1975 mp->m_kobj.kobject.kset = xfs_kset;
1977 * We don't create the finobt per-ag space reservation until after log
1978 * recovery, so we must set this to true so that an ifree transaction
1979 * started during log recovery will not depend on space reservations
1980 * for finobt expansion.
1982 mp->m_finobt_nores = true;
1985 * These can be overridden by the mount option parsing.
1988 mp->m_logbsize = -1;
1989 mp->m_allocsize_log = 16; /* 64k */
1992 * Copy binary VFS mount flags we are interested in.
1994 if (fc->sb_flags & SB_RDONLY)
1995 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1996 if (fc->sb_flags & SB_DIRSYNC)
1997 mp->m_features |= XFS_FEAT_DIRSYNC;
1998 if (fc->sb_flags & SB_SYNCHRONOUS)
1999 mp->m_features |= XFS_FEAT_WSYNC;
2002 fc->ops = &xfs_context_ops;
2007 static struct file_system_type xfs_fs_type = {
2008 .owner = THIS_MODULE,
2010 .init_fs_context = xfs_init_fs_context,
2011 .parameters = xfs_fs_parameters,
2012 .kill_sb = kill_block_super,
2013 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
2015 MODULE_ALIAS_FS("xfs");
2018 xfs_init_caches(void)
2022 xfs_buf_cache = kmem_cache_create("xfs_buf", sizeof(struct xfs_buf), 0,
2023 SLAB_HWCACHE_ALIGN |
2024 SLAB_RECLAIM_ACCOUNT |
2030 xfs_log_ticket_cache = kmem_cache_create("xfs_log_ticket",
2031 sizeof(struct xlog_ticket),
2033 if (!xfs_log_ticket_cache)
2034 goto out_destroy_buf_cache;
2036 error = xfs_btree_init_cur_caches();
2038 goto out_destroy_log_ticket_cache;
2040 error = xfs_defer_init_item_caches();
2042 goto out_destroy_btree_cur_cache;
2044 xfs_da_state_cache = kmem_cache_create("xfs_da_state",
2045 sizeof(struct xfs_da_state),
2047 if (!xfs_da_state_cache)
2048 goto out_destroy_defer_item_cache;
2050 xfs_ifork_cache = kmem_cache_create("xfs_ifork",
2051 sizeof(struct xfs_ifork),
2053 if (!xfs_ifork_cache)
2054 goto out_destroy_da_state_cache;
2056 xfs_trans_cache = kmem_cache_create("xfs_trans",
2057 sizeof(struct xfs_trans),
2059 if (!xfs_trans_cache)
2060 goto out_destroy_ifork_cache;
2064 * The size of the cache-allocated buf log item is the maximum
2065 * size possible under XFS. This wastes a little bit of memory,
2066 * but it is much faster.
2068 xfs_buf_item_cache = kmem_cache_create("xfs_buf_item",
2069 sizeof(struct xfs_buf_log_item),
2071 if (!xfs_buf_item_cache)
2072 goto out_destroy_trans_cache;
2074 xfs_efd_cache = kmem_cache_create("xfs_efd_item",
2075 xfs_efd_log_item_sizeof(XFS_EFD_MAX_FAST_EXTENTS),
2078 goto out_destroy_buf_item_cache;
2080 xfs_efi_cache = kmem_cache_create("xfs_efi_item",
2081 xfs_efi_log_item_sizeof(XFS_EFI_MAX_FAST_EXTENTS),
2084 goto out_destroy_efd_cache;
2086 xfs_inode_cache = kmem_cache_create("xfs_inode",
2087 sizeof(struct xfs_inode), 0,
2088 (SLAB_HWCACHE_ALIGN |
2089 SLAB_RECLAIM_ACCOUNT |
2090 SLAB_MEM_SPREAD | SLAB_ACCOUNT),
2091 xfs_fs_inode_init_once);
2092 if (!xfs_inode_cache)
2093 goto out_destroy_efi_cache;
2095 xfs_ili_cache = kmem_cache_create("xfs_ili",
2096 sizeof(struct xfs_inode_log_item), 0,
2097 SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
2100 goto out_destroy_inode_cache;
2102 xfs_icreate_cache = kmem_cache_create("xfs_icr",
2103 sizeof(struct xfs_icreate_item),
2105 if (!xfs_icreate_cache)
2106 goto out_destroy_ili_cache;
2108 xfs_rud_cache = kmem_cache_create("xfs_rud_item",
2109 sizeof(struct xfs_rud_log_item),
2112 goto out_destroy_icreate_cache;
2114 xfs_rui_cache = kmem_cache_create("xfs_rui_item",
2115 xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS),
2118 goto out_destroy_rud_cache;
2120 xfs_cud_cache = kmem_cache_create("xfs_cud_item",
2121 sizeof(struct xfs_cud_log_item),
2124 goto out_destroy_rui_cache;
2126 xfs_cui_cache = kmem_cache_create("xfs_cui_item",
2127 xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS),
2130 goto out_destroy_cud_cache;
2132 xfs_bud_cache = kmem_cache_create("xfs_bud_item",
2133 sizeof(struct xfs_bud_log_item),
2136 goto out_destroy_cui_cache;
2138 xfs_bui_cache = kmem_cache_create("xfs_bui_item",
2139 xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS),
2142 goto out_destroy_bud_cache;
2144 xfs_attrd_cache = kmem_cache_create("xfs_attrd_item",
2145 sizeof(struct xfs_attrd_log_item),
2147 if (!xfs_attrd_cache)
2148 goto out_destroy_bui_cache;
2150 xfs_attri_cache = kmem_cache_create("xfs_attri_item",
2151 sizeof(struct xfs_attri_log_item),
2153 if (!xfs_attri_cache)
2154 goto out_destroy_attrd_cache;
2156 xfs_iunlink_cache = kmem_cache_create("xfs_iul_item",
2157 sizeof(struct xfs_iunlink_item),
2159 if (!xfs_iunlink_cache)
2160 goto out_destroy_attri_cache;
2164 out_destroy_attri_cache:
2165 kmem_cache_destroy(xfs_attri_cache);
2166 out_destroy_attrd_cache:
2167 kmem_cache_destroy(xfs_attrd_cache);
2168 out_destroy_bui_cache:
2169 kmem_cache_destroy(xfs_bui_cache);
2170 out_destroy_bud_cache:
2171 kmem_cache_destroy(xfs_bud_cache);
2172 out_destroy_cui_cache:
2173 kmem_cache_destroy(xfs_cui_cache);
2174 out_destroy_cud_cache:
2175 kmem_cache_destroy(xfs_cud_cache);
2176 out_destroy_rui_cache:
2177 kmem_cache_destroy(xfs_rui_cache);
2178 out_destroy_rud_cache:
2179 kmem_cache_destroy(xfs_rud_cache);
2180 out_destroy_icreate_cache:
2181 kmem_cache_destroy(xfs_icreate_cache);
2182 out_destroy_ili_cache:
2183 kmem_cache_destroy(xfs_ili_cache);
2184 out_destroy_inode_cache:
2185 kmem_cache_destroy(xfs_inode_cache);
2186 out_destroy_efi_cache:
2187 kmem_cache_destroy(xfs_efi_cache);
2188 out_destroy_efd_cache:
2189 kmem_cache_destroy(xfs_efd_cache);
2190 out_destroy_buf_item_cache:
2191 kmem_cache_destroy(xfs_buf_item_cache);
2192 out_destroy_trans_cache:
2193 kmem_cache_destroy(xfs_trans_cache);
2194 out_destroy_ifork_cache:
2195 kmem_cache_destroy(xfs_ifork_cache);
2196 out_destroy_da_state_cache:
2197 kmem_cache_destroy(xfs_da_state_cache);
2198 out_destroy_defer_item_cache:
2199 xfs_defer_destroy_item_caches();
2200 out_destroy_btree_cur_cache:
2201 xfs_btree_destroy_cur_caches();
2202 out_destroy_log_ticket_cache:
2203 kmem_cache_destroy(xfs_log_ticket_cache);
2204 out_destroy_buf_cache:
2205 kmem_cache_destroy(xfs_buf_cache);
2211 xfs_destroy_caches(void)
2214 * Make sure all delayed rcu free are flushed before we
2218 kmem_cache_destroy(xfs_iunlink_cache);
2219 kmem_cache_destroy(xfs_attri_cache);
2220 kmem_cache_destroy(xfs_attrd_cache);
2221 kmem_cache_destroy(xfs_bui_cache);
2222 kmem_cache_destroy(xfs_bud_cache);
2223 kmem_cache_destroy(xfs_cui_cache);
2224 kmem_cache_destroy(xfs_cud_cache);
2225 kmem_cache_destroy(xfs_rui_cache);
2226 kmem_cache_destroy(xfs_rud_cache);
2227 kmem_cache_destroy(xfs_icreate_cache);
2228 kmem_cache_destroy(xfs_ili_cache);
2229 kmem_cache_destroy(xfs_inode_cache);
2230 kmem_cache_destroy(xfs_efi_cache);
2231 kmem_cache_destroy(xfs_efd_cache);
2232 kmem_cache_destroy(xfs_buf_item_cache);
2233 kmem_cache_destroy(xfs_trans_cache);
2234 kmem_cache_destroy(xfs_ifork_cache);
2235 kmem_cache_destroy(xfs_da_state_cache);
2236 xfs_defer_destroy_item_caches();
2237 xfs_btree_destroy_cur_caches();
2238 kmem_cache_destroy(xfs_log_ticket_cache);
2239 kmem_cache_destroy(xfs_buf_cache);
2243 xfs_init_workqueues(void)
2246 * The allocation workqueue can be used in memory reclaim situations
2247 * (writepage path), and parallelism is only limited by the number of
2248 * AGs in all the filesystems mounted. Hence use the default large
2249 * max_active value for this workqueue.
2251 xfs_alloc_wq = alloc_workqueue("xfsalloc",
2252 XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 0);
2256 xfs_discard_wq = alloc_workqueue("xfsdiscard", XFS_WQFLAGS(WQ_UNBOUND),
2258 if (!xfs_discard_wq)
2259 goto out_free_alloc_wq;
2263 destroy_workqueue(xfs_alloc_wq);
2268 xfs_destroy_workqueues(void)
2270 destroy_workqueue(xfs_discard_wq);
2271 destroy_workqueue(xfs_alloc_wq);
2274 #ifdef CONFIG_HOTPLUG_CPU
2279 struct xfs_mount *mp, *n;
2281 spin_lock(&xfs_mount_list_lock);
2282 list_for_each_entry_safe(mp, n, &xfs_mount_list, m_mount_list) {
2283 spin_unlock(&xfs_mount_list_lock);
2284 xfs_inodegc_cpu_dead(mp, cpu);
2285 xlog_cil_pcp_dead(mp->m_log, cpu);
2286 spin_lock(&xfs_mount_list_lock);
2288 spin_unlock(&xfs_mount_list_lock);
2293 xfs_cpu_hotplug_init(void)
2297 error = cpuhp_setup_state_nocalls(CPUHP_XFS_DEAD, "xfs:dead", NULL,
2301 "Failed to initialise CPU hotplug, error %d. XFS is non-functional.",
2307 xfs_cpu_hotplug_destroy(void)
2309 cpuhp_remove_state_nocalls(CPUHP_XFS_DEAD);
2312 #else /* !CONFIG_HOTPLUG_CPU */
2313 static inline int xfs_cpu_hotplug_init(void) { return 0; }
2314 static inline void xfs_cpu_hotplug_destroy(void) {}
2322 xfs_check_ondisk_structs();
2324 error = xfs_dahash_test();
2328 printk(KERN_INFO XFS_VERSION_STRING " with "
2329 XFS_BUILD_OPTIONS " enabled\n");
2333 error = xfs_cpu_hotplug_init();
2337 error = xfs_init_caches();
2339 goto out_destroy_hp;
2341 error = xfs_init_workqueues();
2343 goto out_destroy_caches;
2345 error = xfs_mru_cache_init();
2347 goto out_destroy_wq;
2349 error = xfs_init_procfs();
2351 goto out_mru_cache_uninit;
2353 error = xfs_sysctl_register();
2355 goto out_cleanup_procfs;
2357 xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
2360 goto out_sysctl_unregister;
2363 xfsstats.xs_kobj.kobject.kset = xfs_kset;
2365 xfsstats.xs_stats = alloc_percpu(struct xfsstats);
2366 if (!xfsstats.xs_stats) {
2368 goto out_kset_unregister;
2371 error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
2374 goto out_free_stats;
2377 xfs_dbg_kobj.kobject.kset = xfs_kset;
2378 error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
2380 goto out_remove_stats_kobj;
2383 error = xfs_qm_init();
2385 goto out_remove_dbg_kobj;
2387 error = register_filesystem(&xfs_fs_type);
2394 out_remove_dbg_kobj:
2396 xfs_sysfs_del(&xfs_dbg_kobj);
2397 out_remove_stats_kobj:
2399 xfs_sysfs_del(&xfsstats.xs_kobj);
2401 free_percpu(xfsstats.xs_stats);
2402 out_kset_unregister:
2403 kset_unregister(xfs_kset);
2404 out_sysctl_unregister:
2405 xfs_sysctl_unregister();
2407 xfs_cleanup_procfs();
2408 out_mru_cache_uninit:
2409 xfs_mru_cache_uninit();
2411 xfs_destroy_workqueues();
2413 xfs_destroy_caches();
2415 xfs_cpu_hotplug_destroy();
2424 unregister_filesystem(&xfs_fs_type);
2426 xfs_sysfs_del(&xfs_dbg_kobj);
2428 xfs_sysfs_del(&xfsstats.xs_kobj);
2429 free_percpu(xfsstats.xs_stats);
2430 kset_unregister(xfs_kset);
2431 xfs_sysctl_unregister();
2432 xfs_cleanup_procfs();
2433 xfs_mru_cache_uninit();
2434 xfs_destroy_workqueues();
2435 xfs_destroy_caches();
2436 xfs_uuid_table_free();
2437 xfs_cpu_hotplug_destroy();
2440 module_init(init_xfs_fs);
2441 module_exit(exit_xfs_fs);
2443 MODULE_AUTHOR("Silicon Graphics, Inc.");
2444 MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
2445 MODULE_LICENSE("GPL");