diff mbox series

[3/4] xfs: strengthen rmap record flags checking

Message ID 160494587178.772802.7759758846362664950.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfs: fix various scrub problems | expand

Commit Message

Darrick J. Wong Nov. 9, 2020, 6:17 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

We always know the correct state of the rmap record flags (attr, bmbt,
unwritten) so check them by direct comparison.

Fixes: d852657ccfc0 ("xfs: cross-reference reverse-mapping btree")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/bmap.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Chandan Babu R Nov. 13, 2020, 7:02 a.m. UTC | #1
On Monday 9 November 2020 11:47:51 PM IST Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> We always know the correct state of the rmap record flags (attr, bmbt,
> unwritten) so check them by direct comparison.
>

The statement "operand1 == operand2" returns a 1 or 0 as its value. So the
"!!"  operation on the resulting value is probably not required. But still,
the changes are logically correct.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Fixes: d852657ccfc0 ("xfs: cross-reference reverse-mapping btree")
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/scrub/bmap.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> 
> diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
> index 412e2ec55e38..fed56d213a3f 100644
> --- a/fs/xfs/scrub/bmap.c
> +++ b/fs/xfs/scrub/bmap.c
> @@ -218,13 +218,13 @@ xchk_bmap_xref_rmap(
>  	 * which doesn't track unwritten state.
>  	 */
>  	if (owner != XFS_RMAP_OWN_COW &&
> -	    irec->br_state == XFS_EXT_UNWRITTEN &&
> -	    !(rmap.rm_flags & XFS_RMAP_UNWRITTEN))
> +	    !!(irec->br_state == XFS_EXT_UNWRITTEN) !=
> +	    !!(rmap.rm_flags & XFS_RMAP_UNWRITTEN))
>  		xchk_fblock_xref_set_corrupt(info->sc, info->whichfork,
>  				irec->br_startoff);
>  
> -	if (info->whichfork == XFS_ATTR_FORK &&
> -	    !(rmap.rm_flags & XFS_RMAP_ATTR_FORK))
> +	if (!!(info->whichfork == XFS_ATTR_FORK) !=
> +	    !!(rmap.rm_flags & XFS_RMAP_ATTR_FORK))
>  		xchk_fblock_xref_set_corrupt(info->sc, info->whichfork,
>  				irec->br_startoff);
>  	if (rmap.rm_flags & XFS_RMAP_BMBT_BLOCK)
> 
>
Christoph Hellwig Nov. 14, 2020, 10:40 a.m. UTC | #2
On Mon, Nov 09, 2020 at 10:17:51AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> We always know the correct state of the rmap record flags (attr, bmbt,
> unwritten) so check them by direct comparison.
> 
> Fixes: d852657ccfc0 ("xfs: cross-reference reverse-mapping btree")
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
index 412e2ec55e38..fed56d213a3f 100644
--- a/fs/xfs/scrub/bmap.c
+++ b/fs/xfs/scrub/bmap.c
@@ -218,13 +218,13 @@  xchk_bmap_xref_rmap(
 	 * which doesn't track unwritten state.
 	 */
 	if (owner != XFS_RMAP_OWN_COW &&
-	    irec->br_state == XFS_EXT_UNWRITTEN &&
-	    !(rmap.rm_flags & XFS_RMAP_UNWRITTEN))
+	    !!(irec->br_state == XFS_EXT_UNWRITTEN) !=
+	    !!(rmap.rm_flags & XFS_RMAP_UNWRITTEN))
 		xchk_fblock_xref_set_corrupt(info->sc, info->whichfork,
 				irec->br_startoff);
 
-	if (info->whichfork == XFS_ATTR_FORK &&
-	    !(rmap.rm_flags & XFS_RMAP_ATTR_FORK))
+	if (!!(info->whichfork == XFS_ATTR_FORK) !=
+	    !!(rmap.rm_flags & XFS_RMAP_ATTR_FORK))
 		xchk_fblock_xref_set_corrupt(info->sc, info->whichfork,
 				irec->br_startoff);
 	if (rmap.rm_flags & XFS_RMAP_BMBT_BLOCK)