diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-02-07 13:37:13 -0500 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-02-11 19:07:01 -0500 |
commit | 7d36c19538d38f9ff6b93d2a3d23ee879b076dc6 (patch) | |
tree | fe8bf04bddb297059e7db80126f9db0bb63a31e2 /fs/xfs/libxfs | |
parent | 5837f62592ef7c07859a1b1a6e82030d85869f0f (diff) |
xfs: add xfs_verify_agino_or_null helper
Add a new helper to check that a per-AG inode pointer is either null or
points somewhere valid within that AG.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r-- | fs/xfs/libxfs/xfs_inode_buf.c | 3 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_types.c | 13 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_types.h | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 09d9c8cfa4a0..82c4374acb4c 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c | |||
@@ -99,8 +99,7 @@ xfs_inode_buf_verify( | |||
99 | unlinked_ino = be32_to_cpu(dip->di_next_unlinked); | 99 | unlinked_ino = be32_to_cpu(dip->di_next_unlinked); |
100 | di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) && | 100 | di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) && |
101 | xfs_dinode_good_version(mp, dip->di_version) && | 101 | xfs_dinode_good_version(mp, dip->di_version) && |
102 | (unlinked_ino == NULLAGINO || | 102 | xfs_verify_agino_or_null(mp, agno, unlinked_ino); |
103 | xfs_verify_agino(mp, agno, unlinked_ino)); | ||
104 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, | 103 | if (unlikely(XFS_TEST_ERROR(!di_ok, mp, |
105 | XFS_ERRTAG_ITOBP_INOTOBP))) { | 104 | XFS_ERRTAG_ITOBP_INOTOBP))) { |
106 | if (readahead) { | 105 | if (readahead) { |
diff --git a/fs/xfs/libxfs/xfs_types.c b/fs/xfs/libxfs/xfs_types.c index 451608b5a37b..de310712dd6d 100644 --- a/fs/xfs/libxfs/xfs_types.c +++ b/fs/xfs/libxfs/xfs_types.c | |||
@@ -116,6 +116,19 @@ xfs_verify_agino( | |||
116 | } | 116 | } |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Verify that an AG inode number pointer neither points outside the AG | ||
120 | * nor points at static metadata, or is NULLAGINO. | ||
121 | */ | ||
122 | bool | ||
123 | xfs_verify_agino_or_null( | ||
124 | struct xfs_mount *mp, | ||
125 | xfs_agnumber_t agno, | ||
126 | xfs_agino_t agino) | ||
127 | { | ||
128 | return agino == NULLAGINO || xfs_verify_agino(mp, agno, agino); | ||
129 | } | ||
130 | |||
131 | /* | ||
119 | * Verify that an FS inode number pointer neither points outside the | 132 | * Verify that an FS inode number pointer neither points outside the |
120 | * filesystem nor points at static AG metadata. | 133 | * filesystem nor points at static AG metadata. |
121 | */ | 134 | */ |
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h index 704b4f308780..c5a25403b4db 100644 --- a/fs/xfs/libxfs/xfs_types.h +++ b/fs/xfs/libxfs/xfs_types.h | |||
@@ -183,6 +183,8 @@ void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno, | |||
183 | xfs_agino_t *first, xfs_agino_t *last); | 183 | xfs_agino_t *first, xfs_agino_t *last); |
184 | bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno, | 184 | bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno, |
185 | xfs_agino_t agino); | 185 | xfs_agino_t agino); |
186 | bool xfs_verify_agino_or_null(struct xfs_mount *mp, xfs_agnumber_t agno, | ||
187 | xfs_agino_t agino); | ||
186 | bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); | 188 | bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); |
187 | bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); | 189 | bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); |
188 | bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); | 190 | bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); |