diff mbox series

[1/2] xfs_db: fix nlink usage in check

Message ID 159716414414.2135493.1784583001962165153.stgit@magnolia
State Superseded
Headers show
Series xfsprogs: various small enhancements | expand

Commit Message

Darrick J. Wong Aug. 11, 2020, 4:42 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

process_inode uses a local convenience variable to abstract the
differences between the ondisk nlink fields in a v1 inode and a v2
inode.  Use this variable for checking and reporting errors.

Fixes: 6526f30e4801 ("xfs_db: stop misusing an onstack inode")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 db/check.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Sandeen Aug. 11, 2020, 7:25 p.m. UTC | #1
On 8/11/20 9:42 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> process_inode uses a local convenience variable to abstract the
> differences between the ondisk nlink fields in a v1 inode and a v2
> inode.  Use this variable for checking and reporting errors.

Ah, otherwise we risk looking at the V2 field for a V1 inode, right?

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> Fixes: 6526f30e4801 ("xfs_db: stop misusing an onstack inode")
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  db/check.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/db/check.c b/db/check.c
> index c2233a0d1ba7..ef0e82d4efa1 100644
> --- a/db/check.c
> +++ b/db/check.c
> @@ -2797,10 +2797,10 @@ process_inode(
>  					be64_to_cpu(dip->di_nblocks), ino);
>  			error++;
>  		}
> -		if (dip->di_nlink != 0) {
> +		if (nlink != 0) {
>  			if (v)
>  				dbprintf(_("bad nlink %d for free inode %lld\n"),
> -					be32_to_cpu(dip->di_nlink), ino);
> +					nlink, ino);
>  			error++;
>  		}
>  		if (dip->di_mode != 0) {
>
diff mbox series

Patch

diff --git a/db/check.c b/db/check.c
index c2233a0d1ba7..ef0e82d4efa1 100644
--- a/db/check.c
+++ b/db/check.c
@@ -2797,10 +2797,10 @@  process_inode(
 					be64_to_cpu(dip->di_nblocks), ino);
 			error++;
 		}
-		if (dip->di_nlink != 0) {
+		if (nlink != 0) {
 			if (v)
 				dbprintf(_("bad nlink %d for free inode %lld\n"),
-					be32_to_cpu(dip->di_nlink), ino);
+					nlink, ino);
 			error++;
 		}
 		if (dip->di_mode != 0) {