57 #include <linux/slab.h>
69 #define MNTOPT_LOGBUFS "logbufs"
70 #define MNTOPT_LOGBSIZE "logbsize"
71 #define MNTOPT_LOGDEV "logdev"
72 #define MNTOPT_RTDEV "rtdev"
73 #define MNTOPT_BIOSIZE "biosize"
74 #define MNTOPT_WSYNC "wsync"
75 #define MNTOPT_NOALIGN "noalign"
76 #define MNTOPT_SWALLOC "swalloc"
77 #define MNTOPT_SUNIT "sunit"
78 #define MNTOPT_SWIDTH "swidth"
79 #define MNTOPT_NOUUID "nouuid"
80 #define MNTOPT_MTPT "mtpt"
81 #define MNTOPT_GRPID "grpid"
82 #define MNTOPT_NOGRPID "nogrpid"
83 #define MNTOPT_BSDGROUPS "bsdgroups"
84 #define MNTOPT_SYSVGROUPS "sysvgroups"
85 #define MNTOPT_ALLOCSIZE "allocsize"
86 #define MNTOPT_NORECOVERY "norecovery"
87 #define MNTOPT_BARRIER "barrier"
89 #define MNTOPT_NOBARRIER "nobarrier"
90 #define MNTOPT_64BITINODE "inode64"
91 #define MNTOPT_32BITINODE "inode32"
93 #define MNTOPT_IKEEP "ikeep"
94 #define MNTOPT_NOIKEEP "noikeep"
95 #define MNTOPT_LARGEIO "largeio"
96 #define MNTOPT_NOLARGEIO "nolargeio"
98 #define MNTOPT_ATTR2 "attr2"
99 #define MNTOPT_NOATTR2 "noattr2"
100 #define MNTOPT_FILESTREAM "filestreams"
101 #define MNTOPT_QUOTA "quota"
102 #define MNTOPT_NOQUOTA "noquota"
103 #define MNTOPT_USRQUOTA "usrquota"
104 #define MNTOPT_GRPQUOTA "grpquota"
105 #define MNTOPT_PRJQUOTA "prjquota"
106 #define MNTOPT_UQUOTA "uquota"
107 #define MNTOPT_GQUOTA "gquota"
108 #define MNTOPT_PQUOTA "pquota"
109 #define MNTOPT_UQUOTANOENF "uqnoenforce"
110 #define MNTOPT_GQUOTANOENF "gqnoenforce"
111 #define MNTOPT_PQUOTANOENF "pqnoenforce"
112 #define MNTOPT_QUOTANOENF "qnoenforce"
113 #define MNTOPT_DELAYLOG "delaylog"
114 #define MNTOPT_NODELAYLOG "nodelaylog"
115 #define MNTOPT_DISCARD "discard"
116 #define MNTOPT_NODISCARD "nodiscard"
144 int last, shift_left_factor = 0;
148 if (value[last] ==
'K' || value[last] ==
'k') {
149 shift_left_factor = 10;
152 if (value[last] ==
'M' || value[last] ==
'm') {
153 shift_left_factor = 20;
156 if (value[last] ==
'G' || value[last] ==
'g') {
157 shift_left_factor = 30;
161 return simple_strtoul((
const char *)s, endp, base) << shift_left_factor;
173 struct xfs_mount *
mp,
177 char *this_char, *
value, *eov;
181 __uint8_t iosizelog = 0;
190 mp->m_fsname_len =
strlen(mp->m_fsname) + 1;
196 mp->m_flags |= XFS_MOUNT_RDONLY;
198 mp->m_flags |= XFS_MOUNT_DIRSYNC;
200 mp->m_flags |= XFS_MOUNT_WSYNC;
206 mp->m_flags |= XFS_MOUNT_BARRIER;
207 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
209 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
221 while ((this_char =
strsep(&options,
",")) !=
NULL) {
228 if (!value || !*value) {
229 xfs_warn(mp,
"%s option requires an argument",
235 if (!value || !*value) {
236 xfs_warn(mp,
"%s option requires an argument",
242 if (!value || !*value) {
243 xfs_warn(mp,
"%s option requires an argument",
251 xfs_warn(mp,
"%s option not allowed on this system",
255 if (!value || !*value) {
256 xfs_warn(mp,
"%s option requires an argument",
264 if (!value || !*value) {
265 xfs_warn(mp,
"%s option requires an argument",
270 iosizelog =
ffs(iosize) - 1;
272 if (!value || !*value) {
273 xfs_warn(mp,
"%s option requires an argument",
278 iosizelog =
ffs(iosize) - 1;
281 mp->m_flags |= XFS_MOUNT_GRPID;
284 mp->m_flags &= ~XFS_MOUNT_GRPID;
286 mp->m_flags |= XFS_MOUNT_WSYNC;
288 mp->m_flags |= XFS_MOUNT_NORECOVERY;
290 mp->m_flags |= XFS_MOUNT_NOALIGN;
292 mp->m_flags |= XFS_MOUNT_SWALLOC;
294 if (!value || !*value) {
295 xfs_warn(mp,
"%s option requires an argument",
301 if (!value || !*value) {
302 xfs_warn(mp,
"%s option requires an argument",
308 mp->m_flags |= XFS_MOUNT_SMALL_INUMS;
310 mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS;
312 xfs_warn(mp,
"%s option not allowed on this system",
317 mp->m_flags |= XFS_MOUNT_NOUUID;
319 mp->m_flags |= XFS_MOUNT_BARRIER;
321 mp->m_flags &= ~XFS_MOUNT_BARRIER;
323 mp->m_flags |= XFS_MOUNT_IKEEP;
325 mp->m_flags &= ~XFS_MOUNT_IKEEP;
327 mp->m_flags &= ~XFS_MOUNT_COMPAT_IOSIZE;
329 mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
331 mp->m_flags |= XFS_MOUNT_ATTR2;
333 mp->m_flags &= ~XFS_MOUNT_ATTR2;
334 mp->m_flags |= XFS_MOUNT_NOATTR2;
336 mp->m_flags |= XFS_MOUNT_FILESTREAMS;
366 "delaylog is the default now, option is deprecated.");
369 "nodelaylog support has been removed, option is deprecated.");
371 mp->m_flags |= XFS_MOUNT_DISCARD;
373 mp->m_flags &= ~XFS_MOUNT_DISCARD;
374 }
else if (!
strcmp(this_char,
"ihashsize")) {
376 "ihashsize no longer used, option is deprecated.");
377 }
else if (!
strcmp(this_char,
"osyncisdsync")) {
379 "osyncisdsync has no effect, option is deprecated.");
380 }
else if (!
strcmp(this_char,
"osyncisosync")) {
382 "osyncisosync has no effect, option is deprecated.");
383 }
else if (!
strcmp(this_char,
"irixsgid")) {
385 "irixsgid is now a sysctl(2) variable, option is deprecated.");
387 xfs_warn(mp,
"unknown mount option [%s].", this_char);
395 if ((mp->m_flags & XFS_MOUNT_NORECOVERY) &&
396 !(mp->m_flags & XFS_MOUNT_RDONLY)) {
397 xfs_warn(mp,
"no-recovery mounts must be read-only.");
401 if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) {
403 "sunit and swidth options incompatible with the noalign option");
407 #ifndef CONFIG_XFS_QUOTA
409 xfs_warn(mp,
"quota support not available in this kernel.");
416 xfs_warn(mp,
"cannot mount with both project and group quota");
420 if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
421 xfs_warn(mp,
"sunit and swidth must be specified together");
425 if (dsunit && (dswidth % dsunit != 0)) {
427 "stripe width (%d) must be a multiple of the stripe unit (%d)",
433 if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) {
441 mp->m_dalign = dsunit;
442 mp->m_flags |= XFS_MOUNT_RETERR;
446 mp->m_swidth = dswidth;
449 if (mp->m_logbufs != -1 &&
450 mp->m_logbufs != 0 &&
453 xfs_warn(mp,
"invalid logbufs value: %d [not %d-%d]",
457 if (mp->m_logbsize != -1 &&
458 mp->m_logbsize != 0 &&
463 "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]",
469 if (iosizelog > XFS_MAX_IO_LOG ||
470 iosizelog < XFS_MIN_IO_LOG) {
471 xfs_warn(mp,
"invalid log iosize: %d [not %d-%d]",
472 iosizelog, XFS_MIN_IO_LOG,
477 mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE;
478 mp->m_readio_log = iosizelog;
479 mp->m_writeio_log = iosizelog;
492 struct xfs_mount *
mp,
519 for (xfs_infop = xfs_info_set; xfs_infop->
flag; xfs_infop++) {
520 if (mp->m_flags & xfs_infop->
flag)
523 for (xfs_infop = xfs_info_unset; xfs_infop->
flag; xfs_infop++) {
524 if (!(mp->m_flags & xfs_infop->
flag))
528 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
530 (
int)(1 << mp->m_writeio_log) >> 10);
532 if (mp->m_logbufs > 0)
534 if (mp->m_logbsize > 0)
542 if (mp->m_dalign > 0)
545 if (mp->m_swidth > 0)
575 unsigned int blockshift)
577 unsigned int pagefactor = 1;
594 #if BITS_PER_LONG == 32
595 # if defined(CONFIG_LBDAF)
604 return (((__uint64_t)pagefactor) << bitshift) - 1;
621 if (mp->m_maxicount) {
628 max_metadata = icount;
633 for (index = 0; index < sbp->
sb_agcount; index++) {
647 if (index < max_metadata)
651 mp->m_flags |= (XFS_MOUNT_32BITINODES |
652 XFS_MOUNT_SMALL_INUMS);
662 for (index = 0; index < mp->m_sb.sb_agcount; index++) {
676 mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
677 XFS_MOUNT_SMALL_INUMS);
691 if (IS_ERR(*bdevp)) {
692 error = PTR_ERR(*bdevp);
693 xfs_warn(mp,
"Invalid device [%s], error=%d\n", name, error);
716 struct xfs_mount *mp)
718 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
719 struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
723 if (mp->m_rtdev_targp) {
724 struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev;
743 struct xfs_mount *mp)
761 goto out_close_logdev;
763 if (rtdev == ddev || rtdev == logdev) {
765 "Cannot mount filesystem with identical rtdev and ddev/logdev.");
767 goto out_close_rtdev;
776 if (!mp->m_ddev_targp)
777 goto out_close_rtdev;
782 if (!mp->m_rtdev_targp)
783 goto out_free_ddev_targ;
786 if (logdev && logdev != ddev) {
789 if (!mp->m_logdev_targp)
790 goto out_free_rtdev_targ;
792 mp->m_logdev_targp = mp->m_ddev_targp;
798 if (mp->m_rtdev_targp)
806 if (logdev && logdev != ddev)
817 struct xfs_mount *mp)
822 mp->m_sb.sb_sectsize);
826 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
827 unsigned int log_sector_size =
BBSIZE;
829 if (xfs_sb_version_hassector(&mp->m_sb))
830 log_sector_size = mp->m_sb.sb_logsectsize;
832 mp->m_sb.sb_blocksize,
837 if (mp->m_rtdev_targp) {
839 mp->m_sb.sb_blocksize,
840 mp->m_sb.sb_sectsize);
850 struct xfs_mount *mp)
854 if (!mp->m_data_workqueue)
859 if (!mp->m_unwritten_workqueue)
860 goto out_destroy_data_iodone_queue;
864 if (!mp->m_cil_workqueue)
865 goto out_destroy_unwritten;
868 out_destroy_unwritten:
870 out_destroy_data_iodone_queue:
878 struct xfs_mount *mp)
902 struct xfs_inode *
ip = XFS_I(inode);
904 trace_xfs_destroy_inode(ip);
912 ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);
945 memset(ip, 0,
sizeof(
struct xfs_inode));
954 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
955 "xfsino", ip->i_ino);
962 xfs_inode_t *
ip = XFS_I(inode);
966 trace_xfs_evict_inode(ip);
988 struct xfs_inode *
ip = XFS_I(inode);
990 return generic_drop_inode(inode) || (ip->i_flags & XFS_IDONTCACHE);
995 struct xfs_mount *mp)
999 kfree(mp->m_logname);
1006 struct xfs_mount *mp =
XFS_M(sb);
1013 xfs_icsb_destroy_counters(mp);
1025 struct xfs_mount *mp =
XFS_M(sb);
1055 struct xfs_mount *mp =
XFS_M(dentry->
d_sb);
1057 struct xfs_inode *
ip = XFS_I(dentry->
d_inode);
1058 __uint64_t fakeinos,
id;
1065 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
1069 xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
1071 spin_lock(&mp->m_sb_lock);
1080 if (mp->m_maxicount)
1089 spin_unlock(&mp->m_sb_lock);
1101 __uint64_t resblks = 0;
1103 mp->m_resblks_save = mp->m_resblks;
1112 if (mp->m_resblks_save) {
1113 resblks = mp->m_resblks_save;
1114 mp->m_resblks_save = 0;
1127 struct xfs_mount *mp =
XFS_M(sb);
1132 while ((p =
strsep(&options,
",")) !=
NULL) {
1141 mp->m_flags |= XFS_MOUNT_BARRIER;
1144 mp->m_flags &= ~XFS_MOUNT_BARRIER;
1171 "mount option \"%s\" not supported for remount\n", p);
1180 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags &
MS_RDONLY)) {
1181 mp->m_flags &= ~XFS_MOUNT_RDONLY;
1187 if (mp->m_update_flags) {
1190 xfs_warn(mp,
"failed to write sb changes");
1193 mp->m_update_flags = 0;
1204 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
1217 mp->m_flags |= XFS_MOUNT_RDONLY;
1232 struct xfs_mount *mp =
XFS_M(sb);
1243 struct xfs_mount *mp =
XFS_M(sb);
1263 struct xfs_mount *mp)
1265 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
1268 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
1269 if (mp->m_logbsize <= 0 &&
1271 mp->m_logbsize = mp->m_sb.sb_logsunit;
1272 }
else if (mp->m_logbsize > 0 &&
1273 mp->m_logbsize < mp->m_sb.sb_logsunit) {
1275 "logbuf size must be greater than or equal to log stripe size");
1282 "logbuf size for version 1 logs must be 16K or 32K");
1291 if (xfs_sb_version_hasattr2(&mp->m_sb) &&
1292 !(mp->m_flags & XFS_MOUNT_NOATTR2))
1293 mp->m_flags |= XFS_MOUNT_ATTR2;
1300 "cannot mount a read-only filesystem as read-write");
1314 struct xfs_mount *mp =
NULL;
1315 int flags = 0, error =
ENOMEM;
1317 mp = kzalloc(
sizeof(
struct xfs_mount),
GFP_KERNEL);
1330 goto out_free_fsname;
1335 #ifdef CONFIG_XFS_QUOTA
1338 sb->
s_op = &xfs_super_operations;
1341 flags |= XFS_MFSI_QUIET;
1345 goto out_free_fsname;
1349 goto out_close_devices;
1351 error = xfs_icsb_init_counters(mp);
1353 goto out_destroy_workqueues;
1357 goto out_destroy_counters;
1389 goto out_filestream_unmount;
1393 goto out_syncd_stop;
1395 root =
igrab(VFS_I(mp->m_rootip));
1413 out_filestream_unmount:
1417 out_destroy_counters:
1418 xfs_icsb_destroy_counters(mp);
1419 out_destroy_workqueues:
1440 const char *dev_name,
1447 xfs_fs_nr_cached_objects(
1454 xfs_fs_free_cached_objects(
1473 .nr_cached_objects = xfs_fs_nr_cached_objects,
1474 .free_cached_objects = xfs_fs_free_cached_objects,
1489 xfs_ioend_zone = kmem_zone_init(
sizeof(
xfs_ioend_t),
"xfs_ioend");
1490 if (!xfs_ioend_zone)
1493 xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
1495 if (!xfs_ioend_pool)
1496 goto out_destroy_ioend_zone;
1501 goto out_destroy_ioend_pool;
1504 "xfs_bmap_free_item");
1506 goto out_destroy_log_ticket_zone;
1511 goto out_destroy_bmap_free_item_zone;
1516 goto out_destroy_btree_cur_zone;
1520 goto out_destroy_da_state_zone;
1522 xfs_trans_zone = kmem_zone_init(
sizeof(xfs_trans_t),
"xfs_trans");
1524 goto out_destroy_ifork_zone;
1528 "xfs_log_item_desc");
1530 goto out_destroy_trans_zone;
1540 goto out_destroy_log_item_desc_zone;
1542 xfs_efd_zone = kmem_zone_init((
sizeof(xfs_efd_log_item_t) +
1543 ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
1546 goto out_destroy_buf_item_zone;
1548 xfs_efi_zone = kmem_zone_init((
sizeof(xfs_efi_log_item_t) +
1549 ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
1552 goto out_destroy_efd_zone;
1555 kmem_zone_init_flags(
sizeof(xfs_inode_t),
"xfs_inode",
1559 goto out_destroy_efi_zone;
1562 kmem_zone_init_flags(
sizeof(xfs_inode_log_item_t),
"xfs_ili",
1565 goto out_destroy_inode_zone;
1569 out_destroy_inode_zone:
1571 out_destroy_efi_zone:
1573 out_destroy_efd_zone:
1575 out_destroy_buf_item_zone:
1577 out_destroy_log_item_desc_zone:
1579 out_destroy_trans_zone:
1581 out_destroy_ifork_zone:
1583 out_destroy_da_state_zone:
1585 out_destroy_btree_cur_zone:
1587 out_destroy_bmap_free_item_zone:
1589 out_destroy_log_ticket_zone:
1591 out_destroy_ioend_pool:
1593 out_destroy_ioend_zone:
1594 kmem_zone_destroy(xfs_ioend_zone);
1620 kmem_zone_destroy(xfs_ioend_zone);
1645 goto out_destroy_syncd;
1677 goto out_destroy_zones;
1681 goto out_destroy_wq;
1685 goto out_mru_cache_uninit;
1689 goto out_filestream_uninit;
1693 goto out_buf_terminate;
1697 goto out_cleanup_procfs;
1701 goto out_sysctl_unregister;
1710 out_sysctl_unregister:
1716 out_filestream_uninit:
1718 out_mru_cache_uninit: