Commit c75921a7 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: xfs_quiesce_attr() should quiesce the log like unmount

xfs_quiesce_attr() is supposed to leave the log empty with an
unmount record written. Right now it does not wait for the AIL to be
emptied before writing the unmount record, not does it wait for
metadata IO completion, either. Fix it to use the same method and
code as xfs_log_unmount().
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent c7eea6f7
...@@ -855,20 +855,17 @@ xfs_log_unmount_write(xfs_mount_t *mp) ...@@ -855,20 +855,17 @@ xfs_log_unmount_write(xfs_mount_t *mp)
} /* xfs_log_unmount_write */ } /* xfs_log_unmount_write */
/* /*
* Shut down and release the AIL and Log. * Empty the log for unmount/freeze.
*
* During unmount, we need to ensure we flush all the dirty metadata objects
* from the AIL so that the log is empty before we write the unmount record to
* the log.
* *
* To do this, we first need to shut down the background log work so it is not * To do this, we first need to shut down the background log work so it is not
* trying to cover the log as we clean up. We then need to unpin all objects in * trying to cover the log as we clean up. We then need to unpin all objects in
* the log so we can then flush them out. Once they have completed their IO and * the log so we can then flush them out. Once they have completed their IO and
* run the callbacks removing themselves from the AIL, we can write the unmount * run the callbacks removing themselves from the AIL, we can write the unmount
* record, tear down the AIL and finally free the log. * record.
*/ */
void void
xfs_log_unmount(xfs_mount_t *mp) xfs_log_quiesce(
struct xfs_mount *mp)
{ {
cancel_delayed_work_sync(&mp->m_log->l_work); cancel_delayed_work_sync(&mp->m_log->l_work);
xfs_log_force(mp, XFS_LOG_SYNC); xfs_log_force(mp, XFS_LOG_SYNC);
...@@ -886,6 +883,20 @@ xfs_log_unmount(xfs_mount_t *mp) ...@@ -886,6 +883,20 @@ xfs_log_unmount(xfs_mount_t *mp)
xfs_buf_unlock(mp->m_sb_bp); xfs_buf_unlock(mp->m_sb_bp);
xfs_log_unmount_write(mp); xfs_log_unmount_write(mp);
}
/*
* Shut down and release the AIL and Log.
*
* During unmount, we need to ensure we flush all the dirty metadata objects
* from the AIL so that the log is empty before we write the unmount record to
* the log. Once this is done, we can tear down the AIL and the log.
*/
void
xfs_log_unmount(
struct xfs_mount *mp)
{
xfs_log_quiesce(mp);
xfs_trans_ail_destroy(mp); xfs_trans_ail_destroy(mp);
xlog_dealloc_log(mp->m_log); xlog_dealloc_log(mp->m_log);
......
...@@ -183,6 +183,7 @@ bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip); ...@@ -183,6 +183,7 @@ bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);
void xfs_log_work_queue(struct xfs_mount *mp); void xfs_log_work_queue(struct xfs_mount *mp);
void xfs_log_worker(struct work_struct *work); void xfs_log_worker(struct work_struct *work);
void xfs_log_quiesce(struct xfs_mount *mp);
#endif #endif
#endif /* __XFS_LOG_H__ */ #endif /* __XFS_LOG_H__ */
...@@ -1153,15 +1153,11 @@ xfs_restore_resvblks(struct xfs_mount *mp) ...@@ -1153,15 +1153,11 @@ xfs_restore_resvblks(struct xfs_mount *mp)
* *
* This ensures that the metadata is written to their location on disk rather * This ensures that the metadata is written to their location on disk rather
* than just existing in transactions in the log. This means after a quiesce * than just existing in transactions in the log. This means after a quiesce
* there is no log replay required to write the inodes to disk (this is the main * there is no log replay required to write the inodes to disk - this is the
* difference between a sync and a quiesce). * primary difference between a sync and a quiesce.
* *
* This shoul deffectively mimic the code in xfs_unmountfs() and * Note: xfs_log_quiesce() stops background log work - the callers must ensure
* xfs_log_umount() but without tearing down any structures. * it is started again when appropriate.
* XXX: bug fixes needed!
*
* Note: this stops background log work - the callers must ensure it is started
* again when appropriate.
*/ */
void void
xfs_quiesce_attr( xfs_quiesce_attr(
...@@ -1180,39 +1176,18 @@ xfs_quiesce_attr( ...@@ -1180,39 +1176,18 @@ xfs_quiesce_attr(
xfs_reclaim_inodes(mp, 0); xfs_reclaim_inodes(mp, 0);
xfs_reclaim_inodes(mp, SYNC_WAIT); xfs_reclaim_inodes(mp, SYNC_WAIT);
/* flush all pending changes from the AIL */
xfs_ail_push_all_sync(mp->m_ail);
/* stop background log work */
cancel_delayed_work_sync(&mp->m_log->l_work);
/*
* Just warn here till VFS can correctly support
* read-only remount without racing.
*/
WARN_ON(atomic_read(&mp->m_active_trans) != 0);
/* Push the superblock and write an unmount record */ /* Push the superblock and write an unmount record */
error = xfs_log_sbcount(mp); error = xfs_log_sbcount(mp);
if (error) if (error)
xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. " xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. "
"Frozen image may not be consistent."); "Frozen image may not be consistent.");
xfs_log_unmount_write(mp);
/* /*
* At this point we might have modified the superblock again and thus * Just warn here till VFS can correctly support
* added an item to the AIL, thus flush it again. * read-only remount without racing.
*/ */
xfs_ail_push_all_sync(mp->m_ail); WARN_ON(atomic_read(&mp->m_active_trans) != 0);
/* xfs_log_quiesce(mp);
* The superblock buffer is uncached and xfsaild_push() will lock and
* set the XBF_ASYNC flag on the buffer. We cannot do xfs_buf_iowait()
* here but a lock on the superblock buffer will block until iodone()
* has completed.
*/
xfs_buf_lock(mp->m_sb_bp);
xfs_buf_unlock(mp->m_sb_bp);
} }
STATIC int STATIC int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment