diff mbox

[02/21] xfs: add helper to decide if an inode has allocated cow blocks

Message ID 152986822251.3155.14348466047540978889.stgit@magnolia (mailing list archive)
State New, archived
Headers show

Commit Message

Darrick J. Wong June 24, 2018, 7:23 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Add a helper to decide if an inode has real or unwritten extents in the
CoW fork.  The upcoming repair freeze functionality will have to know if
it's safe to iput an inode -- if the inode has incore any state that
would require a transaction to unwind during iput, we'll have to defer
the iput.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_inode.c |   19 +++++++++++++++++++
 fs/xfs/xfs_inode.h |    1 +
 2 files changed, 20 insertions(+)



--
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

Dave Chinner June 27, 2018, 1:02 a.m. UTC | #1
On Sun, Jun 24, 2018 at 12:23:42PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add a helper to decide if an inode has real or unwritten extents in the
> CoW fork.  The upcoming repair freeze functionality will have to know if
> it's safe to iput an inode -- if the inode has incore any state that
> would require a transaction to unwind during iput, we'll have to defer
> the iput.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Seems ok, but I really can't review this in isolation because at
this point I've got no idea what it's calling context is.

i.e. I'm not going to say this is OK until I see how/why/where
delayed iput()s are used.

Cheers,

Dave.
Allison Henderson June 28, 2018, 9:12 p.m. UTC | #2
On 06/24/2018 12:23 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add a helper to decide if an inode has real or unwritten extents in the
> CoW fork.  The upcoming repair freeze functionality will have to know if
> it's safe to iput an inode -- if the inode has incore any state that
> would require a transaction to unwind during iput, we'll have to defer
> the iput.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   fs/xfs/xfs_inode.c |   19 +++++++++++++++++++
>   fs/xfs/xfs_inode.h |    1 +
>   2 files changed, 20 insertions(+)
> 
> 
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 7a96c4e0ab5c..e6859dfc29af 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3689,3 +3689,22 @@ xfs_iflush_int(
>   corrupt_out:
>   	return -EFSCORRUPTED;
>   }
> +
> +/* Decide if there are real or unwritten extents in the CoW fork. */
> +bool
> +xfs_inode_has_cow_blocks(
> +	struct xfs_inode		*ip)
> +{
> +	struct xfs_iext_cursor		icur;
> +	struct xfs_bmbt_irec		irec;
> +	struct xfs_ifork		*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
> +
> +	if (!ifp)
> +		return false;
> +
> +	for_each_xfs_iext(ifp, &icur, &irec) {
> +		if (!isnullstartblock(irec.br_startblock))
> +			return true;
> +	}
> +	return false;
> +}
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 2ed63a49e890..735d0788bfdb 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -503,5 +503,6 @@ extern struct kmem_zone	*xfs_inode_zone;
>   #define XFS_DEFAULT_COWEXTSZ_HINT 32
>   
>   bool xfs_inode_verify_forks(struct xfs_inode *ip);
> +bool xfs_inode_has_cow_blocks(struct xfs_inode *ip);
>   
>   #endif	/* __XFS_INODE_H__ */
> 

Ok, this one looks pretty straight forward.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> --
> 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=gITPMUadlG9a62qcCKtadzb41y_zIzqRNXMCANKITeM&s=hmiK2_87KL5oO6gl-LQ00avYqc5HcijzCgyErYAM1Cc&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
diff mbox

Patch

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 7a96c4e0ab5c..e6859dfc29af 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3689,3 +3689,22 @@  xfs_iflush_int(
 corrupt_out:
 	return -EFSCORRUPTED;
 }
+
+/* Decide if there are real or unwritten extents in the CoW fork. */
+bool
+xfs_inode_has_cow_blocks(
+	struct xfs_inode		*ip)
+{
+	struct xfs_iext_cursor		icur;
+	struct xfs_bmbt_irec		irec;
+	struct xfs_ifork		*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
+
+	if (!ifp)
+		return false;
+
+	for_each_xfs_iext(ifp, &icur, &irec) {
+		if (!isnullstartblock(irec.br_startblock))
+			return true;
+	}
+	return false;
+}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 2ed63a49e890..735d0788bfdb 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -503,5 +503,6 @@  extern struct kmem_zone	*xfs_inode_zone;
 #define XFS_DEFAULT_COWEXTSZ_HINT 32
 
 bool xfs_inode_verify_forks(struct xfs_inode *ip);
+bool xfs_inode_has_cow_blocks(struct xfs_inode *ip);
 
 #endif	/* __XFS_INODE_H__ */