From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH v2 3/4] xfs: remove leftover CoW reservations when remounting ro
Date: Tue, 19 Dec 2017 13:08:56 -0800 [thread overview]
Message-ID: <20171219210856.GG12613@magnolia> (raw)
In-Reply-To: <151335789173.26575.16460983789473064032.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
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: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_icache.c | 2 +-
fs/xfs/xfs_icache.h | 1 +
fs/xfs/xfs_super.c | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 58d2d42..3861d61 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -870,7 +870,7 @@ xfs_eofblocks_worker(
* based on the 'speculative_cow_prealloc_lifetime' tunable (5m by default).
* (We'll just piggyback on the post-EOF prealloc space workqueue.)
*/
-STATIC void
+void
xfs_queue_cowblocks(
struct xfs_mount *mp)
{
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h
index bff4d85..d4a7758 100644
--- a/fs/xfs/xfs_icache.h
+++ b/fs/xfs/xfs_icache.h
@@ -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_inode_free_quota_cowblocks(struct xfs_inode *ip);
void xfs_cowblocks_worker(struct work_struct *);
+void xfs_queue_cowblocks(struct xfs_mount *);
int xfs_inode_ag_iterator(struct xfs_mount *mp,
int (*execute)(struct xfs_inode *ip, int flags, void *args),
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f663022..2db6a40 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1360,6 +1360,7 @@ xfs_fs_remount(
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
return error;
}
+ xfs_queue_cowblocks(mp);
/* Create the per-AG metadata reservation pool .*/
error = xfs_fs_reserve_ag_blocks(mp);
@@ -1369,6 +1370,14 @@ xfs_fs_remount(
/* rw -> ro */
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. */
error = xfs_fs_unreserve_ag_blocks(mp);
if (error) {
next prev parent reply other threads:[~2017-12-19 21:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 17:11 [PATCH 0/4] xfs: more reflink fixes Darrick J. Wong
2017-12-15 17:11 ` [PATCH 1/4] xfs: track cowblocks separately in i_flags Darrick J. Wong
2017-12-19 0:12 ` Dave Chinner
2017-12-21 13:36 ` Christoph Hellwig
2017-12-15 17:11 ` [PATCH 2/4] xfs: don't be so eager to clear the cowblocks tag on truncate Darrick J. Wong
2017-12-19 0:12 ` Dave Chinner
2017-12-21 13:37 ` Christoph Hellwig
2017-12-15 17:11 ` [PATCH 3/4] xfs: remove leftover CoW reservations when remounting ro Darrick J. Wong
2017-12-19 0:17 ` Dave Chinner
2017-12-19 3:49 ` Darrick J. Wong
2017-12-19 4:37 ` Dave Chinner
2017-12-19 4:53 ` Darrick J. Wong
2017-12-19 6:46 ` Dave Chinner
2017-12-19 19:00 ` Darrick J. Wong
2017-12-19 20:55 ` Dave Chinner
2017-12-19 21:08 ` Darrick J. Wong [this message]
2017-12-21 13:38 ` [PATCH v2 " Christoph Hellwig
2017-12-15 17:11 ` [PATCH 4/4] xfs: set cowblocks tag for direct cow writes too Darrick J. Wong
2017-12-19 0:18 ` Dave Chinner
2017-12-21 13:39 ` Christoph Hellwig
2017-12-19 21:09 ` [PATCH 5/4] xfs: clean up cow mappings during fs data freeze Darrick J. Wong
2017-12-21 13:39 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171219210856.GG12613@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).