diff mbox

[1/8] xfs: allow empty transactions while frozen

Message ID 152960587035.26246.9220199251468325711.stgit@magnolia (mailing list archive)
State Accepted
Headers show

Commit Message

Darrick J. Wong June 21, 2018, 6:31 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

In commit e89c041338ed6ef ("xfs: implement the GETFSMAP ioctl") we
created the ability to obtain empty transactions.  These transactions
have no log or block reservations and therefore can't modify anything.
Since they're also NO_WRITECOUNT they can run while the fs is frozen,
so we don't need to WARN_ON about that usage.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_trans.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Allison Henderson June 22, 2018, 6:18 a.m. UTC | #1
Looks fine
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

On 06/21/2018 11:31 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> In commit e89c041338ed6ef ("xfs: implement the GETFSMAP ioctl") we
> created the ability to obtain empty transactions.  These transactions
> have no log or block reservations and therefore can't modify anything.
> Since they're also NO_WRITECOUNT they can run while the fs is frozen,
> so we don't need to WARN_ON about that usage.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   fs/xfs/xfs_trans.c |    7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index e040af120b69..524f543c5b82 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -258,7 +258,12 @@ xfs_trans_alloc(
>   	if (!(flags & XFS_TRANS_NO_WRITECOUNT))
>   		sb_start_intwrite(mp->m_super);
>   
> -	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
> +	/*
> +	 * Zero-reservation ("empty") transactions can't modify anything, so
> +	 * they're allowed to run while we're frozen.
> +	 */
> +	WARN_ON(resp->tr_logres > 0 &&
> +		mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
>   	atomic_inc(&mp->m_active_trans);
>   
>   	tp = kmem_zone_zalloc(xfs_trans_zone,
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwICaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=jfRT1oYtPVNVBt-lMSR8ZrPgEPjfv7foQ0meuw0oGxM&s=GsacuLUdUkUoZWMAAmlRTyyR7FByN9OA43H6dYDIK6Q&e=
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoph Hellwig June 22, 2018, 6:31 a.m. UTC | #2
On Thu, Jun 21, 2018 at 11:31:10AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> In commit e89c041338ed6ef ("xfs: implement the GETFSMAP ioctl") we
> created the ability to obtain empty transactions.

That was sneaked in nicely, normally it should be a separate
commit..

> These transactions
> have no log or block reservations and therefore can't modify anything.
> Since they're also NO_WRITECOUNT they can run while the fs is frozen,
> so we don't need to WARN_ON about that usage.

This looks correct, but it really makes me hate these empty
transactions.  We're going to find more and more issues like this
and will end up with a huge bag of special cases.

Reluctantly:

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index e040af120b69..524f543c5b82 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -258,7 +258,12 @@  xfs_trans_alloc(
 	if (!(flags & XFS_TRANS_NO_WRITECOUNT))
 		sb_start_intwrite(mp->m_super);
 
-	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
+	/*
+	 * Zero-reservation ("empty") transactions can't modify anything, so
+	 * they're allowed to run while we're frozen.
+	 */
+	WARN_ON(resp->tr_logres > 0 &&
+		mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
 	atomic_inc(&mp->m_active_trans);
 
 	tp = kmem_zone_zalloc(xfs_trans_zone,