Commit 10ddf64e authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: remove leftover CoW reservations when remounting ro

When we're remounting the filesystem readonly, remove all CoW
preallocations prior to going ro.  If the fs goes down after the ro
remount, we never clean up the staging extents, which means xfs_check
will trip over them on a subsequent run.  Practically speaking, the next
mount will clean them up too, so this is unlikely to be seen.  Since we
shut down the cowblocks cleaner on remount-ro, we also have to make sure
we start it back up if/when we remount-rw.

Found by adding clonerange to fsstress and running xfs/017.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 363e59ba
...@@ -870,7 +870,7 @@ xfs_eofblocks_worker( ...@@ -870,7 +870,7 @@ xfs_eofblocks_worker(
* based on the 'speculative_cow_prealloc_lifetime' tunable (5m by default). * based on the 'speculative_cow_prealloc_lifetime' tunable (5m by default).
* (We'll just piggyback on the post-EOF prealloc space workqueue.) * (We'll just piggyback on the post-EOF prealloc space workqueue.)
*/ */
STATIC void void
xfs_queue_cowblocks( xfs_queue_cowblocks(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
......
...@@ -81,6 +81,7 @@ void xfs_inode_clear_cowblocks_tag(struct xfs_inode *ip); ...@@ -81,6 +81,7 @@ void xfs_inode_clear_cowblocks_tag(struct xfs_inode *ip);
int xfs_icache_free_cowblocks(struct xfs_mount *, struct xfs_eofblocks *); int xfs_icache_free_cowblocks(struct xfs_mount *, struct xfs_eofblocks *);
int xfs_inode_free_quota_cowblocks(struct xfs_inode *ip); int xfs_inode_free_quota_cowblocks(struct xfs_inode *ip);
void xfs_cowblocks_worker(struct work_struct *); void xfs_cowblocks_worker(struct work_struct *);
void xfs_queue_cowblocks(struct xfs_mount *);
int xfs_inode_ag_iterator(struct xfs_mount *mp, int xfs_inode_ag_iterator(struct xfs_mount *mp,
int (*execute)(struct xfs_inode *ip, int flags, void *args), int (*execute)(struct xfs_inode *ip, int flags, void *args),
......
...@@ -1360,6 +1360,7 @@ xfs_fs_remount( ...@@ -1360,6 +1360,7 @@ xfs_fs_remount(
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
return error; return error;
} }
xfs_queue_cowblocks(mp);
/* Create the per-AG metadata reservation pool .*/ /* Create the per-AG metadata reservation pool .*/
error = xfs_fs_reserve_ag_blocks(mp); error = xfs_fs_reserve_ag_blocks(mp);
...@@ -1369,6 +1370,14 @@ xfs_fs_remount( ...@@ -1369,6 +1370,14 @@ xfs_fs_remount(
/* rw -> ro */ /* rw -> ro */
if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
/* Get rid of any leftover CoW reservations... */
cancel_delayed_work_sync(&mp->m_cowblocks_work);
error = xfs_icache_free_cowblocks(mp, NULL);
if (error) {
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
return error;
}
/* Free the per-AG metadata reservation pool. */ /* Free the per-AG metadata reservation pool. */
error = xfs_fs_unreserve_ag_blocks(mp); error = xfs_fs_unreserve_ag_blocks(mp);
if (error) { if (error) {
......
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