Lines Matching +full:buffered +full:- +full:positive

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()
202 struct xfs_mount *mp = XFS_M(root->d_sb); in xfs_fs_show_options()
205 for (xfs_infop = xfs_info_set; xfs_infop->flag; xfs_infop++) { in xfs_fs_show_options()
206 if (mp->m_features & xfs_infop->flag) in xfs_fs_show_options()
207 seq_puts(m, xfs_infop->str); in xfs_fs_show_options()
214 (1 << mp->m_allocsize_log) >> 10); in xfs_fs_show_options()
216 if (mp->m_logbufs > 0) in xfs_fs_show_options()
217 seq_printf(m, ",logbufs=%d", mp->m_logbufs); in xfs_fs_show_options()
218 if (mp->m_logbsize > 0) in xfs_fs_show_options()
219 seq_printf(m, ",logbsize=%dk", mp->m_logbsize >> 10); in xfs_fs_show_options()
221 if (mp->m_logname) in xfs_fs_show_options()
222 seq_show_option(m, "logdev", mp->m_logname); in xfs_fs_show_options()
223 if (mp->m_rtname) in xfs_fs_show_options()
224 seq_show_option(m, "rtdev", mp->m_rtname); in xfs_fs_show_options()
226 if (mp->m_dalign > 0) in xfs_fs_show_options()
228 (int)XFS_FSB_TO_BB(mp, mp->m_dalign)); in xfs_fs_show_options()
229 if (mp->m_swidth > 0) in xfs_fs_show_options()
231 (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); in xfs_fs_show_options()
233 if (mp->m_qflags & XFS_UQUOTA_ENFD) in xfs_fs_show_options()
235 else if (mp->m_qflags & XFS_UQUOTA_ACCT) in xfs_fs_show_options()
238 if (mp->m_qflags & XFS_PQUOTA_ENFD) in xfs_fs_show_options()
240 else if (mp->m_qflags & XFS_PQUOTA_ACCT) in xfs_fs_show_options()
243 if (mp->m_qflags & XFS_GQUOTA_ENFD) in xfs_fs_show_options()
245 else if (mp->m_qflags & XFS_GQUOTA_ACCT) in xfs_fs_show_options()
248 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) in xfs_fs_show_options()
251 if (mp->m_max_open_zones) in xfs_fs_show_options()
252 seq_printf(m, ",max_open_zones=%u", mp->m_max_open_zones); in xfs_fs_show_options()
253 if (mp->m_awu_max_bytes) in xfs_fs_show_options()
255 mp->m_awu_max_bytes >> 10); in xfs_fs_show_options()
267 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
268 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
273 clear_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
274 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
278 set_bit(XFS_AGSTATE_ALLOWS_INODES, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
280 set_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
282 clear_bit(XFS_AGSTATE_PREFERS_METADATA, &pag->pag_opstate); in xfs_set_inode_alloc_perag()
296 * because in the growfs case, mp->m_sb.sb_agcount is not yet updated
308 xfs_sb_t *sbp = &mp->m_sb; in xfs_set_inode_alloc()
317 if (M_IGEO(mp)->maxicount) { in xfs_set_inode_alloc()
320 icount = sbp->sb_dblocks * sbp->sb_imax_pct; in xfs_set_inode_alloc()
322 icount += sbp->sb_agblocks - 1; in xfs_set_inode_alloc()
323 do_div(icount, sbp->sb_agblocks); in xfs_set_inode_alloc()
330 agino = XFS_AGB_TO_AGINO(mp, sbp->sb_agblocks - 1); in xfs_set_inode_alloc()
331 ino = XFS_AGINO_TO_INO(mp, agcount - 1, agino); in xfs_set_inode_alloc()
334 * If user asked for no more than 32-bit inodes, and the fs is in xfs_set_inode_alloc()
361 if (!mp->m_ddev_targp->bt_daxdev && in xfs_setup_dax_always()
362 (!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) { in xfs_setup_dax_always()
368 if (mp->m_super->s_blocksize != PAGE_SIZE) { in xfs_setup_dax_always()
375 bdev_is_partition(mp->m_ddev_targp->bt_bdev)) { in xfs_setup_dax_always()
377 "DAX and reflink cannot work with multi-partitions!"); in xfs_setup_dax_always()
378 return -EINVAL; in xfs_setup_dax_always()
397 mode = sb_open_mode(mp->m_super->s_flags); in xfs_blkdev_get()
399 mp->m_super, &fs_holder_ops); in xfs_blkdev_get()
417 * symlinks to the bdev under /dev/disk. For this, it uses buffered in xfs_shutdown_devices()
420 * xfs_db also uses buffered reads to examine metadata. There is no in xfs_shutdown_devices()
439 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { in xfs_shutdown_devices()
440 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev); in xfs_shutdown_devices()
441 invalidate_bdev(mp->m_logdev_targp->bt_bdev); in xfs_shutdown_devices()
443 if (mp->m_rtdev_targp) { in xfs_shutdown_devices()
444 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev); in xfs_shutdown_devices()
445 invalidate_bdev(mp->m_rtdev_targp->bt_bdev); in xfs_shutdown_devices()
447 blkdev_issue_flush(mp->m_ddev_targp->bt_bdev); in xfs_shutdown_devices()
448 invalidate_bdev(mp->m_ddev_targp->bt_bdev); in xfs_shutdown_devices()
459 * get_sb_bdev() and is stored in sb->s_bdev.
465 struct super_block *sb = mp->m_super; in xfs_open_devices()
466 struct block_device *ddev = sb->s_bdev; in xfs_open_devices()
471 * Open real time and log devices - order is important. in xfs_open_devices()
473 if (mp->m_logname) { in xfs_open_devices()
474 error = xfs_blkdev_get(mp, mp->m_logname, &logdev_file); in xfs_open_devices()
479 if (mp->m_rtname) { in xfs_open_devices()
480 error = xfs_blkdev_get(mp, mp->m_rtname, &rtdev_file); in xfs_open_devices()
489 error = -EINVAL; in xfs_open_devices()
497 mp->m_ddev_targp = xfs_alloc_buftarg(mp, sb->s_bdev_file); in xfs_open_devices()
498 if (IS_ERR(mp->m_ddev_targp)) { in xfs_open_devices()
499 error = PTR_ERR(mp->m_ddev_targp); in xfs_open_devices()
500 mp->m_ddev_targp = NULL; in xfs_open_devices()
505 mp->m_rtdev_targp = xfs_alloc_buftarg(mp, rtdev_file); in xfs_open_devices()
506 if (IS_ERR(mp->m_rtdev_targp)) { in xfs_open_devices()
507 error = PTR_ERR(mp->m_rtdev_targp); in xfs_open_devices()
508 mp->m_rtdev_targp = NULL; in xfs_open_devices()
514 mp->m_logdev_targp = xfs_alloc_buftarg(mp, logdev_file); in xfs_open_devices()
515 if (IS_ERR(mp->m_logdev_targp)) { in xfs_open_devices()
516 error = PTR_ERR(mp->m_logdev_targp); in xfs_open_devices()
517 mp->m_logdev_targp = NULL; in xfs_open_devices()
521 mp->m_logdev_targp = mp->m_ddev_targp; in xfs_open_devices()
530 if (mp->m_rtdev_targp) in xfs_open_devices()
531 xfs_free_buftarg(mp->m_rtdev_targp); in xfs_open_devices()
533 xfs_free_buftarg(mp->m_ddev_targp); in xfs_open_devices()
552 error = xfs_configure_buftarg(mp->m_ddev_targp, mp->m_sb.sb_sectsize, in xfs_setup_devices()
553 mp->m_sb.sb_dblocks); in xfs_setup_devices()
557 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { in xfs_setup_devices()
561 log_sector_size = mp->m_sb.sb_logsectsize; in xfs_setup_devices()
562 error = xfs_configure_buftarg(mp->m_logdev_targp, in xfs_setup_devices()
563 log_sector_size, mp->m_sb.sb_logblocks); in xfs_setup_devices()
568 if (mp->m_sb.sb_rtstart) { in xfs_setup_devices()
569 if (mp->m_rtdev_targp) { in xfs_setup_devices()
572 return -EINVAL; in xfs_setup_devices()
574 mp->m_rtdev_targp = mp->m_ddev_targp; in xfs_setup_devices()
575 } else if (mp->m_rtname) { in xfs_setup_devices()
576 error = xfs_configure_buftarg(mp->m_rtdev_targp, in xfs_setup_devices()
577 mp->m_sb.sb_sectsize, mp->m_sb.sb_rblocks); in xfs_setup_devices()
589 mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s", in xfs_init_mount_workqueues()
591 1, mp->m_super->s_id); in xfs_init_mount_workqueues()
592 if (!mp->m_buf_workqueue) in xfs_init_mount_workqueues()
595 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", in xfs_init_mount_workqueues()
597 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
598 if (!mp->m_unwritten_workqueue) in xfs_init_mount_workqueues()
601 mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s", in xfs_init_mount_workqueues()
603 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
604 if (!mp->m_reclaim_workqueue) in xfs_init_mount_workqueues()
607 mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s", in xfs_init_mount_workqueues()
609 0, mp->m_super->s_id); in xfs_init_mount_workqueues()
610 if (!mp->m_blockgc_wq) in xfs_init_mount_workqueues()
613 mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s", in xfs_init_mount_workqueues()
615 1, mp->m_super->s_id); in xfs_init_mount_workqueues()
616 if (!mp->m_inodegc_wq) in xfs_init_mount_workqueues()
619 mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s", in xfs_init_mount_workqueues()
621 mp->m_super->s_id); in xfs_init_mount_workqueues()
622 if (!mp->m_sync_workqueue) in xfs_init_mount_workqueues()
628 destroy_workqueue(mp->m_inodegc_wq); in xfs_init_mount_workqueues()
630 destroy_workqueue(mp->m_blockgc_wq); in xfs_init_mount_workqueues()
632 destroy_workqueue(mp->m_reclaim_workqueue); in xfs_init_mount_workqueues()
634 destroy_workqueue(mp->m_unwritten_workqueue); in xfs_init_mount_workqueues()
636 destroy_workqueue(mp->m_buf_workqueue); in xfs_init_mount_workqueues()
638 return -ENOMEM; in xfs_init_mount_workqueues()
645 destroy_workqueue(mp->m_sync_workqueue); in xfs_destroy_mount_workqueues()
646 destroy_workqueue(mp->m_blockgc_wq); in xfs_destroy_mount_workqueues()
647 destroy_workqueue(mp->m_inodegc_wq); in xfs_destroy_mount_workqueues()
648 destroy_workqueue(mp->m_reclaim_workqueue); in xfs_destroy_mount_workqueues()
649 destroy_workqueue(mp->m_unwritten_workqueue); in xfs_destroy_mount_workqueues()
650 destroy_workqueue(mp->m_buf_workqueue); in xfs_destroy_mount_workqueues()
659 struct super_block *sb = mp->m_super; in xfs_flush_inodes_worker()
661 if (down_read_trylock(&sb->s_umount)) { in xfs_flush_inodes_worker()
663 up_read(&sb->s_umount); in xfs_flush_inodes_worker()
681 if (flush_work(&mp->m_flush_inodes_work)) in xfs_flush_inodes()
684 queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work); in xfs_flush_inodes()
685 flush_work(&mp->m_flush_inodes_work); in xfs_flush_inodes()
709 ASSERT(!rwsem_is_locked(&inode->i_rwsem)); in xfs_fs_destroy_inode()
710 XFS_STATS_INC(ip->i_mount, vn_rele); in xfs_fs_destroy_inode()
711 XFS_STATS_INC(ip->i_mount, vn_remove); in xfs_fs_destroy_inode()
721 struct xfs_mount *mp = ip->i_mount; in xfs_fs_dirty_inode()
724 if (!(inode->i_sb->s_flags & SB_LAZYTIME)) in xfs_fs_dirty_inode()
735 if (xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp)) in xfs_fs_dirty_inode()
763 atomic_set(&ip->i_pincount, 0); in xfs_fs_inode_init_once()
764 spin_lock_init(&ip->i_flags_lock); in xfs_fs_inode_init_once()
765 init_rwsem(&ip->i_lock); in xfs_fs_inode_init_once()
770 * serialised against cache hits here via the inode->i_lock and igrab() in
786 if (ip->i_flags & XFS_IRECOVERY) { in xfs_fs_drop_inode()
787 ASSERT(xlog_recovery_needed(ip->i_mount->m_log)); in xfs_fs_drop_inode()
801 truncate_inode_pages_final(&inode->i_data); in xfs_fs_evict_inode()
805 S_ISREG(inode->i_mode) && inode->i_private) { in xfs_fs_evict_inode()
806 xfs_open_zone_put(inode->i_private); in xfs_fs_evict_inode()
807 inode->i_private = NULL; in xfs_fs_evict_inode()
815 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) in xfs_mount_free()
816 xfs_free_buftarg(mp->m_logdev_targp); in xfs_mount_free()
817 if (mp->m_rtdev_targp && mp->m_rtdev_targp != mp->m_ddev_targp) in xfs_mount_free()
818 xfs_free_buftarg(mp->m_rtdev_targp); in xfs_mount_free()
819 if (mp->m_ddev_targp) in xfs_mount_free()
820 xfs_free_buftarg(mp->m_ddev_targp); in xfs_mount_free()
822 debugfs_remove(mp->m_debugfs); in xfs_mount_free()
823 kfree(mp->m_rtname); in xfs_mount_free()
824 kfree(mp->m_logname); in xfs_mount_free()
854 flush_delayed_work(&mp->m_log->l_work); in xfs_fs_sync_fs()
867 * freeze that does this - we can run this multiple times without issue in xfs_fs_sync_fs()
871 if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) { in xfs_fs_sync_fs()
884 if (!mp->m_sb.sb_logstart) in xfs_internal_log_size()
886 return mp->m_sb.sb_logblocks; in xfs_internal_log_size()
897 /* make sure st->f_bfree does not underflow */ in xfs_statfs_data()
898 st->f_bfree = max(0LL, in xfs_statfs_data()
899 fdblocks - xfs_freecounter_unavailable(mp, XC_FREE_BLOCKS)); in xfs_statfs_data()
905 st->f_blocks = mp->m_sb.sb_dblocks - xfs_internal_log_size(mp); in xfs_statfs_data()
918 st->f_bfree = xfs_rtbxlen_to_blen(mp, in xfs_statfs_rt()
920 st->f_blocks = mp->m_sb.sb_rblocks - xfs_rtbxlen_to_blen(mp, in xfs_statfs_rt()
921 mp->m_free[XC_FREE_RTEXTENTS].res_total); in xfs_statfs_rt()
929 uint64_t icount = percpu_counter_sum(&mp->m_icount); in xfs_statfs_inodes()
930 uint64_t ifree = percpu_counter_sum(&mp->m_ifree); in xfs_statfs_inodes()
931 uint64_t fakeinos = XFS_FSB_TO_INO(mp, st->f_bfree); in xfs_statfs_inodes()
933 st->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER); in xfs_statfs_inodes()
934 if (M_IGEO(mp)->maxicount) in xfs_statfs_inodes()
935 st->f_files = min_t(typeof(st->f_files), st->f_files, in xfs_statfs_inodes()
936 M_IGEO(mp)->maxicount); in xfs_statfs_inodes()
939 st->f_files = max_t(typeof(st->f_files), st->f_files, in xfs_statfs_inodes()
940 mp->m_sb.sb_icount); in xfs_statfs_inodes()
942 /* Make sure st->f_ffree does not underflow */ in xfs_statfs_inodes()
943 st->f_ffree = max_t(int64_t, 0, st->f_files - (icount - ifree)); in xfs_statfs_inodes()
951 struct xfs_mount *mp = XFS_M(dentry->d_sb); in xfs_fs_statfs()
960 st->f_type = XFS_SUPER_MAGIC; in xfs_fs_statfs()
961 st->f_namelen = MAXNAMELEN - 1; in xfs_fs_statfs()
962 st->f_bsize = mp->m_sb.sb_blocksize; in xfs_fs_statfs()
963 st->f_fsid = u64_to_fsid(huge_encode_dev(mp->m_ddev_targp->bt_dev)); in xfs_fs_statfs()
969 (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) in xfs_fs_statfs()
972 if ((ip->i_diflags & XFS_DIFLAG_PROJINHERIT) && in xfs_fs_statfs()
973 ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == in xfs_fs_statfs()
981 st->f_bavail = st->f_bfree; in xfs_fs_statfs()
992 mp->m_free[i].res_saved = mp->m_free[i].res_total; in xfs_save_resvblks()
1005 if (mp->m_free[i].res_saved) { in xfs_restore_resvblks()
1006 resblks = mp->m_free[i].res_saved; in xfs_restore_resvblks()
1007 mp->m_free[i].res_saved = 0; in xfs_restore_resvblks()
1039 * For read-write filesystems, we need to restart the inodegc on error in xfs_fs_freeze()
1088 if (mp->m_logbsize <= 0 && in xfs_finish_flags()
1089 mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE) { in xfs_finish_flags()
1090 mp->m_logbsize = mp->m_sb.sb_logsunit; in xfs_finish_flags()
1091 } else if (mp->m_logbsize > 0 && in xfs_finish_flags()
1092 mp->m_logbsize < mp->m_sb.sb_logsunit) { in xfs_finish_flags()
1095 return -EINVAL; in xfs_finish_flags()
1099 if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { in xfs_finish_flags()
1102 return -EINVAL; in xfs_finish_flags()
1107 * prohibit r/w mounts of read-only filesystems in xfs_finish_flags()
1109 if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !xfs_is_readonly(mp)) { in xfs_finish_flags()
1111 "cannot mount a read-only filesystem as read-write"); in xfs_finish_flags()
1112 return -EROFS; in xfs_finish_flags()
1115 if ((mp->m_qflags & XFS_GQUOTA_ACCT) && in xfs_finish_flags()
1116 (mp->m_qflags & XFS_PQUOTA_ACCT) && in xfs_finish_flags()
1120 return -EINVAL; in xfs_finish_flags()
1124 if (mp->m_max_open_zones) { in xfs_finish_flags()
1127 return -EINVAL; in xfs_finish_flags()
1129 if (mp->m_features & XFS_FEAT_NOLIFETIME) { in xfs_finish_flags()
1132 return -EINVAL; in xfs_finish_flags()
1146 error = percpu_counter_init(&mp->m_icount, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1148 return -ENOMEM; in xfs_init_percpu_counters()
1150 error = percpu_counter_init(&mp->m_ifree, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1154 error = percpu_counter_init(&mp->m_delalloc_blks, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1158 error = percpu_counter_init(&mp->m_delalloc_rtextents, 0, GFP_KERNEL); in xfs_init_percpu_counters()
1163 error = percpu_counter_init(&mp->m_free[i].count, 0, in xfs_init_percpu_counters()
1172 while (--i >= 0) in xfs_init_percpu_counters()
1173 percpu_counter_destroy(&mp->m_free[i].count); in xfs_init_percpu_counters()
1174 percpu_counter_destroy(&mp->m_delalloc_rtextents); in xfs_init_percpu_counters()
1176 percpu_counter_destroy(&mp->m_delalloc_blks); in xfs_init_percpu_counters()
1178 percpu_counter_destroy(&mp->m_ifree); in xfs_init_percpu_counters()
1180 percpu_counter_destroy(&mp->m_icount); in xfs_init_percpu_counters()
1181 return -ENOMEM; in xfs_init_percpu_counters()
1188 percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount); in xfs_reinit_percpu_counters()
1189 percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree); in xfs_reinit_percpu_counters()
1190 xfs_set_freecounter(mp, XC_FREE_BLOCKS, mp->m_sb.sb_fdblocks); in xfs_reinit_percpu_counters()
1193 mp->m_sb.sb_frextents); in xfs_reinit_percpu_counters()
1203 percpu_counter_destroy(&mp->m_free[i].count); in xfs_destroy_percpu_counters()
1204 percpu_counter_destroy(&mp->m_icount); in xfs_destroy_percpu_counters()
1205 percpu_counter_destroy(&mp->m_ifree); in xfs_destroy_percpu_counters()
1207 percpu_counter_sum(&mp->m_delalloc_rtextents) == 0); in xfs_destroy_percpu_counters()
1208 percpu_counter_destroy(&mp->m_delalloc_rtextents); in xfs_destroy_percpu_counters()
1210 percpu_counter_sum(&mp->m_delalloc_blks) == 0); in xfs_destroy_percpu_counters()
1211 percpu_counter_destroy(&mp->m_delalloc_blks); in xfs_destroy_percpu_counters()
1221 mp->m_inodegc = alloc_percpu(struct xfs_inodegc); in xfs_inodegc_init_percpu()
1222 if (!mp->m_inodegc) in xfs_inodegc_init_percpu()
1223 return -ENOMEM; in xfs_inodegc_init_percpu()
1226 gc = per_cpu_ptr(mp->m_inodegc, cpu); in xfs_inodegc_init_percpu()
1227 gc->cpu = cpu; in xfs_inodegc_init_percpu()
1228 gc->mp = mp; in xfs_inodegc_init_percpu()
1229 init_llist_head(&gc->list); in xfs_inodegc_init_percpu()
1230 gc->items = 0; in xfs_inodegc_init_percpu()
1231 gc->error = 0; in xfs_inodegc_init_percpu()
1232 INIT_DELAYED_WORK(&gc->work, xfs_inodegc_worker); in xfs_inodegc_init_percpu()
1241 if (!mp->m_inodegc) in xfs_inodegc_free_percpu()
1243 free_percpu(mp->m_inodegc); in xfs_inodegc_free_percpu()
1252 xfs_notice(mp, "Unmounting Filesystem %pU", &mp->m_sb.sb_uuid); in xfs_fs_put_super()
1259 free_percpu(mp->m_stats.xs_stats); in xfs_fs_put_super()
1272 if (WARN_ON_ONCE(!sb->s_fs_info)) in xfs_fs_nr_cached_objects()
1282 return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan); in xfs_fs_free_cached_objects()
1297 struct xfs_mount *mp = XFS_M(root->d_sb); in xfs_fs_show_stats()
1334 return -ENOMEM; in suffix_kstrtoint()
1336 last = strlen(value) - 1; in suffix_kstrtoint()
1351 ret = -EINVAL; in suffix_kstrtoint()
1370 return -ENOMEM; in suffix_kstrtoull()
1372 last = strlen(value) - 1; in suffix_kstrtoull()
1387 ret = -EINVAL; in suffix_kstrtoull()
1405 * initramfs and rely on mount -a to remount the root fs with the in xfs_fs_warn_deprecated()
1408 * /etc/fstab. On a single-fs system, that means no warning at all. in xfs_fs_warn_deprecated()
1415 xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key); in xfs_fs_warn_deprecated()
1421 * NOTE: mp->m_super is NULL here!
1428 struct xfs_mount *parsing_mp = fc->s_fs_info; in xfs_fs_parse_param()
1444 parsing_mp->m_logbufs = result.uint_32; in xfs_fs_parse_param()
1447 if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize)) in xfs_fs_parse_param()
1448 return -EINVAL; in xfs_fs_parse_param()
1451 kfree(parsing_mp->m_logname); in xfs_fs_parse_param()
1452 parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL); in xfs_fs_parse_param()
1453 if (!parsing_mp->m_logname) in xfs_fs_parse_param()
1454 return -ENOMEM; in xfs_fs_parse_param()
1457 kfree(parsing_mp->m_rtname); in xfs_fs_parse_param()
1458 parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL); in xfs_fs_parse_param()
1459 if (!parsing_mp->m_rtname) in xfs_fs_parse_param()
1460 return -ENOMEM; in xfs_fs_parse_param()
1463 if (suffix_kstrtoint(param->string, 10, &size)) in xfs_fs_parse_param()
1464 return -EINVAL; in xfs_fs_parse_param()
1465 parsing_mp->m_allocsize_log = ffs(size) - 1; in xfs_fs_parse_param()
1466 parsing_mp->m_features |= XFS_FEAT_ALLOCSIZE; in xfs_fs_parse_param()
1470 parsing_mp->m_features |= XFS_FEAT_GRPID; in xfs_fs_parse_param()
1474 parsing_mp->m_features &= ~XFS_FEAT_GRPID; in xfs_fs_parse_param()
1477 parsing_mp->m_features |= XFS_FEAT_WSYNC; in xfs_fs_parse_param()
1480 parsing_mp->m_features |= XFS_FEAT_NORECOVERY; in xfs_fs_parse_param()
1483 parsing_mp->m_features |= XFS_FEAT_NOALIGN; in xfs_fs_parse_param()
1486 parsing_mp->m_features |= XFS_FEAT_SWALLOC; in xfs_fs_parse_param()
1489 parsing_mp->m_dalign = result.uint_32; in xfs_fs_parse_param()
1492 parsing_mp->m_swidth = result.uint_32; in xfs_fs_parse_param()
1495 parsing_mp->m_features |= XFS_FEAT_SMALL_INUMS; in xfs_fs_parse_param()
1498 parsing_mp->m_features &= ~XFS_FEAT_SMALL_INUMS; in xfs_fs_parse_param()
1501 parsing_mp->m_features |= XFS_FEAT_NOUUID; in xfs_fs_parse_param()
1504 parsing_mp->m_features |= XFS_FEAT_LARGE_IOSIZE; in xfs_fs_parse_param()
1507 parsing_mp->m_features &= ~XFS_FEAT_LARGE_IOSIZE; in xfs_fs_parse_param()
1510 parsing_mp->m_features |= XFS_FEAT_FILESTREAMS; in xfs_fs_parse_param()
1513 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; in xfs_fs_parse_param()
1514 parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD; in xfs_fs_parse_param()
1515 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1520 parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ENFD); in xfs_fs_parse_param()
1521 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1525 parsing_mp->m_qflags |= XFS_UQUOTA_ACCT; in xfs_fs_parse_param()
1526 parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD; in xfs_fs_parse_param()
1527 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1531 parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ENFD); in xfs_fs_parse_param()
1532 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1535 parsing_mp->m_qflags |= XFS_PQUOTA_ACCT; in xfs_fs_parse_param()
1536 parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD; in xfs_fs_parse_param()
1537 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1541 parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ENFD); in xfs_fs_parse_param()
1542 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1545 parsing_mp->m_qflags |= XFS_GQUOTA_ACCT; in xfs_fs_parse_param()
1546 parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD; in xfs_fs_parse_param()
1547 parsing_mp->m_qflags |= XFS_QFLAGS_MNTOPTS; in xfs_fs_parse_param()
1550 parsing_mp->m_features |= XFS_FEAT_DISCARD; in xfs_fs_parse_param()
1553 parsing_mp->m_features &= ~XFS_FEAT_DISCARD; in xfs_fs_parse_param()
1564 parsing_mp->m_max_open_zones = result.uint_32; in xfs_fs_parse_param()
1567 parsing_mp->m_features &= ~XFS_FEAT_NOLIFETIME; in xfs_fs_parse_param()
1570 parsing_mp->m_features |= XFS_FEAT_NOLIFETIME; in xfs_fs_parse_param()
1573 if (suffix_kstrtoull(param->string, 10, in xfs_fs_parse_param()
1574 &parsing_mp->m_awu_max_bytes)) { in xfs_fs_parse_param()
1576 "max atomic write size must be positive integer"); in xfs_fs_parse_param()
1577 return -EINVAL; in xfs_fs_parse_param()
1581 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); in xfs_fs_parse_param()
1582 return -EINVAL; in xfs_fs_parse_param()
1592 /* No recovery flag requires a read-only mount */ in xfs_fs_validate_params()
1594 xfs_warn(mp, "no-recovery mounts must be read-only."); in xfs_fs_validate_params()
1595 return -EINVAL; in xfs_fs_validate_params()
1598 if (xfs_has_noalign(mp) && (mp->m_dalign || mp->m_swidth)) { in xfs_fs_validate_params()
1601 return -EINVAL; in xfs_fs_validate_params()
1605 (mp->m_qflags & ~XFS_QFLAGS_MNTOPTS)) { in xfs_fs_validate_params()
1607 return -EINVAL; in xfs_fs_validate_params()
1610 if ((mp->m_dalign && !mp->m_swidth) || in xfs_fs_validate_params()
1611 (!mp->m_dalign && mp->m_swidth)) { in xfs_fs_validate_params()
1613 return -EINVAL; in xfs_fs_validate_params()
1616 if (mp->m_dalign && (mp->m_swidth % mp->m_dalign != 0)) { in xfs_fs_validate_params()
1619 mp->m_swidth, mp->m_dalign); in xfs_fs_validate_params()
1620 return -EINVAL; in xfs_fs_validate_params()
1623 if (mp->m_logbufs != -1 && in xfs_fs_validate_params()
1624 mp->m_logbufs != 0 && in xfs_fs_validate_params()
1625 (mp->m_logbufs < XLOG_MIN_ICLOGS || in xfs_fs_validate_params()
1626 mp->m_logbufs > XLOG_MAX_ICLOGS)) { in xfs_fs_validate_params()
1627 xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", in xfs_fs_validate_params()
1628 mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); in xfs_fs_validate_params()
1629 return -EINVAL; in xfs_fs_validate_params()
1632 if (mp->m_logbsize != -1 && in xfs_fs_validate_params()
1633 mp->m_logbsize != 0 && in xfs_fs_validate_params()
1634 (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || in xfs_fs_validate_params()
1635 mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || in xfs_fs_validate_params()
1636 !is_power_of_2(mp->m_logbsize))) { in xfs_fs_validate_params()
1639 mp->m_logbsize); in xfs_fs_validate_params()
1640 return -EINVAL; in xfs_fs_validate_params()
1644 (mp->m_allocsize_log > XFS_MAX_IO_LOG || in xfs_fs_validate_params()
1645 mp->m_allocsize_log < XFS_MIN_IO_LOG)) { in xfs_fs_validate_params()
1646 xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", in xfs_fs_validate_params()
1647 mp->m_allocsize_log, XFS_MIN_IO_LOG, XFS_MAX_IO_LOG); in xfs_fs_validate_params()
1648 return -EINVAL; in xfs_fs_validate_params()
1674 struct xfs_mount *mp = sb->s_fs_info; in xfs_fs_fill_super()
1678 mp->m_super = sb; in xfs_fs_fill_super()
1685 if (fc->sb_flags & SB_RDONLY) in xfs_fs_fill_super()
1687 if (fc->sb_flags & SB_DIRSYNC) in xfs_fs_fill_super()
1688 mp->m_features |= XFS_FEAT_DIRSYNC; in xfs_fs_fill_super()
1689 if (fc->sb_flags & SB_SYNCHRONOUS) in xfs_fs_fill_super()
1690 mp->m_features |= XFS_FEAT_WSYNC; in xfs_fs_fill_super()
1697 sb->s_xattr = xfs_xattr_handlers; in xfs_fs_fill_super()
1698 sb->s_export_op = &xfs_export_operations; in xfs_fs_fill_super()
1700 sb->s_qcop = &xfs_quotactl_operations; in xfs_fs_fill_super()
1701 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; in xfs_fs_fill_super()
1703 sb->s_op = &xfs_super_operations; in xfs_fs_fill_super()
1716 if (fc->sb_flags & SB_SILENT) in xfs_fs_fill_super()
1724 mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id, in xfs_fs_fill_super()
1727 mp->m_debugfs = NULL; in xfs_fs_fill_super()
1743 mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); in xfs_fs_fill_super()
1744 if (!mp->m_stats.xs_stats) { in xfs_fs_fill_super()
1745 error = -ENOMEM; in xfs_fs_fill_super()
1771 if (!(mp->m_features & XFS_FEAT_CRC)) { in xfs_fs_fill_super()
1775 error = -EINVAL; in xfs_fs_fill_super()
1786 …"Deprecated ASCII case-insensitivity feature (ascii-ci=1) will not be supported after September 20… in xfs_fs_fill_super()
1789 "Deprecated ASCII case-insensitivity feature (ascii-ci=1) not supported by kernel."); in xfs_fs_fill_super()
1790 error = -EINVAL; in xfs_fs_fill_super()
1802 error = -EFSCORRUPTED; in xfs_fs_fill_super()
1811 if (mp->m_sb.sb_inprogress) { in xfs_fs_fill_super()
1813 error = -EFSCORRUPTED; in xfs_fs_fill_super()
1817 if (mp->m_sb.sb_blocksize > PAGE_SIZE) { in xfs_fs_fill_super()
1823 mp->m_sb.sb_blocksize, PAGE_SIZE); in xfs_fs_fill_super()
1824 error = -ENOSYS; in xfs_fs_fill_super()
1828 if (mp->m_sb.sb_blocksize > max_folio_size) { in xfs_fs_fill_super()
1831 mp->m_sb.sb_blocksize, max_folio_size); in xfs_fs_fill_super()
1832 error = -ENOSYS; in xfs_fs_fill_super()
1840 if (xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_dblocks) || in xfs_fs_fill_super()
1841 xfs_sb_validate_fsb_count(&mp->m_sb, mp->m_sb.sb_rblocks)) { in xfs_fs_fill_super()
1844 error = -EFBIG; in xfs_fs_fill_super()
1851 * supports (currently 2^63 bytes on 64-bit and ULONG_MAX << PAGE_SHIFT in xfs_fs_fill_super()
1852 * bytes on 32-bit), but as XFS and VFS have gotten the s_maxbytes in xfs_fs_fill_super()
1853 * calculation wrong on 32-bit kernels in the past, we'll add a WARN_ON in xfs_fs_fill_super()
1864 error = -EINVAL; in xfs_fs_fill_super()
1880 sb->s_magic = XFS_SUPER_MAGIC; in xfs_fs_fill_super()
1881 sb->s_blocksize = mp->m_sb.sb_blocksize; in xfs_fs_fill_super()
1882 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; in xfs_fs_fill_super()
1883 sb->s_maxbytes = MAX_LFS_FILESIZE; in xfs_fs_fill_super()
1884 sb->s_max_links = XFS_MAXLINK; in xfs_fs_fill_super()
1885 sb->s_time_gran = 1; in xfs_fs_fill_super()
1887 sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN); in xfs_fs_fill_super()
1888 sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX); in xfs_fs_fill_super()
1890 sb->s_time_min = XFS_LEGACY_TIME_MIN; in xfs_fs_fill_super()
1891 sb->s_time_max = XFS_LEGACY_TIME_MAX; in xfs_fs_fill_super()
1893 trace_xfs_inode_timestamp_range(mp, sb->s_time_min, sb->s_time_max); in xfs_fs_fill_super()
1894 sb->s_iflags |= SB_I_CGROUPWB | SB_I_ALLOW_HSM; in xfs_fs_fill_super()
1900 sb->s_flags |= SB_I_VERSION; in xfs_fs_fill_super()
1908 if (xfs_has_discard(mp) && !bdev_max_discard_sectors(sb->s_bdev)) { in xfs_fs_fill_super()
1911 mp->m_features &= ~XFS_FEAT_DISCARD; in xfs_fs_fill_super()
1918 error = -EINVAL; in xfs_fs_fill_super()
1928 !xfs_reflink_supports_rextsize(mp, mp->m_sb.sb_rextsize)) { in xfs_fs_fill_super()
1931 mp->m_sb.sb_rextsize); in xfs_fs_fill_super()
1932 error = -EINVAL; in xfs_fs_fill_super()
1939 error = -EINVAL; in xfs_fs_fill_super()
1944 xfs_info(mp, "using DEBUG-only always_cow mode."); in xfs_fs_fill_super()
1945 mp->m_always_cow = true; in xfs_fs_fill_super()
1953 if (!(mp->m_qflags & XFS_QFLAGS_MNTOPTS)) in xfs_fs_fill_super()
1955 mp->m_qflags &= ~XFS_QFLAGS_MNTOPTS; in xfs_fs_fill_super()
1961 root = igrab(VFS_I(mp->m_rootip)); in xfs_fs_fill_super()
1963 error = -ENOENT; in xfs_fs_fill_super()
1966 sb->s_root = d_make_root(root); in xfs_fs_fill_super()
1967 if (!sb->s_root) { in xfs_fs_fill_super()
1968 error = -ENOMEM; in xfs_fs_fill_super()
1983 free_percpu(mp->m_stats.xs_stats); in xfs_fs_fill_super()
2011 struct xfs_sb *sbp = &mp->m_sb; in xfs_remount_rw()
2014 if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp && in xfs_remount_rw()
2015 xfs_readonly_buftarg(mp->m_logdev_targp)) { in xfs_remount_rw()
2017 "ro->rw transition prohibited by read-only logdev"); in xfs_remount_rw()
2018 return -EACCES; in xfs_remount_rw()
2021 if (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp)) { in xfs_remount_rw()
2023 "ro->rw transition prohibited by read-only rtdev"); in xfs_remount_rw()
2024 return -EACCES; in xfs_remount_rw()
2029 "ro->rw transition prohibited on norecovery mount"); in xfs_remount_rw()
2030 return -EINVAL; in xfs_remount_rw()
2036 "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem", in xfs_remount_rw()
2037 (sbp->sb_features_ro_compat & in xfs_remount_rw()
2039 return -EINVAL; in xfs_remount_rw()
2048 if (mp->m_update_sb) { in xfs_remount_rw()
2054 mp->m_update_sb = false; in xfs_remount_rw()
2059 * it is non-zero, otherwise go with the default. in xfs_remount_rw()
2065 /* Create the per-AG metadata reservation pool .*/ in xfs_remount_rw()
2067 if (error && error != -ENOSPC) in xfs_remount_rw()
2070 /* Re-enable the background inode inactivation worker. */ in xfs_remount_rw()
2089 error = sync_filesystem(mp->m_super); in xfs_remount_ro()
2100 * Clear out all remaining COW staging extents and speculative post-EOF in xfs_remount_ro()
2102 * cleanups during reclaim on a read-only mount. We must process every in xfs_remount_ro()
2123 /* Free the per-AG metadata reservation pool. */ in xfs_remount_ro()
2157 struct xfs_mount *mp = XFS_M(fc->root->d_sb); in xfs_fs_reconfigure()
2158 struct xfs_mount *new_mp = fc->s_fs_info; in xfs_fs_reconfigure()
2159 int flags = fc->sb_flags; in xfs_fs_reconfigure()
2162 new_mp->m_qflags &= ~XFS_QFLAGS_MNTOPTS; in xfs_fs_reconfigure()
2166 fc->sb_flags |= SB_I_VERSION; in xfs_fs_reconfigure()
2173 if (mp->m_awu_max_bytes != new_mp->m_awu_max_bytes) { in xfs_fs_reconfigure()
2175 new_mp->m_awu_max_bytes); in xfs_fs_reconfigure()
2180 /* inode32 -> inode64 */ in xfs_fs_reconfigure()
2182 mp->m_features &= ~XFS_FEAT_SMALL_INUMS; in xfs_fs_reconfigure()
2183 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount); in xfs_fs_reconfigure()
2186 /* inode64 -> inode32 */ in xfs_fs_reconfigure()
2188 mp->m_features |= XFS_FEAT_SMALL_INUMS; in xfs_fs_reconfigure()
2189 mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount); in xfs_fs_reconfigure()
2203 /* ro -> rw */ in xfs_fs_reconfigure()
2210 /* rw -> ro */ in xfs_fs_reconfigure()
2224 struct xfs_mount *mp = fc->s_fs_info; in xfs_fs_free()
2257 return -ENOMEM; in xfs_init_fs_context()
2259 spin_lock_init(&mp->m_sb_lock); in xfs_init_fs_context()
2261 xa_init(&mp->m_groups[i].xa); in xfs_init_fs_context()
2262 mutex_init(&mp->m_growlock); in xfs_init_fs_context()
2263 mutex_init(&mp->m_metafile_resv_lock); in xfs_init_fs_context()
2264 INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker); in xfs_init_fs_context()
2265 INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker); in xfs_init_fs_context()
2266 mp->m_kobj.kobject.kset = xfs_kset; in xfs_init_fs_context()
2268 * We don't create the finobt per-ag space reservation until after log in xfs_init_fs_context()
2273 mp->m_finobt_nores = true; in xfs_init_fs_context()
2278 mp->m_logbufs = -1; in xfs_init_fs_context()
2279 mp->m_logbsize = -1; in xfs_init_fs_context()
2280 mp->m_allocsize_log = 16; /* 64k */ in xfs_init_fs_context()
2282 xfs_hooks_init(&mp->m_dir_update_hooks); in xfs_init_fs_context()
2284 fc->s_fs_info = mp; in xfs_init_fs_context()
2285 fc->ops = &xfs_context_ops; in xfs_init_fs_context()
2359 * The size of the cache-allocated buf log item is the maximum in xfs_init_caches()
2528 return -ENOMEM; in xfs_init_caches()
2579 return -ENOMEM; in xfs_init_workqueues()
2589 return -ENOMEM; in xfs_init_workqueues()
2639 error = -ENOMEM; in init_xfs_fs()
2647 error = -ENOMEM; in init_xfs_fs()