diff options
author | Dave Chinner <dchinner@redhat.com> | 2012-10-08 06:56:07 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-10-17 14:30:20 -0400 |
commit | c7eea6f7adca4501d2c2db7f0f7c9dc88efac95e (patch) | |
tree | 0018d3cd55958ed32f3cd3e6a57d82b642e24fe8 /fs/xfs | |
parent | 34061f5c420561dd42addd252811a1fa4b0ac69b (diff) |
xfs: move xfs_quiesce_attr() into xfs_super.c
Both callers of xfs_quiesce_attr() are in xfs_super.c, and there's
nothing really sync-specific about this functionality so it doesn't
really matter where it lives. Move it to benext to it's callers, so
all the remount/sync_fs code is in the one place.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_super.c | 67 | ||||
-rw-r--r-- | fs/xfs/xfs_sync.c | 65 | ||||
-rw-r--r-- | fs/xfs/xfs_sync.h | 3 |
3 files changed, 67 insertions, 68 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index b5e445a13f7b..3bafe66227fb 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -1148,6 +1148,73 @@ xfs_restore_resvblks(struct xfs_mount *mp) | |||
1148 | xfs_reserve_blocks(mp, &resblks, NULL); | 1148 | xfs_reserve_blocks(mp, &resblks, NULL); |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | /* | ||
1152 | * Trigger writeback of all the dirty metadata in the file system. | ||
1153 | * | ||
1154 | * This ensures that the metadata is written to their location on disk rather | ||
1155 | * than just existing in transactions in the log. This means after a quiesce | ||
1156 | * there is no log replay required to write the inodes to disk (this is the main | ||
1157 | * difference between a sync and a quiesce). | ||
1158 | * | ||
1159 | * This shoul deffectively mimic the code in xfs_unmountfs() and | ||
1160 | * xfs_log_umount() but without tearing down any structures. | ||
1161 | * XXX: bug fixes needed! | ||
1162 | * | ||
1163 | * Note: this stops background log work - the callers must ensure it is started | ||
1164 | * again when appropriate. | ||
1165 | */ | ||
1166 | void | ||
1167 | xfs_quiesce_attr( | ||
1168 | struct xfs_mount *mp) | ||
1169 | { | ||
1170 | int error = 0; | ||
1171 | |||
1172 | /* wait for all modifications to complete */ | ||
1173 | while (atomic_read(&mp->m_active_trans) > 0) | ||
1174 | delay(100); | ||
1175 | |||
1176 | /* force the log to unpin objects from the now complete transactions */ | ||
1177 | xfs_log_force(mp, XFS_LOG_SYNC); | ||
1178 | |||
1179 | /* reclaim inodes to do any IO before the freeze completes */ | ||
1180 | xfs_reclaim_inodes(mp, 0); | ||
1181 | xfs_reclaim_inodes(mp, SYNC_WAIT); | ||
1182 | |||
1183 | /* flush all pending changes from the AIL */ | ||
1184 | xfs_ail_push_all_sync(mp->m_ail); | ||
1185 | |||
1186 | /* stop background log work */ | ||
1187 | cancel_delayed_work_sync(&mp->m_log->l_work); | ||
1188 | |||
1189 | /* | ||
1190 | * Just warn here till VFS can correctly support | ||
1191 | * read-only remount without racing. | ||
1192 | */ | ||
1193 | WARN_ON(atomic_read(&mp->m_active_trans) != 0); | ||
1194 | |||
1195 | /* Push the superblock and write an unmount record */ | ||
1196 | error = xfs_log_sbcount(mp); | ||
1197 | if (error) | ||
1198 | xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. " | ||
1199 | "Frozen image may not be consistent."); | ||
1200 | xfs_log_unmount_write(mp); | ||
1201 | |||
1202 | /* | ||
1203 | * At this point we might have modified the superblock again and thus | ||
1204 | * added an item to the AIL, thus flush it again. | ||
1205 | */ | ||
1206 | xfs_ail_push_all_sync(mp->m_ail); | ||
1207 | |||
1208 | /* | ||
1209 | * The superblock buffer is uncached and xfsaild_push() will lock and | ||
1210 | * set the XBF_ASYNC flag on the buffer. We cannot do xfs_buf_iowait() | ||
1211 | * here but a lock on the superblock buffer will block until iodone() | ||
1212 | * has completed. | ||
1213 | */ | ||
1214 | xfs_buf_lock(mp->m_sb_bp); | ||
1215 | xfs_buf_unlock(mp->m_sb_bp); | ||
1216 | } | ||
1217 | |||
1151 | STATIC int | 1218 | STATIC int |
1152 | xfs_fs_remount( | 1219 | xfs_fs_remount( |
1153 | struct super_block *sb, | 1220 | struct super_block *sb, |
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c index 581eb59a85b5..7b630288bab5 100644 --- a/fs/xfs/xfs_sync.c +++ b/fs/xfs/xfs_sync.c | |||
@@ -215,71 +215,6 @@ xfs_inode_ag_iterator( | |||
215 | } | 215 | } |
216 | 216 | ||
217 | /* | 217 | /* |
218 | * Second stage of a quiesce. The data is already synced, now we have to take | ||
219 | * care of the metadata. New transactions are already blocked, so we need to | ||
220 | * wait for any remaining transactions to drain out before proceeding. | ||
221 | * | ||
222 | * The second phase ensures that the inodes are written to their | ||
223 | * location on disk rather than just existing in transactions in the log. This | ||
224 | * means after a quiesce there is no log replay required to write the inodes to | ||
225 | * disk (this is the main difference between a sync and a quiesce). | ||
226 | * | ||
227 | * Note: this stops background sync work - the callers must ensure it is started | ||
228 | * again when appropriate. | ||
229 | */ | ||
230 | void | ||
231 | xfs_quiesce_attr( | ||
232 | struct xfs_mount *mp) | ||
233 | { | ||
234 | int error = 0; | ||
235 | |||
236 | /* wait for all modifications to complete */ | ||
237 | while (atomic_read(&mp->m_active_trans) > 0) | ||
238 | delay(100); | ||
239 | |||
240 | /* force the log to unpin objects from the now complete transactions */ | ||
241 | xfs_log_force(mp, XFS_LOG_SYNC); | ||
242 | |||
243 | /* reclaim inodes to do any IO before the freeze completes */ | ||
244 | xfs_reclaim_inodes(mp, 0); | ||
245 | xfs_reclaim_inodes(mp, SYNC_WAIT); | ||
246 | |||
247 | /* flush all pending changes from the AIL */ | ||
248 | xfs_ail_push_all_sync(mp->m_ail); | ||
249 | |||
250 | /* stop background log work */ | ||
251 | cancel_delayed_work_sync(&mp->m_log->l_work); | ||
252 | |||
253 | /* | ||
254 | * Just warn here till VFS can correctly support | ||
255 | * read-only remount without racing. | ||
256 | */ | ||
257 | WARN_ON(atomic_read(&mp->m_active_trans) != 0); | ||
258 | |||
259 | /* Push the superblock and write an unmount record */ | ||
260 | error = xfs_log_sbcount(mp); | ||
261 | if (error) | ||
262 | xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. " | ||
263 | "Frozen image may not be consistent."); | ||
264 | xfs_log_unmount_write(mp); | ||
265 | |||
266 | /* | ||
267 | * At this point we might have modified the superblock again and thus | ||
268 | * added an item to the AIL, thus flush it again. | ||
269 | */ | ||
270 | xfs_ail_push_all_sync(mp->m_ail); | ||
271 | |||
272 | /* | ||
273 | * The superblock buffer is uncached and xfsaild_push() will lock and | ||
274 | * set the XBF_ASYNC flag on the buffer. We cannot do xfs_buf_iowait() | ||
275 | * here but a lock on the superblock buffer will block until iodone() | ||
276 | * has completed. | ||
277 | */ | ||
278 | xfs_buf_lock(mp->m_sb_bp); | ||
279 | xfs_buf_unlock(mp->m_sb_bp); | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Queue a new inode reclaim pass if there are reclaimable inodes and there | 218 | * Queue a new inode reclaim pass if there are reclaimable inodes and there |
284 | * isn't a reclaim pass already in progress. By default it runs every 5s based | 219 | * isn't a reclaim pass already in progress. By default it runs every 5s based |
285 | * on the xfs periodic sync default of 30s. Perhaps this should have it's own | 220 | * on the xfs periodic sync default of 30s. Perhaps this should have it's own |
diff --git a/fs/xfs/xfs_sync.h b/fs/xfs/xfs_sync.h index 0beabea99e73..0ba9c89c316e 100644 --- a/fs/xfs/xfs_sync.h +++ b/fs/xfs/xfs_sync.h | |||
@@ -26,9 +26,6 @@ struct xfs_perag; | |||
26 | 26 | ||
27 | void xfs_reclaim_worker(struct work_struct *work); | 27 | void xfs_reclaim_worker(struct work_struct *work); |
28 | 28 | ||
29 | int xfs_quiesce_data(struct xfs_mount *mp); | ||
30 | void xfs_quiesce_attr(struct xfs_mount *mp); | ||
31 | |||
32 | int xfs_reclaim_inodes(struct xfs_mount *mp, int mode); | 29 | int xfs_reclaim_inodes(struct xfs_mount *mp, int mode); |
33 | int xfs_reclaim_inodes_count(struct xfs_mount *mp); | 30 | int xfs_reclaim_inodes_count(struct xfs_mount *mp); |
34 | void xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan); | 31 | void xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan); |