xfs: document the invalidate_bdev call in invalidate_bdev
[platform/kernel/linux-rpi.git] / fs / xfs / xfs_super.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6
7 #include "xfs.h"
8 #include "xfs_shared.h"
9 #include "xfs_format.h"
10 #include "xfs_log_format.h"
11 #include "xfs_trans_resv.h"
12 #include "xfs_sb.h"
13 #include "xfs_mount.h"
14 #include "xfs_inode.h"
15 #include "xfs_btree.h"
16 #include "xfs_bmap.h"
17 #include "xfs_alloc.h"
18 #include "xfs_fsops.h"
19 #include "xfs_trans.h"
20 #include "xfs_buf_item.h"
21 #include "xfs_log.h"
22 #include "xfs_log_priv.h"
23 #include "xfs_dir2.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"
39 #include "xfs_ag.h"
40 #include "xfs_defer.h"
41 #include "xfs_attr_item.h"
42 #include "xfs_xattr.h"
43 #include "xfs_iunlink_item.h"
44 #include "xfs_dahash_test.h"
45
46 #include <linux/magic.h>
47 #include <linux/fs_context.h>
48 #include <linux/fs_parser.h>
49
50 static const struct super_operations xfs_super_operations;
51
52 static struct kset *xfs_kset;           /* top-level xfs sysfs dir */
53 #ifdef DEBUG
54 static struct xfs_kobj xfs_dbg_kobj;    /* global debug sysfs attrs */
55 #endif
56
57 #ifdef CONFIG_HOTPLUG_CPU
58 static LIST_HEAD(xfs_mount_list);
59 static DEFINE_SPINLOCK(xfs_mount_list_lock);
60
61 static inline void xfs_mount_list_add(struct xfs_mount *mp)
62 {
63         spin_lock(&xfs_mount_list_lock);
64         list_add(&mp->m_mount_list, &xfs_mount_list);
65         spin_unlock(&xfs_mount_list_lock);
66 }
67
68 static inline void xfs_mount_list_del(struct xfs_mount *mp)
69 {
70         spin_lock(&xfs_mount_list_lock);
71         list_del(&mp->m_mount_list);
72         spin_unlock(&xfs_mount_list_lock);
73 }
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) {}
77 #endif
78
79 enum xfs_dax_mode {
80         XFS_DAX_INODE = 0,
81         XFS_DAX_ALWAYS = 1,
82         XFS_DAX_NEVER = 2,
83 };
84
85 static void
86 xfs_mount_set_dax_mode(
87         struct xfs_mount        *mp,
88         enum xfs_dax_mode       mode)
89 {
90         switch (mode) {
91         case XFS_DAX_INODE:
92                 mp->m_features &= ~(XFS_FEAT_DAX_ALWAYS | XFS_FEAT_DAX_NEVER);
93                 break;
94         case XFS_DAX_ALWAYS:
95                 mp->m_features |= XFS_FEAT_DAX_ALWAYS;
96                 mp->m_features &= ~XFS_FEAT_DAX_NEVER;
97                 break;
98         case XFS_DAX_NEVER:
99                 mp->m_features |= XFS_FEAT_DAX_NEVER;
100                 mp->m_features &= ~XFS_FEAT_DAX_ALWAYS;
101                 break;
102         }
103 }
104
105 static const struct constant_table dax_param_enums[] = {
106         {"inode",       XFS_DAX_INODE },
107         {"always",      XFS_DAX_ALWAYS },
108         {"never",       XFS_DAX_NEVER },
109         {}
110 };
111
112 /*
113  * Table driven mount option parser.
114  */
115 enum {
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,
125 };
126
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),
169         {}
170 };
171
172 struct proc_xfs_info {
173         uint64_t        flag;
174         char            *str;
175 };
176
177 static int
178 xfs_fs_show_options(
179         struct seq_file         *m,
180         struct dentry           *root)
181 {
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" },
197                 { 0, NULL }
198         };
199         struct xfs_mount        *mp = XFS_M(root->d_sb);
200         struct proc_xfs_info    *xfs_infop;
201
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);
205         }
206
207         seq_printf(m, ",inode%d", xfs_has_small_inums(mp) ? 32 : 64);
208
209         if (xfs_has_allocsize(mp))
210                 seq_printf(m, ",allocsize=%dk",
211                            (1 << mp->m_allocsize_log) >> 10);
212
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);
217
218         if (mp->m_logname)
219                 seq_show_option(m, "logdev", mp->m_logname);
220         if (mp->m_rtname)
221                 seq_show_option(m, "rtdev", mp->m_rtname);
222
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));
229
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");
234
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");
239
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");
244
245         if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
246                 seq_puts(m, ",noquota");
247
248         return 0;
249 }
250
251 static bool
252 xfs_set_inode_alloc_perag(
253         struct xfs_perag        *pag,
254         xfs_ino_t               ino,
255         xfs_agnumber_t          max_metadata)
256 {
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);
260                 return false;
261         }
262
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);
266                 return false;
267         }
268
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);
272         else
273                 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate);
274         return true;
275 }
276
277 /*
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.
281  *
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.
285  *
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.
289  *
290  * Returns the maximum AG index which may contain inodes.
291  */
292 xfs_agnumber_t
293 xfs_set_inode_alloc(
294         struct xfs_mount *mp,
295         xfs_agnumber_t  agcount)
296 {
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;
301         xfs_agino_t     agino;
302         xfs_ino_t       ino;
303
304         /*
305          * Calculate how much should be reserved for inodes to meet
306          * the max inode percentage.  Used only for inode32.
307          */
308         if (M_IGEO(mp)->maxicount) {
309                 uint64_t        icount;
310
311                 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
312                 do_div(icount, 100);
313                 icount += sbp->sb_agblocks - 1;
314                 do_div(icount, sbp->sb_agblocks);
315                 max_metadata = icount;
316         } else {
317                 max_metadata = agcount;
318         }
319
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);
323
324         /*
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.
328          */
329         if (xfs_has_small_inums(mp) && ino > XFS_MAXINUMBER_32)
330                 set_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
331         else
332                 clear_bit(XFS_OPSTATE_INODE32, &mp->m_opstate);
333
334         for (index = 0; index < agcount; index++) {
335                 struct xfs_perag        *pag;
336
337                 ino = XFS_AGINO_TO_INO(mp, index, agino);
338
339                 pag = xfs_perag_get(mp, index);
340                 if (xfs_set_inode_alloc_perag(pag, ino, max_metadata))
341                         maxagi++;
342                 xfs_perag_put(pag);
343         }
344
345         return xfs_is_inode32(mp) ? maxagi : agcount;
346 }
347
348 static int
349 xfs_setup_dax_always(
350         struct xfs_mount        *mp)
351 {
352         if (!mp->m_ddev_targp->bt_daxdev &&
353             (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) {
354                 xfs_alert(mp,
355                         "DAX unsupported by block device. Turning off DAX.");
356                 goto disable_dax;
357         }
358
359         if (mp->m_super->s_blocksize != PAGE_SIZE) {
360                 xfs_alert(mp,
361                         "DAX not supported for blocksize. Turning off DAX.");
362                 goto disable_dax;
363         }
364
365         if (xfs_has_reflink(mp) &&
366             bdev_is_partition(mp->m_ddev_targp->bt_bdev)) {
367                 xfs_alert(mp,
368                         "DAX and reflink cannot work with multi-partitions!");
369                 return -EINVAL;
370         }
371
372         xfs_warn(mp, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
373         return 0;
374
375 disable_dax:
376         xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
377         return 0;
378 }
379
380 static void
381 xfs_bdev_mark_dead(
382         struct block_device     *bdev)
383 {
384         xfs_force_shutdown(bdev->bd_holder, SHUTDOWN_DEVICE_REMOVED);
385 }
386
387 static const struct blk_holder_ops xfs_holder_ops = {
388         .mark_dead              = xfs_bdev_mark_dead,
389 };
390
391 STATIC int
392 xfs_blkdev_get(
393         xfs_mount_t             *mp,
394         const char              *name,
395         struct block_device     **bdevp)
396 {
397         int                     error = 0;
398
399         *bdevp = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE, mp,
400                                     &xfs_holder_ops);
401         if (IS_ERR(*bdevp)) {
402                 error = PTR_ERR(*bdevp);
403                 xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
404         }
405
406         return error;
407 }
408
409 STATIC void
410 xfs_shutdown_devices(
411         struct xfs_mount        *mp)
412 {
413         /*
414          * Udev is triggered whenever anyone closes a block device or unmounts
415          * a file systemm on a block device.
416          * The default udev rules invoke blkid to read the fs super and create
417          * symlinks to the bdev under /dev/disk.  For this, it uses buffered
418          * reads through the page cache.
419          *
420          * xfs_db also uses buffered reads to examine metadata.  There is no
421          * coordination between xfs_db and udev, which means that they can run
422          * concurrently.  Note there is no coordination between the kernel and
423          * blkid either.
424          *
425          * On a system with 64k pages, the page cache can cache the superblock
426          * and the root inode (and hence the root directory) with the same 64k
427          * page.  If udev spawns blkid after the mkfs and the system is busy
428          * enough that it is still running when xfs_db starts up, they'll both
429          * read from the same page in the pagecache.
430          *
431          * The unmount writes updated inode metadata to disk directly.  The XFS
432          * buffer cache does not use the bdev pagecache, so it needs to
433          * invalidate that pagecache on unmount.  If the above scenario occurs,
434          * the pagecache no longer reflects what's on disk, xfs_db reads the
435          * stale metadata, and fails to find /a.  Most of the time this succeeds
436          * because closing a bdev invalidates the page cache, but when processes
437          * race, everyone loses.
438          */
439         if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
440                 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev);
441                 invalidate_bdev(mp->m_logdev_targp->bt_bdev);
442         }
443         if (mp->m_rtdev_targp) {
444                 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev);
445                 invalidate_bdev(mp->m_rtdev_targp->bt_bdev);
446         }
447         blkdev_issue_flush(mp->m_ddev_targp->bt_bdev);
448         invalidate_bdev(mp->m_ddev_targp->bt_bdev);
449 }
450
451 /*
452  * The file system configurations are:
453  *      (1) device (partition) with data and internal log
454  *      (2) logical volume with data and log subvolumes.
455  *      (3) logical volume with data, log, and realtime subvolumes.
456  *
457  * We only have to handle opening the log and realtime volumes here if
458  * they are present.  The data subvolume has already been opened by
459  * get_sb_bdev() and is stored in sb->s_bdev.
460  */
461 STATIC int
462 xfs_open_devices(
463         struct xfs_mount        *mp)
464 {
465         struct block_device     *ddev = mp->m_super->s_bdev;
466         struct block_device     *logdev = NULL, *rtdev = NULL;
467         int                     error;
468
469         /*
470          * Open real time and log devices - order is important.
471          */
472         if (mp->m_logname) {
473                 error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
474                 if (error)
475                         return error;
476         }
477
478         if (mp->m_rtname) {
479                 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev);
480                 if (error)
481                         goto out_close_logdev;
482
483                 if (rtdev == ddev || rtdev == logdev) {
484                         xfs_warn(mp,
485         "Cannot mount filesystem with identical rtdev and ddev/logdev.");
486                         error = -EINVAL;
487                         goto out_close_rtdev;
488                 }
489         }
490
491         /*
492          * Setup xfs_mount buffer target pointers
493          */
494         error = -ENOMEM;
495         mp->m_ddev_targp = xfs_alloc_buftarg(mp, ddev);
496         if (!mp->m_ddev_targp)
497                 goto out_close_rtdev;
498
499         if (rtdev) {
500                 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev);
501                 if (!mp->m_rtdev_targp)
502                         goto out_free_ddev_targ;
503         }
504
505         if (logdev && logdev != ddev) {
506                 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev);
507                 if (!mp->m_logdev_targp)
508                         goto out_free_rtdev_targ;
509         } else {
510                 mp->m_logdev_targp = mp->m_ddev_targp;
511         }
512
513         return 0;
514
515  out_free_rtdev_targ:
516         if (mp->m_rtdev_targp)
517                 xfs_free_buftarg(mp->m_rtdev_targp);
518  out_free_ddev_targ:
519         xfs_free_buftarg(mp->m_ddev_targp);
520  out_close_rtdev:
521          if (rtdev)
522                  blkdev_put(rtdev, mp);
523  out_close_logdev:
524         if (logdev && logdev != ddev)
525                 blkdev_put(logdev, mp);
526         return error;
527 }
528
529 /*
530  * Setup xfs_mount buffer target pointers based on superblock
531  */
532 STATIC int
533 xfs_setup_devices(
534         struct xfs_mount        *mp)
535 {
536         int                     error;
537
538         error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize);
539         if (error)
540                 return error;
541
542         if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
543                 unsigned int    log_sector_size = BBSIZE;
544
545                 if (xfs_has_sector(mp))
546                         log_sector_size = mp->m_sb.sb_logsectsize;
547                 error = xfs_setsize_buftarg(mp->m_logdev_targp,
548                                             log_sector_size);
549                 if (error)
550                         return error;
551         }
552         if (mp->m_rtdev_targp) {
553                 error = xfs_setsize_buftarg(mp->m_rtdev_targp,
554                                             mp->m_sb.sb_sectsize);
555                 if (error)
556                         return error;
557         }
558
559         return 0;
560 }
561
562 STATIC int
563 xfs_init_mount_workqueues(
564         struct xfs_mount        *mp)
565 {
566         mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
567                         XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
568                         1, mp->m_super->s_id);
569         if (!mp->m_buf_workqueue)
570                 goto out;
571
572         mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
573                         XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
574                         0, mp->m_super->s_id);
575         if (!mp->m_unwritten_workqueue)
576                 goto out_destroy_buf;
577
578         mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s",
579                         XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
580                         0, mp->m_super->s_id);
581         if (!mp->m_reclaim_workqueue)
582                 goto out_destroy_unwritten;
583
584         mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s",
585                         XFS_WQFLAGS(WQ_UNBOUND | WQ_FREEZABLE | WQ_MEM_RECLAIM),
586                         0, mp->m_super->s_id);
587         if (!mp->m_blockgc_wq)
588                 goto out_destroy_reclaim;
589
590         mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s",
591                         XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
592                         1, mp->m_super->s_id);
593         if (!mp->m_inodegc_wq)
594                 goto out_destroy_blockgc;
595
596         mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s",
597                         XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id);
598         if (!mp->m_sync_workqueue)
599                 goto out_destroy_inodegc;
600
601         return 0;
602
603 out_destroy_inodegc:
604         destroy_workqueue(mp->m_inodegc_wq);
605 out_destroy_blockgc:
606         destroy_workqueue(mp->m_blockgc_wq);
607 out_destroy_reclaim:
608         destroy_workqueue(mp->m_reclaim_workqueue);
609 out_destroy_unwritten:
610         destroy_workqueue(mp->m_unwritten_workqueue);
611 out_destroy_buf:
612         destroy_workqueue(mp->m_buf_workqueue);
613 out:
614         return -ENOMEM;
615 }
616
617 STATIC void
618 xfs_destroy_mount_workqueues(
619         struct xfs_mount        *mp)
620 {
621         destroy_workqueue(mp->m_sync_workqueue);
622         destroy_workqueue(mp->m_blockgc_wq);
623         destroy_workqueue(mp->m_inodegc_wq);
624         destroy_workqueue(mp->m_reclaim_workqueue);
625         destroy_workqueue(mp->m_unwritten_workqueue);
626         destroy_workqueue(mp->m_buf_workqueue);
627 }
628
629 static void
630 xfs_flush_inodes_worker(
631         struct work_struct      *work)
632 {
633         struct xfs_mount        *mp = container_of(work, struct xfs_mount,
634                                                    m_flush_inodes_work);
635         struct super_block      *sb = mp->m_super;
636
637         if (down_read_trylock(&sb->s_umount)) {
638                 sync_inodes_sb(sb);
639                 up_read(&sb->s_umount);
640         }
641 }
642
643 /*
644  * Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK
645  * or a page lock. We use sync_inodes_sb() here to ensure we block while waiting
646  * for IO to complete so that we effectively throttle multiple callers to the
647  * rate at which IO is completing.
648  */
649 void
650 xfs_flush_inodes(
651         struct xfs_mount        *mp)
652 {
653         /*
654          * If flush_work() returns true then that means we waited for a flush
655          * which was already in progress.  Don't bother running another scan.
656          */
657         if (flush_work(&mp->m_flush_inodes_work))
658                 return;
659
660         queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work);
661         flush_work(&mp->m_flush_inodes_work);
662 }
663
664 /* Catch misguided souls that try to use this interface on XFS */
665 STATIC struct inode *
666 xfs_fs_alloc_inode(
667         struct super_block      *sb)
668 {
669         BUG();
670         return NULL;
671 }
672
673 /*
674  * Now that the generic code is guaranteed not to be accessing
675  * the linux inode, we can inactivate and reclaim the inode.
676  */
677 STATIC void
678 xfs_fs_destroy_inode(
679         struct inode            *inode)
680 {
681         struct xfs_inode        *ip = XFS_I(inode);
682
683         trace_xfs_destroy_inode(ip);
684
685         ASSERT(!rwsem_is_locked(&inode->i_rwsem));
686         XFS_STATS_INC(ip->i_mount, vn_rele);
687         XFS_STATS_INC(ip->i_mount, vn_remove);
688         xfs_inode_mark_reclaimable(ip);
689 }
690
691 static void
692 xfs_fs_dirty_inode(
693         struct inode                    *inode,
694         int                             flags)
695 {
696         struct xfs_inode                *ip = XFS_I(inode);
697         struct xfs_mount                *mp = ip->i_mount;
698         struct xfs_trans                *tp;
699
700         if (!(inode->i_sb->s_flags & SB_LAZYTIME))
701                 return;
702
703         /*
704          * Only do the timestamp update if the inode is dirty (I_DIRTY_SYNC)
705          * and has dirty timestamp (I_DIRTY_TIME). I_DIRTY_TIME can be passed
706          * in flags possibly together with I_DIRTY_SYNC.
707          */
708         if ((flags & ~I_DIRTY_TIME) != I_DIRTY_SYNC || !(flags & I_DIRTY_TIME))
709                 return;
710
711         if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp))
712                 return;
713         xfs_ilock(ip, XFS_ILOCK_EXCL);
714         xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
715         xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
716         xfs_trans_commit(tp);
717 }
718
719 /*
720  * Slab object creation initialisation for the XFS inode.
721  * This covers only the idempotent fields in the XFS inode;
722  * all other fields need to be initialised on allocation
723  * from the slab. This avoids the need to repeatedly initialise
724  * fields in the xfs inode that left in the initialise state
725  * when freeing the inode.
726  */
727 STATIC void
728 xfs_fs_inode_init_once(
729         void                    *inode)
730 {
731         struct xfs_inode        *ip = inode;
732
733         memset(ip, 0, sizeof(struct xfs_inode));
734
735         /* vfs inode */
736         inode_init_once(VFS_I(ip));
737
738         /* xfs inode */
739         atomic_set(&ip->i_pincount, 0);
740         spin_lock_init(&ip->i_flags_lock);
741
742         mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
743                      "xfsino", ip->i_ino);
744 }
745
746 /*
747  * We do an unlocked check for XFS_IDONTCACHE here because we are already
748  * serialised against cache hits here via the inode->i_lock and igrab() in
749  * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be
750  * racing with us, and it avoids needing to grab a spinlock here for every inode
751  * we drop the final reference on.
752  */
753 STATIC int
754 xfs_fs_drop_inode(
755         struct inode            *inode)
756 {
757         struct xfs_inode        *ip = XFS_I(inode);
758
759         /*
760          * If this unlinked inode is in the middle of recovery, don't
761          * drop the inode just yet; log recovery will take care of
762          * that.  See the comment for this inode flag.
763          */
764         if (ip->i_flags & XFS_IRECOVERY) {
765                 ASSERT(xlog_recovery_needed(ip->i_mount->m_log));
766                 return 0;
767         }
768
769         return generic_drop_inode(inode);
770 }
771
772 static void
773 xfs_mount_free(
774         struct xfs_mount        *mp)
775 {
776         /*
777          * Free the buftargs here because blkdev_put needs to be called outside
778          * of sb->s_umount, which is held around the call to ->put_super.
779          */
780         if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
781                 xfs_free_buftarg(mp->m_logdev_targp);
782         if (mp->m_rtdev_targp)
783                 xfs_free_buftarg(mp->m_rtdev_targp);
784         if (mp->m_ddev_targp)
785                 xfs_free_buftarg(mp->m_ddev_targp);
786
787         kfree(mp->m_rtname);
788         kfree(mp->m_logname);
789         kmem_free(mp);
790 }
791
792 STATIC int
793 xfs_fs_sync_fs(
794         struct super_block      *sb,
795         int                     wait)
796 {
797         struct xfs_mount        *mp = XFS_M(sb);
798         int                     error;
799
800         trace_xfs_fs_sync_fs(mp, __return_address);
801
802         /*
803          * Doing anything during the async pass would be counterproductive.
804          */
805         if (!wait)
806                 return 0;
807
808         error = xfs_log_force(mp, XFS_LOG_SYNC);
809         if (error)
810                 return error;
811
812         if (laptop_mode) {
813                 /*
814                  * The disk must be active because we're syncing.
815                  * We schedule log work now (now that the disk is
816                  * active) instead of later (when it might not be).
817                  */
818                 flush_delayed_work(&mp->m_log->l_work);
819         }
820
821         /*
822          * If we are called with page faults frozen out, it means we are about
823          * to freeze the transaction subsystem. Take the opportunity to shut
824          * down inodegc because once SB_FREEZE_FS is set it's too late to
825          * prevent inactivation races with freeze. The fs doesn't get called
826          * again by the freezing process until after SB_FREEZE_FS has been set,
827          * so it's now or never.  Same logic applies to speculative allocation
828          * garbage collection.
829          *
830          * We don't care if this is a normal syncfs call that does this or
831          * freeze that does this - we can run this multiple times without issue
832          * and we won't race with a restart because a restart can only occur
833          * when the state is either SB_FREEZE_FS or SB_FREEZE_COMPLETE.
834          */
835         if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) {
836                 xfs_inodegc_stop(mp);
837                 xfs_blockgc_stop(mp);
838         }
839
840         return 0;
841 }
842
843 STATIC int
844 xfs_fs_statfs(
845         struct dentry           *dentry,
846         struct kstatfs          *statp)
847 {
848         struct xfs_mount        *mp = XFS_M(dentry->d_sb);
849         xfs_sb_t                *sbp = &mp->m_sb;
850         struct xfs_inode        *ip = XFS_I(d_inode(dentry));
851         uint64_t                fakeinos, id;
852         uint64_t                icount;
853         uint64_t                ifree;
854         uint64_t                fdblocks;
855         xfs_extlen_t            lsize;
856         int64_t                 ffree;
857
858         /*
859          * Expedite background inodegc but don't wait. We do not want to block
860          * here waiting hours for a billion extent file to be truncated.
861          */
862         xfs_inodegc_push(mp);
863
864         statp->f_type = XFS_SUPER_MAGIC;
865         statp->f_namelen = MAXNAMELEN - 1;
866
867         id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
868         statp->f_fsid = u64_to_fsid(id);
869
870         icount = percpu_counter_sum(&mp->m_icount);
871         ifree = percpu_counter_sum(&mp->m_ifree);
872         fdblocks = percpu_counter_sum(&mp->m_fdblocks);
873
874         spin_lock(&mp->m_sb_lock);
875         statp->f_bsize = sbp->sb_blocksize;
876         lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
877         statp->f_blocks = sbp->sb_dblocks - lsize;
878         spin_unlock(&mp->m_sb_lock);
879
880         /* make sure statp->f_bfree does not underflow */
881         statp->f_bfree = max_t(int64_t, 0,
882                                 fdblocks - xfs_fdblocks_unavailable(mp));
883         statp->f_bavail = statp->f_bfree;
884
885         fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);
886         statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
887         if (M_IGEO(mp)->maxicount)
888                 statp->f_files = min_t(typeof(statp->f_files),
889                                         statp->f_files,
890                                         M_IGEO(mp)->maxicount);
891
892         /* If sb_icount overshot maxicount, report actual allocation */
893         statp->f_files = max_t(typeof(statp->f_files),
894                                         statp->f_files,
895                                         sbp->sb_icount);
896
897         /* make sure statp->f_ffree does not underflow */
898         ffree = statp->f_files - (icount - ifree);
899         statp->f_ffree = max_t(int64_t, ffree, 0);
900
901
902         if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) &&
903             ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
904                               (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
905                 xfs_qm_statvfs(ip, statp);
906
907         if (XFS_IS_REALTIME_MOUNT(mp) &&
908             (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
909                 s64     freertx;
910
911                 statp->f_blocks = sbp->sb_rblocks;
912                 freertx = percpu_counter_sum_positive(&mp->m_frextents);
913                 statp->f_bavail = statp->f_bfree = freertx * sbp->sb_rextsize;
914         }
915
916         return 0;
917 }
918
919 STATIC void
920 xfs_save_resvblks(struct xfs_mount *mp)
921 {
922         uint64_t resblks = 0;
923
924         mp->m_resblks_save = mp->m_resblks;
925         xfs_reserve_blocks(mp, &resblks, NULL);
926 }
927
928 STATIC void
929 xfs_restore_resvblks(struct xfs_mount *mp)
930 {
931         uint64_t resblks;
932
933         if (mp->m_resblks_save) {
934                 resblks = mp->m_resblks_save;
935                 mp->m_resblks_save = 0;
936         } else
937                 resblks = xfs_default_resblks(mp);
938
939         xfs_reserve_blocks(mp, &resblks, NULL);
940 }
941
942 /*
943  * Second stage of a freeze. The data is already frozen so we only
944  * need to take care of the metadata. Once that's done sync the superblock
945  * to the log to dirty it in case of a crash while frozen. This ensures that we
946  * will recover the unlinked inode lists on the next mount.
947  */
948 STATIC int
949 xfs_fs_freeze(
950         struct super_block      *sb)
951 {
952         struct xfs_mount        *mp = XFS_M(sb);
953         unsigned int            flags;
954         int                     ret;
955
956         /*
957          * The filesystem is now frozen far enough that memory reclaim
958          * cannot safely operate on the filesystem. Hence we need to
959          * set a GFP_NOFS context here to avoid recursion deadlocks.
960          */
961         flags = memalloc_nofs_save();
962         xfs_save_resvblks(mp);
963         ret = xfs_log_quiesce(mp);
964         memalloc_nofs_restore(flags);
965
966         /*
967          * For read-write filesystems, we need to restart the inodegc on error
968          * because we stopped it at SB_FREEZE_PAGEFAULT level and a thaw is not
969          * going to be run to restart it now.  We are at SB_FREEZE_FS level
970          * here, so we can restart safely without racing with a stop in
971          * xfs_fs_sync_fs().
972          */
973         if (ret && !xfs_is_readonly(mp)) {
974                 xfs_blockgc_start(mp);
975                 xfs_inodegc_start(mp);
976         }
977
978         return ret;
979 }
980
981 STATIC int
982 xfs_fs_unfreeze(
983         struct super_block      *sb)
984 {
985         struct xfs_mount        *mp = XFS_M(sb);
986
987         xfs_restore_resvblks(mp);
988         xfs_log_work_queue(mp);
989
990         /*
991          * Don't reactivate the inodegc worker on a readonly filesystem because
992          * inodes are sent directly to reclaim.  Don't reactivate the blockgc
993          * worker because there are no speculative preallocations on a readonly
994          * filesystem.
995          */
996         if (!xfs_is_readonly(mp)) {
997                 xfs_blockgc_start(mp);
998                 xfs_inodegc_start(mp);
999         }
1000
1001         return 0;
1002 }
1003
1004 /*
1005  * This function fills in xfs_mount_t fields based on mount args.
1006  * Note: the superblock _has_ now been read in.
1007  */
1008 STATIC int
1009 xfs_finish_flags(
1010         struct xfs_mount        *mp)
1011 {
1012         /* Fail a mount where the logbuf is smaller than the log stripe */
1013         if (xfs_has_logv2(mp)) {
1014                 if (mp->m_logbsize <= 0 &&
1015                     mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) {
1016                         mp->m_logbsize = mp->m_sb.sb_logsunit;
1017                 } else if (mp->m_logbsize > 0 &&
1018                            mp->m_logbsize < mp->m_sb.sb_logsunit) {
1019                         xfs_warn(mp,
1020                 "logbuf size must be greater than or equal to log stripe size");
1021                         return -EINVAL;
1022                 }
1023         } else {
1024                 /* Fail a mount if the logbuf is larger than 32K */
1025                 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) {
1026                         xfs_warn(mp,
1027                 "logbuf size for version 1 logs must be 16K or 32K");
1028                         return -EINVAL;
1029                 }
1030         }
1031
1032         /*
1033          * V5 filesystems always use attr2 format for attributes.
1034          */
1035         if (xfs_has_crc(mp) && xfs_has_noattr2(mp)) {
1036                 xfs_warn(mp, "Cannot mount a V5 filesystem as noattr2. "
1037                              "attr2 is always enabled for V5 filesystems.");
1038                 return -EINVAL;
1039         }
1040
1041         /*
1042          * prohibit r/w mounts of read-only filesystems
1043          */
1044         if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) {
1045                 xfs_warn(mp,
1046                         "cannot mount a read-only filesystem as read-write");
1047                 return -EROFS;
1048         }
1049
1050         if ((mp->m_qflags & XFS_GQUOTA_ACCT) &&
1051             (mp->m_qflags & XFS_PQUOTA_ACCT) &&
1052             !xfs_has_pquotino(mp)) {
1053                 xfs_warn(mp,
1054                   "Super block does not support project and group quota together");
1055                 return -EINVAL;
1056         }
1057
1058         return 0;
1059 }
1060
1061 static int
1062 xfs_init_percpu_counters(
1063         struct xfs_mount        *mp)
1064 {
1065         int             error;
1066
1067         error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL);
1068         if (error)
1069                 return -ENOMEM;
1070
1071         error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL);
1072         if (error)
1073                 goto free_icount;
1074
1075         error = percpu_counter_init(&mp->m_fdblocks, 0, GFP_KERNEL);
1076         if (error)
1077                 goto free_ifree;
1078
1079         error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL);
1080         if (error)
1081                 goto free_fdblocks;
1082
1083         error = percpu_counter_init(&mp->m_frextents, 0, GFP_KERNEL);
1084         if (error)
1085                 goto free_delalloc;
1086
1087         return 0;
1088
1089 free_delalloc:
1090         percpu_counter_destroy(&mp->m_delalloc_blks);
1091 free_fdblocks:
1092         percpu_counter_destroy(&mp->m_fdblocks);
1093 free_ifree:
1094         percpu_counter_destroy(&mp->m_ifree);
1095 free_icount:
1096         percpu_counter_destroy(&mp->m_icount);
1097         return -ENOMEM;
1098 }
1099
1100 void
1101 xfs_reinit_percpu_counters(
1102         struct xfs_mount        *mp)
1103 {
1104         percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount);
1105         percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree);
1106         percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks);
1107         percpu_counter_set(&mp->m_frextents, mp->m_sb.sb_frextents);
1108 }
1109
1110 static void
1111 xfs_destroy_percpu_counters(
1112         struct xfs_mount        *mp)
1113 {
1114         percpu_counter_destroy(&mp->m_icount);
1115         percpu_counter_destroy(&mp->m_ifree);
1116         percpu_counter_destroy(&mp->m_fdblocks);
1117         ASSERT(xfs_is_shutdown(mp) ||
1118                percpu_counter_sum(&mp->m_delalloc_blks) == 0);
1119         percpu_counter_destroy(&mp->m_delalloc_blks);
1120         percpu_counter_destroy(&mp->m_frextents);
1121 }
1122
1123 static int
1124 xfs_inodegc_init_percpu(
1125         struct xfs_mount        *mp)
1126 {
1127         struct xfs_inodegc      *gc;
1128         int                     cpu;
1129
1130         mp->m_inodegc = alloc_percpu(struct xfs_inodegc);
1131         if (!mp->m_inodegc)
1132                 return -ENOMEM;
1133
1134         for_each_possible_cpu(cpu) {
1135                 gc = per_cpu_ptr(mp->m_inodegc, cpu);
1136 #if defined(DEBUG) || defined(XFS_WARN)
1137                 gc->cpu = cpu;
1138 #endif
1139                 init_llist_head(&gc->list);
1140                 gc->items = 0;
1141                 gc->error = 0;
1142                 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker);
1143         }
1144         return 0;
1145 }
1146
1147 static void
1148 xfs_inodegc_free_percpu(
1149         struct xfs_mount        *mp)
1150 {
1151         if (!mp->m_inodegc)
1152                 return;
1153         free_percpu(mp->m_inodegc);
1154 }
1155
1156 static void
1157 xfs_fs_put_super(
1158         struct super_block      *sb)
1159 {
1160         struct xfs_mount        *mp = XFS_M(sb);
1161
1162         xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid);
1163         xfs_filestream_unmount(mp);
1164         xfs_unmountfs(mp);
1165
1166         xfs_freesb(mp);
1167         free_percpu(mp->m_stats.xs_stats);
1168         xfs_mount_list_del(mp);
1169         xfs_inodegc_free_percpu(mp);
1170         xfs_destroy_percpu_counters(mp);
1171         xfs_destroy_mount_workqueues(mp);
1172         xfs_shutdown_devices(mp);
1173 }
1174
1175 static long
1176 xfs_fs_nr_cached_objects(
1177         struct super_block      *sb,
1178         struct shrink_control   *sc)
1179 {
1180         /* Paranoia: catch incorrect calls during mount setup or teardown */
1181         if (WARN_ON_ONCE(!sb->s_fs_info))
1182                 return 0;
1183         return xfs_reclaim_inodes_count(XFS_M(sb));
1184 }
1185
1186 static long
1187 xfs_fs_free_cached_objects(
1188         struct super_block      *sb,
1189         struct shrink_control   *sc)
1190 {
1191         return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan);
1192 }
1193
1194 static void
1195 xfs_fs_shutdown(
1196         struct super_block      *sb)
1197 {
1198         xfs_force_shutdown(XFS_M(sb), SHUTDOWN_DEVICE_REMOVED);
1199 }
1200
1201 static const struct super_operations xfs_super_operations = {
1202         .alloc_inode            = xfs_fs_alloc_inode,
1203         .destroy_inode          = xfs_fs_destroy_inode,
1204         .dirty_inode            = xfs_fs_dirty_inode,
1205         .drop_inode             = xfs_fs_drop_inode,
1206         .put_super              = xfs_fs_put_super,
1207         .sync_fs                = xfs_fs_sync_fs,
1208         .freeze_fs              = xfs_fs_freeze,
1209         .unfreeze_fs            = xfs_fs_unfreeze,
1210         .statfs                 = xfs_fs_statfs,
1211         .show_options           = xfs_fs_show_options,
1212         .nr_cached_objects      = xfs_fs_nr_cached_objects,
1213         .free_cached_objects    = xfs_fs_free_cached_objects,
1214         .shutdown               = xfs_fs_shutdown,
1215 };
1216
1217 static int
1218 suffix_kstrtoint(
1219         const char      *s,
1220         unsigned int    base,
1221         int             *res)
1222 {
1223         int             last, shift_left_factor = 0, _res;
1224         char            *value;
1225         int             ret = 0;
1226
1227         value = kstrdup(s, GFP_KERNEL);
1228         if (!value)
1229                 return -ENOMEM;
1230
1231         last = strlen(value) - 1;
1232         if (value[last] == 'K' || value[last] == 'k') {
1233                 shift_left_factor = 10;
1234                 value[last] = '\0';
1235         }
1236         if (value[last] == 'M' || value[last] == 'm') {
1237                 shift_left_factor = 20;
1238                 value[last] = '\0';
1239         }
1240         if (value[last] == 'G' || value[last] == 'g') {
1241                 shift_left_factor = 30;
1242                 value[last] = '\0';
1243         }
1244
1245         if (kstrtoint(value, base, &_res))
1246                 ret = -EINVAL;
1247         kfree(value);
1248         *res = _res << shift_left_factor;
1249         return ret;
1250 }
1251
1252 static inline void
1253 xfs_fs_warn_deprecated(
1254         struct fs_context       *fc,
1255         struct fs_parameter     *param,
1256         uint64_t                flag,
1257         bool                    value)
1258 {
1259         /* Don't print the warning if reconfiguring and current mount point
1260          * already had the flag set
1261          */
1262         if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) &&
1263             !!(XFS_M(fc->root->d_sb)->m_features & flag) == value)
1264                 return;
1265         xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key);
1266 }
1267
1268 /*
1269  * Set mount state from a mount option.
1270  *
1271  * NOTE: mp->m_super is NULL here!
1272  */
1273 static int
1274 xfs_fs_parse_param(
1275         struct fs_context       *fc,
1276         struct fs_parameter     *param)
1277 {
1278         struct xfs_mount        *parsing_mp = fc->s_fs_info;
1279         struct fs_parse_result  result;
1280         int                     size = 0;
1281         int                     opt;
1282
1283         opt = fs_parse(fc, xfs_fs_parameters, param, &result);
1284         if (opt < 0)
1285                 return opt;
1286
1287         switch (opt) {
1288         case Opt_logbufs:
1289                 parsing_mp->m_logbufs = result.uint_32;
1290                 return 0;
1291         case Opt_logbsize:
1292                 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize))
1293                         return -EINVAL;
1294                 return 0;
1295         case Opt_logdev:
1296                 kfree(parsing_mp->m_logname);
1297                 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL);
1298                 if (!parsing_mp->m_logname)
1299                         return -ENOMEM;
1300                 return 0;
1301         case Opt_rtdev:
1302                 kfree(parsing_mp->m_rtname);
1303                 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL);
1304                 if (!parsing_mp->m_rtname)
1305                         return -ENOMEM;
1306                 return 0;
1307         case Opt_allocsize:
1308                 if (suffix_kstrtoint(param->string, 10, &size))
1309                         return -EINVAL;
1310                 parsing_mp->m_allocsize_log = ffs(size) - 1;
1311                 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE;
1312                 return 0;
1313         case Opt_grpid:
1314         case Opt_bsdgroups:
1315                 parsing_mp->m_features |= XFS_FEAT_GRPID;
1316                 return 0;
1317         case Opt_nogrpid:
1318         case Opt_sysvgroups:
1319                 parsing_mp->m_features &= ~XFS_FEAT_GRPID;
1320                 return 0;
1321         case Opt_wsync:
1322                 parsing_mp->m_features |= XFS_FEAT_WSYNC;
1323                 return 0;
1324         case Opt_norecovery:
1325                 parsing_mp->m_features |= XFS_FEAT_NORECOVERY;
1326                 return 0;
1327         case Opt_noalign:
1328                 parsing_mp->m_features |= XFS_FEAT_NOALIGN;
1329                 return 0;
1330         case Opt_swalloc:
1331                 parsing_mp->m_features |= XFS_FEAT_SWALLOC;
1332                 return 0;
1333         case Opt_sunit:
1334                 parsing_mp->m_dalign = result.uint_32;
1335                 return 0;
1336         case Opt_swidth:
1337                 parsing_mp->m_swidth = result.uint_32;
1338                 return 0;
1339         case Opt_inode32:
1340                 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS;
1341                 return 0;
1342         case Opt_inode64:
1343                 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1344                 return 0;
1345         case Opt_nouuid:
1346                 parsing_mp->m_features |= XFS_FEAT_NOUUID;
1347                 return 0;
1348         case Opt_largeio:
1349                 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE;
1350                 return 0;
1351         case Opt_nolargeio:
1352                 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE;
1353                 return 0;
1354         case Opt_filestreams:
1355                 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS;
1356                 return 0;
1357         case Opt_noquota:
1358                 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT;
1359                 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD;
1360                 return 0;
1361         case Opt_quota:
1362         case Opt_uquota:
1363         case Opt_usrquota:
1364                 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD);
1365                 return 0;
1366         case Opt_qnoenforce:
1367         case Opt_uqnoenforce:
1368                 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT;
1369                 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD;
1370                 return 0;
1371         case Opt_pquota:
1372         case Opt_prjquota:
1373                 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD);
1374                 return 0;
1375         case Opt_pqnoenforce:
1376                 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT;
1377                 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD;
1378                 return 0;
1379         case Opt_gquota:
1380         case Opt_grpquota:
1381                 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD);
1382                 return 0;
1383         case Opt_gqnoenforce:
1384                 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT;
1385                 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD;
1386                 return 0;
1387         case Opt_discard:
1388                 parsing_mp->m_features |= XFS_FEAT_DISCARD;
1389                 return 0;
1390         case Opt_nodiscard:
1391                 parsing_mp->m_features &= ~XFS_FEAT_DISCARD;
1392                 return 0;
1393 #ifdef CONFIG_FS_DAX
1394         case Opt_dax:
1395                 xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS);
1396                 return 0;
1397         case Opt_dax_enum:
1398                 xfs_mount_set_dax_mode(parsing_mp, result.uint_32);
1399                 return 0;
1400 #endif
1401         /* Following mount options will be removed in September 2025 */
1402         case Opt_ikeep:
1403                 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, true);
1404                 parsing_mp->m_features |= XFS_FEAT_IKEEP;
1405                 return 0;
1406         case Opt_noikeep:
1407                 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_IKEEP, false);
1408                 parsing_mp->m_features &= ~XFS_FEAT_IKEEP;
1409                 return 0;
1410         case Opt_attr2:
1411                 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_ATTR2, true);
1412                 parsing_mp->m_features |= XFS_FEAT_ATTR2;
1413                 return 0;
1414         case Opt_noattr2:
1415                 xfs_fs_warn_deprecated(fc, param, XFS_FEAT_NOATTR2, true);
1416                 parsing_mp->m_features |= XFS_FEAT_NOATTR2;
1417                 return 0;
1418         default:
1419                 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key);
1420                 return -EINVAL;
1421         }
1422
1423         return 0;
1424 }
1425
1426 static int
1427 xfs_fs_validate_params(
1428         struct xfs_mount        *mp)
1429 {
1430         /* No recovery flag requires a read-only mount */
1431         if (xfs_has_norecovery(mp) && !xfs_is_readonly(mp)) {
1432                 xfs_warn(mp, "no-recovery mounts must be read-only.");
1433                 return -EINVAL;
1434         }
1435
1436         /*
1437          * We have not read the superblock at this point, so only the attr2
1438          * mount option can set the attr2 feature by this stage.
1439          */
1440         if (xfs_has_attr2(mp) && xfs_has_noattr2(mp)) {
1441                 xfs_warn(mp, "attr2 and noattr2 cannot both be specified.");
1442                 return -EINVAL;
1443         }
1444
1445
1446         if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) {
1447                 xfs_warn(mp,
1448         "sunit and swidth options incompatible with the noalign option");
1449                 return -EINVAL;
1450         }
1451
1452         if (!IS_ENABLED(CONFIG_XFS_QUOTA) && mp->m_qflags != 0) {
1453                 xfs_warn(mp, "quota support not available in this kernel.");
1454                 return -EINVAL;
1455         }
1456
1457         if ((mp->m_dalign && !mp->m_swidth) ||
1458             (!mp->m_dalign && mp->m_swidth)) {
1459                 xfs_warn(mp, "sunit and swidth must be specified together");
1460                 return -EINVAL;
1461         }
1462
1463         if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) {
1464                 xfs_warn(mp,
1465         "stripe width (%d) must be a multiple of the stripe unit (%d)",
1466                         mp->m_swidth, mp->m_dalign);
1467                 return -EINVAL;
1468         }
1469
1470         if (mp->m_logbufs != -1 &&
1471             mp->m_logbufs != 0 &&
1472             (mp->m_logbufs < XLOG_MIN_ICLOGS ||
1473              mp->m_logbufs > XLOG_MAX_ICLOGS)) {
1474                 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]",
1475                         mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS);
1476                 return -EINVAL;
1477         }
1478
1479         if (mp->m_logbsize != -1 &&
1480             mp->m_logbsize !=  0 &&
1481             (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE ||
1482              mp->m_logbsize > XLOG_MAX_RECORD_BSIZE ||
1483              !is_power_of_2(mp->m_logbsize))) {
1484                 xfs_warn(mp,
1485                         "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
1486                         mp->m_logbsize);
1487                 return -EINVAL;
1488         }
1489
1490         if (xfs_has_allocsize(mp) &&
1491             (mp->m_allocsize_log > XFS_MAX_IO_LOG ||
1492              mp->m_allocsize_log < XFS_MIN_IO_LOG)) {
1493                 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]",
1494                         mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG);
1495                 return -EINVAL;
1496         }
1497
1498         return 0;
1499 }
1500
1501 static int
1502 xfs_fs_fill_super(
1503         struct super_block      *sb,
1504         struct fs_context       *fc)
1505 {
1506         struct xfs_mount        *mp = sb->s_fs_info;
1507         struct inode            *root;
1508         int                     flags = 0, error;
1509
1510         mp->m_super = sb;
1511
1512         error = xfs_fs_validate_params(mp);
1513         if (error)
1514                 return error;
1515
1516         sb_min_blocksize(sb, BBSIZE);
1517         sb->s_xattr = xfs_xattr_handlers;
1518         sb->s_export_op = &xfs_export_operations;
1519 #ifdef CONFIG_XFS_QUOTA
1520         sb->s_qcop = &xfs_quotactl_operations;
1521         sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
1522 #endif
1523         sb->s_op = &xfs_super_operations;
1524
1525         /*
1526          * Delay mount work if the debug hook is set. This is debug
1527          * instrumention to coordinate simulation of xfs mount failures with
1528          * VFS superblock operations
1529          */
1530         if (xfs_globals.mount_delay) {
1531                 xfs_notice(mp, "Delaying mount for %d seconds.",
1532                         xfs_globals.mount_delay);
1533                 msleep(xfs_globals.mount_delay * 1000);
1534         }
1535
1536         if (fc->sb_flags & SB_SILENT)
1537                 flags |= XFS_MFSI_QUIET;
1538
1539         error = xfs_open_devices(mp);
1540         if (error)
1541                 return error;
1542
1543         error = xfs_init_mount_workqueues(mp);
1544         if (error)
1545                 goto out_shutdown_devices;
1546
1547         error = xfs_init_percpu_counters(mp);
1548         if (error)
1549                 goto out_destroy_workqueues;
1550
1551         error = xfs_inodegc_init_percpu(mp);
1552         if (error)
1553                 goto out_destroy_counters;
1554
1555         /*
1556          * All percpu data structures requiring cleanup when a cpu goes offline
1557          * must be allocated before adding this @mp to the cpu-dead handler's
1558          * mount list.
1559          */
1560         xfs_mount_list_add(mp);
1561
1562         /* Allocate stats memory before we do operations that might use it */
1563         mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
1564         if (!mp->m_stats.xs_stats) {
1565                 error = -ENOMEM;
1566                 goto out_destroy_inodegc;
1567         }
1568
1569         error = xfs_readsb(mp, flags);
1570         if (error)
1571                 goto out_free_stats;
1572
1573         error = xfs_finish_flags(mp);
1574         if (error)
1575                 goto out_free_sb;
1576
1577         error = xfs_setup_devices(mp);
1578         if (error)
1579                 goto out_free_sb;
1580
1581         /* V4 support is undergoing deprecation. */
1582         if (!xfs_has_crc(mp)) {
1583 #ifdef CONFIG_XFS_SUPPORT_V4
1584                 xfs_warn_once(mp,
1585         "Deprecated V4 format (crc=0) will not be supported after September 2030.");
1586 #else
1587                 xfs_warn(mp,
1588         "Deprecated V4 format (crc=0) not supported by kernel.");
1589                 error = -EINVAL;
1590                 goto out_free_sb;
1591 #endif
1592         }
1593
1594         /* ASCII case insensitivity is undergoing deprecation. */
1595         if (xfs_has_asciici(mp)) {
1596 #ifdef CONFIG_XFS_SUPPORT_ASCII_CI
1597                 xfs_warn_once(mp,
1598         "Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 2030.");
1599 #else
1600                 xfs_warn(mp,
1601         "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel.");
1602                 error = -EINVAL;
1603                 goto out_free_sb;
1604 #endif
1605         }
1606
1607         /* Filesystem claims it needs repair, so refuse the mount. */
1608         if (xfs_has_needsrepair(mp)) {
1609                 xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
1610                 error = -EFSCORRUPTED;
1611                 goto out_free_sb;
1612         }
1613
1614         /*
1615          * Don't touch the filesystem if a user tool thinks it owns the primary
1616          * superblock.  mkfs doesn't clear the flag from secondary supers, so
1617          * we don't check them at all.
1618          */
1619         if (mp->m_sb.sb_inprogress) {
1620                 xfs_warn(mp, "Offline file system operation in progress!");
1621                 error = -EFSCORRUPTED;
1622                 goto out_free_sb;
1623         }
1624
1625         /*
1626          * Until this is fixed only page-sized or smaller data blocks work.
1627          */
1628         if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
1629                 xfs_warn(mp,
1630                 "File system with blocksize %d bytes. "
1631                 "Only pagesize (%ld) or less will currently work.",
1632                                 mp->m_sb.sb_blocksize, PAGE_SIZE);
1633                 error = -ENOSYS;
1634                 goto out_free_sb;
1635         }
1636
1637         /* Ensure this filesystem fits in the page cache limits */
1638         if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) ||
1639             xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) {
1640                 xfs_warn(mp,
1641                 "file system too large to be mounted on this system.");
1642                 error = -EFBIG;
1643                 goto out_free_sb;
1644         }
1645
1646         /*
1647          * XFS block mappings use 54 bits to store the logical block offset.
1648          * This should suffice to handle the maximum file size that the VFS
1649          * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT
1650          * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes
1651          * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON
1652          * to check this assertion.
1653          *
1654          * Avoid integer overflow by comparing the maximum bmbt offset to the
1655          * maximum pagecache offset in units of fs blocks.
1656          */
1657         if (!xfs_verify_fileoff(mp, XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE))) {
1658                 xfs_warn(mp,
1659 "MAX_LFS_FILESIZE block offset (%llu) exceeds extent map maximum (%llu)!",
1660                          XFS_B_TO_FSBT(mp, MAX_LFS_FILESIZE),
1661                          XFS_MAX_FILEOFF);
1662                 error = -EINVAL;
1663                 goto out_free_sb;
1664         }
1665
1666         error = xfs_filestream_mount(mp);
1667         if (error)
1668                 goto out_free_sb;
1669
1670         /*
1671          * we must configure the block size in the superblock before we run the
1672          * full mount process as the mount process can lookup and cache inodes.
1673          */
1674         sb->s_magic = XFS_SUPER_MAGIC;
1675         sb->s_blocksize = mp->m_sb.sb_blocksize;
1676         sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
1677         sb->s_maxbytes = MAX_LFS_FILESIZE;
1678         sb->s_max_links = XFS_MAXLINK;
1679         sb->s_time_gran = 1;
1680         if (xfs_has_bigtime(mp)) {
1681                 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN);
1682                 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX);
1683         } else {
1684                 sb->s_time_min = XFS_LEGACY_TIME_MIN;
1685                 sb->s_time_max = XFS_LEGACY_TIME_MAX;
1686         }
1687         trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max);
1688         sb->s_iflags |= SB_I_CGROUPWB;
1689
1690         set_posix_acl_flag(sb);
1691
1692         /* version 5 superblocks support inode version counters. */
1693         if (xfs_has_crc(mp))
1694                 sb->s_flags |= SB_I_VERSION;
1695
1696         if (xfs_has_dax_always(mp)) {
1697                 error = xfs_setup_dax_always(mp);
1698                 if (error)
1699                         goto out_filestream_unmount;
1700         }
1701
1702         if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) {
1703                 xfs_warn(mp,
1704         "mounting with \"discard\" option, but the device does not support discard");
1705                 mp->m_features &= ~XFS_FEAT_DISCARD;
1706         }
1707
1708         if (xfs_has_reflink(mp)) {
1709                 if (mp->m_sb.sb_rblocks) {
1710                         xfs_alert(mp,
1711         "reflink not compatible with realtime device!");
1712                         error = -EINVAL;
1713                         goto out_filestream_unmount;
1714                 }
1715
1716                 if (xfs_globals.always_cow) {
1717                         xfs_info(mp, "using DEBUG-only always_cow mode.");
1718                         mp->m_always_cow = true;
1719                 }
1720         }
1721
1722         if (xfs_has_rmapbt(mp) && mp->m_sb.sb_rblocks) {
1723                 xfs_alert(mp,
1724         "reverse mapping btree not compatible with realtime device!");
1725                 error = -EINVAL;
1726                 goto out_filestream_unmount;
1727         }
1728
1729         error = xfs_mountfs(mp);
1730         if (error)
1731                 goto out_filestream_unmount;
1732
1733         root = igrab(VFS_I(mp->m_rootip));
1734         if (!root) {
1735                 error = -ENOENT;
1736                 goto out_unmount;
1737         }
1738         sb->s_root = d_make_root(root);
1739         if (!sb->s_root) {
1740                 error = -ENOMEM;
1741                 goto out_unmount;
1742         }
1743
1744         return 0;
1745
1746  out_filestream_unmount:
1747         xfs_filestream_unmount(mp);
1748  out_free_sb:
1749         xfs_freesb(mp);
1750  out_free_stats:
1751         free_percpu(mp->m_stats.xs_stats);
1752  out_destroy_inodegc:
1753         xfs_mount_list_del(mp);
1754         xfs_inodegc_free_percpu(mp);
1755  out_destroy_counters:
1756         xfs_destroy_percpu_counters(mp);
1757  out_destroy_workqueues:
1758         xfs_destroy_mount_workqueues(mp);
1759  out_shutdown_devices:
1760         xfs_shutdown_devices(mp);
1761         return error;
1762
1763  out_unmount:
1764         xfs_filestream_unmount(mp);
1765         xfs_unmountfs(mp);
1766         goto out_free_sb;
1767 }
1768
1769 static int
1770 xfs_fs_get_tree(
1771         struct fs_context       *fc)
1772 {
1773         return get_tree_bdev(fc, xfs_fs_fill_super);
1774 }
1775
1776 static int
1777 xfs_remount_rw(
1778         struct xfs_mount        *mp)
1779 {
1780         struct xfs_sb           *sbp = &mp->m_sb;
1781         int error;
1782
1783         if (xfs_has_norecovery(mp)) {
1784                 xfs_warn(mp,
1785                         "ro->rw transition prohibited on norecovery mount");
1786                 return -EINVAL;
1787         }
1788
1789         if (xfs_sb_is_v5(sbp) &&
1790             xfs_sb_has_ro_compat_feature(sbp, XFS_SB_FEAT_RO_COMPAT_UNKNOWN)) {
1791                 xfs_warn(mp,
1792         "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
1793                         (sbp->sb_features_ro_compat &
1794                                 XFS_SB_FEAT_RO_COMPAT_UNKNOWN));
1795                 return -EINVAL;
1796         }
1797
1798         clear_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1799
1800         /*
1801          * If this is the first remount to writeable state we might have some
1802          * superblock changes to update.
1803          */
1804         if (mp->m_update_sb) {
1805                 error = xfs_sync_sb(mp, false);
1806                 if (error) {
1807                         xfs_warn(mp, "failed to write sb changes");
1808                         return error;
1809                 }
1810                 mp->m_update_sb = false;
1811         }
1812
1813         /*
1814          * Fill out the reserve pool if it is empty. Use the stashed value if
1815          * it is non-zero, otherwise go with the default.
1816          */
1817         xfs_restore_resvblks(mp);
1818         xfs_log_work_queue(mp);
1819         xfs_blockgc_start(mp);
1820
1821         /* Create the per-AG metadata reservation pool .*/
1822         error = xfs_fs_reserve_ag_blocks(mp);
1823         if (error && error != -ENOSPC)
1824                 return error;
1825
1826         /* Re-enable the background inode inactivation worker. */
1827         xfs_inodegc_start(mp);
1828
1829         return 0;
1830 }
1831
1832 static int
1833 xfs_remount_ro(
1834         struct xfs_mount        *mp)
1835 {
1836         struct xfs_icwalk       icw = {
1837                 .icw_flags      = XFS_ICWALK_FLAG_SYNC,
1838         };
1839         int                     error;
1840
1841         /* Flush all the dirty data to disk. */
1842         error = sync_filesystem(mp->m_super);
1843         if (error)
1844                 return error;
1845
1846         /*
1847          * Cancel background eofb scanning so it cannot race with the final
1848          * log force+buftarg wait and deadlock the remount.
1849          */
1850         xfs_blockgc_stop(mp);
1851
1852         /*
1853          * Clear out all remaining COW staging extents and speculative post-EOF
1854          * preallocations so that we don't leave inodes requiring inactivation
1855          * cleanups during reclaim on a read-only mount.  We must process every
1856          * cached inode, so this requires a synchronous cache scan.
1857          */
1858         error = xfs_blockgc_free_space(mp, &icw);
1859         if (error) {
1860                 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1861                 return error;
1862         }
1863
1864         /*
1865          * Stop the inodegc background worker.  xfs_fs_reconfigure already
1866          * flushed all pending inodegc work when it sync'd the filesystem.
1867          * The VFS holds s_umount, so we know that inodes cannot enter
1868          * xfs_fs_destroy_inode during a remount operation.  In readonly mode
1869          * we send inodes straight to reclaim, so no inodes will be queued.
1870          */
1871         xfs_inodegc_stop(mp);
1872
1873         /* Free the per-AG metadata reservation pool. */
1874         error = xfs_fs_unreserve_ag_blocks(mp);
1875         if (error) {
1876                 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
1877                 return error;
1878         }
1879
1880         /*
1881          * Before we sync the metadata, we need to free up the reserve block
1882          * pool so that the used block count in the superblock on disk is
1883          * correct at the end of the remount. Stash the current* reserve pool
1884          * size so that if we get remounted rw, we can return it to the same
1885          * size.
1886          */
1887         xfs_save_resvblks(mp);
1888
1889         xfs_log_clean(mp);
1890         set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
1891
1892         return 0;
1893 }
1894
1895 /*
1896  * Logically we would return an error here to prevent users from believing
1897  * they might have changed mount options using remount which can't be changed.
1898  *
1899  * But unfortunately mount(8) adds all options from mtab and fstab to the mount
1900  * arguments in some cases so we can't blindly reject options, but have to
1901  * check for each specified option if it actually differs from the currently
1902  * set option and only reject it if that's the case.
1903  *
1904  * Until that is implemented we return success for every remount request, and
1905  * silently ignore all options that we can't actually change.
1906  */
1907 static int
1908 xfs_fs_reconfigure(
1909         struct fs_context *fc)
1910 {
1911         struct xfs_mount        *mp = XFS_M(fc->root->d_sb);
1912         struct xfs_mount        *new_mp = fc->s_fs_info;
1913         int                     flags = fc->sb_flags;
1914         int                     error;
1915
1916         /* version 5 superblocks always support version counters. */
1917         if (xfs_has_crc(mp))
1918                 fc->sb_flags |= SB_I_VERSION;
1919
1920         error = xfs_fs_validate_params(new_mp);
1921         if (error)
1922                 return error;
1923
1924         /* inode32 -> inode64 */
1925         if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) {
1926                 mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
1927                 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1928         }
1929
1930         /* inode64 -> inode32 */
1931         if (!xfs_has_small_inums(mp) && xfs_has_small_inums(new_mp)) {
1932                 mp->m_features |= XFS_FEAT_SMALL_INUMS;
1933                 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
1934         }
1935
1936         /* ro -> rw */
1937         if (xfs_is_readonly(mp) && !(flags & SB_RDONLY)) {
1938                 error = xfs_remount_rw(mp);
1939                 if (error)
1940                         return error;
1941         }
1942
1943         /* rw -> ro */
1944         if (!xfs_is_readonly(mp) && (flags & SB_RDONLY)) {
1945                 error = xfs_remount_ro(mp);
1946                 if (error)
1947                         return error;
1948         }
1949
1950         return 0;
1951 }
1952
1953 static void
1954 xfs_fs_free(
1955         struct fs_context       *fc)
1956 {
1957         struct xfs_mount        *mp = fc->s_fs_info;
1958
1959         /*
1960          * mp is stored in the fs_context when it is initialized.
1961          * mp is transferred to the superblock on a successful mount,
1962          * but if an error occurs before the transfer we have to free
1963          * it here.
1964          */
1965         if (mp)
1966                 xfs_mount_free(mp);
1967 }
1968
1969 static const struct fs_context_operations xfs_context_ops = {
1970         .parse_param = xfs_fs_parse_param,
1971         .get_tree    = xfs_fs_get_tree,
1972         .reconfigure = xfs_fs_reconfigure,
1973         .free        = xfs_fs_free,
1974 };
1975
1976 static int xfs_init_fs_context(
1977         struct fs_context       *fc)
1978 {
1979         struct xfs_mount        *mp;
1980
1981         mp = kmem_alloc(sizeof(struct xfs_mount), KM_ZERO);
1982         if (!mp)
1983                 return -ENOMEM;
1984
1985         spin_lock_init(&mp->m_sb_lock);
1986         INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC);
1987         spin_lock_init(&mp->m_perag_lock);
1988         mutex_init(&mp->m_growlock);
1989         INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker);
1990         INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker);
1991         mp->m_kobj.kobject.kset = xfs_kset;
1992         /*
1993          * We don't create the finobt per-ag space reservation until after log
1994          * recovery, so we must set this to true so that an ifree transaction
1995          * started during log recovery will not depend on space reservations
1996          * for finobt expansion.
1997          */
1998         mp->m_finobt_nores = true;
1999
2000         /*
2001          * These can be overridden by the mount option parsing.
2002          */
2003         mp->m_logbufs = -1;
2004         mp->m_logbsize = -1;
2005         mp->m_allocsize_log = 16; /* 64k */
2006
2007         /*
2008          * Copy binary VFS mount flags we are interested in.
2009          */
2010         if (fc->sb_flags & SB_RDONLY)
2011                 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate);
2012         if (fc->sb_flags & SB_DIRSYNC)
2013                 mp->m_features |= XFS_FEAT_DIRSYNC;
2014         if (fc->sb_flags & SB_SYNCHRONOUS)
2015                 mp->m_features |= XFS_FEAT_WSYNC;
2016
2017         fc->s_fs_info = mp;
2018         fc->ops = &xfs_context_ops;
2019
2020         return 0;
2021 }
2022
2023 static void
2024 xfs_kill_sb(
2025         struct super_block              *sb)
2026 {
2027         kill_block_super(sb);
2028         xfs_mount_free(XFS_M(sb));
2029 }
2030
2031 static struct file_system_type xfs_fs_type = {
2032         .owner                  = THIS_MODULE,
2033         .name                   = "xfs",
2034         .init_fs_context        = xfs_init_fs_context,
2035         .parameters             = xfs_fs_parameters,
2036         .kill_sb                = xfs_kill_sb,
2037         .fs_flags               = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
2038 };
2039 MODULE_ALIAS_FS("xfs");
2040
2041 STATIC int __init
2042 xfs_init_caches(void)
2043 {
2044         int             error;
2045
2046         xfs_buf_cache = kmem_cache_create("xfs_buf", sizeof(struct xfs_buf), 0,
2047                                          SLAB_HWCACHE_ALIGN |
2048                                          SLAB_RECLAIM_ACCOUNT |
2049                                          SLAB_MEM_SPREAD,
2050                                          NULL);
2051         if (!xfs_buf_cache)
2052                 goto out;
2053
2054         xfs_log_ticket_cache = kmem_cache_create("xfs_log_ticket",
2055                                                 sizeof(struct xlog_ticket),
2056                                                 0, 0, NULL);
2057         if (!xfs_log_ticket_cache)
2058                 goto out_destroy_buf_cache;
2059
2060         error = xfs_btree_init_cur_caches();
2061         if (error)
2062                 goto out_destroy_log_ticket_cache;
2063
2064         error = xfs_defer_init_item_caches();
2065         if (error)
2066                 goto out_destroy_btree_cur_cache;
2067
2068         xfs_da_state_cache = kmem_cache_create("xfs_da_state",
2069                                               sizeof(struct xfs_da_state),
2070                                               0, 0, NULL);
2071         if (!xfs_da_state_cache)
2072                 goto out_destroy_defer_item_cache;
2073
2074         xfs_ifork_cache = kmem_cache_create("xfs_ifork",
2075                                            sizeof(struct xfs_ifork),
2076                                            0, 0, NULL);
2077         if (!xfs_ifork_cache)
2078                 goto out_destroy_da_state_cache;
2079
2080         xfs_trans_cache = kmem_cache_create("xfs_trans",
2081                                            sizeof(struct xfs_trans),
2082                                            0, 0, NULL);
2083         if (!xfs_trans_cache)
2084                 goto out_destroy_ifork_cache;
2085
2086
2087         /*
2088          * The size of the cache-allocated buf log item is the maximum
2089          * size possible under XFS.  This wastes a little bit of memory,
2090          * but it is much faster.
2091          */
2092         xfs_buf_item_cache = kmem_cache_create("xfs_buf_item",
2093                                               sizeof(struct xfs_buf_log_item),
2094                                               0, 0, NULL);
2095         if (!xfs_buf_item_cache)
2096                 goto out_destroy_trans_cache;
2097
2098         xfs_efd_cache = kmem_cache_create("xfs_efd_item",
2099                         xfs_efd_log_item_sizeof(XFS_EFD_MAX_FAST_EXTENTS),
2100                         0, 0, NULL);
2101         if (!xfs_efd_cache)
2102                 goto out_destroy_buf_item_cache;
2103
2104         xfs_efi_cache = kmem_cache_create("xfs_efi_item",
2105                         xfs_efi_log_item_sizeof(XFS_EFI_MAX_FAST_EXTENTS),
2106                         0, 0, NULL);
2107         if (!xfs_efi_cache)
2108                 goto out_destroy_efd_cache;
2109
2110         xfs_inode_cache = kmem_cache_create("xfs_inode",
2111                                            sizeof(struct xfs_inode), 0,
2112                                            (SLAB_HWCACHE_ALIGN |
2113                                             SLAB_RECLAIM_ACCOUNT |
2114                                             SLAB_MEM_SPREAD | SLAB_ACCOUNT),
2115                                            xfs_fs_inode_init_once);
2116         if (!xfs_inode_cache)
2117                 goto out_destroy_efi_cache;
2118
2119         xfs_ili_cache = kmem_cache_create("xfs_ili",
2120                                          sizeof(struct xfs_inode_log_item), 0,
2121                                          SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
2122                                          NULL);
2123         if (!xfs_ili_cache)
2124                 goto out_destroy_inode_cache;
2125
2126         xfs_icreate_cache = kmem_cache_create("xfs_icr",
2127                                              sizeof(struct xfs_icreate_item),
2128                                              0, 0, NULL);
2129         if (!xfs_icreate_cache)
2130                 goto out_destroy_ili_cache;
2131
2132         xfs_rud_cache = kmem_cache_create("xfs_rud_item",
2133                                          sizeof(struct xfs_rud_log_item),
2134                                          0, 0, NULL);
2135         if (!xfs_rud_cache)
2136                 goto out_destroy_icreate_cache;
2137
2138         xfs_rui_cache = kmem_cache_create("xfs_rui_item",
2139                         xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS),
2140                         0, 0, NULL);
2141         if (!xfs_rui_cache)
2142                 goto out_destroy_rud_cache;
2143
2144         xfs_cud_cache = kmem_cache_create("xfs_cud_item",
2145                                          sizeof(struct xfs_cud_log_item),
2146                                          0, 0, NULL);
2147         if (!xfs_cud_cache)
2148                 goto out_destroy_rui_cache;
2149
2150         xfs_cui_cache = kmem_cache_create("xfs_cui_item",
2151                         xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS),
2152                         0, 0, NULL);
2153         if (!xfs_cui_cache)
2154                 goto out_destroy_cud_cache;
2155
2156         xfs_bud_cache = kmem_cache_create("xfs_bud_item",
2157                                          sizeof(struct xfs_bud_log_item),
2158                                          0, 0, NULL);
2159         if (!xfs_bud_cache)
2160                 goto out_destroy_cui_cache;
2161
2162         xfs_bui_cache = kmem_cache_create("xfs_bui_item",
2163                         xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS),
2164                         0, 0, NULL);
2165         if (!xfs_bui_cache)
2166                 goto out_destroy_bud_cache;
2167
2168         xfs_attrd_cache = kmem_cache_create("xfs_attrd_item",
2169                                             sizeof(struct xfs_attrd_log_item),
2170                                             0, 0, NULL);
2171         if (!xfs_attrd_cache)
2172                 goto out_destroy_bui_cache;
2173
2174         xfs_attri_cache = kmem_cache_create("xfs_attri_item",
2175                                             sizeof(struct xfs_attri_log_item),
2176                                             0, 0, NULL);
2177         if (!xfs_attri_cache)
2178                 goto out_destroy_attrd_cache;
2179
2180         xfs_iunlink_cache = kmem_cache_create("xfs_iul_item",
2181                                              sizeof(struct xfs_iunlink_item),
2182                                              0, 0, NULL);
2183         if (!xfs_iunlink_cache)
2184                 goto out_destroy_attri_cache;
2185
2186         return 0;
2187
2188  out_destroy_attri_cache:
2189         kmem_cache_destroy(xfs_attri_cache);
2190  out_destroy_attrd_cache:
2191         kmem_cache_destroy(xfs_attrd_cache);
2192  out_destroy_bui_cache:
2193         kmem_cache_destroy(xfs_bui_cache);
2194  out_destroy_bud_cache:
2195         kmem_cache_destroy(xfs_bud_cache);
2196  out_destroy_cui_cache:
2197         kmem_cache_destroy(xfs_cui_cache);
2198  out_destroy_cud_cache:
2199         kmem_cache_destroy(xfs_cud_cache);
2200  out_destroy_rui_cache:
2201         kmem_cache_destroy(xfs_rui_cache);
2202  out_destroy_rud_cache:
2203         kmem_cache_destroy(xfs_rud_cache);
2204  out_destroy_icreate_cache:
2205         kmem_cache_destroy(xfs_icreate_cache);
2206  out_destroy_ili_cache:
2207         kmem_cache_destroy(xfs_ili_cache);
2208  out_destroy_inode_cache:
2209         kmem_cache_destroy(xfs_inode_cache);
2210  out_destroy_efi_cache:
2211         kmem_cache_destroy(xfs_efi_cache);
2212  out_destroy_efd_cache:
2213         kmem_cache_destroy(xfs_efd_cache);
2214  out_destroy_buf_item_cache:
2215         kmem_cache_destroy(xfs_buf_item_cache);
2216  out_destroy_trans_cache:
2217         kmem_cache_destroy(xfs_trans_cache);
2218  out_destroy_ifork_cache:
2219         kmem_cache_destroy(xfs_ifork_cache);
2220  out_destroy_da_state_cache:
2221         kmem_cache_destroy(xfs_da_state_cache);
2222  out_destroy_defer_item_cache:
2223         xfs_defer_destroy_item_caches();
2224  out_destroy_btree_cur_cache:
2225         xfs_btree_destroy_cur_caches();
2226  out_destroy_log_ticket_cache:
2227         kmem_cache_destroy(xfs_log_ticket_cache);
2228  out_destroy_buf_cache:
2229         kmem_cache_destroy(xfs_buf_cache);
2230  out:
2231         return -ENOMEM;
2232 }
2233
2234 STATIC void
2235 xfs_destroy_caches(void)
2236 {
2237         /*
2238          * Make sure all delayed rcu free are flushed before we
2239          * destroy caches.
2240          */
2241         rcu_barrier();
2242         kmem_cache_destroy(xfs_iunlink_cache);
2243         kmem_cache_destroy(xfs_attri_cache);
2244         kmem_cache_destroy(xfs_attrd_cache);
2245         kmem_cache_destroy(xfs_bui_cache);
2246         kmem_cache_destroy(xfs_bud_cache);
2247         kmem_cache_destroy(xfs_cui_cache);
2248         kmem_cache_destroy(xfs_cud_cache);
2249         kmem_cache_destroy(xfs_rui_cache);
2250         kmem_cache_destroy(xfs_rud_cache);
2251         kmem_cache_destroy(xfs_icreate_cache);
2252         kmem_cache_destroy(xfs_ili_cache);
2253         kmem_cache_destroy(xfs_inode_cache);
2254         kmem_cache_destroy(xfs_efi_cache);
2255         kmem_cache_destroy(xfs_efd_cache);
2256         kmem_cache_destroy(xfs_buf_item_cache);
2257         kmem_cache_destroy(xfs_trans_cache);
2258         kmem_cache_destroy(xfs_ifork_cache);
2259         kmem_cache_destroy(xfs_da_state_cache);
2260         xfs_defer_destroy_item_caches();
2261         xfs_btree_destroy_cur_caches();
2262         kmem_cache_destroy(xfs_log_ticket_cache);
2263         kmem_cache_destroy(xfs_buf_cache);
2264 }
2265
2266 STATIC int __init
2267 xfs_init_workqueues(void)
2268 {
2269         /*
2270          * The allocation workqueue can be used in memory reclaim situations
2271          * (writepage path), and parallelism is only limited by the number of
2272          * AGs in all the filesystems mounted. Hence use the default large
2273          * max_active value for this workqueue.
2274          */
2275         xfs_alloc_wq = alloc_workqueue("xfsalloc",
2276                         XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 0);
2277         if (!xfs_alloc_wq)
2278                 return -ENOMEM;
2279
2280         xfs_discard_wq = alloc_workqueue("xfsdiscard", XFS_WQFLAGS(WQ_UNBOUND),
2281                         0);
2282         if (!xfs_discard_wq)
2283                 goto out_free_alloc_wq;
2284
2285         return 0;
2286 out_free_alloc_wq:
2287         destroy_workqueue(xfs_alloc_wq);
2288         return -ENOMEM;
2289 }
2290
2291 STATIC void
2292 xfs_destroy_workqueues(void)
2293 {
2294         destroy_workqueue(xfs_discard_wq);
2295         destroy_workqueue(xfs_alloc_wq);
2296 }
2297
2298 #ifdef CONFIG_HOTPLUG_CPU
2299 static int
2300 xfs_cpu_dead(
2301         unsigned int            cpu)
2302 {
2303         struct xfs_mount        *mp, *n;
2304
2305         spin_lock(&xfs_mount_list_lock);
2306         list_for_each_entry_safe(mp, n, &xfs_mount_list, m_mount_list) {
2307                 spin_unlock(&xfs_mount_list_lock);
2308                 xfs_inodegc_cpu_dead(mp, cpu);
2309                 xlog_cil_pcp_dead(mp->m_log, cpu);
2310                 spin_lock(&xfs_mount_list_lock);
2311         }
2312         spin_unlock(&xfs_mount_list_lock);
2313         return 0;
2314 }
2315
2316 static int __init
2317 xfs_cpu_hotplug_init(void)
2318 {
2319         int     error;
2320
2321         error = cpuhp_setup_state_nocalls(CPUHP_XFS_DEAD, "xfs:dead", NULL,
2322                         xfs_cpu_dead);
2323         if (error < 0)
2324                 xfs_alert(NULL,
2325 "Failed to initialise CPU hotplug, error %d. XFS is non-functional.",
2326                         error);
2327         return error;
2328 }
2329
2330 static void
2331 xfs_cpu_hotplug_destroy(void)
2332 {
2333         cpuhp_remove_state_nocalls(CPUHP_XFS_DEAD);
2334 }
2335
2336 #else /* !CONFIG_HOTPLUG_CPU */
2337 static inline int xfs_cpu_hotplug_init(void) { return 0; }
2338 static inline void xfs_cpu_hotplug_destroy(void) {}
2339 #endif
2340
2341 STATIC int __init
2342 init_xfs_fs(void)
2343 {
2344         int                     error;
2345
2346         xfs_check_ondisk_structs();
2347
2348         error = xfs_dahash_test();
2349         if (error)
2350                 return error;
2351
2352         printk(KERN_INFO XFS_VERSION_STRING " with "
2353                          XFS_BUILD_OPTIONS " enabled\n");
2354
2355         xfs_dir_startup();
2356
2357         error = xfs_cpu_hotplug_init();
2358         if (error)
2359                 goto out;
2360
2361         error = xfs_init_caches();
2362         if (error)
2363                 goto out_destroy_hp;
2364
2365         error = xfs_init_workqueues();
2366         if (error)
2367                 goto out_destroy_caches;
2368
2369         error = xfs_mru_cache_init();
2370         if (error)
2371                 goto out_destroy_wq;
2372
2373         error = xfs_init_procfs();
2374         if (error)
2375                 goto out_mru_cache_uninit;
2376
2377         error = xfs_sysctl_register();
2378         if (error)
2379                 goto out_cleanup_procfs;
2380
2381         xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
2382         if (!xfs_kset) {
2383                 error = -ENOMEM;
2384                 goto out_sysctl_unregister;
2385         }
2386
2387         xfsstats.xs_kobj.kobject.kset = xfs_kset;
2388
2389         xfsstats.xs_stats = alloc_percpu(struct xfsstats);
2390         if (!xfsstats.xs_stats) {
2391                 error = -ENOMEM;
2392                 goto out_kset_unregister;
2393         }
2394
2395         error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
2396                                "stats");
2397         if (error)
2398                 goto out_free_stats;
2399
2400 #ifdef DEBUG
2401         xfs_dbg_kobj.kobject.kset = xfs_kset;
2402         error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
2403         if (error)
2404                 goto out_remove_stats_kobj;
2405 #endif
2406
2407         error = xfs_qm_init();
2408         if (error)
2409                 goto out_remove_dbg_kobj;
2410
2411         error = register_filesystem(&xfs_fs_type);
2412         if (error)
2413                 goto out_qm_exit;
2414         return 0;
2415
2416  out_qm_exit:
2417         xfs_qm_exit();
2418  out_remove_dbg_kobj:
2419 #ifdef DEBUG
2420         xfs_sysfs_del(&xfs_dbg_kobj);
2421  out_remove_stats_kobj:
2422 #endif
2423         xfs_sysfs_del(&xfsstats.xs_kobj);
2424  out_free_stats:
2425         free_percpu(xfsstats.xs_stats);
2426  out_kset_unregister:
2427         kset_unregister(xfs_kset);
2428  out_sysctl_unregister:
2429         xfs_sysctl_unregister();
2430  out_cleanup_procfs:
2431         xfs_cleanup_procfs();
2432  out_mru_cache_uninit:
2433         xfs_mru_cache_uninit();
2434  out_destroy_wq:
2435         xfs_destroy_workqueues();
2436  out_destroy_caches:
2437         xfs_destroy_caches();
2438  out_destroy_hp:
2439         xfs_cpu_hotplug_destroy();
2440  out:
2441         return error;
2442 }
2443
2444 STATIC void __exit
2445 exit_xfs_fs(void)
2446 {
2447         xfs_qm_exit();
2448         unregister_filesystem(&xfs_fs_type);
2449 #ifdef DEBUG
2450         xfs_sysfs_del(&xfs_dbg_kobj);
2451 #endif
2452         xfs_sysfs_del(&xfsstats.xs_kobj);
2453         free_percpu(xfsstats.xs_stats);
2454         kset_unregister(xfs_kset);
2455         xfs_sysctl_unregister();
2456         xfs_cleanup_procfs();
2457         xfs_mru_cache_uninit();
2458         xfs_destroy_workqueues();
2459         xfs_destroy_caches();
2460         xfs_uuid_table_free();
2461         xfs_cpu_hotplug_destroy();
2462 }
2463
2464 module_init(init_xfs_fs);
2465 module_exit(exit_xfs_fs);
2466
2467 MODULE_AUTHOR("Silicon Graphics, Inc.");
2468 MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
2469 MODULE_LICENSE("GPL");