xfs_super.c (5b0ad7c2a52d4fdfec86a2c29096701783f46719) xfs_super.c (f736d93d76d3e97d6986c6d26c8eaa32536ccc5c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7#include "xfs.h"
8#include "xfs_shared.h"

--- 854 unchanged lines hidden (view full) ---

863 mp->m_resblks_save = 0;
864 } else
865 resblks = xfs_default_resblks(mp);
866
867 xfs_reserve_blocks(mp, &resblks, NULL);
868}
869
870/*
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7#include "xfs.h"
8#include "xfs_shared.h"

--- 854 unchanged lines hidden (view full) ---

863 mp->m_resblks_save = 0;
864 } else
865 resblks = xfs_default_resblks(mp);
866
867 xfs_reserve_blocks(mp, &resblks, NULL);
868}
869
870/*
871 * Trigger writeback of all the dirty metadata in the file system.
872 *
873 * This ensures that the metadata is written to their location on disk rather
874 * than just existing in transactions in the log. This means after a quiesce
875 * there is no log replay required to write the inodes to disk - this is the
876 * primary difference between a sync and a quiesce.
877 *
878 * We cancel log work early here to ensure all transactions the log worker may
879 * run have finished before we clean up and log the superblock and write an
880 * unmount record. The unfreeze process is responsible for restarting the log
881 * worker correctly.
882 */
883void
884xfs_quiesce_attr(
885 struct xfs_mount *mp)
886{
887 int error = 0;
888
889 cancel_delayed_work_sync(&mp->m_log->l_work);
890
891 /* force the log to unpin objects from the now complete transactions */
892 xfs_log_force(mp, XFS_LOG_SYNC);
893
894
895 /* Push the superblock and write an unmount record */
896 error = xfs_log_sbcount(mp);
897 if (error)
898 xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. "
899 "Frozen image may not be consistent.");
900 xfs_log_quiesce(mp);
901}
902
903/*
871 * Second stage of a freeze. The data is already frozen so we only
872 * need to take care of the metadata. Once that's done sync the superblock
873 * to the log to dirty it in case of a crash while frozen. This ensures that we
874 * will recover the unlinked inode lists on the next mount.
875 */
876STATIC int
877xfs_fs_freeze(
878 struct super_block *sb)

--- 5 unchanged lines hidden (view full) ---

884 /*
885 * The filesystem is now frozen far enough that memory reclaim
886 * cannot safely operate on the filesystem. Hence we need to
887 * set a GFP_NOFS context here to avoid recursion deadlocks.
888 */
889 flags = memalloc_nofs_save();
890 xfs_stop_block_reaping(mp);
891 xfs_save_resvblks(mp);
904 * Second stage of a freeze. The data is already frozen so we only
905 * need to take care of the metadata. Once that's done sync the superblock
906 * to the log to dirty it in case of a crash while frozen. This ensures that we
907 * will recover the unlinked inode lists on the next mount.
908 */
909STATIC int
910xfs_fs_freeze(
911 struct super_block *sb)

--- 5 unchanged lines hidden (view full) ---

917 /*
918 * The filesystem is now frozen far enough that memory reclaim
919 * cannot safely operate on the filesystem. Hence we need to
920 * set a GFP_NOFS context here to avoid recursion deadlocks.
921 */
922 flags = memalloc_nofs_save();
923 xfs_stop_block_reaping(mp);
924 xfs_save_resvblks(mp);
892 ret = xfs_log_quiesce(mp);
925 xfs_quiesce_attr(mp);
926 ret = xfs_sync_sb(mp, true);
893 memalloc_nofs_restore(flags);
894 return ret;
895}
896
897STATIC int
898xfs_fs_unfreeze(
899 struct super_block *sb)
900{

--- 825 unchanged lines hidden (view full) ---

1726 * Before we sync the metadata, we need to free up the reserve block
1727 * pool so that the used block count in the superblock on disk is
1728 * correct at the end of the remount. Stash the current* reserve pool
1729 * size so that if we get remounted rw, we can return it to the same
1730 * size.
1731 */
1732 xfs_save_resvblks(mp);
1733
927 memalloc_nofs_restore(flags);
928 return ret;
929}
930
931STATIC int
932xfs_fs_unfreeze(
933 struct super_block *sb)
934{

--- 825 unchanged lines hidden (view full) ---

1760 * Before we sync the metadata, we need to free up the reserve block
1761 * pool so that the used block count in the superblock on disk is
1762 * correct at the end of the remount. Stash the current* reserve pool
1763 * size so that if we get remounted rw, we can return it to the same
1764 * size.
1765 */
1766 xfs_save_resvblks(mp);
1767
1734 xfs_log_clean(mp);
1768 xfs_quiesce_attr(mp);
1735 mp->m_flags |= XFS_MOUNT_RDONLY;
1736
1737 return 0;
1738}
1739
1740/*
1741 * Logically we would return an error here to prevent users from believing
1742 * they might have changed mount options using remount which can't be changed.

--- 130 unchanged lines hidden (view full) ---

1873}
1874
1875static struct file_system_type xfs_fs_type = {
1876 .owner = THIS_MODULE,
1877 .name = "xfs",
1878 .init_fs_context = xfs_init_fs_context,
1879 .parameters = xfs_fs_parameters,
1880 .kill_sb = kill_block_super,
1769 mp->m_flags |= XFS_MOUNT_RDONLY;
1770
1771 return 0;
1772}
1773
1774/*
1775 * Logically we would return an error here to prevent users from believing
1776 * they might have changed mount options using remount which can't be changed.

--- 130 unchanged lines hidden (view full) ---

1907}
1908
1909static struct file_system_type xfs_fs_type = {
1910 .owner = THIS_MODULE,
1911 .name = "xfs",
1912 .init_fs_context = xfs_init_fs_context,
1913 .parameters = xfs_fs_parameters,
1914 .kill_sb = kill_block_super,
1881 .fs_flags = FS_REQUIRES_DEV,
1915 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
1882};
1883MODULE_ALIAS_FS("xfs");
1884
1885STATIC int __init
1886xfs_init_zones(void)
1887{
1888 xfs_log_ticket_zone = kmem_cache_create("xfs_log_ticket",
1889 sizeof(struct xlog_ticket),

--- 344 unchanged lines hidden ---
1916};
1917MODULE_ALIAS_FS("xfs");
1918
1919STATIC int __init
1920xfs_init_zones(void)
1921{
1922 xfs_log_ticket_zone = kmem_cache_create("xfs_log_ticket",
1923 sizeof(struct xlog_ticket),

--- 344 unchanged lines hidden ---