Lines Matching +full:sc +full:- +full:partitions

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
54 static struct dentry *xfs_debugfs; /* top-level xfs debugfs dir */
55 static struct kset *xfs_kset; /* top-level xfs sysfs dir */
73 mp->m_features &= ~(XFS_FEAT_DAX_ALWAYS | XFS_FEAT_DAX_NEVER); in xfs_mount_set_dax_mode()
76 mp->m_features |= XFS_FEAT_DAX_ALWAYS; in xfs_mount_set_dax_mode()
77 mp->m_features &= ~XFS_FEAT_DAX_NEVER; in xfs_mount_set_dax_mode()
80 mp->m_features |= XFS_FEAT_DAX_NEVER; in xfs_mount_set_dax_mode()
81 mp->m_features &= ~XFS_FEAT_DAX_ALWAYS; in xfs_mount_set_dax_mode()
180 struct xfs_mount *mp = XFS_M(root->d_sb); in xfs_fs_show_options()
183 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) { in xfs_fs_show_options()
184 if (mp->m_features & xfs_infop->flag) in xfs_fs_show_options()
185 seq_puts(m, xfs_infop->str); in xfs_fs_show_options()
192 (1 << mp->m_allocsize_log) >> 10); in xfs_fs_show_options()
194 if (mp->m_logbufs > 0) in xfs_fs_show_options()
195 seq_printf(m, ",logbufs=%d", mp->m_logbufs); in xfs_fs_show_options()
196 if (mp->m_logbsize > 0) in xfs_fs_show_options()
197 seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10); in xfs_fs_show_options()
199 if (mp->m_logname) in xfs_fs_show_options()
200 seq_show_option(m, "logdev", mp->m_logname); in xfs_fs_show_options()
201 if (mp->m_rtname) in xfs_fs_show_options()
202 seq_show_option(m, "rtdev", mp->m_rtname); in xfs_fs_show_options()
204 if (mp->m_dalign > 0) in xfs_fs_show_options()
206 (int)XFS_FSB_TO_BB(mp, mp->m_dalign)); in xfs_fs_show_options()
207 if (mp->m_swidth > 0) in xfs_fs_show_options()
209 (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); in xfs_fs_show_options()
211 if (mp->m_qflags & XFS_UQUOTA_ENFD) in xfs_fs_show_options()
213 else if (mp->m_qflags & XFS_UQUOTA_ACCT) in xfs_fs_show_options()
216 if (mp->m_qflags & XFS_PQUOTA_ENFD) in xfs_fs_show_options()
218 else if (mp->m_qflags & XFS_PQUOTA_ACCT) in xfs_fs_show_options()
221 if (mp->m_qflags & XFS_GQUOTA_ENFD) in xfs_fs_show_options()
223 else if (mp->m_qflags & XFS_GQUOTA_ACCT) in xfs_fs_show_options()
226 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) in xfs_fs_show_options()
238 if (!xfs_is_inode32(pag->pag_mount)) { in xfs_set_inode_alloc_perag()
239 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
240 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
245 clear_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
246 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
250 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
251 if (pag->pag_agno < max_metadata) in xfs_set_inode_alloc_perag()
252 set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
254 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
268 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
280 xfs_sb_t *sbp = &mp->m_sb; in xfs_set_inode_alloc()
289 if (M_IGEO(mp)->maxicount) { in xfs_set_inode_alloc()
292 icount = sbp->sb_dblocks * sbp->sb_imax_pct; in xfs_set_inode_alloc()
294 icount += sbp->sb_agblocks - 1; in xfs_set_inode_alloc()
295 do_div(icount, sbp->sb_agblocks); in xfs_set_inode_alloc()
302 agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1); in xfs_set_inode_alloc()
303 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino); in xfs_set_inode_alloc()
306 * If user asked for no more than 32-bit inodes, and the fs is in xfs_set_inode_alloc()
311 set_bit(XFS_OPSTATE_INODE32, &mp->m_opstate); in xfs_set_inode_alloc()
313 clear_bit(XFS_OPSTATE_INODE32, &mp->m_opstate); in xfs_set_inode_alloc()
333 if (!mp->m_ddev_targp->bt_daxdev && in xfs_setup_dax_always()
334 (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) { in xfs_setup_dax_always()
340 if (mp->m_super->s_blocksize != PAGE_SIZE) { in xfs_setup_dax_always()
347 bdev_is_partition(mp->m_ddev_targp->bt_bdev)) { in xfs_setup_dax_always()
349 "DAX and reflink cannot work with multi-partitions!"); in xfs_setup_dax_always()
350 return -EINVAL; in xfs_setup_dax_always()
370 mp->m_super, &fs_holder_ops); in xfs_blkdev_get()
410 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { in xfs_shutdown_devices()
411 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev); in xfs_shutdown_devices()
412 invalidate_bdev(mp->m_logdev_targp->bt_bdev); in xfs_shutdown_devices()
414 if (mp->m_rtdev_targp) { in xfs_shutdown_devices()
415 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev); in xfs_shutdown_devices()
416 invalidate_bdev(mp->m_rtdev_targp->bt_bdev); in xfs_shutdown_devices()
418 blkdev_issue_flush(mp->m_ddev_targp->bt_bdev); in xfs_shutdown_devices()
419 invalidate_bdev(mp->m_ddev_targp->bt_bdev); in xfs_shutdown_devices()
430 * get_sb_bdev() and is stored in sb->s_bdev.
436 struct super_block *sb = mp->m_super; in xfs_open_devices()
437 struct block_device *ddev = sb->s_bdev; in xfs_open_devices()
442 * Open real time and log devices - order is important. in xfs_open_devices()
444 if (mp->m_logname) { in xfs_open_devices()
445 error = xfs_blkdev_get(mp, mp->m_logname, &logdev_handle); in xfs_open_devices()
450 if (mp->m_rtname) { in xfs_open_devices()
451 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev_handle); in xfs_open_devices()
455 if (rtdev_handle->bdev == ddev || in xfs_open_devices()
457 rtdev_handle->bdev == logdev_handle->bdev)) { in xfs_open_devices()
460 error = -EINVAL; in xfs_open_devices()
468 error = -ENOMEM; in xfs_open_devices()
469 mp->m_ddev_targp = xfs_alloc_buftarg(mp, sb->s_bdev_handle); in xfs_open_devices()
470 if (!mp->m_ddev_targp) in xfs_open_devices()
474 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev_handle); in xfs_open_devices()
475 if (!mp->m_rtdev_targp) in xfs_open_devices()
479 if (logdev_handle && logdev_handle->bdev != ddev) { in xfs_open_devices()
480 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev_handle); in xfs_open_devices()
481 if (!mp->m_logdev_targp) in xfs_open_devices()
484 mp->m_logdev_targp = mp->m_ddev_targp; in xfs_open_devices()
493 if (mp->m_rtdev_targp) in xfs_open_devices()
494 xfs_free_buftarg(mp->m_rtdev_targp); in xfs_open_devices()
496 xfs_free_buftarg(mp->m_ddev_targp); in xfs_open_devices()
515 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize); in xfs_setup_devices()
519 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { in xfs_setup_devices()
523 log_sector_size = mp->m_sb.sb_logsectsize; in xfs_setup_devices()
524 error = xfs_setsize_buftarg(mp->m_logdev_targp, in xfs_setup_devices()
529 if (mp->m_rtdev_targp) { in xfs_setup_devices()
530 error = xfs_setsize_buftarg(mp->m_rtdev_targp, in xfs_setup_devices()
531 mp->m_sb.sb_sectsize); in xfs_setup_devices()
543 mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s", in xfs_init_mount_workqueues()
545 1, mp->m_super->s_id); in xfs_init_mount_workqueues()
546 if (!mp->m_buf_workqueue) in xfs_init_mount_workqueues()
549 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", in xfs_init_mount_workqueues()
551 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
552 if (!mp->m_unwritten_workqueue) in xfs_init_mount_workqueues()
555 mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s", in xfs_init_mount_workqueues()
557 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
558 if (!mp->m_reclaim_workqueue) in xfs_init_mount_workqueues()
561 mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s", in xfs_init_mount_workqueues()
563 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
564 if (!mp->m_blockgc_wq) in xfs_init_mount_workqueues()
567 mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s", in xfs_init_mount_workqueues()
569 1, mp->m_super->s_id); in xfs_init_mount_workqueues()
570 if (!mp->m_inodegc_wq) in xfs_init_mount_workqueues()
573 mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s", in xfs_init_mount_workqueues()
574 XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
575 if (!mp->m_sync_workqueue) in xfs_init_mount_workqueues()
581 destroy_workqueue(mp->m_inodegc_wq); in xfs_init_mount_workqueues()
583 destroy_workqueue(mp->m_blockgc_wq); in xfs_init_mount_workqueues()
585 destroy_workqueue(mp->m_reclaim_workqueue); in xfs_init_mount_workqueues()
587 destroy_workqueue(mp->m_unwritten_workqueue); in xfs_init_mount_workqueues()
589 destroy_workqueue(mp->m_buf_workqueue); in xfs_init_mount_workqueues()
591 return -ENOMEM; in xfs_init_mount_workqueues()
598 destroy_workqueue(mp->m_sync_workqueue); in xfs_destroy_mount_workqueues()
599 destroy_workqueue(mp->m_blockgc_wq); in xfs_destroy_mount_workqueues()
600 destroy_workqueue(mp->m_inodegc_wq); in xfs_destroy_mount_workqueues()
601 destroy_workqueue(mp->m_reclaim_workqueue); in xfs_destroy_mount_workqueues()
602 destroy_workqueue(mp->m_unwritten_workqueue); in xfs_destroy_mount_workqueues()
603 destroy_workqueue(mp->m_buf_workqueue); in xfs_destroy_mount_workqueues()
612 struct super_block *sb = mp->m_super; in xfs_flush_inodes_worker()
614 if (down_read_trylock(&sb->s_umount)) { in xfs_flush_inodes_worker()
616 up_read(&sb->s_umount); in xfs_flush_inodes_worker()
634 if (flush_work(&mp->m_flush_inodes_work)) in xfs_flush_inodes()
637 queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work); in xfs_flush_inodes()
638 flush_work(&mp->m_flush_inodes_work); in xfs_flush_inodes()
662 ASSERT(!rwsem_is_locked(&inode->i_rwsem)); in xfs_fs_destroy_inode()
663 XFS_STATS_INC(ip->i_mount, vn_rele); in xfs_fs_destroy_inode()
664 XFS_STATS_INC(ip->i_mount, vn_remove); in xfs_fs_destroy_inode()
674 struct xfs_mount *mp = ip->i_mount; in xfs_fs_dirty_inode()
677 if (!(inode->i_sb->s_flags & SB_LAZYTIME)) in xfs_fs_dirty_inode()
688 if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp)) in xfs_fs_dirty_inode()
716 atomic_set(&ip->i_pincount, 0); in xfs_fs_inode_init_once()
717 spin_lock_init(&ip->i_flags_lock); in xfs_fs_inode_init_once()
719 mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER, in xfs_fs_inode_init_once()
720 "xfsino", ip->i_ino); in xfs_fs_inode_init_once()
725 * serialised against cache hits here via the inode->i_lock and igrab() in
741 if (ip->i_flags & XFS_IRECOVERY) { in xfs_fs_drop_inode()
742 ASSERT(xlog_recovery_needed(ip->i_mount->m_log)); in xfs_fs_drop_inode()
753 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) in xfs_mount_free()
754 xfs_free_buftarg(mp->m_logdev_targp); in xfs_mount_free()
755 if (mp->m_rtdev_targp) in xfs_mount_free()
756 xfs_free_buftarg(mp->m_rtdev_targp); in xfs_mount_free()
757 if (mp->m_ddev_targp) in xfs_mount_free()
758 xfs_free_buftarg(mp->m_ddev_targp); in xfs_mount_free()
760 debugfs_remove(mp->m_debugfs); in xfs_mount_free()
761 kfree(mp->m_rtname); in xfs_mount_free()
762 kfree(mp->m_logname); in xfs_mount_free()
792 flush_delayed_work(&mp->m_log->l_work); in xfs_fs_sync_fs()
805 * freeze that does this - we can run this multiple times without issue in xfs_fs_sync_fs()
809 if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) { in xfs_fs_sync_fs()
822 struct xfs_mount *mp = XFS_M(dentry->d_sb); in xfs_fs_statfs()
823 xfs_sb_t *sbp = &mp->m_sb; in xfs_fs_statfs()
838 statp->f_type = XFS_SUPER_MAGIC; in xfs_fs_statfs()
839 statp->f_namelen = MAXNAMELEN - 1; in xfs_fs_statfs()
841 id = huge_encode_dev(mp->m_ddev_targp->bt_dev); in xfs_fs_statfs()
842 statp->f_fsid = u64_to_fsid(id); in xfs_fs_statfs()
844 icount = percpu_counter_sum(&mp->m_icount); in xfs_fs_statfs()
845 ifree = percpu_counter_sum(&mp->m_ifree); in xfs_fs_statfs()
846 fdblocks = percpu_counter_sum(&mp->m_fdblocks); in xfs_fs_statfs()
848 spin_lock(&mp->m_sb_lock); in xfs_fs_statfs()
849 statp->f_bsize = sbp->sb_blocksize; in xfs_fs_statfs()
850 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0; in xfs_fs_statfs()
851 statp->f_blocks = sbp->sb_dblocks - lsize; in xfs_fs_statfs()
852 spin_unlock(&mp->m_sb_lock); in xfs_fs_statfs()
854 /* make sure statp->f_bfree does not underflow */ in xfs_fs_statfs()
855 statp->f_bfree = max_t(int64_t, 0, in xfs_fs_statfs()
856 fdblocks - xfs_fdblocks_unavailable(mp)); in xfs_fs_statfs()
857 statp->f_bavail = statp->f_bfree; in xfs_fs_statfs()
859 fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree); in xfs_fs_statfs()
860 statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER); in xfs_fs_statfs()
861 if (M_IGEO(mp)->maxicount) in xfs_fs_statfs()
862 statp->f_files = min_t(typeof(statp->f_files), in xfs_fs_statfs()
863 statp->f_files, in xfs_fs_statfs()
864 M_IGEO(mp)->maxicount); in xfs_fs_statfs()
867 statp->f_files = max_t(typeof(statp->f_files), in xfs_fs_statfs()
868 statp->f_files, in xfs_fs_statfs()
869 sbp->sb_icount); in xfs_fs_statfs()
871 /* make sure statp->f_ffree does not underflow */ in xfs_fs_statfs()
872 ffree = statp->f_files - (icount - ifree); in xfs_fs_statfs()
873 statp->f_ffree = max_t(int64_t, ffree, 0); in xfs_fs_statfs()
876 if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) && in xfs_fs_statfs()
877 ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == in xfs_fs_statfs()
882 (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) { in xfs_fs_statfs()
885 statp->f_blocks = sbp->sb_rblocks; in xfs_fs_statfs()
886 freertx = percpu_counter_sum_positive(&mp->m_frextents); in xfs_fs_statfs()
887 statp->f_bavail = statp->f_bfree = xfs_rtx_to_rtb(mp, freertx); in xfs_fs_statfs()
896 mp->m_resblks_save = mp->m_resblks; in xfs_save_resvblks()
905 if (mp->m_resblks_save) { in xfs_restore_resvblks()
906 resblks = mp->m_resblks_save; in xfs_restore_resvblks()
907 mp->m_resblks_save = 0; in xfs_restore_resvblks()
939 * For read-write filesystems, we need to restart the inodegc on error in xfs_fs_freeze()
986 if (mp->m_logbsize <= 0 && in xfs_finish_flags()
987 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) { in xfs_finish_flags()
988 mp->m_logbsize = mp->m_sb.sb_logsunit; in xfs_finish_flags()
989 } else if (mp->m_logbsize > 0 && in xfs_finish_flags()
990 mp->m_logbsize < mp->m_sb.sb_logsunit) { in xfs_finish_flags()
993 return -EINVAL; in xfs_finish_flags()
997 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { in xfs_finish_flags()
1000 return -EINVAL; in xfs_finish_flags()
1010 return -EINVAL; in xfs_finish_flags()
1014 * prohibit r/w mounts of read-only filesystems in xfs_finish_flags()
1016 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) { in xfs_finish_flags()
1018 "cannot mount a read-only filesystem as read-write"); in xfs_finish_flags()
1019 return -EROFS; in xfs_finish_flags()
1022 if ((mp->m_qflags & XFS_GQUOTA_ACCT) && in xfs_finish_flags()
1023 (mp->m_qflags & XFS_PQUOTA_ACCT) && in xfs_finish_flags()
1027 return -EINVAL; in xfs_finish_flags()
1039 error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1041 return -ENOMEM; in xfs_init_percpu_counters()
1043 error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1047 error = percpu_counter_init(&mp->m_fdblocks, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1051 error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1055 error = percpu_counter_init(&mp->m_frextents, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1062 percpu_counter_destroy(&mp->m_delalloc_blks); in xfs_init_percpu_counters()
1064 percpu_counter_destroy(&mp->m_fdblocks); in xfs_init_percpu_counters()
1066 percpu_counter_destroy(&mp->m_ifree); in xfs_init_percpu_counters()
1068 percpu_counter_destroy(&mp->m_icount); in xfs_init_percpu_counters()
1069 return -ENOMEM; in xfs_init_percpu_counters()
1076 percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount); in xfs_reinit_percpu_counters()
1077 percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree); in xfs_reinit_percpu_counters()
1078 percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks); in xfs_reinit_percpu_counters()
1079 percpu_counter_set(&mp->m_frextents, mp->m_sb.sb_frextents); in xfs_reinit_percpu_counters()
1086 percpu_counter_destroy(&mp->m_icount); in xfs_destroy_percpu_counters()
1087 percpu_counter_destroy(&mp->m_ifree); in xfs_destroy_percpu_counters()
1088 percpu_counter_destroy(&mp->m_fdblocks); in xfs_destroy_percpu_counters()
1090 percpu_counter_sum(&mp->m_delalloc_blks) == 0); in xfs_destroy_percpu_counters()
1091 percpu_counter_destroy(&mp->m_delalloc_blks); in xfs_destroy_percpu_counters()
1092 percpu_counter_destroy(&mp->m_frextents); in xfs_destroy_percpu_counters()
1102 mp->m_inodegc = alloc_percpu(struct xfs_inodegc); in xfs_inodegc_init_percpu()
1103 if (!mp->m_inodegc) in xfs_inodegc_init_percpu()
1104 return -ENOMEM; in xfs_inodegc_init_percpu()
1107 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_init_percpu()
1108 gc->cpu = cpu; in xfs_inodegc_init_percpu()
1109 gc->mp = mp; in xfs_inodegc_init_percpu()
1110 init_llist_head(&gc->list); in xfs_inodegc_init_percpu()
1111 gc->items = 0; in xfs_inodegc_init_percpu()
1112 gc->error = 0; in xfs_inodegc_init_percpu()
1113 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker); in xfs_inodegc_init_percpu()
1122 if (!mp->m_inodegc) in xfs_inodegc_free_percpu()
1124 free_percpu(mp->m_inodegc); in xfs_inodegc_free_percpu()
1133 xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid); in xfs_fs_put_super()
1139 free_percpu(mp->m_stats.xs_stats); in xfs_fs_put_super()
1149 struct shrink_control *sc) in xfs_fs_nr_cached_objects() argument
1152 if (WARN_ON_ONCE(!sb->s_fs_info)) in xfs_fs_nr_cached_objects()
1160 struct shrink_control *sc) in xfs_fs_free_cached_objects() argument
1162 return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan); in xfs_fs_free_cached_objects()
1200 return -ENOMEM; in suffix_kstrtoint()
1202 last = strlen(value) - 1; in suffix_kstrtoint()
1217 ret = -EINVAL; in suffix_kstrtoint()
1233 if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) && in xfs_fs_warn_deprecated()
1234 !!(XFS_M(fc->root->d_sb)->m_features & flag) == value) in xfs_fs_warn_deprecated()
1236 xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key); in xfs_fs_warn_deprecated()
1242 * NOTE: mp->m_super is NULL here!
1249 struct xfs_mount *parsing_mp = fc->s_fs_info; in xfs_fs_parse_param()
1260 parsing_mp->m_logbufs = result.uint_32; in xfs_fs_parse_param()
1263 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize)) in xfs_fs_parse_param()
1264 return -EINVAL; in xfs_fs_parse_param()
1267 kfree(parsing_mp->m_logname); in xfs_fs_parse_param()
1268 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL); in xfs_fs_parse_param()
1269 if (!parsing_mp->m_logname) in xfs_fs_parse_param()
1270 return -ENOMEM; in xfs_fs_parse_param()
1273 kfree(parsing_mp->m_rtname); in xfs_fs_parse_param()
1274 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL); in xfs_fs_parse_param()
1275 if (!parsing_mp->m_rtname) in xfs_fs_parse_param()
1276 return -ENOMEM; in xfs_fs_parse_param()
1279 if (suffix_kstrtoint(param->string, 10, &size)) in xfs_fs_parse_param()
1280 return -EINVAL; in xfs_fs_parse_param()
1281 parsing_mp->m_allocsize_log = ffs(size) - 1; in xfs_fs_parse_param()
1282 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE; in xfs_fs_parse_param()
1286 parsing_mp->m_features |= XFS_FEAT_GRPID; in xfs_fs_parse_param()
1290 parsing_mp->m_features &= ~XFS_FEAT_GRPID; in xfs_fs_parse_param()
1293 parsing_mp->m_features |= XFS_FEAT_WSYNC; in xfs_fs_parse_param()
1296 parsing_mp->m_features |= XFS_FEAT_NORECOVERY; in xfs_fs_parse_param()
1299 parsing_mp->m_features |= XFS_FEAT_NOALIGN; in xfs_fs_parse_param()
1302 parsing_mp->m_features |= XFS_FEAT_SWALLOC; in xfs_fs_parse_param()
1305 parsing_mp->m_dalign = result.uint_32; in xfs_fs_parse_param()
1308 parsing_mp->m_swidth = result.uint_32; in xfs_fs_parse_param()
1311 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS; in xfs_fs_parse_param()
1314 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS; in xfs_fs_parse_param()
1317 parsing_mp->m_features |= XFS_FEAT_NOUUID; in xfs_fs_parse_param()
1320 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE; in xfs_fs_parse_param()
1323 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE; in xfs_fs_parse_param()
1326 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS; in xfs_fs_parse_param()
1329 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; in xfs_fs_parse_param()
1330 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD; in xfs_fs_parse_param()
1335 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD); in xfs_fs_parse_param()
1339 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT; in xfs_fs_parse_param()
1340 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD; in xfs_fs_parse_param()
1344 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD); in xfs_fs_parse_param()
1347 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT; in xfs_fs_parse_param()
1348 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD; in xfs_fs_parse_param()
1352 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD); in xfs_fs_parse_param()
1355 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT; in xfs_fs_parse_param()
1356 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD; in xfs_fs_parse_param()
1359 parsing_mp->m_features |= XFS_FEAT_DISCARD; in xfs_fs_parse_param()
1362 parsing_mp->m_features &= ~XFS_FEAT_DISCARD; in xfs_fs_parse_param()
1375 parsing_mp->m_features |= XFS_FEAT_IKEEP; in xfs_fs_parse_param()
1379 parsing_mp->m_features &= ~XFS_FEAT_IKEEP; in xfs_fs_parse_param()
1383 parsing_mp->m_features |= XFS_FEAT_ATTR2; in xfs_fs_parse_param()
1387 parsing_mp->m_features |= XFS_FEAT_NOATTR2; in xfs_fs_parse_param()
1390 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); in xfs_fs_parse_param()
1391 return -EINVAL; in xfs_fs_parse_param()
1401 /* No recovery flag requires a read-only mount */ in xfs_fs_validate_params()
1403 xfs_warn(mp, "no-recovery mounts must be read-only."); in xfs_fs_validate_params()
1404 return -EINVAL; in xfs_fs_validate_params()
1413 return -EINVAL; in xfs_fs_validate_params()
1417 if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) { in xfs_fs_validate_params()
1420 return -EINVAL; in xfs_fs_validate_params()
1423 if (!IS_ENABLED(CONFIG_XFS_QUOTA) && mp->m_qflags != 0) { in xfs_fs_validate_params()
1425 return -EINVAL; in xfs_fs_validate_params()
1428 if ((mp->m_dalign && !mp->m_swidth) || in xfs_fs_validate_params()
1429 (!mp->m_dalign && mp->m_swidth)) { in xfs_fs_validate_params()
1431 return -EINVAL; in xfs_fs_validate_params()
1434 if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) { in xfs_fs_validate_params()
1437 mp->m_swidth, mp->m_dalign); in xfs_fs_validate_params()
1438 return -EINVAL; in xfs_fs_validate_params()
1441 if (mp->m_logbufs != -1 && in xfs_fs_validate_params()
1442 mp->m_logbufs != 0 && in xfs_fs_validate_params()
1443 (mp->m_logbufs < XLOG_MIN_ICLOGS || in xfs_fs_validate_params()
1444 mp->m_logbufs > XLOG_MAX_ICLOGS)) { in xfs_fs_validate_params()
1445 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", in xfs_fs_validate_params()
1446 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); in xfs_fs_validate_params()
1447 return -EINVAL; in xfs_fs_validate_params()
1450 if (mp->m_logbsize != -1 && in xfs_fs_validate_params()
1451 mp->m_logbsize != 0 && in xfs_fs_validate_params()
1452 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || in xfs_fs_validate_params()
1453 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || in xfs_fs_validate_params()
1454 !is_power_of_2(mp->m_logbsize))) { in xfs_fs_validate_params()
1457 mp->m_logbsize); in xfs_fs_validate_params()
1458 return -EINVAL; in xfs_fs_validate_params()
1462 (mp->m_allocsize_log > XFS_MAX_IO_LOG || in xfs_fs_validate_params()
1463 mp->m_allocsize_log < XFS_MIN_IO_LOG)) { in xfs_fs_validate_params()
1464 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", in xfs_fs_validate_params()
1465 mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG); in xfs_fs_validate_params()
1466 return -EINVAL; in xfs_fs_validate_params()
1492 struct xfs_mount *mp = sb->s_fs_info; in xfs_fs_fill_super()
1496 mp->m_super = sb; in xfs_fs_fill_super()
1503 if (fc->sb_flags & SB_RDONLY) in xfs_fs_fill_super()
1504 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate); in xfs_fs_fill_super()
1505 if (fc->sb_flags & SB_DIRSYNC) in xfs_fs_fill_super()
1506 mp->m_features |= XFS_FEAT_DIRSYNC; in xfs_fs_fill_super()
1507 if (fc->sb_flags & SB_SYNCHRONOUS) in xfs_fs_fill_super()
1508 mp->m_features |= XFS_FEAT_WSYNC; in xfs_fs_fill_super()
1515 sb->s_xattr = xfs_xattr_handlers; in xfs_fs_fill_super()
1516 sb->s_export_op = &xfs_export_operations; in xfs_fs_fill_super()
1518 sb->s_qcop = &xfs_quotactl_operations; in xfs_fs_fill_super()
1519 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; in xfs_fs_fill_super()
1521 sb->s_op = &xfs_super_operations; in xfs_fs_fill_super()
1534 if (fc->sb_flags & SB_SILENT) in xfs_fs_fill_super()
1542 mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id, in xfs_fs_fill_super()
1545 mp->m_debugfs = NULL; in xfs_fs_fill_super()
1561 mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); in xfs_fs_fill_super()
1562 if (!mp->m_stats.xs_stats) { in xfs_fs_fill_super()
1563 error = -ENOMEM; in xfs_fs_fill_super()
1591 error = -EINVAL; in xfs_fs_fill_super()
1600 …"Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 20… in xfs_fs_fill_super()
1603 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel."); in xfs_fs_fill_super()
1604 error = -EINVAL; in xfs_fs_fill_super()
1612 error = -EFSCORRUPTED; in xfs_fs_fill_super()
1621 if (mp->m_sb.sb_inprogress) { in xfs_fs_fill_super()
1623 error = -EFSCORRUPTED; in xfs_fs_fill_super()
1628 * Until this is fixed only page-sized or smaller data blocks work. in xfs_fs_fill_super()
1630 if (mp->m_sb.sb_blocksize > PAGE_SIZE) { in xfs_fs_fill_super()
1634 mp->m_sb.sb_blocksize, PAGE_SIZE); in xfs_fs_fill_super()
1635 error = -ENOSYS; in xfs_fs_fill_super()
1640 if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) || in xfs_fs_fill_super()
1641 xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) { in xfs_fs_fill_super()
1644 error = -EFBIG; in xfs_fs_fill_super()
1651 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT in xfs_fs_fill_super()
1652 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes in xfs_fs_fill_super()
1653 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON in xfs_fs_fill_super()
1664 error = -EINVAL; in xfs_fs_fill_super()
1676 sb->s_magic = XFS_SUPER_MAGIC; in xfs_fs_fill_super()
1677 sb->s_blocksize = mp->m_sb.sb_blocksize; in xfs_fs_fill_super()
1678 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; in xfs_fs_fill_super()
1679 sb->s_maxbytes = MAX_LFS_FILESIZE; in xfs_fs_fill_super()
1680 sb->s_max_links = XFS_MAXLINK; in xfs_fs_fill_super()
1681 sb->s_time_gran = 1; in xfs_fs_fill_super()
1683 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN); in xfs_fs_fill_super()
1684 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX); in xfs_fs_fill_super()
1686 sb->s_time_min = XFS_LEGACY_TIME_MIN; in xfs_fs_fill_super()
1687 sb->s_time_max = XFS_LEGACY_TIME_MAX; in xfs_fs_fill_super()
1689 trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max); in xfs_fs_fill_super()
1690 sb->s_iflags |= SB_I_CGROUPWB; in xfs_fs_fill_super()
1696 sb->s_flags |= SB_I_VERSION; in xfs_fs_fill_super()
1704 if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) { in xfs_fs_fill_super()
1707 mp->m_features &= ~XFS_FEAT_DISCARD; in xfs_fs_fill_super()
1711 if (mp->m_sb.sb_rblocks) { in xfs_fs_fill_super()
1714 error = -EINVAL; in xfs_fs_fill_super()
1719 xfs_info(mp, "using DEBUG-only always_cow mode."); in xfs_fs_fill_super()
1720 mp->m_always_cow = true; in xfs_fs_fill_super()
1724 if (xfs_has_rmapbt(mp) && mp->m_sb.sb_rblocks) { in xfs_fs_fill_super()
1727 error = -EINVAL; in xfs_fs_fill_super()
1735 root = igrab(VFS_I(mp->m_rootip)); in xfs_fs_fill_super()
1737 error = -ENOENT; in xfs_fs_fill_super()
1740 sb->s_root = d_make_root(root); in xfs_fs_fill_super()
1741 if (!sb->s_root) { in xfs_fs_fill_super()
1742 error = -ENOMEM; in xfs_fs_fill_super()
1755 free_percpu(mp->m_stats.xs_stats); in xfs_fs_fill_super()
1783 struct xfs_sb *sbp = &mp->m_sb; in xfs_remount_rw()
1788 "ro->rw transition prohibited on norecovery mount"); in xfs_remount_rw()
1789 return -EINVAL; in xfs_remount_rw()
1795 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem", in xfs_remount_rw()
1796 (sbp->sb_features_ro_compat & in xfs_remount_rw()
1798 return -EINVAL; in xfs_remount_rw()
1801 clear_bit(XFS_OPSTATE_READONLY, &mp->m_opstate); in xfs_remount_rw()
1807 if (mp->m_update_sb) { in xfs_remount_rw()
1813 mp->m_update_sb = false; in xfs_remount_rw()
1818 * it is non-zero, otherwise go with the default. in xfs_remount_rw()
1824 /* Create the per-AG metadata reservation pool .*/ in xfs_remount_rw()
1826 if (error && error != -ENOSPC) in xfs_remount_rw()
1829 /* Re-enable the background inode inactivation worker. */ in xfs_remount_rw()
1845 error = sync_filesystem(mp->m_super); in xfs_remount_ro()
1856 * Clear out all remaining COW staging extents and speculative post-EOF in xfs_remount_ro()
1858 * cleanups during reclaim on a read-only mount. We must process every in xfs_remount_ro()
1876 /* Free the per-AG metadata reservation pool. */ in xfs_remount_ro()
1893 set_bit(XFS_OPSTATE_READONLY, &mp->m_opstate); in xfs_remount_ro()
1914 struct xfs_mount *mp = XFS_M(fc->root->d_sb); in xfs_fs_reconfigure()
1915 struct xfs_mount *new_mp = fc->s_fs_info; in xfs_fs_reconfigure()
1916 int flags = fc->sb_flags; in xfs_fs_reconfigure()
1921 fc->sb_flags |= SB_I_VERSION; in xfs_fs_reconfigure()
1927 /* inode32 -> inode64 */ in xfs_fs_reconfigure()
1929 mp->m_features &= ~XFS_FEAT_SMALL_INUMS; in xfs_fs_reconfigure()
1930 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount); in xfs_fs_reconfigure()
1933 /* inode64 -> inode32 */ in xfs_fs_reconfigure()
1935 mp->m_features |= XFS_FEAT_SMALL_INUMS; in xfs_fs_reconfigure()
1936 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount); in xfs_fs_reconfigure()
1939 /* ro -> rw */ in xfs_fs_reconfigure()
1946 /* rw -> ro */ in xfs_fs_reconfigure()
1960 struct xfs_mount *mp = fc->s_fs_info; in xfs_fs_free()
1991 return -ENOMEM; in xfs_init_fs_context()
1993 spin_lock_init(&mp->m_sb_lock); in xfs_init_fs_context()
1994 INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC); in xfs_init_fs_context()
1995 spin_lock_init(&mp->m_perag_lock); in xfs_init_fs_context()
1996 mutex_init(&mp->m_growlock); in xfs_init_fs_context()
1997 INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker); in xfs_init_fs_context()
1998 INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker); in xfs_init_fs_context()
1999 mp->m_kobj.kobject.kset = xfs_kset; in xfs_init_fs_context()
2001 * We don't create the finobt per-ag space reservation until after log in xfs_init_fs_context()
2006 mp->m_finobt_nores = true; in xfs_init_fs_context()
2011 mp->m_logbufs = -1; in xfs_init_fs_context()
2012 mp->m_logbsize = -1; in xfs_init_fs_context()
2013 mp->m_allocsize_log = 16; /* 64k */ in xfs_init_fs_context()
2015 fc->s_fs_info = mp; in xfs_init_fs_context()
2016 fc->ops = &xfs_context_ops; in xfs_init_fs_context()
2086 * The size of the cache-allocated buf log item is the maximum in xfs_init_caches()
2229 return -ENOMEM; in xfs_init_caches()
2276 return -ENOMEM; in xfs_init_workqueues()
2286 return -ENOMEM; in xfs_init_workqueues()
2336 error = -ENOMEM; in init_xfs_fs()
2344 error = -ENOMEM; in init_xfs_fs()