linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, hch@infradead.org
Subject: [PATCH 1/2] xfs: move the xfs_can_free_eofblocks call under the IOLOCK
Date: Thu, 18 Mar 2021 15:33:32 -0700	[thread overview]
Message-ID: <161610681213.1887542.5172499515393116902.stgit@magnolia> (raw)
In-Reply-To: <161610680641.1887542.10509468263256161712.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

In xfs_inode_free_eofblocks, move the xfs_can_free_eofblocks call
further down in the function to the point where we have taken the
IOLOCK.  This is preparation for the next patch, where we will need that
lock (or equivalent) so that we can check if there are any post-eof
blocks to clean out.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_icache.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)


diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index e6a62f765422..7353c9fe05db 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1294,13 +1294,6 @@ xfs_inode_free_eofblocks(
 	if (!xfs_iflags_test(ip, XFS_IEOFBLOCKS))
 		return 0;
 
-	if (!xfs_can_free_eofblocks(ip, false)) {
-		/* inode could be preallocated or append-only */
-		trace_xfs_inode_free_eofblocks_invalid(ip);
-		xfs_inode_clear_eofblocks_tag(ip);
-		return 0;
-	}
-
 	/*
 	 * If the mapping is dirty the operation can block and wait for some
 	 * time. Unless we are waiting, skip it.
@@ -1322,7 +1315,10 @@ xfs_inode_free_eofblocks(
 	}
 	*lockflags |= XFS_IOLOCK_EXCL;
 
-	return xfs_free_eofblocks(ip);
+	if (xfs_can_free_eofblocks(ip, false))
+		return xfs_free_eofblocks(ip);
+
+	return 0;
 }
 
 /*


  reply	other threads:[~2021-03-18 22:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 22:33 [PATCHSET 0/2] xfs: make xfs_can_free_eofblocks a predicate Darrick J. Wong
2021-03-18 22:33 ` Darrick J. Wong [this message]
2021-03-19  5:53   ` [PATCH 1/2] xfs: move the xfs_can_free_eofblocks call under the IOLOCK Christoph Hellwig
2021-03-19  6:01     ` Darrick J. Wong
2021-03-19  6:31       ` Christoph Hellwig
2021-03-18 22:33 ` [PATCH 2/2] xfs: move the check for post-EOF mappings into xfs_can_free_eofblocks Darrick J. Wong
2021-03-19  5:59   ` Christoph Hellwig
2021-03-19  6:05     ` Darrick J. Wong
2021-03-19  6:35       ` Christoph Hellwig
2021-03-19 16:59         ` Darrick J. Wong
2021-03-23 18:32           ` Christoph Hellwig
2021-03-26  0:20 [PATCHSET v2 0/2] xfs: make xfs_can_free_eofblocks a predicate Darrick J. Wong
2021-03-26  0:21 ` [PATCH 1/2] xfs: move the xfs_can_free_eofblocks call under the IOLOCK Darrick J. Wong
2021-03-26  5:59   ` 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=161610681213.1887542.5172499515393116902.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=hch@infradead.org \
    --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).