diff options
author | David Chinner <david@fromorbit.com> | 2008-10-30 02:06:18 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 02:06:18 -0400 |
commit | a167b17e899a930758506bbc18748078d6fd8c89 (patch) | |
tree | 698f8efbe5085ae75e0b46e1b71c7bfc7186d3b2 /fs/xfs/linux-2.6/xfs_super.c | |
parent | fe4fa4b8e463fa5848ef9e86ed75d27501d0da1e (diff) |
[XFS] move xfssyncd code to xfs_sync.c
Move all the xfssyncd code to the new xfs_sync.c file. This places it
closer to the actual code that it interacts with, rather than just being
associated with high level VFS code.
SGI-PV: 988139
SGI-Modid: xfs-linux-melb:xfs-kern:32283a
Signed-off-by: David Chinner <david@fromorbit.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_super.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 151 |
1 files changed, 3 insertions, 148 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 727d0e47e80f..767f38e0e0bb 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -979,146 +979,6 @@ xfs_fs_clear_inode( | |||
979 | ASSERT(XFS_I(inode) == NULL); | 979 | ASSERT(XFS_I(inode) == NULL); |
980 | } | 980 | } |
981 | 981 | ||
982 | /* | ||
983 | * Enqueue a work item to be picked up by the vfs xfssyncd thread. | ||
984 | * Doing this has two advantages: | ||
985 | * - It saves on stack space, which is tight in certain situations | ||
986 | * - It can be used (with care) as a mechanism to avoid deadlocks. | ||
987 | * Flushing while allocating in a full filesystem requires both. | ||
988 | */ | ||
989 | STATIC void | ||
990 | xfs_syncd_queue_work( | ||
991 | struct xfs_mount *mp, | ||
992 | void *data, | ||
993 | void (*syncer)(struct xfs_mount *, void *)) | ||
994 | { | ||
995 | struct bhv_vfs_sync_work *work; | ||
996 | |||
997 | work = kmem_alloc(sizeof(struct bhv_vfs_sync_work), KM_SLEEP); | ||
998 | INIT_LIST_HEAD(&work->w_list); | ||
999 | work->w_syncer = syncer; | ||
1000 | work->w_data = data; | ||
1001 | work->w_mount = mp; | ||
1002 | spin_lock(&mp->m_sync_lock); | ||
1003 | list_add_tail(&work->w_list, &mp->m_sync_list); | ||
1004 | spin_unlock(&mp->m_sync_lock); | ||
1005 | wake_up_process(mp->m_sync_task); | ||
1006 | } | ||
1007 | |||
1008 | /* | ||
1009 | * Flush delayed allocate data, attempting to free up reserved space | ||
1010 | * from existing allocations. At this point a new allocation attempt | ||
1011 | * has failed with ENOSPC and we are in the process of scratching our | ||
1012 | * heads, looking about for more room... | ||
1013 | */ | ||
1014 | STATIC void | ||
1015 | xfs_flush_inode_work( | ||
1016 | struct xfs_mount *mp, | ||
1017 | void *arg) | ||
1018 | { | ||
1019 | struct inode *inode = arg; | ||
1020 | filemap_flush(inode->i_mapping); | ||
1021 | iput(inode); | ||
1022 | } | ||
1023 | |||
1024 | void | ||
1025 | xfs_flush_inode( | ||
1026 | xfs_inode_t *ip) | ||
1027 | { | ||
1028 | struct inode *inode = VFS_I(ip); | ||
1029 | |||
1030 | igrab(inode); | ||
1031 | xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_inode_work); | ||
1032 | delay(msecs_to_jiffies(500)); | ||
1033 | } | ||
1034 | |||
1035 | /* | ||
1036 | * This is the "bigger hammer" version of xfs_flush_inode_work... | ||
1037 | * (IOW, "If at first you don't succeed, use a Bigger Hammer"). | ||
1038 | */ | ||
1039 | STATIC void | ||
1040 | xfs_flush_device_work( | ||
1041 | struct xfs_mount *mp, | ||
1042 | void *arg) | ||
1043 | { | ||
1044 | struct inode *inode = arg; | ||
1045 | sync_blockdev(mp->m_super->s_bdev); | ||
1046 | iput(inode); | ||
1047 | } | ||
1048 | |||
1049 | void | ||
1050 | xfs_flush_device( | ||
1051 | xfs_inode_t *ip) | ||
1052 | { | ||
1053 | struct inode *inode = VFS_I(ip); | ||
1054 | |||
1055 | igrab(inode); | ||
1056 | xfs_syncd_queue_work(ip->i_mount, inode, xfs_flush_device_work); | ||
1057 | delay(msecs_to_jiffies(500)); | ||
1058 | xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC); | ||
1059 | } | ||
1060 | |||
1061 | STATIC void | ||
1062 | xfs_sync_worker( | ||
1063 | struct xfs_mount *mp, | ||
1064 | void *unused) | ||
1065 | { | ||
1066 | int error; | ||
1067 | |||
1068 | if (!(mp->m_flags & XFS_MOUNT_RDONLY)) | ||
1069 | error = xfs_sync(mp, SYNC_FSDATA | SYNC_BDFLUSH | SYNC_ATTR); | ||
1070 | mp->m_sync_seq++; | ||
1071 | wake_up(&mp->m_wait_single_sync_task); | ||
1072 | } | ||
1073 | |||
1074 | STATIC int | ||
1075 | xfssyncd( | ||
1076 | void *arg) | ||
1077 | { | ||
1078 | struct xfs_mount *mp = arg; | ||
1079 | long timeleft; | ||
1080 | bhv_vfs_sync_work_t *work, *n; | ||
1081 | LIST_HEAD (tmp); | ||
1082 | |||
1083 | set_freezable(); | ||
1084 | timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10); | ||
1085 | for (;;) { | ||
1086 | timeleft = schedule_timeout_interruptible(timeleft); | ||
1087 | /* swsusp */ | ||
1088 | try_to_freeze(); | ||
1089 | if (kthread_should_stop() && list_empty(&mp->m_sync_list)) | ||
1090 | break; | ||
1091 | |||
1092 | spin_lock(&mp->m_sync_lock); | ||
1093 | /* | ||
1094 | * We can get woken by laptop mode, to do a sync - | ||
1095 | * that's the (only!) case where the list would be | ||
1096 | * empty with time remaining. | ||
1097 | */ | ||
1098 | if (!timeleft || list_empty(&mp->m_sync_list)) { | ||
1099 | if (!timeleft) | ||
1100 | timeleft = xfs_syncd_centisecs * | ||
1101 | msecs_to_jiffies(10); | ||
1102 | INIT_LIST_HEAD(&mp->m_sync_work.w_list); | ||
1103 | list_add_tail(&mp->m_sync_work.w_list, | ||
1104 | &mp->m_sync_list); | ||
1105 | } | ||
1106 | list_for_each_entry_safe(work, n, &mp->m_sync_list, w_list) | ||
1107 | list_move(&work->w_list, &tmp); | ||
1108 | spin_unlock(&mp->m_sync_lock); | ||
1109 | |||
1110 | list_for_each_entry_safe(work, n, &tmp, w_list) { | ||
1111 | (*work->w_syncer)(mp, work->w_data); | ||
1112 | list_del(&work->w_list); | ||
1113 | if (work == &mp->m_sync_work) | ||
1114 | continue; | ||
1115 | kmem_free(work); | ||
1116 | } | ||
1117 | } | ||
1118 | |||
1119 | return 0; | ||
1120 | } | ||
1121 | |||
1122 | STATIC void | 982 | STATIC void |
1123 | xfs_free_fsname( | 983 | xfs_free_fsname( |
1124 | struct xfs_mount *mp) | 984 | struct xfs_mount *mp) |
@@ -1137,8 +997,7 @@ xfs_fs_put_super( | |||
1137 | int unmount_event_flags = 0; | 997 | int unmount_event_flags = 0; |
1138 | int error; | 998 | int error; |
1139 | 999 | ||
1140 | kthread_stop(mp->m_sync_task); | 1000 | xfs_syncd_stop(mp); |
1141 | |||
1142 | xfs_sync(mp, SYNC_ATTR | SYNC_DELWRI); | 1001 | xfs_sync(mp, SYNC_ATTR | SYNC_DELWRI); |
1143 | 1002 | ||
1144 | #ifdef HAVE_DMAPI | 1003 | #ifdef HAVE_DMAPI |
@@ -1808,13 +1667,9 @@ xfs_fs_fill_super( | |||
1808 | goto fail_vnrele; | 1667 | goto fail_vnrele; |
1809 | } | 1668 | } |
1810 | 1669 | ||
1811 | mp->m_sync_work.w_syncer = xfs_sync_worker; | 1670 | error = xfs_syncd_init(mp); |
1812 | mp->m_sync_work.w_mount = mp; | 1671 | if (error) |
1813 | mp->m_sync_task = kthread_run(xfssyncd, mp, "xfssyncd"); | ||
1814 | if (IS_ERR(mp->m_sync_task)) { | ||
1815 | error = -PTR_ERR(mp->m_sync_task); | ||
1816 | goto fail_vnrele; | 1672 | goto fail_vnrele; |
1817 | } | ||
1818 | 1673 | ||
1819 | xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); | 1674 | xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); |
1820 | 1675 | ||