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

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
59 static struct dentry *xfs_debugfs; /* top-level xfs debugfs dir */
60 static struct kset *xfs_kset; /* top-level xfs sysfs dir */
81 mp->m_features &= ~(XFS_FEAT_DAX_ALWAYS | XFS_FEAT_DAX_NEVER); in xfs_mount_set_dax_mode()
84 mp->m_features |= XFS_FEAT_DAX_ALWAYS; in xfs_mount_set_dax_mode()
85 mp->m_features &= ~XFS_FEAT_DAX_NEVER; in xfs_mount_set_dax_mode()
88 mp->m_features |= XFS_FEAT_DAX_NEVER; in xfs_mount_set_dax_mode()
89 mp->m_features &= ~XFS_FEAT_DAX_ALWAYS; in xfs_mount_set_dax_mode()
193 struct xfs_mount *mp = XFS_M(root->d_sb); in xfs_fs_show_options()
196 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) { in xfs_fs_show_options()
197 if (mp->m_features & xfs_infop->flag) in xfs_fs_show_options()
198 seq_puts(m, xfs_infop->str); in xfs_fs_show_options()
205 (1 << mp->m_allocsize_log) >> 10); in xfs_fs_show_options()
207 if (mp->m_logbufs > 0) in xfs_fs_show_options()
208 seq_printf(m, ",logbufs=%d", mp->m_logbufs); in xfs_fs_show_options()
209 if (mp->m_logbsize > 0) in xfs_fs_show_options()
210 seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10); in xfs_fs_show_options()
212 if (mp->m_logname) in xfs_fs_show_options()
213 seq_show_option(m, "logdev", mp->m_logname); in xfs_fs_show_options()
214 if (mp->m_rtname) in xfs_fs_show_options()
215 seq_show_option(m, "rtdev", mp->m_rtname); in xfs_fs_show_options()
217 if (mp->m_dalign > 0) in xfs_fs_show_options()
219 (int)XFS_FSB_TO_BB(mp, mp->m_dalign)); in xfs_fs_show_options()
220 if (mp->m_swidth > 0) in xfs_fs_show_options()
222 (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); in xfs_fs_show_options()
224 if (mp->m_qflags & XFS_UQUOTA_ENFD) in xfs_fs_show_options()
226 else if (mp->m_qflags & XFS_UQUOTA_ACCT) in xfs_fs_show_options()
229 if (mp->m_qflags & XFS_PQUOTA_ENFD) in xfs_fs_show_options()
231 else if (mp->m_qflags & XFS_PQUOTA_ACCT) in xfs_fs_show_options()
234 if (mp->m_qflags & XFS_GQUOTA_ENFD) in xfs_fs_show_options()
236 else if (mp->m_qflags & XFS_GQUOTA_ACCT) in xfs_fs_show_options()
239 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) in xfs_fs_show_options()
242 if (mp->m_max_open_zones) in xfs_fs_show_options()
243 seq_printf(m, ",max_open_zones=%u", mp->m_max_open_zones); in xfs_fs_show_options()
255 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
256 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
261 clear_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
262 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
266 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
268 set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
270 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
284 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
296 xfs_sb_t *sbp = &mp->m_sb; in xfs_set_inode_alloc()
305 if (M_IGEO(mp)->maxicount) { in xfs_set_inode_alloc()
308 icount = sbp->sb_dblocks * sbp->sb_imax_pct; in xfs_set_inode_alloc()
310 icount += sbp->sb_agblocks - 1; in xfs_set_inode_alloc()
311 do_div(icount, sbp->sb_agblocks); in xfs_set_inode_alloc()
318 agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1); in xfs_set_inode_alloc()
319 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino); in xfs_set_inode_alloc()
322 * If user asked for no more than 32-bit inodes, and the fs is in xfs_set_inode_alloc()
349 if (!mp->m_ddev_targp->bt_daxdev && in xfs_setup_dax_always()
350 (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) { in xfs_setup_dax_always()
356 if (mp->m_super->s_blocksize != PAGE_SIZE) { in xfs_setup_dax_always()
363 bdev_is_partition(mp->m_ddev_targp->bt_bdev)) { in xfs_setup_dax_always()
365 "DAX and reflink cannot work with multi-partitions!"); in xfs_setup_dax_always()
366 return -EINVAL; in xfs_setup_dax_always()
386 mp->m_super, &fs_holder_ops); in xfs_blkdev_get()
426 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { in xfs_shutdown_devices()
427 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev); in xfs_shutdown_devices()
428 invalidate_bdev(mp->m_logdev_targp->bt_bdev); in xfs_shutdown_devices()
430 if (mp->m_rtdev_targp) { in xfs_shutdown_devices()
431 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev); in xfs_shutdown_devices()
432 invalidate_bdev(mp->m_rtdev_targp->bt_bdev); in xfs_shutdown_devices()
434 blkdev_issue_flush(mp->m_ddev_targp->bt_bdev); in xfs_shutdown_devices()
435 invalidate_bdev(mp->m_ddev_targp->bt_bdev); in xfs_shutdown_devices()
446 * get_sb_bdev() and is stored in sb->s_bdev.
452 struct super_block *sb = mp->m_super; in xfs_open_devices()
453 struct block_device *ddev = sb->s_bdev; in xfs_open_devices()
458 * Open real time and log devices - order is important. in xfs_open_devices()
460 if (mp->m_logname) { in xfs_open_devices()
461 error = xfs_blkdev_get(mp, mp->m_logname, &logdev_file); in xfs_open_devices()
466 if (mp->m_rtname) { in xfs_open_devices()
467 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev_file); in xfs_open_devices()
476 error = -EINVAL; in xfs_open_devices()
484 error = -ENOMEM; in xfs_open_devices()
485 mp->m_ddev_targp = xfs_alloc_buftarg(mp, sb->s_bdev_file); in xfs_open_devices()
486 if (!mp->m_ddev_targp) in xfs_open_devices()
490 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev_file); in xfs_open_devices()
491 if (!mp->m_rtdev_targp) in xfs_open_devices()
496 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev_file); in xfs_open_devices()
497 if (!mp->m_logdev_targp) in xfs_open_devices()
500 mp->m_logdev_targp = mp->m_ddev_targp; in xfs_open_devices()
509 if (mp->m_rtdev_targp) in xfs_open_devices()
510 xfs_free_buftarg(mp->m_rtdev_targp); in xfs_open_devices()
512 xfs_free_buftarg(mp->m_ddev_targp); in xfs_open_devices()
531 error = xfs_setsize_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize); in xfs_setup_devices()
535 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { in xfs_setup_devices()
539 log_sector_size = mp->m_sb.sb_logsectsize; in xfs_setup_devices()
540 error = xfs_setsize_buftarg(mp->m_logdev_targp, in xfs_setup_devices()
546 if (mp->m_sb.sb_rtstart) { in xfs_setup_devices()
547 if (mp->m_rtdev_targp) { in xfs_setup_devices()
550 return -EINVAL; in xfs_setup_devices()
552 mp->m_rtdev_targp = mp->m_ddev_targp; in xfs_setup_devices()
553 } else if (mp->m_rtname) { in xfs_setup_devices()
554 error = xfs_setsize_buftarg(mp->m_rtdev_targp, in xfs_setup_devices()
555 mp->m_sb.sb_sectsize); in xfs_setup_devices()
567 mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s", in xfs_init_mount_workqueues()
569 1, mp->m_super->s_id); in xfs_init_mount_workqueues()
570 if (!mp->m_buf_workqueue) in xfs_init_mount_workqueues()
573 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", in xfs_init_mount_workqueues()
575 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
576 if (!mp->m_unwritten_workqueue) in xfs_init_mount_workqueues()
579 mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s", in xfs_init_mount_workqueues()
581 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
582 if (!mp->m_reclaim_workqueue) in xfs_init_mount_workqueues()
585 mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s", in xfs_init_mount_workqueues()
587 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
588 if (!mp->m_blockgc_wq) in xfs_init_mount_workqueues()
591 mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s", in xfs_init_mount_workqueues()
593 1, mp->m_super->s_id); in xfs_init_mount_workqueues()
594 if (!mp->m_inodegc_wq) in xfs_init_mount_workqueues()
597 mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s", in xfs_init_mount_workqueues()
598 XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
599 if (!mp->m_sync_workqueue) in xfs_init_mount_workqueues()
605 destroy_workqueue(mp->m_inodegc_wq); in xfs_init_mount_workqueues()
607 destroy_workqueue(mp->m_blockgc_wq); in xfs_init_mount_workqueues()
609 destroy_workqueue(mp->m_reclaim_workqueue); in xfs_init_mount_workqueues()
611 destroy_workqueue(mp->m_unwritten_workqueue); in xfs_init_mount_workqueues()
613 destroy_workqueue(mp->m_buf_workqueue); in xfs_init_mount_workqueues()
615 return -ENOMEM; in xfs_init_mount_workqueues()
622 destroy_workqueue(mp->m_sync_workqueue); in xfs_destroy_mount_workqueues()
623 destroy_workqueue(mp->m_blockgc_wq); in xfs_destroy_mount_workqueues()
624 destroy_workqueue(mp->m_inodegc_wq); in xfs_destroy_mount_workqueues()
625 destroy_workqueue(mp->m_reclaim_workqueue); in xfs_destroy_mount_workqueues()
626 destroy_workqueue(mp->m_unwritten_workqueue); in xfs_destroy_mount_workqueues()
627 destroy_workqueue(mp->m_buf_workqueue); in xfs_destroy_mount_workqueues()
636 struct super_block *sb = mp->m_super; in xfs_flush_inodes_worker()
638 if (down_read_trylock(&sb->s_umount)) { in xfs_flush_inodes_worker()
640 up_read(&sb->s_umount); in xfs_flush_inodes_worker()
658 if (flush_work(&mp->m_flush_inodes_work)) in xfs_flush_inodes()
661 queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work); in xfs_flush_inodes()
662 flush_work(&mp->m_flush_inodes_work); in xfs_flush_inodes()
686 ASSERT(!rwsem_is_locked(&inode->i_rwsem)); in xfs_fs_destroy_inode()
687 XFS_STATS_INC(ip->i_mount, vn_rele); in xfs_fs_destroy_inode()
688 XFS_STATS_INC(ip->i_mount, vn_remove); in xfs_fs_destroy_inode()
698 struct xfs_mount *mp = ip->i_mount; in xfs_fs_dirty_inode()
701 if (!(inode->i_sb->s_flags & SB_LAZYTIME)) in xfs_fs_dirty_inode()
712 if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp)) in xfs_fs_dirty_inode()
740 atomic_set(&ip->i_pincount, 0); in xfs_fs_inode_init_once()
741 spin_lock_init(&ip->i_flags_lock); in xfs_fs_inode_init_once()
742 init_rwsem(&ip->i_lock); in xfs_fs_inode_init_once()
747 * serialised against cache hits here via the inode->i_lock and igrab() in
763 if (ip->i_flags & XFS_IRECOVERY) { in xfs_fs_drop_inode()
764 ASSERT(xlog_recovery_needed(ip->i_mount->m_log)); in xfs_fs_drop_inode()
778 truncate_inode_pages_final(&inode->i_data); in xfs_fs_evict_inode()
786 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) in xfs_mount_free()
787 xfs_free_buftarg(mp->m_logdev_targp); in xfs_mount_free()
788 if (mp->m_rtdev_targp && mp->m_rtdev_targp != mp->m_ddev_targp) in xfs_mount_free()
789 xfs_free_buftarg(mp->m_rtdev_targp); in xfs_mount_free()
790 if (mp->m_ddev_targp) in xfs_mount_free()
791 xfs_free_buftarg(mp->m_ddev_targp); in xfs_mount_free()
793 debugfs_remove(mp->m_debugfs); in xfs_mount_free()
794 kfree(mp->m_rtname); in xfs_mount_free()
795 kfree(mp->m_logname); in xfs_mount_free()
825 flush_delayed_work(&mp->m_log->l_work); in xfs_fs_sync_fs()
838 * freeze that does this - we can run this multiple times without issue in xfs_fs_sync_fs()
842 if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) { in xfs_fs_sync_fs()
855 if (!mp->m_sb.sb_logstart) in xfs_internal_log_size()
857 return mp->m_sb.sb_logblocks; in xfs_internal_log_size()
868 /* make sure st->f_bfree does not underflow */ in xfs_statfs_data()
869 st->f_bfree = max(0LL, in xfs_statfs_data()
870 fdblocks - xfs_freecounter_unavailable(mp, XC_FREE_BLOCKS)); in xfs_statfs_data()
876 st->f_blocks = mp->m_sb.sb_dblocks - xfs_internal_log_size(mp); in xfs_statfs_data()
889 st->f_bfree = xfs_rtbxlen_to_blen(mp, in xfs_statfs_rt()
891 st->f_blocks = mp->m_sb.sb_rblocks - xfs_rtbxlen_to_blen(mp, in xfs_statfs_rt()
892 mp->m_free[XC_FREE_RTEXTENTS].res_total); in xfs_statfs_rt()
900 uint64_t icount = percpu_counter_sum(&mp->m_icount); in xfs_statfs_inodes()
901 uint64_t ifree = percpu_counter_sum(&mp->m_ifree); in xfs_statfs_inodes()
902 uint64_t fakeinos = XFS_FSB_TO_INO(mp, st->f_bfree); in xfs_statfs_inodes()
904 st->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER); in xfs_statfs_inodes()
905 if (M_IGEO(mp)->maxicount) in xfs_statfs_inodes()
906 st->f_files = min_t(typeof(st->f_files), st->f_files, in xfs_statfs_inodes()
907 M_IGEO(mp)->maxicount); in xfs_statfs_inodes()
910 st->f_files = max_t(typeof(st->f_files), st->f_files, in xfs_statfs_inodes()
911 mp->m_sb.sb_icount); in xfs_statfs_inodes()
913 /* Make sure st->f_ffree does not underflow */ in xfs_statfs_inodes()
914 st->f_ffree = max_t(int64_t, 0, st->f_files - (icount - ifree)); in xfs_statfs_inodes()
922 struct xfs_mount *mp = XFS_M(dentry->d_sb); in xfs_fs_statfs()
931 st->f_type = XFS_SUPER_MAGIC; in xfs_fs_statfs()
932 st->f_namelen = MAXNAMELEN - 1; in xfs_fs_statfs()
933 st->f_bsize = mp->m_sb.sb_blocksize; in xfs_fs_statfs()
934 st->f_fsid = u64_to_fsid(huge_encode_dev(mp->m_ddev_targp->bt_dev)); in xfs_fs_statfs()
940 (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) in xfs_fs_statfs()
943 if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) && in xfs_fs_statfs()
944 ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == in xfs_fs_statfs()
952 st->f_bavail = st->f_bfree; in xfs_fs_statfs()
963 mp->m_free[i].res_saved = mp->m_free[i].res_total; in xfs_save_resvblks()
976 if (mp->m_free[i].res_saved) { in xfs_restore_resvblks()
977 resblks = mp->m_free[i].res_saved; in xfs_restore_resvblks()
978 mp->m_free[i].res_saved = 0; in xfs_restore_resvblks()
1010 * For read-write filesystems, we need to restart the inodegc on error in xfs_fs_freeze()
1059 if (mp->m_logbsize <= 0 && in xfs_finish_flags()
1060 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) { in xfs_finish_flags()
1061 mp->m_logbsize = mp->m_sb.sb_logsunit; in xfs_finish_flags()
1062 } else if (mp->m_logbsize > 0 && in xfs_finish_flags()
1063 mp->m_logbsize < mp->m_sb.sb_logsunit) { in xfs_finish_flags()
1066 return -EINVAL; in xfs_finish_flags()
1070 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { in xfs_finish_flags()
1073 return -EINVAL; in xfs_finish_flags()
1083 return -EINVAL; in xfs_finish_flags()
1087 * prohibit r/w mounts of read-only filesystems in xfs_finish_flags()
1089 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) { in xfs_finish_flags()
1091 "cannot mount a read-only filesystem as read-write"); in xfs_finish_flags()
1092 return -EROFS; in xfs_finish_flags()
1095 if ((mp->m_qflags & XFS_GQUOTA_ACCT) && in xfs_finish_flags()
1096 (mp->m_qflags & XFS_PQUOTA_ACCT) && in xfs_finish_flags()
1100 return -EINVAL; in xfs_finish_flags()
1104 if (mp->m_max_open_zones) { in xfs_finish_flags()
1107 return -EINVAL; in xfs_finish_flags()
1109 if (mp->m_features & XFS_FEAT_NOLIFETIME) { in xfs_finish_flags()
1112 return -EINVAL; in xfs_finish_flags()
1126 error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1128 return -ENOMEM; in xfs_init_percpu_counters()
1130 error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1134 error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1138 error = percpu_counter_init(&mp->m_delalloc_rtextents, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1143 error = percpu_counter_init(&mp->m_free[i].count, 0, in xfs_init_percpu_counters()
1152 while (--i >= 0) in xfs_init_percpu_counters()
1153 percpu_counter_destroy(&mp->m_free[i].count); in xfs_init_percpu_counters()
1154 percpu_counter_destroy(&mp->m_delalloc_rtextents); in xfs_init_percpu_counters()
1156 percpu_counter_destroy(&mp->m_delalloc_blks); in xfs_init_percpu_counters()
1158 percpu_counter_destroy(&mp->m_ifree); in xfs_init_percpu_counters()
1160 percpu_counter_destroy(&mp->m_icount); in xfs_init_percpu_counters()
1161 return -ENOMEM; in xfs_init_percpu_counters()
1168 percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount); in xfs_reinit_percpu_counters()
1169 percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree); in xfs_reinit_percpu_counters()
1170 xfs_set_freecounter(mp, XC_FREE_BLOCKS, mp->m_sb.sb_fdblocks); in xfs_reinit_percpu_counters()
1173 mp->m_sb.sb_frextents); in xfs_reinit_percpu_counters()
1183 percpu_counter_destroy(&mp->m_free[i].count); in xfs_destroy_percpu_counters()
1184 percpu_counter_destroy(&mp->m_icount); in xfs_destroy_percpu_counters()
1185 percpu_counter_destroy(&mp->m_ifree); in xfs_destroy_percpu_counters()
1187 percpu_counter_sum(&mp->m_delalloc_rtextents) == 0); in xfs_destroy_percpu_counters()
1188 percpu_counter_destroy(&mp->m_delalloc_rtextents); in xfs_destroy_percpu_counters()
1190 percpu_counter_sum(&mp->m_delalloc_blks) == 0); in xfs_destroy_percpu_counters()
1191 percpu_counter_destroy(&mp->m_delalloc_blks); in xfs_destroy_percpu_counters()
1201 mp->m_inodegc = alloc_percpu(struct xfs_inodegc); in xfs_inodegc_init_percpu()
1202 if (!mp->m_inodegc) in xfs_inodegc_init_percpu()
1203 return -ENOMEM; in xfs_inodegc_init_percpu()
1206 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_init_percpu()
1207 gc->cpu = cpu; in xfs_inodegc_init_percpu()
1208 gc->mp = mp; in xfs_inodegc_init_percpu()
1209 init_llist_head(&gc->list); in xfs_inodegc_init_percpu()
1210 gc->items = 0; in xfs_inodegc_init_percpu()
1211 gc->error = 0; in xfs_inodegc_init_percpu()
1212 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker); in xfs_inodegc_init_percpu()
1221 if (!mp->m_inodegc) in xfs_inodegc_free_percpu()
1223 free_percpu(mp->m_inodegc); in xfs_inodegc_free_percpu()
1232 xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid); in xfs_fs_put_super()
1239 free_percpu(mp->m_stats.xs_stats); in xfs_fs_put_super()
1249 struct shrink_control *sc) in xfs_fs_nr_cached_objects() argument
1252 if (WARN_ON_ONCE(!sb->s_fs_info)) in xfs_fs_nr_cached_objects()
1260 struct shrink_control *sc) in xfs_fs_free_cached_objects() argument
1262 return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan); in xfs_fs_free_cached_objects()
1277 struct xfs_mount *mp = XFS_M(root->d_sb); in xfs_fs_show_stats()
1314 return -ENOMEM; in suffix_kstrtoint()
1316 last = strlen(value) - 1; in suffix_kstrtoint()
1331 ret = -EINVAL; in suffix_kstrtoint()
1347 if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) && in xfs_fs_warn_deprecated()
1348 !!(XFS_M(fc->root->d_sb)->m_features & flag) == value) in xfs_fs_warn_deprecated()
1350 xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key); in xfs_fs_warn_deprecated()
1356 * NOTE: mp->m_super is NULL here!
1363 struct xfs_mount *parsing_mp = fc->s_fs_info; in xfs_fs_parse_param()
1376 parsing_mp->m_logbufs = result.uint_32; in xfs_fs_parse_param()
1379 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize)) in xfs_fs_parse_param()
1380 return -EINVAL; in xfs_fs_parse_param()
1383 kfree(parsing_mp->m_logname); in xfs_fs_parse_param()
1384 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL); in xfs_fs_parse_param()
1385 if (!parsing_mp->m_logname) in xfs_fs_parse_param()
1386 return -ENOMEM; in xfs_fs_parse_param()
1389 kfree(parsing_mp->m_rtname); in xfs_fs_parse_param()
1390 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL); in xfs_fs_parse_param()
1391 if (!parsing_mp->m_rtname) in xfs_fs_parse_param()
1392 return -ENOMEM; in xfs_fs_parse_param()
1395 if (suffix_kstrtoint(param->string, 10, &size)) in xfs_fs_parse_param()
1396 return -EINVAL; in xfs_fs_parse_param()
1397 parsing_mp->m_allocsize_log = ffs(size) - 1; in xfs_fs_parse_param()
1398 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE; in xfs_fs_parse_param()
1402 parsing_mp->m_features |= XFS_FEAT_GRPID; in xfs_fs_parse_param()
1406 parsing_mp->m_features &= ~XFS_FEAT_GRPID; in xfs_fs_parse_param()
1409 parsing_mp->m_features |= XFS_FEAT_WSYNC; in xfs_fs_parse_param()
1412 parsing_mp->m_features |= XFS_FEAT_NORECOVERY; in xfs_fs_parse_param()
1415 parsing_mp->m_features |= XFS_FEAT_NOALIGN; in xfs_fs_parse_param()
1418 parsing_mp->m_features |= XFS_FEAT_SWALLOC; in xfs_fs_parse_param()
1421 parsing_mp->m_dalign = result.uint_32; in xfs_fs_parse_param()
1424 parsing_mp->m_swidth = result.uint_32; in xfs_fs_parse_param()
1427 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS; in xfs_fs_parse_param()
1430 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS; in xfs_fs_parse_param()
1433 parsing_mp->m_features |= XFS_FEAT_NOUUID; in xfs_fs_parse_param()
1436 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE; in xfs_fs_parse_param()
1439 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE; in xfs_fs_parse_param()
1442 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS; in xfs_fs_parse_param()
1445 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; in xfs_fs_parse_param()
1446 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD; in xfs_fs_parse_param()
1447 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1452 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD); in xfs_fs_parse_param()
1453 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1457 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT; in xfs_fs_parse_param()
1458 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD; in xfs_fs_parse_param()
1459 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1463 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD); in xfs_fs_parse_param()
1464 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1467 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT; in xfs_fs_parse_param()
1468 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD; in xfs_fs_parse_param()
1469 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1473 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD); in xfs_fs_parse_param()
1474 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1477 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT; in xfs_fs_parse_param()
1478 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD; in xfs_fs_parse_param()
1479 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1482 parsing_mp->m_features |= XFS_FEAT_DISCARD; in xfs_fs_parse_param()
1485 parsing_mp->m_features &= ~XFS_FEAT_DISCARD; in xfs_fs_parse_param()
1498 parsing_mp->m_features |= XFS_FEAT_IKEEP; in xfs_fs_parse_param()
1502 parsing_mp->m_features &= ~XFS_FEAT_IKEEP; in xfs_fs_parse_param()
1506 parsing_mp->m_features |= XFS_FEAT_ATTR2; in xfs_fs_parse_param()
1510 parsing_mp->m_features |= XFS_FEAT_NOATTR2; in xfs_fs_parse_param()
1513 parsing_mp->m_max_open_zones = result.uint_32; in xfs_fs_parse_param()
1516 parsing_mp->m_features &= ~XFS_FEAT_NOLIFETIME; in xfs_fs_parse_param()
1519 parsing_mp->m_features |= XFS_FEAT_NOLIFETIME; in xfs_fs_parse_param()
1522 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); in xfs_fs_parse_param()
1523 return -EINVAL; in xfs_fs_parse_param()
1533 /* No recovery flag requires a read-only mount */ in xfs_fs_validate_params()
1535 xfs_warn(mp, "no-recovery mounts must be read-only."); in xfs_fs_validate_params()
1536 return -EINVAL; in xfs_fs_validate_params()
1545 return -EINVAL; in xfs_fs_validate_params()
1549 if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) { in xfs_fs_validate_params()
1552 return -EINVAL; in xfs_fs_validate_params()
1556 (mp->m_qflags & ~XFS_QFLAGS_MNTOPTS)) { in xfs_fs_validate_params()
1558 return -EINVAL; in xfs_fs_validate_params()
1561 if ((mp->m_dalign && !mp->m_swidth) || in xfs_fs_validate_params()
1562 (!mp->m_dalign && mp->m_swidth)) { in xfs_fs_validate_params()
1564 return -EINVAL; in xfs_fs_validate_params()
1567 if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) { in xfs_fs_validate_params()
1570 mp->m_swidth, mp->m_dalign); in xfs_fs_validate_params()
1571 return -EINVAL; in xfs_fs_validate_params()
1574 if (mp->m_logbufs != -1 && in xfs_fs_validate_params()
1575 mp->m_logbufs != 0 && in xfs_fs_validate_params()
1576 (mp->m_logbufs < XLOG_MIN_ICLOGS || in xfs_fs_validate_params()
1577 mp->m_logbufs > XLOG_MAX_ICLOGS)) { in xfs_fs_validate_params()
1578 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", in xfs_fs_validate_params()
1579 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); in xfs_fs_validate_params()
1580 return -EINVAL; in xfs_fs_validate_params()
1583 if (mp->m_logbsize != -1 && in xfs_fs_validate_params()
1584 mp->m_logbsize != 0 && in xfs_fs_validate_params()
1585 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || in xfs_fs_validate_params()
1586 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || in xfs_fs_validate_params()
1587 !is_power_of_2(mp->m_logbsize))) { in xfs_fs_validate_params()
1590 mp->m_logbsize); in xfs_fs_validate_params()
1591 return -EINVAL; in xfs_fs_validate_params()
1595 (mp->m_allocsize_log > XFS_MAX_IO_LOG || in xfs_fs_validate_params()
1596 mp->m_allocsize_log < XFS_MIN_IO_LOG)) { in xfs_fs_validate_params()
1597 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", in xfs_fs_validate_params()
1598 mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG); in xfs_fs_validate_params()
1599 return -EINVAL; in xfs_fs_validate_params()
1625 struct xfs_mount *mp = sb->s_fs_info; in xfs_fs_fill_super()
1629 mp->m_super = sb; in xfs_fs_fill_super()
1636 if (fc->sb_flags & SB_RDONLY) in xfs_fs_fill_super()
1638 if (fc->sb_flags & SB_DIRSYNC) in xfs_fs_fill_super()
1639 mp->m_features |= XFS_FEAT_DIRSYNC; in xfs_fs_fill_super()
1640 if (fc->sb_flags & SB_SYNCHRONOUS) in xfs_fs_fill_super()
1641 mp->m_features |= XFS_FEAT_WSYNC; in xfs_fs_fill_super()
1648 sb->s_xattr = xfs_xattr_handlers; in xfs_fs_fill_super()
1649 sb->s_export_op = &xfs_export_operations; in xfs_fs_fill_super()
1651 sb->s_qcop = &xfs_quotactl_operations; in xfs_fs_fill_super()
1652 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; in xfs_fs_fill_super()
1654 sb->s_op = &xfs_super_operations; in xfs_fs_fill_super()
1667 if (fc->sb_flags & SB_SILENT) in xfs_fs_fill_super()
1675 mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id, in xfs_fs_fill_super()
1678 mp->m_debugfs = NULL; in xfs_fs_fill_super()
1694 mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); in xfs_fs_fill_super()
1695 if (!mp->m_stats.xs_stats) { in xfs_fs_fill_super()
1696 error = -ENOMEM; in xfs_fs_fill_super()
1722 if (!(mp->m_features & XFS_FEAT_CRC)) { in xfs_fs_fill_super()
1726 error = -EINVAL; in xfs_fs_fill_super()
1737 …"Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 20… in xfs_fs_fill_super()
1740 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel."); in xfs_fs_fill_super()
1741 error = -EINVAL; in xfs_fs_fill_super()
1753 error = -EFSCORRUPTED; in xfs_fs_fill_super()
1762 if (mp->m_sb.sb_inprogress) { in xfs_fs_fill_super()
1764 error = -EFSCORRUPTED; in xfs_fs_fill_super()
1768 if (mp->m_sb.sb_blocksize > PAGE_SIZE) { in xfs_fs_fill_super()
1774 mp->m_sb.sb_blocksize, PAGE_SIZE); in xfs_fs_fill_super()
1775 error = -ENOSYS; in xfs_fs_fill_super()
1779 if (mp->m_sb.sb_blocksize > max_folio_size) { in xfs_fs_fill_super()
1782 mp->m_sb.sb_blocksize, max_folio_size); in xfs_fs_fill_super()
1783 error = -ENOSYS; in xfs_fs_fill_super()
1791 if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) || in xfs_fs_fill_super()
1792 xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) { in xfs_fs_fill_super()
1795 error = -EFBIG; in xfs_fs_fill_super()
1802 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT in xfs_fs_fill_super()
1803 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes in xfs_fs_fill_super()
1804 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON in xfs_fs_fill_super()
1815 error = -EINVAL; in xfs_fs_fill_super()
1831 sb->s_magic = XFS_SUPER_MAGIC; in xfs_fs_fill_super()
1832 sb->s_blocksize = mp->m_sb.sb_blocksize; in xfs_fs_fill_super()
1833 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; in xfs_fs_fill_super()
1834 sb->s_maxbytes = MAX_LFS_FILESIZE; in xfs_fs_fill_super()
1835 sb->s_max_links = XFS_MAXLINK; in xfs_fs_fill_super()
1836 sb->s_time_gran = 1; in xfs_fs_fill_super()
1838 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN); in xfs_fs_fill_super()
1839 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX); in xfs_fs_fill_super()
1841 sb->s_time_min = XFS_LEGACY_TIME_MIN; in xfs_fs_fill_super()
1842 sb->s_time_max = XFS_LEGACY_TIME_MAX; in xfs_fs_fill_super()
1844 trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max); in xfs_fs_fill_super()
1845 sb->s_iflags |= SB_I_CGROUPWB | SB_I_ALLOW_HSM; in xfs_fs_fill_super()
1851 sb->s_flags |= SB_I_VERSION; in xfs_fs_fill_super()
1859 if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) { in xfs_fs_fill_super()
1862 mp->m_features &= ~XFS_FEAT_DISCARD; in xfs_fs_fill_super()
1869 error = -EINVAL; in xfs_fs_fill_super()
1879 !xfs_reflink_supports_rextsize(mp, mp->m_sb.sb_rextsize)) { in xfs_fs_fill_super()
1882 mp->m_sb.sb_rextsize); in xfs_fs_fill_super()
1883 error = -EINVAL; in xfs_fs_fill_super()
1890 error = -EINVAL; in xfs_fs_fill_super()
1895 xfs_info(mp, "using DEBUG-only always_cow mode."); in xfs_fs_fill_super()
1896 mp->m_always_cow = true; in xfs_fs_fill_super()
1911 if (!(mp->m_qflags & XFS_QFLAGS_MNTOPTS)) in xfs_fs_fill_super()
1913 mp->m_qflags &= ~XFS_QFLAGS_MNTOPTS; in xfs_fs_fill_super()
1919 root = igrab(VFS_I(mp->m_rootip)); in xfs_fs_fill_super()
1921 error = -ENOENT; in xfs_fs_fill_super()
1924 sb->s_root = d_make_root(root); in xfs_fs_fill_super()
1925 if (!sb->s_root) { in xfs_fs_fill_super()
1926 error = -ENOMEM; in xfs_fs_fill_super()
1941 free_percpu(mp->m_stats.xs_stats); in xfs_fs_fill_super()
1969 struct xfs_sb *sbp = &mp->m_sb; in xfs_remount_rw()
1974 "ro->rw transition prohibited on norecovery mount"); in xfs_remount_rw()
1975 return -EINVAL; in xfs_remount_rw()
1981 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem", in xfs_remount_rw()
1982 (sbp->sb_features_ro_compat & in xfs_remount_rw()
1984 return -EINVAL; in xfs_remount_rw()
1993 if (mp->m_update_sb) { in xfs_remount_rw()
1999 mp->m_update_sb = false; in xfs_remount_rw()
2004 * it is non-zero, otherwise go with the default. in xfs_remount_rw()
2010 /* Create the per-AG metadata reservation pool .*/ in xfs_remount_rw()
2012 if (error && error != -ENOSPC) in xfs_remount_rw()
2015 /* Re-enable the background inode inactivation worker. */ in xfs_remount_rw()
2034 error = sync_filesystem(mp->m_super); in xfs_remount_ro()
2045 * Clear out all remaining COW staging extents and speculative post-EOF in xfs_remount_ro()
2047 * cleanups during reclaim on a read-only mount. We must process every in xfs_remount_ro()
2068 /* Free the per-AG metadata reservation pool. */ in xfs_remount_ro()
2102 struct xfs_mount *mp = XFS_M(fc->root->d_sb); in xfs_fs_reconfigure()
2103 struct xfs_mount *new_mp = fc->s_fs_info; in xfs_fs_reconfigure()
2104 int flags = fc->sb_flags; in xfs_fs_reconfigure()
2107 new_mp->m_qflags &= ~XFS_QFLAGS_MNTOPTS; in xfs_fs_reconfigure()
2111 fc->sb_flags |= SB_I_VERSION; in xfs_fs_reconfigure()
2117 /* attr2 -> noattr2 */ in xfs_fs_reconfigure()
2121 "attr2 is always enabled for a V5 filesystem - can't be changed."); in xfs_fs_reconfigure()
2122 return -EINVAL; in xfs_fs_reconfigure()
2124 mp->m_features &= ~XFS_FEAT_ATTR2; in xfs_fs_reconfigure()
2125 mp->m_features |= XFS_FEAT_NOATTR2; in xfs_fs_reconfigure()
2127 /* noattr2 -> attr2 */ in xfs_fs_reconfigure()
2128 mp->m_features &= ~XFS_FEAT_NOATTR2; in xfs_fs_reconfigure()
2129 mp->m_features |= XFS_FEAT_ATTR2; in xfs_fs_reconfigure()
2132 /* inode32 -> inode64 */ in xfs_fs_reconfigure()
2134 mp->m_features &= ~XFS_FEAT_SMALL_INUMS; in xfs_fs_reconfigure()
2135 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount); in xfs_fs_reconfigure()
2138 /* inode64 -> inode32 */ in xfs_fs_reconfigure()
2140 mp->m_features |= XFS_FEAT_SMALL_INUMS; in xfs_fs_reconfigure()
2141 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount); in xfs_fs_reconfigure()
2155 /* ro -> rw */ in xfs_fs_reconfigure()
2162 /* rw -> ro */ in xfs_fs_reconfigure()
2176 struct xfs_mount *mp = fc->s_fs_info; in xfs_fs_free()
2209 return -ENOMEM; in xfs_init_fs_context()
2211 spin_lock_init(&mp->m_sb_lock); in xfs_init_fs_context()
2213 xa_init(&mp->m_groups[i].xa); in xfs_init_fs_context()
2214 mutex_init(&mp->m_growlock); in xfs_init_fs_context()
2215 mutex_init(&mp->m_metafile_resv_lock); in xfs_init_fs_context()
2216 INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker); in xfs_init_fs_context()
2217 INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker); in xfs_init_fs_context()
2218 mp->m_kobj.kobject.kset = xfs_kset; in xfs_init_fs_context()
2220 * We don't create the finobt per-ag space reservation until after log in xfs_init_fs_context()
2225 mp->m_finobt_nores = true; in xfs_init_fs_context()
2230 mp->m_logbufs = -1; in xfs_init_fs_context()
2231 mp->m_logbsize = -1; in xfs_init_fs_context()
2232 mp->m_allocsize_log = 16; /* 64k */ in xfs_init_fs_context()
2234 xfs_hooks_init(&mp->m_dir_update_hooks); in xfs_init_fs_context()
2236 fc->s_fs_info = mp; in xfs_init_fs_context()
2237 fc->ops = &xfs_context_ops; in xfs_init_fs_context()
2311 * The size of the cache-allocated buf log item is the maximum in xfs_init_caches()
2480 return -ENOMEM; in xfs_init_caches()
2531 return -ENOMEM; in xfs_init_workqueues()
2541 return -ENOMEM; in xfs_init_workqueues()
2591 error = -ENOMEM; in init_xfs_fs()
2599 error = -ENOMEM; in init_xfs_fs()