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"
39 #include <linux/magic.h>
40 #include <linux/fs_context.h>
41 #include <linux/fs_parser.h>
43 static const struct super_operations xfs_super_operations
;
45 static struct kset
*xfs_kset
; /* top-level xfs sysfs dir */
47 static struct xfs_kobj xfs_dbg_kobj
; /* global debug sysfs attrs */
57 xfs_mount_set_dax_mode(
59 enum xfs_dax_mode mode
)
63 mp
->m_flags
&= ~(XFS_MOUNT_DAX_ALWAYS
| XFS_MOUNT_DAX_NEVER
);
66 mp
->m_flags
|= XFS_MOUNT_DAX_ALWAYS
;
67 mp
->m_flags
&= ~XFS_MOUNT_DAX_NEVER
;
70 mp
->m_flags
|= XFS_MOUNT_DAX_NEVER
;
71 mp
->m_flags
&= ~XFS_MOUNT_DAX_ALWAYS
;
76 static const struct constant_table dax_param_enums
[] = {
77 {"inode", XFS_DAX_INODE
},
78 {"always", XFS_DAX_ALWAYS
},
79 {"never", XFS_DAX_NEVER
},
84 * Table driven mount option parser.
87 Opt_logbufs
, Opt_logbsize
, Opt_logdev
, Opt_rtdev
,
88 Opt_wsync
, Opt_noalign
, Opt_swalloc
, Opt_sunit
, Opt_swidth
, Opt_nouuid
,
89 Opt_grpid
, Opt_nogrpid
, Opt_bsdgroups
, Opt_sysvgroups
,
90 Opt_allocsize
, Opt_norecovery
, Opt_inode64
, Opt_inode32
, Opt_ikeep
,
91 Opt_noikeep
, Opt_largeio
, Opt_nolargeio
, Opt_attr2
, Opt_noattr2
,
92 Opt_filestreams
, Opt_quota
, Opt_noquota
, Opt_usrquota
, Opt_grpquota
,
93 Opt_prjquota
, Opt_uquota
, Opt_gquota
, Opt_pquota
,
94 Opt_uqnoenforce
, Opt_gqnoenforce
, Opt_pqnoenforce
, Opt_qnoenforce
,
95 Opt_discard
, Opt_nodiscard
, Opt_dax
, Opt_dax_enum
,
98 static const struct fs_parameter_spec xfs_fs_parameters
[] = {
99 fsparam_u32("logbufs", Opt_logbufs
),
100 fsparam_string("logbsize", Opt_logbsize
),
101 fsparam_string("logdev", Opt_logdev
),
102 fsparam_string("rtdev", Opt_rtdev
),
103 fsparam_flag("wsync", Opt_wsync
),
104 fsparam_flag("noalign", Opt_noalign
),
105 fsparam_flag("swalloc", Opt_swalloc
),
106 fsparam_u32("sunit", Opt_sunit
),
107 fsparam_u32("swidth", Opt_swidth
),
108 fsparam_flag("nouuid", Opt_nouuid
),
109 fsparam_flag("grpid", Opt_grpid
),
110 fsparam_flag("nogrpid", Opt_nogrpid
),
111 fsparam_flag("bsdgroups", Opt_bsdgroups
),
112 fsparam_flag("sysvgroups", Opt_sysvgroups
),
113 fsparam_string("allocsize", Opt_allocsize
),
114 fsparam_flag("norecovery", Opt_norecovery
),
115 fsparam_flag("inode64", Opt_inode64
),
116 fsparam_flag("inode32", Opt_inode32
),
117 fsparam_flag("ikeep", Opt_ikeep
),
118 fsparam_flag("noikeep", Opt_noikeep
),
119 fsparam_flag("largeio", Opt_largeio
),
120 fsparam_flag("nolargeio", Opt_nolargeio
),
121 fsparam_flag("attr2", Opt_attr2
),
122 fsparam_flag("noattr2", Opt_noattr2
),
123 fsparam_flag("filestreams", Opt_filestreams
),
124 fsparam_flag("quota", Opt_quota
),
125 fsparam_flag("noquota", Opt_noquota
),
126 fsparam_flag("usrquota", Opt_usrquota
),
127 fsparam_flag("grpquota", Opt_grpquota
),
128 fsparam_flag("prjquota", Opt_prjquota
),
129 fsparam_flag("uquota", Opt_uquota
),
130 fsparam_flag("gquota", Opt_gquota
),
131 fsparam_flag("pquota", Opt_pquota
),
132 fsparam_flag("uqnoenforce", Opt_uqnoenforce
),
133 fsparam_flag("gqnoenforce", Opt_gqnoenforce
),
134 fsparam_flag("pqnoenforce", Opt_pqnoenforce
),
135 fsparam_flag("qnoenforce", Opt_qnoenforce
),
136 fsparam_flag("discard", Opt_discard
),
137 fsparam_flag("nodiscard", Opt_nodiscard
),
138 fsparam_flag("dax", Opt_dax
),
139 fsparam_enum("dax", Opt_dax_enum
, dax_param_enums
),
143 struct proc_xfs_info
{
153 static struct proc_xfs_info xfs_info_set
[] = {
154 /* the few simple ones we can get from the mount struct */
155 { XFS_MOUNT_IKEEP
, ",ikeep" },
156 { XFS_MOUNT_WSYNC
, ",wsync" },
157 { XFS_MOUNT_NOALIGN
, ",noalign" },
158 { XFS_MOUNT_SWALLOC
, ",swalloc" },
159 { XFS_MOUNT_NOUUID
, ",nouuid" },
160 { XFS_MOUNT_NORECOVERY
, ",norecovery" },
161 { XFS_MOUNT_ATTR2
, ",attr2" },
162 { XFS_MOUNT_FILESTREAMS
, ",filestreams" },
163 { XFS_MOUNT_GRPID
, ",grpid" },
164 { XFS_MOUNT_DISCARD
, ",discard" },
165 { XFS_MOUNT_LARGEIO
, ",largeio" },
166 { XFS_MOUNT_DAX_ALWAYS
, ",dax=always" },
167 { XFS_MOUNT_DAX_NEVER
, ",dax=never" },
170 struct xfs_mount
*mp
= XFS_M(root
->d_sb
);
171 struct proc_xfs_info
*xfs_infop
;
173 for (xfs_infop
= xfs_info_set
; xfs_infop
->flag
; xfs_infop
++) {
174 if (mp
->m_flags
& xfs_infop
->flag
)
175 seq_puts(m
, xfs_infop
->str
);
178 seq_printf(m
, ",inode%d",
179 (mp
->m_flags
& XFS_MOUNT_SMALL_INUMS
) ? 32 : 64);
181 if (mp
->m_flags
& XFS_MOUNT_ALLOCSIZE
)
182 seq_printf(m
, ",allocsize=%dk",
183 (1 << mp
->m_allocsize_log
) >> 10);
185 if (mp
->m_logbufs
> 0)
186 seq_printf(m
, ",logbufs=%d", mp
->m_logbufs
);
187 if (mp
->m_logbsize
> 0)
188 seq_printf(m
, ",logbsize=%dk", mp
->m_logbsize
>> 10);
191 seq_show_option(m
, "logdev", mp
->m_logname
);
193 seq_show_option(m
, "rtdev", mp
->m_rtname
);
195 if (mp
->m_dalign
> 0)
196 seq_printf(m
, ",sunit=%d",
197 (int)XFS_FSB_TO_BB(mp
, mp
->m_dalign
));
198 if (mp
->m_swidth
> 0)
199 seq_printf(m
, ",swidth=%d",
200 (int)XFS_FSB_TO_BB(mp
, mp
->m_swidth
));
202 if (mp
->m_qflags
& XFS_UQUOTA_ACCT
) {
203 if (mp
->m_qflags
& XFS_UQUOTA_ENFD
)
204 seq_puts(m
, ",usrquota");
206 seq_puts(m
, ",uqnoenforce");
209 if (mp
->m_qflags
& XFS_PQUOTA_ACCT
) {
210 if (mp
->m_qflags
& XFS_PQUOTA_ENFD
)
211 seq_puts(m
, ",prjquota");
213 seq_puts(m
, ",pqnoenforce");
215 if (mp
->m_qflags
& XFS_GQUOTA_ACCT
) {
216 if (mp
->m_qflags
& XFS_GQUOTA_ENFD
)
217 seq_puts(m
, ",grpquota");
219 seq_puts(m
, ",gqnoenforce");
222 if (!(mp
->m_qflags
& XFS_ALL_QUOTA_ACCT
))
223 seq_puts(m
, ",noquota");
229 * Set parameters for inode allocation heuristics, taking into account
230 * filesystem size and inode32/inode64 mount options; i.e. specifically
231 * whether or not XFS_MOUNT_SMALL_INUMS is set.
233 * Inode allocation patterns are altered only if inode32 is requested
234 * (XFS_MOUNT_SMALL_INUMS), and the filesystem is sufficiently large.
235 * If altered, XFS_MOUNT_32BITINODES is set as well.
237 * An agcount independent of that in the mount structure is provided
238 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
239 * to the potentially higher ag count.
241 * Returns the maximum AG index which may contain inodes.
245 struct xfs_mount
*mp
,
246 xfs_agnumber_t agcount
)
248 xfs_agnumber_t index
;
249 xfs_agnumber_t maxagi
= 0;
250 xfs_sb_t
*sbp
= &mp
->m_sb
;
251 xfs_agnumber_t max_metadata
;
256 * Calculate how much should be reserved for inodes to meet
257 * the max inode percentage. Used only for inode32.
259 if (M_IGEO(mp
)->maxicount
) {
262 icount
= sbp
->sb_dblocks
* sbp
->sb_imax_pct
;
264 icount
+= sbp
->sb_agblocks
- 1;
265 do_div(icount
, sbp
->sb_agblocks
);
266 max_metadata
= icount
;
268 max_metadata
= agcount
;
271 /* Get the last possible inode in the filesystem */
272 agino
= XFS_AGB_TO_AGINO(mp
, sbp
->sb_agblocks
- 1);
273 ino
= XFS_AGINO_TO_INO(mp
, agcount
- 1, agino
);
276 * If user asked for no more than 32-bit inodes, and the fs is
277 * sufficiently large, set XFS_MOUNT_32BITINODES if we must alter
278 * the allocator to accommodate the request.
280 if ((mp
->m_flags
& XFS_MOUNT_SMALL_INUMS
) && ino
> XFS_MAXINUMBER_32
)
281 mp
->m_flags
|= XFS_MOUNT_32BITINODES
;
283 mp
->m_flags
&= ~XFS_MOUNT_32BITINODES
;
285 for (index
= 0; index
< agcount
; index
++) {
286 struct xfs_perag
*pag
;
288 ino
= XFS_AGINO_TO_INO(mp
, index
, agino
);
290 pag
= xfs_perag_get(mp
, index
);
292 if (mp
->m_flags
& XFS_MOUNT_32BITINODES
) {
293 if (ino
> XFS_MAXINUMBER_32
) {
294 pag
->pagi_inodeok
= 0;
295 pag
->pagf_metadata
= 0;
297 pag
->pagi_inodeok
= 1;
299 if (index
< max_metadata
)
300 pag
->pagf_metadata
= 1;
302 pag
->pagf_metadata
= 0;
305 pag
->pagi_inodeok
= 1;
306 pag
->pagf_metadata
= 0;
312 return (mp
->m_flags
& XFS_MOUNT_32BITINODES
) ? maxagi
: agcount
;
319 struct block_device
**bdevp
)
323 *bdevp
= blkdev_get_by_path(name
, FMODE_READ
|FMODE_WRITE
|FMODE_EXCL
,
325 if (IS_ERR(*bdevp
)) {
326 error
= PTR_ERR(*bdevp
);
327 xfs_warn(mp
, "Invalid device [%s], error=%d", name
, error
);
335 struct block_device
*bdev
)
338 blkdev_put(bdev
, FMODE_READ
|FMODE_WRITE
|FMODE_EXCL
);
342 xfs_blkdev_issue_flush(
343 xfs_buftarg_t
*buftarg
)
345 blkdev_issue_flush(buftarg
->bt_bdev
, GFP_NOFS
);
350 struct xfs_mount
*mp
)
352 struct dax_device
*dax_ddev
= mp
->m_ddev_targp
->bt_daxdev
;
354 if (mp
->m_logdev_targp
&& mp
->m_logdev_targp
!= mp
->m_ddev_targp
) {
355 struct block_device
*logdev
= mp
->m_logdev_targp
->bt_bdev
;
356 struct dax_device
*dax_logdev
= mp
->m_logdev_targp
->bt_daxdev
;
358 xfs_free_buftarg(mp
->m_logdev_targp
);
359 xfs_blkdev_put(logdev
);
360 fs_put_dax(dax_logdev
);
362 if (mp
->m_rtdev_targp
) {
363 struct block_device
*rtdev
= mp
->m_rtdev_targp
->bt_bdev
;
364 struct dax_device
*dax_rtdev
= mp
->m_rtdev_targp
->bt_daxdev
;
366 xfs_free_buftarg(mp
->m_rtdev_targp
);
367 xfs_blkdev_put(rtdev
);
368 fs_put_dax(dax_rtdev
);
370 xfs_free_buftarg(mp
->m_ddev_targp
);
371 fs_put_dax(dax_ddev
);
375 * The file system configurations are:
376 * (1) device (partition) with data and internal log
377 * (2) logical volume with data and log subvolumes.
378 * (3) logical volume with data, log, and realtime subvolumes.
380 * We only have to handle opening the log and realtime volumes here if
381 * they are present. The data subvolume has already been opened by
382 * get_sb_bdev() and is stored in sb->s_bdev.
386 struct xfs_mount
*mp
)
388 struct block_device
*ddev
= mp
->m_super
->s_bdev
;
389 struct dax_device
*dax_ddev
= fs_dax_get_by_bdev(ddev
);
390 struct dax_device
*dax_logdev
= NULL
, *dax_rtdev
= NULL
;
391 struct block_device
*logdev
= NULL
, *rtdev
= NULL
;
395 * Open real time and log devices - order is important.
398 error
= xfs_blkdev_get(mp
, mp
->m_logname
, &logdev
);
401 dax_logdev
= fs_dax_get_by_bdev(logdev
);
405 error
= xfs_blkdev_get(mp
, mp
->m_rtname
, &rtdev
);
407 goto out_close_logdev
;
409 if (rtdev
== ddev
|| rtdev
== logdev
) {
411 "Cannot mount filesystem with identical rtdev and ddev/logdev.");
413 goto out_close_rtdev
;
415 dax_rtdev
= fs_dax_get_by_bdev(rtdev
);
419 * Setup xfs_mount buffer target pointers
422 mp
->m_ddev_targp
= xfs_alloc_buftarg(mp
, ddev
, dax_ddev
);
423 if (!mp
->m_ddev_targp
)
424 goto out_close_rtdev
;
427 mp
->m_rtdev_targp
= xfs_alloc_buftarg(mp
, rtdev
, dax_rtdev
);
428 if (!mp
->m_rtdev_targp
)
429 goto out_free_ddev_targ
;
432 if (logdev
&& logdev
!= ddev
) {
433 mp
->m_logdev_targp
= xfs_alloc_buftarg(mp
, logdev
, dax_logdev
);
434 if (!mp
->m_logdev_targp
)
435 goto out_free_rtdev_targ
;
437 mp
->m_logdev_targp
= mp
->m_ddev_targp
;
443 if (mp
->m_rtdev_targp
)
444 xfs_free_buftarg(mp
->m_rtdev_targp
);
446 xfs_free_buftarg(mp
->m_ddev_targp
);
448 xfs_blkdev_put(rtdev
);
449 fs_put_dax(dax_rtdev
);
451 if (logdev
&& logdev
!= ddev
) {
452 xfs_blkdev_put(logdev
);
453 fs_put_dax(dax_logdev
);
456 fs_put_dax(dax_ddev
);
461 * Setup xfs_mount buffer target pointers based on superblock
465 struct xfs_mount
*mp
)
469 error
= xfs_setsize_buftarg(mp
->m_ddev_targp
, mp
->m_sb
.sb_sectsize
);
473 if (mp
->m_logdev_targp
&& mp
->m_logdev_targp
!= mp
->m_ddev_targp
) {
474 unsigned int log_sector_size
= BBSIZE
;
476 if (xfs_sb_version_hassector(&mp
->m_sb
))
477 log_sector_size
= mp
->m_sb
.sb_logsectsize
;
478 error
= xfs_setsize_buftarg(mp
->m_logdev_targp
,
483 if (mp
->m_rtdev_targp
) {
484 error
= xfs_setsize_buftarg(mp
->m_rtdev_targp
,
485 mp
->m_sb
.sb_sectsize
);
494 xfs_init_mount_workqueues(
495 struct xfs_mount
*mp
)
497 mp
->m_buf_workqueue
= alloc_workqueue("xfs-buf/%s",
498 WQ_MEM_RECLAIM
|WQ_FREEZABLE
, 1, mp
->m_super
->s_id
);
499 if (!mp
->m_buf_workqueue
)
502 mp
->m_unwritten_workqueue
= alloc_workqueue("xfs-conv/%s",
503 WQ_MEM_RECLAIM
|WQ_FREEZABLE
, 0, mp
->m_super
->s_id
);
504 if (!mp
->m_unwritten_workqueue
)
505 goto out_destroy_buf
;
507 mp
->m_cil_workqueue
= alloc_workqueue("xfs-cil/%s",
508 WQ_MEM_RECLAIM
| WQ_FREEZABLE
| WQ_UNBOUND
,
509 0, mp
->m_super
->s_id
);
510 if (!mp
->m_cil_workqueue
)
511 goto out_destroy_unwritten
;
513 mp
->m_reclaim_workqueue
= alloc_workqueue("xfs-reclaim/%s",
514 WQ_MEM_RECLAIM
|WQ_FREEZABLE
, 0, mp
->m_super
->s_id
);
515 if (!mp
->m_reclaim_workqueue
)
516 goto out_destroy_cil
;
518 mp
->m_eofblocks_workqueue
= alloc_workqueue("xfs-eofblocks/%s",
519 WQ_MEM_RECLAIM
|WQ_FREEZABLE
, 0, mp
->m_super
->s_id
);
520 if (!mp
->m_eofblocks_workqueue
)
521 goto out_destroy_reclaim
;
523 mp
->m_sync_workqueue
= alloc_workqueue("xfs-sync/%s", WQ_FREEZABLE
, 0,
525 if (!mp
->m_sync_workqueue
)
526 goto out_destroy_eofb
;
531 destroy_workqueue(mp
->m_eofblocks_workqueue
);
533 destroy_workqueue(mp
->m_reclaim_workqueue
);
535 destroy_workqueue(mp
->m_cil_workqueue
);
536 out_destroy_unwritten
:
537 destroy_workqueue(mp
->m_unwritten_workqueue
);
539 destroy_workqueue(mp
->m_buf_workqueue
);
545 xfs_destroy_mount_workqueues(
546 struct xfs_mount
*mp
)
548 destroy_workqueue(mp
->m_sync_workqueue
);
549 destroy_workqueue(mp
->m_eofblocks_workqueue
);
550 destroy_workqueue(mp
->m_reclaim_workqueue
);
551 destroy_workqueue(mp
->m_cil_workqueue
);
552 destroy_workqueue(mp
->m_unwritten_workqueue
);
553 destroy_workqueue(mp
->m_buf_workqueue
);
557 xfs_flush_inodes_worker(
558 struct work_struct
*work
)
560 struct xfs_mount
*mp
= container_of(work
, struct xfs_mount
,
561 m_flush_inodes_work
);
562 struct super_block
*sb
= mp
->m_super
;
564 if (down_read_trylock(&sb
->s_umount
)) {
566 up_read(&sb
->s_umount
);
571 * Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK
572 * or a page lock. We use sync_inodes_sb() here to ensure we block while waiting
573 * for IO to complete so that we effectively throttle multiple callers to the
574 * rate at which IO is completing.
578 struct xfs_mount
*mp
)
581 * If flush_work() returns true then that means we waited for a flush
582 * which was already in progress. Don't bother running another scan.
584 if (flush_work(&mp
->m_flush_inodes_work
))
587 queue_work(mp
->m_sync_workqueue
, &mp
->m_flush_inodes_work
);
588 flush_work(&mp
->m_flush_inodes_work
);
591 /* Catch misguided souls that try to use this interface on XFS */
592 STATIC
struct inode
*
594 struct super_block
*sb
)
603 struct xfs_inode
*ip
,
606 struct xfs_ifork
*ifp
= XFS_IFORK_PTR(ip
, whichfork
);
607 struct xfs_bmbt_irec got
;
608 struct xfs_iext_cursor icur
;
610 if (!ifp
|| !xfs_iext_lookup_extent(ip
, ifp
, 0, &icur
, &got
))
613 if (isnullstartblock(got
.br_startblock
)) {
614 xfs_warn(ip
->i_mount
,
615 "ino %llx %s fork has delalloc extent at [0x%llx:0x%llx]",
617 whichfork
== XFS_DATA_FORK
? "data" : "cow",
618 got
.br_startoff
, got
.br_blockcount
);
620 } while (xfs_iext_next_extent(ifp
, &icur
, &got
));
623 #define xfs_check_delalloc(ip, whichfork) do { } while (0)
627 * Now that the generic code is guaranteed not to be accessing
628 * the linux inode, we can inactivate and reclaim the inode.
631 xfs_fs_destroy_inode(
634 struct xfs_inode
*ip
= XFS_I(inode
);
636 trace_xfs_destroy_inode(ip
);
638 ASSERT(!rwsem_is_locked(&inode
->i_rwsem
));
639 XFS_STATS_INC(ip
->i_mount
, vn_rele
);
640 XFS_STATS_INC(ip
->i_mount
, vn_remove
);
644 if (!XFS_FORCED_SHUTDOWN(ip
->i_mount
) && ip
->i_delayed_blks
) {
645 xfs_check_delalloc(ip
, XFS_DATA_FORK
);
646 xfs_check_delalloc(ip
, XFS_COW_FORK
);
650 XFS_STATS_INC(ip
->i_mount
, vn_reclaim
);
653 * We should never get here with one of the reclaim flags already set.
655 ASSERT_ALWAYS(!xfs_iflags_test(ip
, XFS_IRECLAIMABLE
));
656 ASSERT_ALWAYS(!xfs_iflags_test(ip
, XFS_IRECLAIM
));
659 * We always use background reclaim here because even if the inode is
660 * clean, it still may be under IO and hence we have wait for IO
661 * completion to occur before we can reclaim the inode. The background
662 * reclaim path handles this more efficiently than we can here, so
663 * simply let background reclaim tear down all inodes.
665 xfs_inode_set_reclaim_tag(ip
);
673 struct xfs_inode
*ip
= XFS_I(inode
);
674 struct xfs_mount
*mp
= ip
->i_mount
;
675 struct xfs_trans
*tp
;
677 if (!(inode
->i_sb
->s_flags
& SB_LAZYTIME
))
679 if (flag
!= I_DIRTY_SYNC
|| !(inode
->i_state
& I_DIRTY_TIME
))
682 if (xfs_trans_alloc(mp
, &M_RES(mp
)->tr_fsyncts
, 0, 0, 0, &tp
))
684 xfs_ilock(ip
, XFS_ILOCK_EXCL
);
685 xfs_trans_ijoin(tp
, ip
, XFS_ILOCK_EXCL
);
686 xfs_trans_log_inode(tp
, ip
, XFS_ILOG_TIMESTAMP
);
687 xfs_trans_commit(tp
);
691 * Slab object creation initialisation for the XFS inode.
692 * This covers only the idempotent fields in the XFS inode;
693 * all other fields need to be initialised on allocation
694 * from the slab. This avoids the need to repeatedly initialise
695 * fields in the xfs inode that left in the initialise state
696 * when freeing the inode.
699 xfs_fs_inode_init_once(
702 struct xfs_inode
*ip
= inode
;
704 memset(ip
, 0, sizeof(struct xfs_inode
));
707 inode_init_once(VFS_I(ip
));
710 atomic_set(&ip
->i_pincount
, 0);
711 spin_lock_init(&ip
->i_flags_lock
);
713 mrlock_init(&ip
->i_mmaplock
, MRLOCK_ALLOW_EQUAL_PRI
|MRLOCK_BARRIER
,
714 "xfsino", ip
->i_ino
);
715 mrlock_init(&ip
->i_lock
, MRLOCK_ALLOW_EQUAL_PRI
|MRLOCK_BARRIER
,
716 "xfsino", ip
->i_ino
);
720 * We do an unlocked check for XFS_IDONTCACHE here because we are already
721 * serialised against cache hits here via the inode->i_lock and igrab() in
722 * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
723 * racing with us, and it avoids needing to grab a spinlock here for every inode
724 * we drop the final reference on.
730 struct xfs_inode
*ip
= XFS_I(inode
);
733 * If this unlinked inode is in the middle of recovery, don't
734 * drop the inode just yet; log recovery will take care of
735 * that. See the comment for this inode flag.
737 if (ip
->i_flags
& XFS_IRECOVERY
) {
738 ASSERT(ip
->i_mount
->m_log
->l_flags
& XLOG_RECOVERY_NEEDED
);
742 return generic_drop_inode(inode
);
747 struct xfs_mount
*mp
)
750 kfree(mp
->m_logname
);
756 struct super_block
*sb
,
759 struct xfs_mount
*mp
= XFS_M(sb
);
762 * Doing anything during the async pass would be counterproductive.
767 xfs_log_force(mp
, XFS_LOG_SYNC
);
770 * The disk must be active because we're syncing.
771 * We schedule log work now (now that the disk is
772 * active) instead of later (when it might not be).
774 flush_delayed_work(&mp
->m_log
->l_work
);
782 struct dentry
*dentry
,
783 struct kstatfs
*statp
)
785 struct xfs_mount
*mp
= XFS_M(dentry
->d_sb
);
786 xfs_sb_t
*sbp
= &mp
->m_sb
;
787 struct xfs_inode
*ip
= XFS_I(d_inode(dentry
));
788 uint64_t fakeinos
, id
;
795 statp
->f_type
= XFS_SUPER_MAGIC
;
796 statp
->f_namelen
= MAXNAMELEN
- 1;
798 id
= huge_encode_dev(mp
->m_ddev_targp
->bt_dev
);
799 statp
->f_fsid
= u64_to_fsid(id
);
801 icount
= percpu_counter_sum(&mp
->m_icount
);
802 ifree
= percpu_counter_sum(&mp
->m_ifree
);
803 fdblocks
= percpu_counter_sum(&mp
->m_fdblocks
);
805 spin_lock(&mp
->m_sb_lock
);
806 statp
->f_bsize
= sbp
->sb_blocksize
;
807 lsize
= sbp
->sb_logstart
? sbp
->sb_logblocks
: 0;
808 statp
->f_blocks
= sbp
->sb_dblocks
- lsize
;
809 spin_unlock(&mp
->m_sb_lock
);
811 /* make sure statp->f_bfree does not underflow */
812 statp
->f_bfree
= max_t(int64_t, fdblocks
- mp
->m_alloc_set_aside
, 0);
813 statp
->f_bavail
= statp
->f_bfree
;
815 fakeinos
= XFS_FSB_TO_INO(mp
, statp
->f_bfree
);
816 statp
->f_files
= min(icount
+ fakeinos
, (uint64_t)XFS_MAXINUMBER
);
817 if (M_IGEO(mp
)->maxicount
)
818 statp
->f_files
= min_t(typeof(statp
->f_files
),
820 M_IGEO(mp
)->maxicount
);
822 /* If sb_icount overshot maxicount, report actual allocation */
823 statp
->f_files
= max_t(typeof(statp
->f_files
),
827 /* make sure statp->f_ffree does not underflow */
828 ffree
= statp
->f_files
- (icount
- ifree
);
829 statp
->f_ffree
= max_t(int64_t, ffree
, 0);
832 if ((ip
->i_d
.di_flags
& XFS_DIFLAG_PROJINHERIT
) &&
833 ((mp
->m_qflags
& (XFS_PQUOTA_ACCT
|XFS_PQUOTA_ENFD
))) ==
834 (XFS_PQUOTA_ACCT
|XFS_PQUOTA_ENFD
))
835 xfs_qm_statvfs(ip
, statp
);
837 if (XFS_IS_REALTIME_MOUNT(mp
) &&
838 (ip
->i_d
.di_flags
& (XFS_DIFLAG_RTINHERIT
| XFS_DIFLAG_REALTIME
))) {
839 statp
->f_blocks
= sbp
->sb_rblocks
;
840 statp
->f_bavail
= statp
->f_bfree
=
841 sbp
->sb_frextents
* sbp
->sb_rextsize
;
848 xfs_save_resvblks(struct xfs_mount
*mp
)
850 uint64_t resblks
= 0;
852 mp
->m_resblks_save
= mp
->m_resblks
;
853 xfs_reserve_blocks(mp
, &resblks
, NULL
);
857 xfs_restore_resvblks(struct xfs_mount
*mp
)
861 if (mp
->m_resblks_save
) {
862 resblks
= mp
->m_resblks_save
;
863 mp
->m_resblks_save
= 0;
865 resblks
= xfs_default_resblks(mp
);
867 xfs_reserve_blocks(mp
, &resblks
, NULL
);
871 * Trigger writeback of all the dirty metadata in the file system.
873 * This ensures that the metadata is written to their location on disk rather
874 * than just existing in transactions in the log. This means after a quiesce
875 * there is no log replay required to write the inodes to disk - this is the
876 * primary difference between a sync and a quiesce.
878 * We cancel log work early here to ensure all transactions the log worker may
879 * run have finished before we clean up and log the superblock and write an
880 * unmount record. The unfreeze process is responsible for restarting the log
885 struct xfs_mount
*mp
)
889 cancel_delayed_work_sync(&mp
->m_log
->l_work
);
891 /* force the log to unpin objects from the now complete transactions */
892 xfs_log_force(mp
, XFS_LOG_SYNC
);
895 /* Push the superblock and write an unmount record */
896 error
= xfs_log_sbcount(mp
);
898 xfs_warn(mp
, "xfs_attr_quiesce: failed to log sb changes. "
899 "Frozen image may not be consistent.");
904 * Second stage of a freeze. The data is already frozen so we only
905 * need to take care of the metadata. Once that's done sync the superblock
906 * to the log to dirty it in case of a crash while frozen. This ensures that we
907 * will recover the unlinked inode lists on the next mount.
911 struct super_block
*sb
)
913 struct xfs_mount
*mp
= XFS_M(sb
);
918 * The filesystem is now frozen far enough that memory reclaim
919 * cannot safely operate on the filesystem. Hence we need to
920 * set a GFP_NOFS context here to avoid recursion deadlocks.
922 flags
= memalloc_nofs_save();
923 xfs_stop_block_reaping(mp
);
924 xfs_save_resvblks(mp
);
925 xfs_quiesce_attr(mp
);
926 ret
= xfs_sync_sb(mp
, true);
927 memalloc_nofs_restore(flags
);
933 struct super_block
*sb
)
935 struct xfs_mount
*mp
= XFS_M(sb
);
937 xfs_restore_resvblks(mp
);
938 xfs_log_work_queue(mp
);
939 xfs_start_block_reaping(mp
);
944 * This function fills in xfs_mount_t fields based on mount args.
945 * Note: the superblock _has_ now been read in.
949 struct xfs_mount
*mp
)
951 int ronly
= (mp
->m_flags
& XFS_MOUNT_RDONLY
);
953 /* Fail a mount where the logbuf is smaller than the log stripe */
954 if (xfs_sb_version_haslogv2(&mp
->m_sb
)) {
955 if (mp
->m_logbsize
<= 0 &&
956 mp
->m_sb
.sb_logsunit
> XLOG_BIG_RECORD_BSIZE
) {
957 mp
->m_logbsize
= mp
->m_sb
.sb_logsunit
;
958 } else if (mp
->m_logbsize
> 0 &&
959 mp
->m_logbsize
< mp
->m_sb
.sb_logsunit
) {
961 "logbuf size must be greater than or equal to log stripe size");
965 /* Fail a mount if the logbuf is larger than 32K */
966 if (mp
->m_logbsize
> XLOG_BIG_RECORD_BSIZE
) {
968 "logbuf size for version 1 logs must be 16K or 32K");
974 * V5 filesystems always use attr2 format for attributes.
976 if (xfs_sb_version_hascrc(&mp
->m_sb
) &&
977 (mp
->m_flags
& XFS_MOUNT_NOATTR2
)) {
978 xfs_warn(mp
, "Cannot mount a V5 filesystem as noattr2. "
979 "attr2 is always enabled for V5 filesystems.");
984 * mkfs'ed attr2 will turn on attr2 mount unless explicitly
985 * told by noattr2 to turn it off
987 if (xfs_sb_version_hasattr2(&mp
->m_sb
) &&
988 !(mp
->m_flags
& XFS_MOUNT_NOATTR2
))
989 mp
->m_flags
|= XFS_MOUNT_ATTR2
;
992 * prohibit r/w mounts of read-only filesystems
994 if ((mp
->m_sb
.sb_flags
& XFS_SBF_READONLY
) && !ronly
) {
996 "cannot mount a read-only filesystem as read-write");
1000 if ((mp
->m_qflags
& (XFS_GQUOTA_ACCT
| XFS_GQUOTA_ACTIVE
)) &&
1001 (mp
->m_qflags
& (XFS_PQUOTA_ACCT
| XFS_PQUOTA_ACTIVE
)) &&
1002 !xfs_sb_version_has_pquotino(&mp
->m_sb
)) {
1004 "Super block does not support project and group quota together");
1012 xfs_init_percpu_counters(
1013 struct xfs_mount
*mp
)
1017 error
= percpu_counter_init(&mp
->m_icount
, 0, GFP_KERNEL
);
1021 error
= percpu_counter_init(&mp
->m_ifree
, 0, GFP_KERNEL
);
1025 error
= percpu_counter_init(&mp
->m_fdblocks
, 0, GFP_KERNEL
);
1029 error
= percpu_counter_init(&mp
->m_delalloc_blks
, 0, GFP_KERNEL
);
1036 percpu_counter_destroy(&mp
->m_fdblocks
);
1038 percpu_counter_destroy(&mp
->m_ifree
);
1040 percpu_counter_destroy(&mp
->m_icount
);
1045 xfs_reinit_percpu_counters(
1046 struct xfs_mount
*mp
)
1048 percpu_counter_set(&mp
->m_icount
, mp
->m_sb
.sb_icount
);
1049 percpu_counter_set(&mp
->m_ifree
, mp
->m_sb
.sb_ifree
);
1050 percpu_counter_set(&mp
->m_fdblocks
, mp
->m_sb
.sb_fdblocks
);
1054 xfs_destroy_percpu_counters(
1055 struct xfs_mount
*mp
)
1057 percpu_counter_destroy(&mp
->m_icount
);
1058 percpu_counter_destroy(&mp
->m_ifree
);
1059 percpu_counter_destroy(&mp
->m_fdblocks
);
1060 ASSERT(XFS_FORCED_SHUTDOWN(mp
) ||
1061 percpu_counter_sum(&mp
->m_delalloc_blks
) == 0);
1062 percpu_counter_destroy(&mp
->m_delalloc_blks
);
1067 struct super_block
*sb
)
1069 struct xfs_mount
*mp
= XFS_M(sb
);
1071 /* if ->fill_super failed, we have no mount to tear down */
1075 xfs_notice(mp
, "Unmounting Filesystem");
1076 xfs_filestream_unmount(mp
);
1080 free_percpu(mp
->m_stats
.xs_stats
);
1081 xfs_destroy_percpu_counters(mp
);
1082 xfs_destroy_mount_workqueues(mp
);
1083 xfs_close_devices(mp
);
1085 sb
->s_fs_info
= NULL
;
1090 xfs_fs_nr_cached_objects(
1091 struct super_block
*sb
,
1092 struct shrink_control
*sc
)
1094 /* Paranoia: catch incorrect calls during mount setup or teardown */
1095 if (WARN_ON_ONCE(!sb
->s_fs_info
))
1097 return xfs_reclaim_inodes_count(XFS_M(sb
));
1101 xfs_fs_free_cached_objects(
1102 struct super_block
*sb
,
1103 struct shrink_control
*sc
)
1105 return xfs_reclaim_inodes_nr(XFS_M(sb
), sc
->nr_to_scan
);
1108 static const struct super_operations xfs_super_operations
= {
1109 .alloc_inode
= xfs_fs_alloc_inode
,
1110 .destroy_inode
= xfs_fs_destroy_inode
,
1111 .dirty_inode
= xfs_fs_dirty_inode
,
1112 .drop_inode
= xfs_fs_drop_inode
,
1113 .put_super
= xfs_fs_put_super
,
1114 .sync_fs
= xfs_fs_sync_fs
,
1115 .freeze_fs
= xfs_fs_freeze
,
1116 .unfreeze_fs
= xfs_fs_unfreeze
,
1117 .statfs
= xfs_fs_statfs
,
1118 .show_options
= xfs_fs_show_options
,
1119 .nr_cached_objects
= xfs_fs_nr_cached_objects
,
1120 .free_cached_objects
= xfs_fs_free_cached_objects
,
1129 int last
, shift_left_factor
= 0, _res
;
1133 value
= kstrdup(s
, GFP_KERNEL
);
1137 last
= strlen(value
) - 1;
1138 if (value
[last
] == 'K' || value
[last
] == 'k') {
1139 shift_left_factor
= 10;
1142 if (value
[last
] == 'M' || value
[last
] == 'm') {
1143 shift_left_factor
= 20;
1146 if (value
[last
] == 'G' || value
[last
] == 'g') {
1147 shift_left_factor
= 30;
1151 if (kstrtoint(value
, base
, &_res
))
1154 *res
= _res
<< shift_left_factor
;
1159 * Set mount state from a mount option.
1161 * NOTE: mp->m_super is NULL here!
1165 struct fs_context
*fc
,
1166 struct fs_parameter
*param
)
1168 struct xfs_mount
*mp
= fc
->s_fs_info
;
1169 struct fs_parse_result result
;
1173 opt
= fs_parse(fc
, xfs_fs_parameters
, param
, &result
);
1179 mp
->m_logbufs
= result
.uint_32
;
1182 if (suffix_kstrtoint(param
->string
, 10, &mp
->m_logbsize
))
1186 kfree(mp
->m_logname
);
1187 mp
->m_logname
= kstrdup(param
->string
, GFP_KERNEL
);
1192 kfree(mp
->m_rtname
);
1193 mp
->m_rtname
= kstrdup(param
->string
, GFP_KERNEL
);
1198 if (suffix_kstrtoint(param
->string
, 10, &size
))
1200 mp
->m_allocsize_log
= ffs(size
) - 1;
1201 mp
->m_flags
|= XFS_MOUNT_ALLOCSIZE
;
1205 mp
->m_flags
|= XFS_MOUNT_GRPID
;
1208 case Opt_sysvgroups
:
1209 mp
->m_flags
&= ~XFS_MOUNT_GRPID
;
1212 mp
->m_flags
|= XFS_MOUNT_WSYNC
;
1214 case Opt_norecovery
:
1215 mp
->m_flags
|= XFS_MOUNT_NORECOVERY
;
1218 mp
->m_flags
|= XFS_MOUNT_NOALIGN
;
1221 mp
->m_flags
|= XFS_MOUNT_SWALLOC
;
1224 mp
->m_dalign
= result
.uint_32
;
1227 mp
->m_swidth
= result
.uint_32
;
1230 mp
->m_flags
|= XFS_MOUNT_SMALL_INUMS
;
1233 mp
->m_flags
&= ~XFS_MOUNT_SMALL_INUMS
;
1236 mp
->m_flags
|= XFS_MOUNT_NOUUID
;
1239 mp
->m_flags
|= XFS_MOUNT_LARGEIO
;
1242 mp
->m_flags
&= ~XFS_MOUNT_LARGEIO
;
1244 case Opt_filestreams
:
1245 mp
->m_flags
|= XFS_MOUNT_FILESTREAMS
;
1248 mp
->m_qflags
&= ~XFS_ALL_QUOTA_ACCT
;
1249 mp
->m_qflags
&= ~XFS_ALL_QUOTA_ENFD
;
1250 mp
->m_qflags
&= ~XFS_ALL_QUOTA_ACTIVE
;
1255 mp
->m_qflags
|= (XFS_UQUOTA_ACCT
| XFS_UQUOTA_ACTIVE
|
1258 case Opt_qnoenforce
:
1259 case Opt_uqnoenforce
:
1260 mp
->m_qflags
|= (XFS_UQUOTA_ACCT
| XFS_UQUOTA_ACTIVE
);
1261 mp
->m_qflags
&= ~XFS_UQUOTA_ENFD
;
1265 mp
->m_qflags
|= (XFS_PQUOTA_ACCT
| XFS_PQUOTA_ACTIVE
|
1268 case Opt_pqnoenforce
:
1269 mp
->m_qflags
|= (XFS_PQUOTA_ACCT
| XFS_PQUOTA_ACTIVE
);
1270 mp
->m_qflags
&= ~XFS_PQUOTA_ENFD
;
1274 mp
->m_qflags
|= (XFS_GQUOTA_ACCT
| XFS_GQUOTA_ACTIVE
|
1277 case Opt_gqnoenforce
:
1278 mp
->m_qflags
|= (XFS_GQUOTA_ACCT
| XFS_GQUOTA_ACTIVE
);
1279 mp
->m_qflags
&= ~XFS_GQUOTA_ENFD
;
1282 mp
->m_flags
|= XFS_MOUNT_DISCARD
;
1285 mp
->m_flags
&= ~XFS_MOUNT_DISCARD
;
1287 #ifdef CONFIG_FS_DAX
1289 xfs_mount_set_dax_mode(mp
, XFS_DAX_ALWAYS
);
1292 xfs_mount_set_dax_mode(mp
, result
.uint_32
);
1295 /* Following mount options will be removed in September 2025 */
1297 xfs_warn(mp
, "%s mount option is deprecated.", param
->key
);
1298 mp
->m_flags
|= XFS_MOUNT_IKEEP
;
1301 xfs_warn(mp
, "%s mount option is deprecated.", param
->key
);
1302 mp
->m_flags
&= ~XFS_MOUNT_IKEEP
;
1305 xfs_warn(mp
, "%s mount option is deprecated.", param
->key
);
1306 mp
->m_flags
|= XFS_MOUNT_ATTR2
;
1309 xfs_warn(mp
, "%s mount option is deprecated.", param
->key
);
1310 mp
->m_flags
&= ~XFS_MOUNT_ATTR2
;
1311 mp
->m_flags
|= XFS_MOUNT_NOATTR2
;
1314 xfs_warn(mp
, "unknown mount option [%s].", param
->key
);
1322 xfs_fs_validate_params(
1323 struct xfs_mount
*mp
)
1326 * no recovery flag requires a read-only mount
1328 if ((mp
->m_flags
& XFS_MOUNT_NORECOVERY
) &&
1329 !(mp
->m_flags
& XFS_MOUNT_RDONLY
)) {
1330 xfs_warn(mp
, "no-recovery mounts must be read-only.");
1334 if ((mp
->m_flags
& XFS_MOUNT_NOALIGN
) &&
1335 (mp
->m_dalign
|| mp
->m_swidth
)) {
1337 "sunit and swidth options incompatible with the noalign option");
1341 if (!IS_ENABLED(CONFIG_XFS_QUOTA
) && mp
->m_qflags
!= 0) {
1342 xfs_warn(mp
, "quota support not available in this kernel.");
1346 if ((mp
->m_dalign
&& !mp
->m_swidth
) ||
1347 (!mp
->m_dalign
&& mp
->m_swidth
)) {
1348 xfs_warn(mp
, "sunit and swidth must be specified together");
1352 if (mp
->m_dalign
&& (mp
->m_swidth
% mp
->m_dalign
!= 0)) {
1354 "stripe width (%d) must be a multiple of the stripe unit (%d)",
1355 mp
->m_swidth
, mp
->m_dalign
);
1359 if (mp
->m_logbufs
!= -1 &&
1360 mp
->m_logbufs
!= 0 &&
1361 (mp
->m_logbufs
< XLOG_MIN_ICLOGS
||
1362 mp
->m_logbufs
> XLOG_MAX_ICLOGS
)) {
1363 xfs_warn(mp
, "invalid logbufs value: %d [not %d-%d]",
1364 mp
->m_logbufs
, XLOG_MIN_ICLOGS
, XLOG_MAX_ICLOGS
);
1368 if (mp
->m_logbsize
!= -1 &&
1369 mp
->m_logbsize
!= 0 &&
1370 (mp
->m_logbsize
< XLOG_MIN_RECORD_BSIZE
||
1371 mp
->m_logbsize
> XLOG_MAX_RECORD_BSIZE
||
1372 !is_power_of_2(mp
->m_logbsize
))) {
1374 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
1379 if ((mp
->m_flags
& XFS_MOUNT_ALLOCSIZE
) &&
1380 (mp
->m_allocsize_log
> XFS_MAX_IO_LOG
||
1381 mp
->m_allocsize_log
< XFS_MIN_IO_LOG
)) {
1382 xfs_warn(mp
, "invalid log iosize: %d [not %d-%d]",
1383 mp
->m_allocsize_log
, XFS_MIN_IO_LOG
, XFS_MAX_IO_LOG
);
1392 struct super_block
*sb
,
1393 struct fs_context
*fc
)
1395 struct xfs_mount
*mp
= sb
->s_fs_info
;
1397 int flags
= 0, error
;
1401 error
= xfs_fs_validate_params(mp
);
1403 goto out_free_names
;
1405 sb_min_blocksize(sb
, BBSIZE
);
1406 sb
->s_xattr
= xfs_xattr_handlers
;
1407 sb
->s_export_op
= &xfs_export_operations
;
1408 #ifdef CONFIG_XFS_QUOTA
1409 sb
->s_qcop
= &xfs_quotactl_operations
;
1410 sb
->s_quota_types
= QTYPE_MASK_USR
| QTYPE_MASK_GRP
| QTYPE_MASK_PRJ
;
1412 sb
->s_op
= &xfs_super_operations
;
1415 * Delay mount work if the debug hook is set. This is debug
1416 * instrumention to coordinate simulation of xfs mount failures with
1417 * VFS superblock operations
1419 if (xfs_globals
.mount_delay
) {
1420 xfs_notice(mp
, "Delaying mount for %d seconds.",
1421 xfs_globals
.mount_delay
);
1422 msleep(xfs_globals
.mount_delay
* 1000);
1425 if (fc
->sb_flags
& SB_SILENT
)
1426 flags
|= XFS_MFSI_QUIET
;
1428 error
= xfs_open_devices(mp
);
1430 goto out_free_names
;
1432 error
= xfs_init_mount_workqueues(mp
);
1434 goto out_close_devices
;
1436 error
= xfs_init_percpu_counters(mp
);
1438 goto out_destroy_workqueues
;
1440 /* Allocate stats memory before we do operations that might use it */
1441 mp
->m_stats
.xs_stats
= alloc_percpu(struct xfsstats
);
1442 if (!mp
->m_stats
.xs_stats
) {
1444 goto out_destroy_counters
;
1447 error
= xfs_readsb(mp
, flags
);
1449 goto out_free_stats
;
1451 error
= xfs_finish_flags(mp
);
1455 error
= xfs_setup_devices(mp
);
1459 /* V4 support is undergoing deprecation. */
1460 if (!xfs_sb_version_hascrc(&mp
->m_sb
)) {
1461 #ifdef CONFIG_XFS_SUPPORT_V4
1463 "Deprecated V4 format (crc=0) will not be supported after September 2030.");
1466 "Deprecated V4 format (crc=0) not supported by kernel.");
1472 /* Filesystem claims it needs repair, so refuse the mount. */
1473 if (xfs_sb_version_needsrepair(&mp
->m_sb
)) {
1474 xfs_warn(mp
, "Filesystem needs repair. Please run xfs_repair.");
1475 error
= -EFSCORRUPTED
;
1480 * Don't touch the filesystem if a user tool thinks it owns the primary
1481 * superblock. mkfs doesn't clear the flag from secondary supers, so
1482 * we don't check them at all.
1484 if (mp
->m_sb
.sb_inprogress
) {
1485 xfs_warn(mp
, "Offline file system operation in progress!");
1486 error
= -EFSCORRUPTED
;
1491 * Until this is fixed only page-sized or smaller data blocks work.
1493 if (mp
->m_sb
.sb_blocksize
> PAGE_SIZE
) {
1495 "File system with blocksize %d bytes. "
1496 "Only pagesize (%ld) or less will currently work.",
1497 mp
->m_sb
.sb_blocksize
, PAGE_SIZE
);
1502 /* Ensure this filesystem fits in the page cache limits */
1503 if (xfs_sb_validate_fsb_count(&mp
->m_sb
, mp
->m_sb
.sb_dblocks
) ||
1504 xfs_sb_validate_fsb_count(&mp
->m_sb
, mp
->m_sb
.sb_rblocks
)) {
1506 "file system too large to be mounted on this system.");
1512 * XFS block mappings use 54 bits to store the logical block offset.
1513 * This should suffice to handle the maximum file size that the VFS
1514 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT
1515 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes
1516 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON
1517 * to check this assertion.
1519 * Avoid integer overflow by comparing the maximum bmbt offset to the
1520 * maximum pagecache offset in units of fs blocks.
1522 if (!xfs_verify_fileoff(mp
, XFS_B_TO_FSBT(mp
, MAX_LFS_FILESIZE
))) {
1524 "MAX_LFS_FILESIZE block offset (%llu) exceeds extent map maximum (%llu)!",
1525 XFS_B_TO_FSBT(mp
, MAX_LFS_FILESIZE
),
1531 error
= xfs_filestream_mount(mp
);
1536 * we must configure the block size in the superblock before we run the
1537 * full mount process as the mount process can lookup and cache inodes.
1539 sb
->s_magic
= XFS_SUPER_MAGIC
;
1540 sb
->s_blocksize
= mp
->m_sb
.sb_blocksize
;
1541 sb
->s_blocksize_bits
= ffs(sb
->s_blocksize
) - 1;
1542 sb
->s_maxbytes
= MAX_LFS_FILESIZE
;
1543 sb
->s_max_links
= XFS_MAXLINK
;
1544 sb
->s_time_gran
= 1;
1545 if (xfs_sb_version_hasbigtime(&mp
->m_sb
)) {
1546 sb
->s_time_min
= xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN
);
1547 sb
->s_time_max
= xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX
);
1549 sb
->s_time_min
= XFS_LEGACY_TIME_MIN
;
1550 sb
->s_time_max
= XFS_LEGACY_TIME_MAX
;
1552 trace_xfs_inode_timestamp_range(mp
, sb
->s_time_min
, sb
->s_time_max
);
1553 sb
->s_iflags
|= SB_I_CGROUPWB
;
1555 set_posix_acl_flag(sb
);
1557 /* version 5 superblocks support inode version counters. */
1558 if (XFS_SB_VERSION_NUM(&mp
->m_sb
) == XFS_SB_VERSION_5
)
1559 sb
->s_flags
|= SB_I_VERSION
;
1561 if (xfs_sb_version_hasbigtime(&mp
->m_sb
))
1563 "EXPERIMENTAL big timestamp feature in use. Use at your own risk!");
1565 if (mp
->m_flags
& XFS_MOUNT_DAX_ALWAYS
) {
1566 bool rtdev_is_dax
= false, datadev_is_dax
;
1569 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
1571 datadev_is_dax
= bdev_dax_supported(mp
->m_ddev_targp
->bt_bdev
,
1573 if (mp
->m_rtdev_targp
)
1574 rtdev_is_dax
= bdev_dax_supported(
1575 mp
->m_rtdev_targp
->bt_bdev
, sb
->s_blocksize
);
1576 if (!rtdev_is_dax
&& !datadev_is_dax
) {
1578 "DAX unsupported by block device. Turning off DAX.");
1579 xfs_mount_set_dax_mode(mp
, XFS_DAX_NEVER
);
1581 if (xfs_sb_version_hasreflink(&mp
->m_sb
)) {
1583 "DAX and reflink cannot be used together!");
1585 goto out_filestream_unmount
;
1589 if (mp
->m_flags
& XFS_MOUNT_DISCARD
) {
1590 struct request_queue
*q
= bdev_get_queue(sb
->s_bdev
);
1592 if (!blk_queue_discard(q
)) {
1593 xfs_warn(mp
, "mounting with \"discard\" option, but "
1594 "the device does not support discard");
1595 mp
->m_flags
&= ~XFS_MOUNT_DISCARD
;
1599 if (xfs_sb_version_hasreflink(&mp
->m_sb
)) {
1600 if (mp
->m_sb
.sb_rblocks
) {
1602 "reflink not compatible with realtime device!");
1604 goto out_filestream_unmount
;
1607 if (xfs_globals
.always_cow
) {
1608 xfs_info(mp
, "using DEBUG-only always_cow mode.");
1609 mp
->m_always_cow
= true;
1613 if (xfs_sb_version_hasrmapbt(&mp
->m_sb
) && mp
->m_sb
.sb_rblocks
) {
1615 "reverse mapping btree not compatible with realtime device!");
1617 goto out_filestream_unmount
;
1620 if (xfs_sb_version_hasinobtcounts(&mp
->m_sb
))
1622 "EXPERIMENTAL inode btree counters feature in use. Use at your own risk!");
1624 error
= xfs_mountfs(mp
);
1626 goto out_filestream_unmount
;
1628 root
= igrab(VFS_I(mp
->m_rootip
));
1633 sb
->s_root
= d_make_root(root
);
1641 out_filestream_unmount
:
1642 xfs_filestream_unmount(mp
);
1646 free_percpu(mp
->m_stats
.xs_stats
);
1647 out_destroy_counters
:
1648 xfs_destroy_percpu_counters(mp
);
1649 out_destroy_workqueues
:
1650 xfs_destroy_mount_workqueues(mp
);
1652 xfs_close_devices(mp
);
1654 sb
->s_fs_info
= NULL
;
1659 xfs_filestream_unmount(mp
);
1666 struct fs_context
*fc
)
1668 return get_tree_bdev(fc
, xfs_fs_fill_super
);
1673 struct xfs_mount
*mp
)
1675 struct xfs_sb
*sbp
= &mp
->m_sb
;
1678 if (mp
->m_flags
& XFS_MOUNT_NORECOVERY
) {
1680 "ro->rw transition prohibited on norecovery mount");
1684 if (XFS_SB_VERSION_NUM(sbp
) == XFS_SB_VERSION_5
&&
1685 xfs_sb_has_ro_compat_feature(sbp
, XFS_SB_FEAT_RO_COMPAT_UNKNOWN
)) {
1687 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
1688 (sbp
->sb_features_ro_compat
&
1689 XFS_SB_FEAT_RO_COMPAT_UNKNOWN
));
1693 mp
->m_flags
&= ~XFS_MOUNT_RDONLY
;
1696 * If this is the first remount to writeable state we might have some
1697 * superblock changes to update.
1699 if (mp
->m_update_sb
) {
1700 error
= xfs_sync_sb(mp
, false);
1702 xfs_warn(mp
, "failed to write sb changes");
1705 mp
->m_update_sb
= false;
1709 * Fill out the reserve pool if it is empty. Use the stashed value if
1710 * it is non-zero, otherwise go with the default.
1712 xfs_restore_resvblks(mp
);
1713 xfs_log_work_queue(mp
);
1715 /* Recover any CoW blocks that never got remapped. */
1716 error
= xfs_reflink_recover_cow(mp
);
1719 "Error %d recovering leftover CoW allocations.", error
);
1720 xfs_force_shutdown(mp
, SHUTDOWN_CORRUPT_INCORE
);
1723 xfs_start_block_reaping(mp
);
1725 /* Create the per-AG metadata reservation pool .*/
1726 error
= xfs_fs_reserve_ag_blocks(mp
);
1727 if (error
&& error
!= -ENOSPC
)
1735 struct xfs_mount
*mp
)
1740 * Cancel background eofb scanning so it cannot race with the final
1741 * log force+buftarg wait and deadlock the remount.
1743 xfs_stop_block_reaping(mp
);
1745 /* Get rid of any leftover CoW reservations... */
1746 error
= xfs_icache_free_cowblocks(mp
, NULL
);
1748 xfs_force_shutdown(mp
, SHUTDOWN_CORRUPT_INCORE
);
1752 /* Free the per-AG metadata reservation pool. */
1753 error
= xfs_fs_unreserve_ag_blocks(mp
);
1755 xfs_force_shutdown(mp
, SHUTDOWN_CORRUPT_INCORE
);
1760 * Before we sync the metadata, we need to free up the reserve block
1761 * pool so that the used block count in the superblock on disk is
1762 * correct at the end of the remount. Stash the current* reserve pool
1763 * size so that if we get remounted rw, we can return it to the same
1766 xfs_save_resvblks(mp
);
1768 xfs_quiesce_attr(mp
);
1769 mp
->m_flags
|= XFS_MOUNT_RDONLY
;
1775 * Logically we would return an error here to prevent users from believing
1776 * they might have changed mount options using remount which can't be changed.
1778 * But unfortunately mount(8) adds all options from mtab and fstab to the mount
1779 * arguments in some cases so we can't blindly reject options, but have to
1780 * check for each specified option if it actually differs from the currently
1781 * set option and only reject it if that's the case.
1783 * Until that is implemented we return success for every remount request, and
1784 * silently ignore all options that we can't actually change.
1788 struct fs_context
*fc
)
1790 struct xfs_mount
*mp
= XFS_M(fc
->root
->d_sb
);
1791 struct xfs_mount
*new_mp
= fc
->s_fs_info
;
1792 xfs_sb_t
*sbp
= &mp
->m_sb
;
1793 int flags
= fc
->sb_flags
;
1796 /* version 5 superblocks always support version counters. */
1797 if (XFS_SB_VERSION_NUM(&mp
->m_sb
) == XFS_SB_VERSION_5
)
1798 fc
->sb_flags
|= SB_I_VERSION
;
1800 error
= xfs_fs_validate_params(new_mp
);
1804 sync_filesystem(mp
->m_super
);
1806 /* inode32 -> inode64 */
1807 if ((mp
->m_flags
& XFS_MOUNT_SMALL_INUMS
) &&
1808 !(new_mp
->m_flags
& XFS_MOUNT_SMALL_INUMS
)) {
1809 mp
->m_flags
&= ~XFS_MOUNT_SMALL_INUMS
;
1810 mp
->m_maxagi
= xfs_set_inode_alloc(mp
, sbp
->sb_agcount
);
1813 /* inode64 -> inode32 */
1814 if (!(mp
->m_flags
& XFS_MOUNT_SMALL_INUMS
) &&
1815 (new_mp
->m_flags
& XFS_MOUNT_SMALL_INUMS
)) {
1816 mp
->m_flags
|= XFS_MOUNT_SMALL_INUMS
;
1817 mp
->m_maxagi
= xfs_set_inode_alloc(mp
, sbp
->sb_agcount
);
1821 if ((mp
->m_flags
& XFS_MOUNT_RDONLY
) && !(flags
& SB_RDONLY
)) {
1822 error
= xfs_remount_rw(mp
);
1828 if (!(mp
->m_flags
& XFS_MOUNT_RDONLY
) && (flags
& SB_RDONLY
)) {
1829 error
= xfs_remount_ro(mp
);
1837 static void xfs_fs_free(
1838 struct fs_context
*fc
)
1840 struct xfs_mount
*mp
= fc
->s_fs_info
;
1843 * mp is stored in the fs_context when it is initialized.
1844 * mp is transferred to the superblock on a successful mount,
1845 * but if an error occurs before the transfer we have to free
1852 static const struct fs_context_operations xfs_context_ops
= {
1853 .parse_param
= xfs_fs_parse_param
,
1854 .get_tree
= xfs_fs_get_tree
,
1855 .reconfigure
= xfs_fs_reconfigure
,
1856 .free
= xfs_fs_free
,
1859 static int xfs_init_fs_context(
1860 struct fs_context
*fc
)
1862 struct xfs_mount
*mp
;
1864 mp
= kmem_alloc(sizeof(struct xfs_mount
), KM_ZERO
);
1868 spin_lock_init(&mp
->m_sb_lock
);
1869 spin_lock_init(&mp
->m_agirotor_lock
);
1870 INIT_RADIX_TREE(&mp
->m_perag_tree
, GFP_ATOMIC
);
1871 spin_lock_init(&mp
->m_perag_lock
);
1872 mutex_init(&mp
->m_growlock
);
1873 INIT_WORK(&mp
->m_flush_inodes_work
, xfs_flush_inodes_worker
);
1874 INIT_DELAYED_WORK(&mp
->m_reclaim_work
, xfs_reclaim_worker
);
1875 INIT_DELAYED_WORK(&mp
->m_eofblocks_work
, xfs_eofblocks_worker
);
1876 INIT_DELAYED_WORK(&mp
->m_cowblocks_work
, xfs_cowblocks_worker
);
1877 mp
->m_kobj
.kobject
.kset
= xfs_kset
;
1879 * We don't create the finobt per-ag space reservation until after log
1880 * recovery, so we must set this to true so that an ifree transaction
1881 * started during log recovery will not depend on space reservations
1882 * for finobt expansion.
1884 mp
->m_finobt_nores
= true;
1887 * These can be overridden by the mount option parsing.
1890 mp
->m_logbsize
= -1;
1891 mp
->m_allocsize_log
= 16; /* 64k */
1894 * Copy binary VFS mount flags we are interested in.
1896 if (fc
->sb_flags
& SB_RDONLY
)
1897 mp
->m_flags
|= XFS_MOUNT_RDONLY
;
1898 if (fc
->sb_flags
& SB_DIRSYNC
)
1899 mp
->m_flags
|= XFS_MOUNT_DIRSYNC
;
1900 if (fc
->sb_flags
& SB_SYNCHRONOUS
)
1901 mp
->m_flags
|= XFS_MOUNT_WSYNC
;
1904 fc
->ops
= &xfs_context_ops
;
1909 static struct file_system_type xfs_fs_type
= {
1910 .owner
= THIS_MODULE
,
1912 .init_fs_context
= xfs_init_fs_context
,
1913 .parameters
= xfs_fs_parameters
,
1914 .kill_sb
= kill_block_super
,
1915 .fs_flags
= FS_REQUIRES_DEV
,
1917 MODULE_ALIAS_FS("xfs");
1920 xfs_init_zones(void)
1922 xfs_log_ticket_zone
= kmem_cache_create("xfs_log_ticket",
1923 sizeof(struct xlog_ticket
),
1925 if (!xfs_log_ticket_zone
)
1928 xfs_bmap_free_item_zone
= kmem_cache_create("xfs_bmap_free_item",
1929 sizeof(struct xfs_extent_free_item
),
1931 if (!xfs_bmap_free_item_zone
)
1932 goto out_destroy_log_ticket_zone
;
1934 xfs_btree_cur_zone
= kmem_cache_create("xfs_btree_cur",
1935 sizeof(struct xfs_btree_cur
),
1937 if (!xfs_btree_cur_zone
)
1938 goto out_destroy_bmap_free_item_zone
;
1940 xfs_da_state_zone
= kmem_cache_create("xfs_da_state",
1941 sizeof(struct xfs_da_state
),
1943 if (!xfs_da_state_zone
)
1944 goto out_destroy_btree_cur_zone
;
1946 xfs_ifork_zone
= kmem_cache_create("xfs_ifork",
1947 sizeof(struct xfs_ifork
),
1949 if (!xfs_ifork_zone
)
1950 goto out_destroy_da_state_zone
;
1952 xfs_trans_zone
= kmem_cache_create("xf_trans",
1953 sizeof(struct xfs_trans
),
1955 if (!xfs_trans_zone
)
1956 goto out_destroy_ifork_zone
;
1960 * The size of the zone allocated buf log item is the maximum
1961 * size possible under XFS. This wastes a little bit of memory,
1962 * but it is much faster.
1964 xfs_buf_item_zone
= kmem_cache_create("xfs_buf_item",
1965 sizeof(struct xfs_buf_log_item
),
1967 if (!xfs_buf_item_zone
)
1968 goto out_destroy_trans_zone
;
1970 xfs_efd_zone
= kmem_cache_create("xfs_efd_item",
1971 (sizeof(struct xfs_efd_log_item
) +
1972 (XFS_EFD_MAX_FAST_EXTENTS
- 1) *
1973 sizeof(struct xfs_extent
)),
1976 goto out_destroy_buf_item_zone
;
1978 xfs_efi_zone
= kmem_cache_create("xfs_efi_item",
1979 (sizeof(struct xfs_efi_log_item
) +
1980 (XFS_EFI_MAX_FAST_EXTENTS
- 1) *
1981 sizeof(struct xfs_extent
)),
1984 goto out_destroy_efd_zone
;
1986 xfs_inode_zone
= kmem_cache_create("xfs_inode",
1987 sizeof(struct xfs_inode
), 0,
1988 (SLAB_HWCACHE_ALIGN
|
1989 SLAB_RECLAIM_ACCOUNT
|
1990 SLAB_MEM_SPREAD
| SLAB_ACCOUNT
),
1991 xfs_fs_inode_init_once
);
1992 if (!xfs_inode_zone
)
1993 goto out_destroy_efi_zone
;
1995 xfs_ili_zone
= kmem_cache_create("xfs_ili",
1996 sizeof(struct xfs_inode_log_item
), 0,
1997 SLAB_RECLAIM_ACCOUNT
| SLAB_MEM_SPREAD
,
2000 goto out_destroy_inode_zone
;
2002 xfs_icreate_zone
= kmem_cache_create("xfs_icr",
2003 sizeof(struct xfs_icreate_item
),
2005 if (!xfs_icreate_zone
)
2006 goto out_destroy_ili_zone
;
2008 xfs_rud_zone
= kmem_cache_create("xfs_rud_item",
2009 sizeof(struct xfs_rud_log_item
),
2012 goto out_destroy_icreate_zone
;
2014 xfs_rui_zone
= kmem_cache_create("xfs_rui_item",
2015 xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS
),
2018 goto out_destroy_rud_zone
;
2020 xfs_cud_zone
= kmem_cache_create("xfs_cud_item",
2021 sizeof(struct xfs_cud_log_item
),
2024 goto out_destroy_rui_zone
;
2026 xfs_cui_zone
= kmem_cache_create("xfs_cui_item",
2027 xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS
),
2030 goto out_destroy_cud_zone
;
2032 xfs_bud_zone
= kmem_cache_create("xfs_bud_item",
2033 sizeof(struct xfs_bud_log_item
),
2036 goto out_destroy_cui_zone
;
2038 xfs_bui_zone
= kmem_cache_create("xfs_bui_item",
2039 xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS
),
2042 goto out_destroy_bud_zone
;
2046 out_destroy_bud_zone
:
2047 kmem_cache_destroy(xfs_bud_zone
);
2048 out_destroy_cui_zone
:
2049 kmem_cache_destroy(xfs_cui_zone
);
2050 out_destroy_cud_zone
:
2051 kmem_cache_destroy(xfs_cud_zone
);
2052 out_destroy_rui_zone
:
2053 kmem_cache_destroy(xfs_rui_zone
);
2054 out_destroy_rud_zone
:
2055 kmem_cache_destroy(xfs_rud_zone
);
2056 out_destroy_icreate_zone
:
2057 kmem_cache_destroy(xfs_icreate_zone
);
2058 out_destroy_ili_zone
:
2059 kmem_cache_destroy(xfs_ili_zone
);
2060 out_destroy_inode_zone
:
2061 kmem_cache_destroy(xfs_inode_zone
);
2062 out_destroy_efi_zone
:
2063 kmem_cache_destroy(xfs_efi_zone
);
2064 out_destroy_efd_zone
:
2065 kmem_cache_destroy(xfs_efd_zone
);
2066 out_destroy_buf_item_zone
:
2067 kmem_cache_destroy(xfs_buf_item_zone
);
2068 out_destroy_trans_zone
:
2069 kmem_cache_destroy(xfs_trans_zone
);
2070 out_destroy_ifork_zone
:
2071 kmem_cache_destroy(xfs_ifork_zone
);
2072 out_destroy_da_state_zone
:
2073 kmem_cache_destroy(xfs_da_state_zone
);
2074 out_destroy_btree_cur_zone
:
2075 kmem_cache_destroy(xfs_btree_cur_zone
);
2076 out_destroy_bmap_free_item_zone
:
2077 kmem_cache_destroy(xfs_bmap_free_item_zone
);
2078 out_destroy_log_ticket_zone
:
2079 kmem_cache_destroy(xfs_log_ticket_zone
);
2085 xfs_destroy_zones(void)
2088 * Make sure all delayed rcu free are flushed before we
2092 kmem_cache_destroy(xfs_bui_zone
);
2093 kmem_cache_destroy(xfs_bud_zone
);
2094 kmem_cache_destroy(xfs_cui_zone
);
2095 kmem_cache_destroy(xfs_cud_zone
);
2096 kmem_cache_destroy(xfs_rui_zone
);
2097 kmem_cache_destroy(xfs_rud_zone
);
2098 kmem_cache_destroy(xfs_icreate_zone
);
2099 kmem_cache_destroy(xfs_ili_zone
);
2100 kmem_cache_destroy(xfs_inode_zone
);
2101 kmem_cache_destroy(xfs_efi_zone
);
2102 kmem_cache_destroy(xfs_efd_zone
);
2103 kmem_cache_destroy(xfs_buf_item_zone
);
2104 kmem_cache_destroy(xfs_trans_zone
);
2105 kmem_cache_destroy(xfs_ifork_zone
);
2106 kmem_cache_destroy(xfs_da_state_zone
);
2107 kmem_cache_destroy(xfs_btree_cur_zone
);
2108 kmem_cache_destroy(xfs_bmap_free_item_zone
);
2109 kmem_cache_destroy(xfs_log_ticket_zone
);
2113 xfs_init_workqueues(void)
2116 * The allocation workqueue can be used in memory reclaim situations
2117 * (writepage path), and parallelism is only limited by the number of
2118 * AGs in all the filesystems mounted. Hence use the default large
2119 * max_active value for this workqueue.
2121 xfs_alloc_wq
= alloc_workqueue("xfsalloc",
2122 WQ_MEM_RECLAIM
|WQ_FREEZABLE
, 0);
2126 xfs_discard_wq
= alloc_workqueue("xfsdiscard", WQ_UNBOUND
, 0);
2127 if (!xfs_discard_wq
)
2128 goto out_free_alloc_wq
;
2132 destroy_workqueue(xfs_alloc_wq
);
2137 xfs_destroy_workqueues(void)
2139 destroy_workqueue(xfs_discard_wq
);
2140 destroy_workqueue(xfs_alloc_wq
);
2148 xfs_check_ondisk_structs();
2150 printk(KERN_INFO XFS_VERSION_STRING
" with "
2151 XFS_BUILD_OPTIONS
" enabled\n");
2155 error
= xfs_init_zones();
2159 error
= xfs_init_workqueues();
2161 goto out_destroy_zones
;
2163 error
= xfs_mru_cache_init();
2165 goto out_destroy_wq
;
2167 error
= xfs_buf_init();
2169 goto out_mru_cache_uninit
;
2171 error
= xfs_init_procfs();
2173 goto out_buf_terminate
;
2175 error
= xfs_sysctl_register();
2177 goto out_cleanup_procfs
;
2179 xfs_kset
= kset_create_and_add("xfs", NULL
, fs_kobj
);
2182 goto out_sysctl_unregister
;
2185 xfsstats
.xs_kobj
.kobject
.kset
= xfs_kset
;
2187 xfsstats
.xs_stats
= alloc_percpu(struct xfsstats
);
2188 if (!xfsstats
.xs_stats
) {
2190 goto out_kset_unregister
;
2193 error
= xfs_sysfs_init(&xfsstats
.xs_kobj
, &xfs_stats_ktype
, NULL
,
2196 goto out_free_stats
;
2199 xfs_dbg_kobj
.kobject
.kset
= xfs_kset
;
2200 error
= xfs_sysfs_init(&xfs_dbg_kobj
, &xfs_dbg_ktype
, NULL
, "debug");
2202 goto out_remove_stats_kobj
;
2205 error
= xfs_qm_init();
2207 goto out_remove_dbg_kobj
;
2209 error
= register_filesystem(&xfs_fs_type
);
2216 out_remove_dbg_kobj
:
2218 xfs_sysfs_del(&xfs_dbg_kobj
);
2219 out_remove_stats_kobj
:
2221 xfs_sysfs_del(&xfsstats
.xs_kobj
);
2223 free_percpu(xfsstats
.xs_stats
);
2224 out_kset_unregister
:
2225 kset_unregister(xfs_kset
);
2226 out_sysctl_unregister
:
2227 xfs_sysctl_unregister();
2229 xfs_cleanup_procfs();
2231 xfs_buf_terminate();
2232 out_mru_cache_uninit
:
2233 xfs_mru_cache_uninit();
2235 xfs_destroy_workqueues();
2237 xfs_destroy_zones();
2246 unregister_filesystem(&xfs_fs_type
);
2248 xfs_sysfs_del(&xfs_dbg_kobj
);
2250 xfs_sysfs_del(&xfsstats
.xs_kobj
);
2251 free_percpu(xfsstats
.xs_stats
);
2252 kset_unregister(xfs_kset
);
2253 xfs_sysctl_unregister();
2254 xfs_cleanup_procfs();
2255 xfs_buf_terminate();
2256 xfs_mru_cache_uninit();
2257 xfs_destroy_workqueues();
2258 xfs_destroy_zones();
2259 xfs_uuid_table_free();
2262 module_init(init_xfs_fs
);
2263 module_exit(exit_xfs_fs
);
2265 MODULE_AUTHOR("Silicon Graphics, Inc.");
2266 MODULE_DESCRIPTION(XFS_VERSION_STRING
" with " XFS_BUILD_OPTIONS
" enabled");
2267 MODULE_LICENSE("GPL");